#hendr1x_api
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/1266371671569203304
๐ 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, 21 hours ago, 28 messages
- hendr1x_api, 22 hours ago, 34 messages
- hendr1x_api, 1 day ago, 13 messages
- hendr1x_api, 2 days ago, 38 messages
- hendr1x_api, 3 days ago, 53 messages
- hendr1x_api, 6 days ago, 87 messages
I'm trying to implement a 2 step checkout
hi there!
Hello
I coded everything and now am realizing it seems like SetupIntent doesn't support confirmation Tokens
yes it works with SetupIntent
https://docs.stripe.com/api/confirmation_tokens
ConfirmationTokens help transport client side data collected by Stripe JS over to your server for confirming a PaymentIntent or SetupIntent.
I don't see it in any of the docs I am using
That doesn't help me...I already have a confirmation token created
what's your specific question?
for example when you confirm a SetupIntent you can pass a confirmationToken: https://docs.stripe.com/js/setup_intents/confirm_setup#confirm_setup_intent-options-confirmParams-confirmation_token
ok.
Annoying
Everything was coded to work with payment_method
trying to convert to confirmationToken
doesn't seem to bring me any benefit
Thanks for your help though...I'll figure out how to get this data to confirm step
Annoying
what do you mean? you asked if SetupIntent work with confirmationToken, and I said yes. what's the issue then?
It seems when you converted your system from paymentMethod to confirmationTokens you made some large structural changes to how everything works
of course I am sure there are good reasons for this
but prior I provided payment_method to setupIntent/PaymentIntent
now I have to get the confirmationToken to a new place
I assume all the usage/saving of payment data has changed as well
I'm not sure I follow. you don't have to use confirmationTokens if you don't want to.
I was told by you guys its was the recommended
I've already done 5 days of work as well
While I got you...is there a guide somewhere on how to handle saving payment details for a customer using confirmationToken?
so I they can reuse
nope. but you can use this: https://docs.stripe.com/payments/build-a-two-step-confirmation and basically just replace stripe.paymentIntents.create() by stripe.setupIntents.create and confirmPayment() with confirmSetup() and it should work.
It seems like there are differences
I just noticed that setupIntent doesn't accept currency
Where do I provide that now?
yes there are some small differences. for example a SetupIntent doesn't have an amount or a currency.
you can see all SetupIntent parameters here: https://docs.stripe.com/api/setup_intents/create
you don't. a SetupIntent is not for making a payment, it's just to save a card for later.
Sorry
is your goal to make a payment and also save the card for later?
no worries, I'm happy to help ๐
So how do I use a setupIntent that has been confirmed
save for later
then yes it's a SetupIntent, without any currency or amount set.
once a SetupIntent is confirmed, it will have a Payment Method that you can reuse: https://docs.stripe.com/api/setup_intents/object#setup_intent_object-payment_method
lol
I thought I was getting rid of all payment_methods
to use confirmation_tokens
Is there a guide on using a setupIntent to complete a charge
I thought I was getting rid of all payment_methods
haha, no. payment method are still a key part of a Stripe integtaion!
Is there a guide on using a setupIntent to complete a charge
you mean reusing a existing PaymentMethod to make a payment? if so: https://docs.stripe.com/payments/save-and-reuse?platform=web&ui=elements#charge-saved-payment-method
ok. So this is a bit of an issue for me
Did I just lose you?
we're just changing over so I'll help if you have any followups
ok
just ignore everything before
I'm working on the last step @ https://docs.stripe.com/payments/save-and-reuse?platform=web&ui=elements#charge-saved-payment-method
Charge the saved payment later
Is it possible for me do this step with a confirmationToken and not a payment method code?
sure, it's possible, for example you can do https://docs.stripe.com/js/confirmation_tokens/create_confirmation_token#create_confirmation_token-options-params-payment_method with the ID of the saved payment method on the frontend, if that's what you're looking for.
I just converted everything in my app to run from confirmation tokens.
so I have already successfully created the token and confirmed the setupIntent
I guess I don't even really get the idea of setupIntent
it seems like its just a way to save a paymentMethod
yes
Can i just
clientSecret,
confirmParams: {
confirmation_token: '{{CONFIRMATION_TOKEN_ID}}',
return_url: 'https://example.com/order/123/complete',
},
});
using the confirmation_token I used to create the setupIntent?
no
or confirm the setupItent I mean
no, because the token is consumed when it's used.
so the only way for me process a payment
is for me to retrieve the payment_method from you guys?
by "payment_token" you mean a PaymentMethod ID pm_xxxx? yes, that is how it works; you have a Customer cus_xxx with a number of attached PaymentMethods(the SetupIntent is used to attach a PaymentMethod to a Customer without an initial payment), and you charge one of them by passing the ID of that attached PaymentMethod to a PaymentIntent.
I just spent 5 days removing all traces of payment_method from my system
not sure why you did htat
So...everything now runs from confirmation_tokens
you guys said it was the recommended way
a ConfirmationToken is just a short-lived ephermeral way to transport the context of the transaction from the frontend to the backend, not a persistent ID/object
multiple times
I doubt we said that explicitly. ConfirmationTokens are the recommended way to do certain flows(collecting details on the frontend and then being able to inspect them and add a "confirm your order" step before you use those details to complete a transaction or setup action).
Thats fine
and I don't mean to come off as frustrated at you
I'm just way over my time allotment for this task
that's all. Nothing is different in the overall model of Customer->PaymentMethod->PaymentIntent usage
So let me clarify
For one time payments...using paymentIntent. I am using confirmationTokens. In that situation I don't need to worry about paymentMethods at all correct?
if you have no interest in saving the card used in that one-time payment and using it again, then no, not really. You just confirm the PaymentIntent. There is a pm_xxx PaymentMethod created that you can look at, but it's not attached to the Customer object and can't be charged again.
Ok. That makes sense. That flow is this tutorial that I was following : https://docs.stripe.com/payments/build-a-two-step-confirmation
So now, sticking to the above guide...if I wanted to save the paymentMethod (attached to a customer) what is the recommended way
I still use confirmationTokens I assume. However I need to retrieve the paymentMethod correct?
to be clear, you want to do the payment and also save the card after that transaction? (like a "save your card for future payments here" option)?
I have two checkout flows...I'm sorry for the confustion. In this case I am discussing now, I want to do teh payment and save the card after the transaction...yes...exactly
I found this : https://docs.stripe.com/payments/save-during-payment?platform=web&ui=elements#save-payment-details-for-future-use
It looks like you guys are making me do this
'customer' => '{{CUSTOMER_ID}}',
'type' => 'card',
]);```
then the easiest way is just to pass setupFutureUsage when creating the Elements object(https://docs.stripe.com/payments/finalize-payments-on-the-server?platform=web&type=payment#additional-options) and then on the backend you pass in a customer and setup_future_usage when creating the PaymentIntent in step 5
-d "customer"="{{CUSTOMER_ID}}" \
-d "setup_future_usage"="off_session" \
I have my checkbox for "do you want to save payment method" on the same page has the elements object
I'm sorry I'm being a pain...this stuff is just very confusing to me
Is there a way to get a payment_method_id besides just looking up whats attached to the customer?
That's a real pain for how I coded it
cool, then when the value in that checkbox is set you can call https://docs.stripe.com/js/elements_object/update#elements_update-options-setupFutureUsage so that Elements knows you intend to save the card, so the ConfirmationToken gets created with that context.
let's stick to one thing at at time. You're seemingly also asking how to list and charge an existing payment method, when I'm trying to explain just how to save a card during a payment(so that it's then available for future payments), so one thing at a time
I have two flows...one that saves it for later (setupIntent) one that charges right away (paymentIntent)
both need to support saving card to customer
both are two step checkouts
Nothing is working...lol
So if you want to focus on something first that is fine
I think I understand how to handle both normal flows
I haven't grasped how to handle saving the card for later yet
ok, well that is what I've been addressing in my recent replies. It's basically the same as the one-time payment flow, just that you also pass setupFutureUsage.
ok
Can I just ask
Is there a way to get a payment_method_id besides just looking up whats attached to the customer?
Can I get it with a confirmation_token
or via a paymentIntent, setupIntent
you can :
- list PaymentMethods on the customer
- look at the
payment_methodfield on an existing completed PaymentIntent or SetupIntent - store the ID in your database and read that
- is a pain I would like to avoid if possible
- I don't think I ever get the id now that I am using confirmationTokens
so I think I need to #2
you do. It's on the PaymentIntent or SetupIntent after you use the ConfirmationToken to confirm it.
why is 1) a pain?
No worries....its how my code is...I'll have to do a diff againist an existing list of saved payment methods
One last question please
I'm looking at the docs you provide above
stripe.elements(options?) is shown twice
once without support for setupFurtureUsages once with
Whats going on with that?
because there's two ways to initialise the object :
- the "traditional" way is you create an Payment/SetupIntent on page-load and you just give Elements the client_secret of that. The Intent has all the information on the amount/currency/do-I-want-to-save-the-card so it doesn't need all that passed in to the constuctor
- the "deferred" way where you don't need to create the Intent until later, in which case you do need to pass the amount/currency/do-I-want-to-save-the-card as parameters to the constructor so Elements can show the right things.