#jbergius
1 messages · Page 1 of 1 (latest)
Could you share what your use case is?
For sure.
When my users starts a monthly subscription on a specific product - I want to perform a side effect. I'll hit an external API and update some values. I also want to add my subscription in my own database (this functionality is already in place)
When this subscription updates once a month, I do NOT want to perform a side effect, only update the subscription status in my own database.
customer.subscription.created will be sent when a subscription is created and the status may be incomplete if customer authentication is required to complete the payment or if you set payment_behavior to default_incomplete.
customer.subscription.updated will be sent when the subscription is successfully started after the payment is confirmed OR whenever a subscription is changed.
Ultimately, it depends on what your side effect is looking for
The only thing my side effect is looking for is to differentiate between a subscription created and subscription updated.
If I understand your answer correctly - the customer.subscription.updated is also sent when the customer activates the subscription for the first time?
It depends! customer.subscription.updated will be sent if the subscription is successfully started the payment (non-zero) is confirmed.
If the subscription is on trial (payment is 0) and payment method is not collected, it'll only be customer.subscription.created. Only when payment method is collected along with trial subscription, customer.subscription.updated will then be sent.
Ah ok. I'm not using any trial days. So then I should be able to differentiate the two of them by checking for customer.subscription.created since that event should not be sent on subscription renewal?
Yup! Subscription renewal (recurring charges) doesn't send BOTH customer.subscription.created and customer.subscription.updated. customer.subscription.updated will only be sent when there's a change to the subscription such as downgrading/upgrading the plan, change payment method... etc
Perfect. Thanks for your help! Have a great day!
No problem! I'd recommend testing it out in test mode with test clock (to advance the time) for subscription testing: https://stripe.com/docs/billing/testing/test-clocks
Do you know if it's possible to add metadata to your subscription when using test clock!?
Test clock is only for advancing time purpose. Subscription integration including adding metadata to the subscription remains the same
Hmm yeah, okey. But I only seem to be able to advance time on a subscription that I created through the test clock? And in that UI I can't seem to be able to add metadata to the subscription
I have an active test subscription on my account (that has the correct metadata), but I can't advance time on that particular subscription. I have to create a new test subscription through the test clocks UI to be able to do that.
Yup, you can only advance the subscription created on the test clock. The UI should be able to add metadata on the subscription with test clock. I'm able to do it on my end.
Could you share the subscription ID (sub_xxx) on test clock that you're not able to add metadata?
Seems like I have to create the subscription first, and then add metadata.