#gracine

1 messages · Page 1 of 1 (latest)

kindred badgeBOT
frail ivy
stiff arrow
#

yeah i just realized that the product is not directly referenced by the sub object

#

Thx. I would have another question, is there a best way to handle an existing price change? If we change a price for existing subscriptions

frail ivy
#

Yes exactly

stiff arrow
#

You are still there ?

#

"I would have another question, is there a best way to handle an existing price change? If we change a price for existing subscriptions"

frail ivy
#

Ah sorry, I missed that. Could you please share more details about what you want to achieve with an example? I don't understand you

stiff arrow
#

ok

#

We have existing users in production who subscribed to Premium product with price 20$/month

#

We want to increase the price to 30$ / month for new users, and at renewal of existing users, switch to 30$

frail ivy
#

We want to increase the price to 30$ / month for new users
when new users subscribe, you pass the new priceId
, and at renewal of existing users, switch to 30$
You update the Subscription of the existing users with the new priceId without creating prorations, by passing proration_behiavior=none
https://stripe.com/docs/api/subscriptions/update#update_subscription-proration_behavior
So that the change will take effect in the new billing period

stiff arrow
#

ok

#

should I use a subscription schedule

#

like i could create a script right now to change the new subscription price at the end of the billing period automatically

#

its a subscription so i need to hook up somewhere to change the price of existing subscription

frail ivy
#

or you can just update the existing Subscription and keep it simple

stiff arrow
#

ok, thank you

#

Can I ask you a last question

frail ivy
#

Yes for sure with all my pleasure!

stiff arrow
#

I was debugging locally and I sync my subscriptions in my database based on the Stripe Webhook events

#

i subscribe to a product, I see that my customer has the subscription active in Stripe, but in my database the status is 'incomplete' instead of 'active'

#

Its the first time I see this, I receive the events in the wrong order

#

Greed is the customer.subscription.updated event with the status 'active'

#

latest in read, its the customer.subscription.created with the status 'incomplete' which comes after the customer.subscription.updated event and overwrites the status from active to incomplete

#

so I end up with a bad status compared to the Stripe dashboard

#

*Greed => Green, *read => red

frail ivy
#

Stripe does not guarantee delivery of events in the order in which they are generated

stiff arrow
#

ok...but still when the subscription becomes past_due, cancelled, etc i need to sync my db

#

so i need to listen to customer.subscription.updated

#

not sure how to properly handle this

frail ivy
#

yeah for sure you can keep listening to that event also

stiff arrow
#

what you are saying is that i need a logic to discard some events

#

instead of updating my db from them

#

like, having some kind of invalid transitions logic

#

active => incomplete cannot happen

#

some state machine logic

#

in that case I would simply skip the event

frail ivy
stiff arrow
#

great, i will update our integration accordingly

#

thank you

frail ivy
#

Np!

stiff arrow
#

have a good day

frail ivy
#

Thanks! you too 🙂