#razvi073
1 messages · Page 1 of 1 (latest)
hi! you would use confirmSetup (not confirmCardSetup) but yes, it works.
it's not documented unfortunately but it's the same guide as https://stripe.com/docs/elements/express-checkout-element/ just you create a SetupIntent instead of a PaymentIntent on the backend, and use mode:setup instead of payment and use confirmSetup instead of confirmPayment.
on the backend currently I am using stripe.subscriptions.create for this subscription that also has a trial, what method should I change it with in order to get a setupIntent instead of the payment_intent?
there would be pending_setup_intent on the Subscription object and you can use that
weeklySubscription.pending_setup_intent['client_secret'], this is the intent that i sent to the confirmSetup method
but after trying that I received an error
give me 1 sec
sounds good
"Payment details were collected through Stripe Elements using automatic payment methods and cannot be confirmed with a Setup Intent configured with payment_method_types." this is the error I am receiving and from what I searched payment_method_types is something I need to setup in the front-end, but I don't know where exactly
can you share the exact code used to
- create the Subscription
- confirm the SetupIntent on the frontend
- share the SetupIntent ID
seti_xxx
let weeklySubscription: any = await stripe.subscriptions.create({ customer: customer.id, items: [ { price: weeklyPrice, }, ], payment_behavior: 'default_incomplete', payment_settings: { save_default_payment_method: 'on_subscription', }, expand: ['latest_invoice.payment_intent', 'pending_setup_intent'], trial_end: weeklyTrialEndDate, });
but yeah it's an annoying pit of edge cases you fall into here due to differences in how Subscriptions work versus creating SIs directly, sorry
this is how i setup the subscription
then after that i send pendingIntent: weeklySubscription.pending_setup_intent['client_secret'], to the front-end
error = await this.stripe.confirmSetup({ elements: elements, clientSecret: pendingIntent, confirmParams: { return_url: 'https://chat.thebiblechat.app/download', }, }); and this is how i try to confirm it in the front-end
this.elements = this.stripe.elements({ mode: 'setup', currency: this.allData.currency.toLowerCase(), amount: this.allData.weeklyProductPrice, });
and this is the elements object I use
thanks, that's helpful. And what's the SetupIntent ID seti_xxx where you're getting an error?
I get a new one everytime but let's say for "seti_1NrfrYHPmb4c2WP93SeVO0TP_secret_OezrNoYvcigUlrb2Mae4PlsxIbouu0W"
so "seti_1NrfrYHPmb4c2WP93SeVO0TP"
ok I think I was wrong then and you'd need to use confirmCardSetup instead of confirmSetup
confirmSetup would only work if you created the SetupIntent yourself and used automatic_payment_methods, but here the Subscription creates the SetupIntent and explicitly sets the payment method types instead, so confirmSetup doesn't work with it. Sorry, it's a mess.
honestly I don't know, since confirmCardSetup can't take an ExpressCheckoutElement. I'm not sure this is even possible unfortunately
So would there be another way to get a subscription with a 3 day trial and confirm it with the expressCheckoutElement?
👋 taking over for my colleague. Let me catch up.
ow hi again @glossy pivot
in my opinion the easiest option would be to not use the ExpressCheckoutElement and just use the old PaymentRequestButton, which will definitely work (you can call confirmCardSetup with the ID of the PaymentMethod it creates, inside the callback, like the example at https://stripe.com/docs/stripe-js/elements/payment-request-button?client=html#html-js-complete-payment (again that example is only for payments but you could use it with SetupIntents)).
does it support paypall?
no
so yeah, might be impossible unfortunately until we add more functionality to ExpressCheckoutElement and make it work better with Subscritions, but Tarzan will investigate the options
I was using the PaymentRequestButton , but for some reason inside the tiktok browser I was not receiving anything from the canMakePayment() method. So I thought that maybe the expressCheckout would solve this issue by also adding the other options....
I doubt that would change anything, things not working inside embedded browsers would be the same and is caused by the app(TikTok)'s implementation rather than anything you'd control(you would just need to fall back to a regular card form)
are there any elements like the classic checkout page that includes all the payment methods including card, and also comes up from the bottom of the screen on mobile without needing a redirect?
or let me rephrase that, what would you use in the case that you'd want to guarantee that the customer has a a way to pay in any app browser, while also trying to keep the flow as frictionless as possible?
Hi! I'm taking over from my colleague. Please, give me a moment to catch up.
By "classic checkout page" you mean Stripe Checkout?
yes, but I wanted a way to reduce friction by not redirecting to another page
and also by providing some sort of one click payment by auto detecting the paymentMethod, but the tiktok browser doesn't like that very much
There's the Payment Element, that you can embed on your page: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements
Yes, depending on the customer location.
and it also supports subscriptions with trials?
Yes
could I try to use the PaymentRequestButton first and in the case that the canMakePayment() returns null, launch the Payment Element instead with the same setup_intent?
Sure, you can try this.
I'll try it like this then, thanks a bunch
Happy to help!