mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-07-10 08:03:27 +00:00
send the customer to the payment api
This commit is contained in:
parent
ad5961a4c5
commit
bc8ae3449d
@ -32,10 +32,11 @@ module DiscoursePatrons
|
|||||||
description: SiteSetting.discourse_patrons_payment_description,
|
description: SiteSetting.discourse_patrons_payment_description,
|
||||||
receipt_email: params[:receipt_email],
|
receipt_email: params[:receipt_email],
|
||||||
confirm: true,
|
confirm: true,
|
||||||
|
customer: user_id
|
||||||
)
|
)
|
||||||
|
|
||||||
Payment.create(
|
Payment.create(
|
||||||
user_id: user_id,
|
user_id: response[:customer],
|
||||||
payment_intent_id: response[:id],
|
payment_intent_id: response[:id],
|
||||||
receipt_email: response[:receipt_email],
|
receipt_email: response[:receipt_email],
|
||||||
url: response[:charges][:url],
|
url: response[:charges][:url],
|
||||||
|
@ -41,20 +41,23 @@ module DiscoursePatrons
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe 'create' do
|
describe 'create' do
|
||||||
|
let!(:current_user) { Fabricate(:user) }
|
||||||
|
|
||||||
let(:payment) do
|
let(:payment) do
|
||||||
{
|
{
|
||||||
id: 'xyz-1234',
|
id: 'xyz-1234',
|
||||||
charges: { url: '/v1/charges?payment_intent=xyz-1234' },
|
charges: { url: '/v1/charges?payment_intent=xyz-1234' },
|
||||||
amount: 9000,
|
amount: 9000,
|
||||||
receipt_email: 'hello@example.com',
|
receipt_email: 'hello@example.com',
|
||||||
currency: 'aud'
|
currency: 'aud',
|
||||||
|
customer: current_user.id
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
SiteSetting.stubs(:discourse_patrons_currency).returns('AUD')
|
SiteSetting.stubs(:discourse_patrons_currency).returns('AUD')
|
||||||
SiteSetting.stubs(:discourse_patrons_secret_key).returns('xyz-678')
|
SiteSetting.stubs(:discourse_patrons_secret_key).returns('xyz-678')
|
||||||
controller.stubs(:current_user).returns(Fabricate(:user))
|
controller.stubs(:current_user).returns(current_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'responds ok' do
|
it 'responds ok' do
|
||||||
@ -96,6 +99,12 @@ module DiscoursePatrons
|
|||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'has the customer id' do
|
||||||
|
::Stripe::PaymentIntent.expects(:create).with(has_entry(:customer, current_user.id)).returns(payment)
|
||||||
|
post :create, params: {}, format: :json
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
end
|
||||||
|
|
||||||
it 'has a receipt email' do
|
it 'has a receipt email' do
|
||||||
::Stripe::PaymentIntent.expects(:create).with(has_entry(:receipt_email, 'hello@example.com')).returns(payment)
|
::Stripe::PaymentIntent.expects(:create).with(has_entry(:receipt_email, 'hello@example.com')).returns(payment)
|
||||||
post :create, params: { receipt_email: 'hello@example.com' }, format: :json
|
post :create, params: { receipt_email: 'hello@example.com' }, format: :json
|
||||||
|
Loading…
x
Reference in New Issue
Block a user