FEATURE: Allow one-time purchases on products (#18)
Building off the foundation of using the Prices API, this PR adds the ability to create a one-time purchase plan for any product, which then can add a user to the specified plan group.
Some things to be aware of:
One-time purchases cannot have trials.
One-time purchases use the Invoice API instead of Subscriptions. Invoices are created then charged immediately.
Users should receive emails for these invoices directly from Stripe just like subscriptions.
This commit is contained in:
@@ -98,7 +98,12 @@ module DiscourseSubscriptions
|
||||
|
||||
it "creates a plan with an interval" do
|
||||
::Stripe::Price.expects(:create).with(has_entry(recurring: { interval: 'week' }))
|
||||
post "/s/admin/plans.json", params: { interval: 'week', metadata: { group_name: '' } }
|
||||
post "/s/admin/plans.json", params: { type: 'recurring', interval: 'week', metadata: { group_name: '' } }
|
||||
end
|
||||
|
||||
it "creates a plan as a one-time purchase" do
|
||||
::Stripe::Price.expects(:create).with(Not(has_key(:recurring)))
|
||||
post "/s/admin/plans.json", params: { metadata: { group_name: '' } }
|
||||
end
|
||||
|
||||
it "creates a plan with an amount" do
|
||||
|
||||
Reference in New Issue
Block a user