#Martyn-checkout
1 messages ยท Page 1 of 1 (latest)
Sure thing mate, no rush and thanks!
Q - Is there a "clever" way to get the users stripe ID returned after the redirect so it can be stored in a DB table?
if you append {CHECKOUT_SESSION_ID} in your success_url, the CheckoutSession ID will be sent in the URL to your redirect page where you can grab it and send it to your backend to store it in your DB
Q - Can we just use an API call to provide users with functionality like a "Cancel my subscription" option?
yes, you can make a server-side API call to cancel a Subscription: https://stripe.com/docs/api/subscriptions/cancel
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Mate your a star thanks! I presume for the cancel, I can just pass in the checkout session ID from above as a parameter?
no actually! You need to pass in the Subscription ID.
The CheckoutSession that is completed (assuming it is mode: subscription ) will have a subscription: sub_123 ID on it, so you should store that too.
and thanks for the feedback!
Great thanks mate - sorry just finding my way so apologies for the dumb questions.
Ive got one more if you can tollerate it... The above youve mentioned "will have a subscription: sub_123 ID on it" Can I ask if that is also appended in the URL, or if I have to make a seperate call to get it?
Ah think ive found it. For anyone searching in the future, the page detailing this is here:
https://stripe.com/docs/payments/checkout/custom-success-page
(unless im wrong @pearl escarp , and thanks again for your help!)
Great thanks mate - sorry just finding my way so apologies for the dumb questions.
No silly questions, please continue asking ๐
Can I ask if that is also appended in the URL, or if I have to make a seperate call to get it
it would be a separate call, to fetch the CheckoutSession
or alternatively, you listen to webhook events for checkout.session.succeeded event
and that has the full CheckoutSession object in it