convert amount in param
This commit is contained in:
parent
c636a2896a
commit
ce258d3d08
|
@ -15,7 +15,7 @@ module DiscoursePatrons
|
||||||
begin
|
begin
|
||||||
|
|
||||||
response = ::Stripe::PaymentIntent.create(
|
response = ::Stripe::PaymentIntent.create(
|
||||||
amount: params[:amount],
|
amount: param_currency_to_number,
|
||||||
currency: SiteSetting.discourse_patrons_currency,
|
currency: SiteSetting.discourse_patrons_currency,
|
||||||
payment_method_types: ['card'],
|
payment_method_types: ['card'],
|
||||||
payment_method: params[:paymentMethodId],
|
payment_method: params[:paymentMethodId],
|
||||||
|
@ -30,5 +30,11 @@ module DiscoursePatrons
|
||||||
|
|
||||||
render json: response
|
render json: response
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def param_currency_to_number
|
||||||
|
params[:amount].to_s.sub('.', '').to_i
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,6 +24,18 @@ module DiscoursePatrons
|
||||||
post :create, params: {}, format: :json
|
post :create, params: {}, format: :json
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'has the correct amount' do
|
||||||
|
::Stripe::PaymentIntent.expects(:create).with(has_entry(:amount, 2000))
|
||||||
|
post :create, params: { amount: '20.00' }, format: :json
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has no amount' do
|
||||||
|
::Stripe::PaymentIntent.expects(:create).with(has_entry(:amount, 0))
|
||||||
|
post :create, params: {}, format: :json
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue