REFACTOR: Use the Prices API in place of Plans (#17)
Stripe has a newer API called Prices where you can create a price for any product and it can either be recurring or one-time. The easy part is existing Plans work with the Prices API by passing a Plan ID, but objects are returned in the slightly-different Prices API object format. This commit is a refactor to the new API to handle the data in its new form, and lays the foundation for a one time payment plan to be added to any subscriptions product.
This commit is contained in:
@@ -51,8 +51,8 @@ module DiscourseSubscriptions
|
||||
id: "cus_23456",
|
||||
subscriptions: {
|
||||
data: [
|
||||
{ id: "sub_1234", plan: { id: "plan_1" } },
|
||||
{ id: "sub_4567", plan: { id: "plan_2" } }
|
||||
{ id: "sub_1234", items: { data: [price: { id: "plan_1" }] } },
|
||||
{ id: "sub_4567", items: { data: [price: { id: "plan_2" }] } }
|
||||
]
|
||||
},
|
||||
}]
|
||||
@@ -60,7 +60,7 @@ module DiscourseSubscriptions
|
||||
end
|
||||
|
||||
it "gets subscriptions" do
|
||||
::Stripe::Plan.expects(:list).with(
|
||||
::Stripe::Price.expects(:list).with(
|
||||
expand: ['data.product'],
|
||||
limit: 100
|
||||
).returns(plans)
|
||||
@@ -76,7 +76,8 @@ module DiscourseSubscriptions
|
||||
|
||||
expect(subscription).to eq(
|
||||
"id" => "sub_1234",
|
||||
"plan" => { "id" => "plan_1" },
|
||||
"items" => { "data" => [{ "price" => { "id" => "plan_1" } }] },
|
||||
"plan" => { "id" => "plan_1", "product" => { "name" => "ACME Subscriptions" } },
|
||||
"product" => { "name" => "ACME Subscriptions" }
|
||||
)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user