#rudh_code
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1263095466204336160
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- rudh_code, 19 hours ago, 5 messages
Above is my front end and back end code for creating the subscription and attempting to intialise the payment sheet
What's the sub_xxx ID?
sub_1PdVosCfWIy2jYftUUxG0leT
I retrieve it when I create the subscription but I do not actually use it in my payment sheet and I wonder if that is an issue
Well your code appears to be correct, in that you use the latest_invoice.payment_intent to initialise the Payment Sheet. But what you describe does not align with the state of that intent: pi_3PdVosCfWIy2jYft1ZcoH2PM
It's in a requires_payment_method state which implies that payment hasn't even been attempted yet
But on success of payment, it does not activate the subscription. It just creates a one off payment.
What does 'success of payment' look like exactly?
Also, what is the actual value of clientSecret variable?
this is what it looks like on the dashbord
Looking at your account logs, looks like there are calls to /v1/payment_intents around the same time as your subscription creation calls: https://dashboard.stripe.com/test/logs/req_sCQTTjOmnU5QX4
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
And it is those one-time payments that you're using with the Payment Sheet
Do you have a backend route/endpoint that calls paymentIntents.create?
This is my backend create payment intents api endpoint i seem to call from the front end
I have also just console logged the clinet secret and I can see that the client secret I init my payment sheet, is different to the client secret returned from my subscription endpoint call
Yep, as expected. Something in your code is calling that /create-payment-intent endpoint and you're using that client secret generated there
Ahh ok, so please correct me if I am mistaken,
I am getting a client secret from the /create-payment-intent endpoint that I call when i initialise my payment sheet, and this is wrong (or at least not really what i want). Then I create a subscription, retrieve a client secret (the one I want) but when I then display my payment sheet, I show the payment sheet that was initialised with the previous client secret, that corresponds to a one off payment, and so when I make the payment, i successfully make the one off payment, not the subcription
Please let me know if the above is correct or if I have misunderstood anything
You shouldn't be creating a Payment Intent at all if you're doing Subscriptions. Subscription will take care of that, and you use the intent generated there to automatically transition sub status once its paid
Ok so please advise me on the correct flow and how to fix this, as I am still a little unclear
-
create the customer and get their customer id
-
create a subscription using the customer id
-
return back the subscription id, the client secret (are there any other necessary fields?)
-
now initialise the payment sheet with the above client secret?
const { error } = await initPaymentSheet({
paymentIntentClientSecret: clientSecret, //THAT WE GET FROM THE SUBSCRIPTION CALL
returnURL: "your-app-scheme://payment-sheet",
// allowsDelayedPaymentMethods: true,
}); -
present this payment sheet
-
the user fills in the information and confirms the sbscription payment?
Is the above correct
Just follow this flow: https://docs.stripe.com/billing/subscriptions/build-subscriptions?platform=react-native
But yes, looks about right
ok sure thiing, I will have a go again at following the above, and try not to diverge from it at this point
Yeah you just need not to create a Payment Intent directly. The Subscription creation handles that either via latest_invoice.payment_intent (which you have in your code) or pending_setup_intent if there's no initial payment (i.e. a trial)