#gpatra
1 messages · Page 1 of 1 (latest)
Hi, I am a bit confused when following your statements. Could you list down 2 scenarios you want to differ, in 2 bullet points with some example number?
subscription.updated triggers
- If user cancels their subscription plan,
- if user update their plan
- if auto renew happens at the end of billing period
A. For ex: if user choose free , we give them 10 credits
if user choose paid , we give them 100 credits.
Let say i choose paid and got 100 credits , and after some day i cancelled the plan and it will end at the billing period and we are downgrading user to free plan at the end of current billing period. but subscription.updated trigger immediately. So on this event how can i identify this triggers due to cancellation of plan or change of plan. Because i assign credits in subscription.updated.
B. Give me other conditions where subscription.updated will trigger
when you look at the webhook event, do you see previous_attributes? Would it outline the previous state?
No
For some cases , i see the same subscription plan id, but i am not checking the ids,
I mean in the whole webhook events
No i am not checking
let me see i can find out this one.
Yes, There is a previous_attributes
"previous_attributes": {
"current_period_end": 1704791270,
"current_period_start": 1702112870,
"latest_invoice": "in_1Nd9P4SDvWoeXaF5TET8AM6X"
}
\
Yeah, so that would be the block to determine which kind of update is that. I am sure if the user cancelled, you will have the new cancelled status and the "previous" normal status
okey you are saying i will get same latest invoice id?
latest_invoice_id could change. Everything in the previous_attributes is the changed property
Okey, so you are saying i will get the latest status with current subscription id by using the invoice id
Sorry didn't follow that. Why Invoice Id?