#hendr1x_confirmation-tokens
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1267460400526524438
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- hendr1x_api, 2 days ago, 140 messages
- hendr1x_api, 3 days ago, 28 messages
- hendr1x_api, 3 days ago, 34 messages
- hendr1x_api, 4 days ago, 13 messages
- hendr1x_api, 5 days ago, 38 messages
- hendr1x_api, 6 days ago, 53 messages
The issue is, payment methods can change
based on configuration settings
Is there no way to set a default for all payment methods?
"Optional
Setting conditional parameters setup_future_usage or capture_method based on payment method"
I was also told in the chat at one point that I should do set it on the front end in the elements object but I can't find any reference for that
You can set it when you create elements instance: https://docs.stripe.com/js/elements_object/create_without_intent#stripe_elements_no_intent-options-setupFutureUsage
So what is the best way?
That conflicts with the documentation I provided
I see. I would say, as long as you don't run into any issues, you can use the method I provided.
Also when you create the PaymentIntent, since you need to duplicate all the parameters: https://docs.stripe.com/payments/payment-element/migration-ct#server-side
what do you mean duplicate all the parameters?
Hi there ๐ jumping in as my teammate needs to step away soon.
Just want to make sure I've caught up correctly, sounds like you're building a two-step confirmation flow using Confirmation Tokens? The flow shown here?
https://docs.stripe.com/payments/build-a-two-step-confirmation
converting an existing checkout to use them
I'm just trying to implement setup_future_usage properly at this point
it seems like I have to do the flag on the elements now
and I should keep the existing flags on paymentIntent->create()
does that cover everything?
Yup!
You pass setupFutureUsage when creating the Elements instance:
https://docs.stripe.com/js/elements_object/create_without_intent#stripe_elements_no_intent-options-setupFutureUsage
which sets up the frontend to use that feature.
You also continue to pass setup_future_usage when creating the Payment Intent, which sets up the backend side of the flow.
Those will use the usage parameter instead. Additionally you'll need to change the mode that you use when creating the Elements instance to setup.
I don't see a usage parameter
ok. The setup on the elements is the same though between paymentIntent and setupIntent?
Nope, you need to change the value you're using for the mode parameter when creating the Elements instance:
https://docs.stripe.com/js/elements_object/create_without_intent#stripe_elements_no_intent-options-mode
I believe you would continue to pass the setupFutureUsage when initializing Elements, but don't remember exactly and am working on testing on the side. If you see an error when using that with mode set to setup, then you may need to remove the setupFutureUsage parameter.
You do
I got an error
message": "The provided setup_future_usage (off_session) does not match the setup_future_usage from the provided confirmation_token (null). Try confirming with a Setup Intent that is configured to use the same parameters as the ConfirmationToken."
So if I do setupIntent I just need to set it to 'setup'
nothing else to it?
Wait, Setup Intents, so this isn't a two-step confirmation flow then. Are you building a server-side confirmation flow for setting up payment methods? Just trying to make sure we're talking about the same thing so I can give the right guidance.
If so, then yes, setting the mode to setup is the frontend setting.
https://docs.stripe.com/payments/finalize-payments-on-the-server?platform=web&type=setup#web-collect-payment-details
Unfortunately my setup is complicated
Its a two-step confirmation that needs to support both setupIntent and paymentIntent based off configuration settings
It also needs to support saving payment methods to accounts for later usage
and I'm using confirmationTokens
I'm not sure I understand. The two-step confirmation flow is for when you need to collect payment method details before you're able to confirm the amount the customer should pay and are able to show them that amount. So I'm not grasping how this corresponds to a flow using Setup Intents. What are you confirming with the customer after collecting their payment method details?
I have a checkout flow that collects payment information, then shows a confirmation page for everyone.
Depending on configuration of the site it will charge payment immediately or confirmSetup() and then let the admin review the amount before collecting payment
I'm not sure if this answers your question
Hm, gotcha, I don't think that setup flow sounds the same as the two-step process for payments. This also aligns with why our guide for the two-step process only shows using Payment Intents.
For your Setup Intent flow, I'd suggest your checkout page use one of these patterns:
- This is the easiest version: https://docs.stripe.com/payments/save-and-reuse?platform=web&ui=elements
- But if you need server-side confirmation I'd suggest this one: https://docs.stripe.com/payments/finalize-payments-on-the-server?platform=web&type=setup#web-collect-payment-details
Then once you've confirmed the Setup Intent you can show your confirmation page.
I'd like to clarify, the only difference between creating elements for setupIntent and paymentIntent is the mode. If I am using a setupIntent I set mode to setup. That is the only difference?
That's the key one yes, you may need to drop other parameters that supported your payment flow like setupFutureUsage. Hard to say definitively without understanding your payment flow fully.
Ok. So that was my next question.
So I am using setupIntent, and I want to allow the admin to submit the payment off_session in the future AND I want to store the payment method to the visitors account is that going to be an issue?
No. That's the flow shown in our guide for using Setup Intents that I shared above.
Ok. I will review those documents. Thank you for your help.
Any time!
I have an issue. I am trying to elements.update()
I need to 'disable' setupFutureUsage that was previously assigned. The only options I have are on_session, off_session
How do I delete this setting or disable it
Something like
elements.update({'setupFutureUsage':null});
What do you see if you pass an empty string or null for that parameter?
I can't test it easily...but I will be able to in an hour or so
I will attempt that and see how it goes
Thanks again
Just tested and confirmed, passing null for that parameter unset it.
great thank you
I just ran into a new error "Payment details were collected through Stripe Elements using payment_method_types and cannot be confirmed with a Setup Intent configured with automatic payment methods"
So I am passing in the payment_method_types when creating an elements
That means your frontend and backend are using two different configurations, and they need to be brought into alignment. If you pass paymentMethodTypes when creating the Elements instance then you also need to pass payment_method_types when creating your intent.
Ok, I can pass that in
I also see 'automatic_payment_methods'
do I need to declare that false?
or .enabled=false
No, I'm pretty sure passing payment_method_types automatically disables that, but I expect you'll see an error pretty quickly if I'm mistaken.
sounds good
there one issue I know I'm gonna have...
At some point I need to get the payment_method_code to save to an account
However, because I switched to confirmation_tokens I no longer have that
Is there an easy way to get it?
I would like to avoid getting all payment_methods on a customer level
What is a "payment_method_code"? And what are you referring to here when you say "account"?
sorry
I can't keep track of all the variables
So I mean 'payment_method'
and account, is a user in my database
which will have payment_methods saved to them
So, if a customer saves their payment for future usage...I was planning on saving the payment_method.id into my db so it can be selected later for usage.
however I don't have that value any longer because I switched to using confirmation_tokens.
You mentioned confirmation tokens again, so is this back to talking about your two-step payment flow? Or are you looking at the Setup Intent flow with server-side confirmation?
I am using both paymentIntent and setupIntent with confirmationTokens
Does that answer your question?
Both checkout flows are also two step
both flows ask the visitor if they want to save payment to account if they are logged in
It doesn't, because we don't have a two-step flow for Setup Intents. So I'm trying to understand if you're using this server-side confirmation flow for Setup Intents, which is the only time you use Confirmation Tokens and Setup Intents together.
https://docs.stripe.com/payments/finalize-payments-on-the-server?platform=web&type=setup#web-collect-payment-details
Regardless, the place you're likely going to want to look for that ID is on the intent that was used once you've confirmed it. Both Setup Intents and Payment Intents have a payment_method field that holds the ID of the payment method that they used/created.
hendr1x_confirmation-tokens
Ok. That's what I'm looking for
I'm creating setupIntent server side, confirming via the frontend
WHen I say two step, I mean how my checkout process flows.
I think it might mean something different to you and your system
Yup, I'm very specifically referring to our one particular two-step confirmation flow:
https://docs.stripe.com/payments/build-a-two-step-confirmation
where details about a payment method must be collected in order to know what to charge the customer (for scenarios like: changing different fees per payment method type, adding in tax after collecting billing address details, etc)
There isn't a parallel for that for Setup Intents, because creating the Payment Method is the outcome of a Setup Intent's lifecycle, there isn't anything more that needs to be done once payment method details are available. This is from the Stripe side, there may be more things to do in your flow once you have those details.
Ok. That makes sense.
If you're confirming a Setup Intent client-side, you don't need Confirmation Tokens in that flow.
My understanding is that confirming will reduce the need for handling authentication when I try to process a payment in the future
There is a field to submit a confirmation_token to confirmSetup
That's for if you're confirming the Setup Intent server-side.
Which is mutually exclusive from the elements parameter, and if you're confirming client-side it's much easier to just pass in the Elements instance.
So, at this point I don't have the elements object any longer
that is a different page
Maybe I'm missing some context about your site, but I wouldn't build it that way. If you're doing client-side confirmation, I'd use one of these flows:
- https://docs.stripe.com/payments/save-and-reuse?platform=web&ui=elements
- https://docs.stripe.com/payments/accept-a-payment-deferred?platform=web&type=setup
They're very similar, the key difference being that the second one doesn't create a Setup Intent as early in the process.
Neither requires the use of confirmation tokens, and once you confirm the intent you have the ID of a Payment Method to use downstream rather than needing to handle a Confirmation Token.
If you absolutely need to split the collection of payment method details and confirmation of the setup intent, then that's diving down undocumented territory and some we'll likely need to go through some trial and error.
I wish you guys didn't have setupIntent and paymentIntent be so different
I was only alloted 2 days to work on this...I'm over 8 days in and I worked all weekend
I can't recode everything at this point and try to support two completely different flows