#Shayan-react-element
1 messages · Page 1 of 1 (latest)
for using stripe react-element, we need client-secret, previously I was creating stripe subscription with status incomplete, but it doesn't return client secret if trial is enabled. So I was recommended to use setup intent to get user's card and then attach that card with the subscription.
with this method, I'm facing 2 issues.
1: google pay isn't appearing for setup intent.
2: in setupIntent confirmation call, it requires a return url and provides setupintent client secret in the url params, I get the setup intent with this and then take payment method id from this to create a subscription, but since the client secret is returned in url parameter, user can refresh it by mistake will be charged twice, which is happening quite often
is there any other way to do this? to enable google pay and also safe way to create subscription
I doubt about 1. If you use our UI elements like PaymentElement you should have GooglePay support
I am checking about 2.
You meant this return_url right? https://stripe.com/docs/js/setup_intents/confirm_setup#confirm_setup_intent-options-redirect I still don't get the part where client scret is returned in this URL? Can you show me an example?
I believe you should take the SetupIntent from webhook, instead of url params of a redirected request. You should receive setup_intent.succeeded once a SetupIntent is successfully confirmed
on setup intent confirmation, it returns 3 params in the return url, setup_intent, setup_intent_client_secret and redirect_status
in case of webhook, how to link it with a subscription?
Isn't your Subscription created after you have a succeed SetupIntent? My understanding is that you had a SetupIntent setup on a Customer, now you can create Subscription on that Customer, using PaymentMethod Id collected via the SetupIntent
No actually the usecase is that we have a price id of subscription, then we show user a payment screen, which opens with setup intent, because we can't open it with trail subscription, where he enters his card details, then setup intent is confirm and the rest of the flow that is creating the isssue
this is the screen where the card is taken and the required use case is that on clicking continue the setup intent is confirmed and the subscription with trail is created with that payment method
Yes I see that's PaymentElement
Got it. So there are a few things here:
- If you rely on webhook instead of the redirected URL to "the rest of the flow" then you wouldn't face the problem of refreshing twice
- Event if you use the redirected URL, when you received a SetupIntent, you can check if its payment method id is already been used yourself. It would requires a de-dup logic on your server similar to any de-dup you would need for other incoming requests
Another solution is idempotency key. When you created the Subscription, you can pass in an idempotency key based on the setup intent id. Make sure same id will result in same idempotency key
2 requests with same itempotency key will only result in 1 Subscription
yes I think Idempotency key will help to avoid double billing, thanks a lot @worldly raft