#.abishek

1 messages · Page 1 of 1 (latest)

long elmBOT
versed bridge
#

ok, looks like a new thread

stoic dragon
#

Hi, my colleague had to step away. Do you mind summarising your question for me, please?

versed bridge
#

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)
stoic dragon
#

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.

versed bridge
#

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

stoic dragon
#

Wait, there's no "setup" element. The only differece is to use confirmPayment() and confirmSetup()

versed bridge
#

ok, so how do I use a setup intent with webelements?

stoic dragon
#

Just use the client_secret with Payment Element

#

Payment Element suports both PaymentIntents and SetupIntents, there's no difference.

versed bridge
#

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?

stoic dragon
#

That's not the client_secret but the SetupIntent ID

versed bridge
#

ok, where is the client secret?

stoic dragon
#

You need to expand the ["pending_setup_intent"] when creating the Subscription, to get pending_setup_intent.client_secret

versed bridge
#

ah,

#

thank you. let me try that

versed bridge
#

so, i only need to call confirmSetup or comfirmPayment based on the intent type and the parameters to both of them are the same

stoic dragon
#

Correct.

#

Sorry, it seems like Discord had some connectivity issues.

versed bridge
#

ya, I got blocked through cloudflare, had to connect to VPN