#stripe_connect_platform-subs
1 messages · Page 1 of 1 (latest)
Man I am so confused
So plan is backward compatible, does that mean you always provide a "price" duplicate of "plan" in the sub object?
"object": "list",
"data": [
{
"id": "si_KP5ejERO47xRWc",
"object": "subscription_item",
"billing_thresholds": null,
"created": 1634170008,
"metadata": {
},
"plan": {
"id": "price_1JX6qmGkntF0z1iAzpU2Fjc1",
"object": "plan",
"active": true,
"aggregate_usage": null,
"amount": 2900,
"amount_decimal": "2900",
"billing_scheme": "per_unit",
"created": 1631030924,
"currency": "usd",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {
},
"name": "Basic (monthly)",
"nickname": "Basic (monthly)",
"product": "prod_KBToUY4H3HH7EA",
"statement_descriptor": null,
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
},
"price": {
"id": "price_1JX6qmGkntF0z1iAzpU2Fjc1",
"object": "price",
"active": true,
"billing_scheme": "per_unit",
"created": 1631030924,
"currency": "usd",
"livemode": false,
"lookup_key": null,
"metadata": {
},
"nickname": "Basic (monthly)",
"product": "prod_KBToUY4H3HH7EA",
"recurring": {
"aggregate_usage": null,
"interval": "month",
"interval_count": 1,
"trial_period_days": null,
"usage_type": "licensed"
},
Trying to code this to work with old and new subscriptions on v1 and v2 and am totally confused
Do we ALWAYS look for items.data.price?
Will that work in all cases?
Or is there ever an items.data.plan but no items.data.price?
And I imagine for new subs there is an items.data.price but not an items.data.plan, is that how it works?
Give me a minute just to make sure I understand the question
In the Subscription object we are on Stripe.api_version '2016-03-07' and have invoices being paid for old "PLANS" and new "PRICES" being processed in the same model
We need code to always find the id, interval and interval count from the Subscription we get from the invoice.payment.succeeded webhook
Okay, so my understanding is that you should be able to check items.data.price on any subscription. You should never end up in a situation where you have items.data.plan but no items.data.price
OK that is really helpful
I am trying this.
OK, then if we look for price it is in the new format of "recurring": {"aggregate_usage":null,"interval":"month","interval_count":1,"trial_period_days":null,"usage_type":"licensed"},
ok
interval = subscription.items.data[0].price.recurring.interval
Yeah - sorry should've mentioned that up front
and one-time ends up with a recurring: false or just "recurring" is replaced with "one-time"
It's OK, I will run through these scenarios and test it out
For one-time prices recurring will just be null/empty and type: one_time
got it. thank you. right now I am just working with subscription objects, so they are always recurring yes?
Yup! that's true