FEATURE: Give option to repurchase products multiple times (#46)
Feature requested here: https://meta.discourse.org/t/subscriptions-allow-users-to-purchase-one-time-products-multiple-times/173732/ There may be cases where a site admin wants to allow the repurchasing of a product. This implements the functionality by adding a repurchaseable toggle in the admin screen when creating a product. This saves an attribute to the Stripe product metadata. When a user has already purchased an item with this toggle enabled, they will be able to purchase it again when browsing to `/s`.
This commit is contained in:
@@ -81,9 +81,15 @@ module DiscourseSubscriptions
|
||||
post "/s/admin/products.json", params: { statement_descriptor: '' }
|
||||
end
|
||||
|
||||
it 'has a description' do
|
||||
::Stripe::Product.expects(:create).with(has_entry(metadata: { description: 'Oi, I think he just said bless be all the bignoses!' }))
|
||||
post "/s/admin/products.json", params: { metadata: { description: 'Oi, I think he just said bless be all the bignoses!' } }
|
||||
it 'has metadata' do
|
||||
::Stripe::Product.expects(:create).with(has_entry(metadata: { description: 'Oi, I think he just said bless be all the bignoses!', repurchaseable: 'false' }))
|
||||
|
||||
post "/s/admin/products.json", params: {
|
||||
metadata: {
|
||||
description: 'Oi, I think he just said bless be all the bignoses!',
|
||||
repurchaseable: 'false'
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ module DiscourseSubscriptions
|
||||
id: "prodct_23456",
|
||||
name: "Very Special Product",
|
||||
metadata: {
|
||||
description: "Many people listened to my phone call with the Ukrainian President while it was being made"
|
||||
description: "Many people listened to my phone call with the Ukrainian President while it was being made",
|
||||
repurchaseable: false
|
||||
},
|
||||
otherstuff: true,
|
||||
}
|
||||
@@ -48,7 +49,8 @@ module DiscourseSubscriptions
|
||||
"id" => "prodct_23456",
|
||||
"name" => "Very Special Product",
|
||||
"description" => PrettyText.cook("Many people listened to my phone call with the Ukrainian President while it was being made"),
|
||||
"subscribed" => false
|
||||
"subscribed" => false,
|
||||
"repurchaseable" => false,
|
||||
}])
|
||||
end
|
||||
|
||||
@@ -82,7 +84,8 @@ module DiscourseSubscriptions
|
||||
"id" => "prodct_23456",
|
||||
"name" => "Very Special Product",
|
||||
"description" => PrettyText.cook("Many people listened to my phone call with the Ukrainian President while it was being made"),
|
||||
"subscribed" => false
|
||||
"subscribed" => false,
|
||||
"repurchaseable" => false
|
||||
},
|
||||
"plans" => [
|
||||
{ "currency" => "aud", "id" => "plan_id123", "recurring" => { "interval" => "year" }, "unit_amount" => 1220 },
|
||||
|
||||
Reference in New Issue
Block a user