#pain - subscriptions
1 messages ยท Page 1 of 1 (latest)
Hello! Just starting a thread for you -- I'll review and respond as soon as I can ๐
thanks, please share details here
Thank you for opening the thread
So I am looking at the subscriptions, it can be integrated by using the prebuilt subscription checkout or handling the payment intent myself. Now what I am mainly confused about is how it creates a new customer every time, I have gone through bits of codes in github and everyone does it differently. I was looking at this example https://github.com/stripe-samples/subscription-use-cases/tree/master/fixed-price-subscriptions/
I may be wrong, but am I supposed to create a customer then add a subscription to it?
e.g. I have an account system already and wish to integrate subscriptions for various plans (can hold multiple plans at once)
Just mainly looking for some guidance of what would be the best course of action to handle this, because when I am using the prebuilt checkout it seems to create a new customer every time.
Which path are you trying to use?
You can use an existing customer in either case, certainly
If you already have a customer created, you'd create the subscription manually for that customer
if you're using checkout, you'd provide the customer id when creating the session
Oh I see, so I should technically store the customer.id with the user account for reference.
But now, what if the user wishes to checkout using different details (maybe a different card under a different name) would I just update the customers data and add the card?
Yes, storing this with your own user account record probably makes sense
They can enter new payment/address details at Checkout if they wish, and of course your custom flow is up to you
When using existing customers, you can choose how entered info is used to update the customer object or not: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-customer_update
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I see, this makes a lot more sense now. So it's all about creating the customer once and then working with the existing customer/subscription.
To handle the subscription payments I would listen to the charge events, correct?
Yes, exactly ๐
I would suggest using invoice.paid events
but if you only use this integration pattern, the charge/payment_intent events can work too
Many events are emitted when a subscription renewal payment succeeds, you have to decide which are needed for your business.
Oh I see, makes sense why I saw so many when I logged it out. This information has cleared up a path for me now, thank you for all the clarification, greatly appreciated!
NP!