#TheUchi007 - Subscription Checkout
1 messages ยท Page 1 of 1 (latest)
Hi ๐
Okay so you are using the Payment Element to capture the users payment details when they are signing up for the subscription?
Yes. Well, I am trying to lol but I can't figure out how to make it work, since I am required a client_secret
Okay, so you've got some options.
You can create a Setup Intent to render the Payment Element, create the Payment Method on the customer and then use it on the subscription.
Or, you can specify that you want to save the Payment Method first used with the Subscription using the payment_settings.save_default_payment_method parameter: https://stripe.com/docs/api/subscriptions/create#create_subscription-payment_settings-save_default_payment_method
Hmm ok. Quick question, if I were to create the payment intent(which seems to require me to create the subscription on the customer, but mark as incomplete), can I retrieve the payment method used in there for other type of transactions?
In other words, if I just do the process of doing the whole payment and such, can I use that same payment method for, let's say, buying a book?
Okay if you are creating the subscription it will automatically create the first invoice with a payment intent. So that part is covered.
If you are using the above parameter, the payment method will be saved to the Customer record. So then you can use that payment method for one-off purchases as well.
Ah ok, so as long as I add that parameter, it will save that info that I can use for later purchases, correct?
It will save the payment method to the customer. The customer may still be required to authenticate additional purchases.
I would recommend reviewing this doc: https://stripe.com/docs/billing/subscriptions/build-subscriptions
and testing this out with some of our different testing scenarios: https://stripe.com/docs/billing/testing
and cards: https://stripe.com/docs/testing
Awesome, thank you so much!
Sure thing ๐
Subscriptions can get pretty complex so it's good to test things out thoroughly to be sure you get the behavior you expect.
We have a useful bit of tech call Test Clocks that allow you to simulate time moving forward: https://stripe.com/docs/billing/testing/test-clocks
Those are also complicated because, well, subscriptions are complicated. But it's worth the work of figuring them out.
That is amazing, that will be really handy, thanks!
Happy to help ๐
I have one more question
Ok, so I am at the step in where I create the subscription on the customer on Stripe. The subscription is created as and marked as "incomplete". It will remain that way till I actually process the payment, and then I will update to active. My question is, how can I get the client_secret if the user were to leave, and then come back? I can see the subscription in the subscription list on the customer object, but I am not sure how to get a client_secret
Okay so the client_secret is actually on the latest_invoice.payment_intent. You specify that you want to expand those properties when you create or retrieve the subscription. This allows you to get and use the `client_secret``.
Aah I see it, thank you so much! You are awesome!
Happy to help