#Matt11
1 messages · Page 1 of 1 (latest)
hello! how can I help?
This is my flow:
- inside the checkout page I create a setup intent
- I confirm it
- if the customer selected a plan with trial days I proceed to homepage; otherwise the customer need to pay so I create a payment intent server-side and I confirm it.
But using this card (4000002500003155), for example, I receive two 3DS requests: one for the SI and one for the PI so for the customer is not a good thing.
what I'd like to do is create a setup_intent in case I'm in the checkout with a plan with trial days or directly create a payment_intent in case I'm with a plan without trial days.
The only problem with this choice is that I don't know in advance how much the user will pay because, in the checkout, there is the option to enter a coupon code that lowers the price.
you don't need to create a SetupIntent, a Subscription with a trial will create one - you'll want to expand [0] the pending_setup_intent [1] when creating the Subscription and use that to initialize the Payment Element.
[0] https://stripe.com/docs/api/expanding_objects
[1] https://stripe.com/docs/api/subscriptions/object#subscription_object-pending_setup_intent
are you not using the Stripe Billing product? i.e. creating a Subscription : https://stripe.com/docs/billing
no, we don't use subscriptions. The customer want to use setup intents and payment intents, this is why I'm doing this.
can you help about this please?
ah i see, then for the PaymentIntent, you should create it with off_session=true
since you're creating and confirming the PaymentIntent server-side
I'm creating it with setup_future_usage = 'off_session' because in 1 year I need to do a sort of background job that created a renew that is off_session
or is it superfluous since before I'm creating a setup_intent with usage: 'off_session'?
to clarify, right now you're creating a SetupIntent to create the PaymentMethod, and then a PaymentIntent with the saved PaymentMethod?
exactly
like this { amount: pay_order.final_amount.to_i, customer: user.stripe_customer_id, currency: 'eur', payment_method: payment_method.id, confirm: true, setup_future_usage: 'off_session' }
create the PaymentIntent with off_session=true : https://stripe.com/docs/api/payment_intents/create#create_payment_intent-off_session
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
so basically since I'm confirming server-side every PI need to have off_session: true, rght?
yes, that's correct
I was thinking that since I'm creating the PI after the checkout the user was in-session.
But I believe that in-session is only when I do the confirmPayment directly inside my html page right?
yep, that's correct
cool seems to work!