#.abishek
1 messages · Page 1 of 1 (latest)
ok, looks like a new thread
Hi, my colleague had to step away. Do you mind summarising your question for me, please?
sure, so, when I use web elements and when a subscription has a trial, i use the $stripeSubscription->pending_setup_intent, so when I create the web elements, I need to use a setup as the intent when I do this.elements.create('payment', paymentElementOptions). is that correct?
because if the cutsomer already has a payment method, then I use $stripeSubscription->latest_invoice->payment_intent->client_secret and that returns a payment intent
is there a way to know if the returned secret is a setup intent or a payment intent, because right now the only way I can think of doing this is to check if the string starts with pi or seti
are there any other options?
let me know if it makes sense?
this is what I am currently doing
this.elements.create(clientSecret.startsWith('pi') ? 'payment' : 'setup', paymentElementOptions)
You can just record where you got the client_secret from. If. pending_setup_intent is present then you send setup_intent: true to the frontend. Or something like this.
ok, just did not want another variable to be passed to the UI, so was hoping there was something simpler on the stripe sdk
but is my code correct?
am I passing the correct stripe to the elements?
ok, i get an error
Wait, there's no "setup" element. The only differece is to use confirmPayment() and confirmSetup()
ok, so how do I use a setup intent with webelements?
Just use the client_secret with Payment Element
Payment Element suports both PaymentIntents and SetupIntents, there's no difference.
ok, then why do I get this error
Invalid value for elements(): clientSecret should be a client secret of the form ${id}_secret_${secret}. You specified: seti_1NvdCfJkQCRoh7rJwmoHVdb4.
when a subscription has a trial and the customer doesn't have no payment methods setup, I am getting the setup intent from $stripeSubscription->pending_setup_intent, isn't this the client secret?
That's not the client_secret but the SetupIntent ID
ok, where is the client secret?
You need to expand the ["pending_setup_intent"] when creating the Subscription, to get pending_setup_intent.client_secret
so, i only need to call confirmSetup or comfirmPayment based on the intent type and the parameters to both of them are the same
ya, I got blocked through cloudflare, had to connect to VPN