#more-paymentintent-error
1 messages ยท Page 1 of 1 (latest)
I'm building a system were everytime someone adds a credit card to their file, we do a $1 charge to confirm it.
First you absolutely should never do that. Card issuers strongly dislike this and could flag your account/block you or decline charges overall
Overall for the error you have, you can't just charge the same card N times without attaching it first. So when you accept their first payment, you need to configure the PaymentIntent to properly save the card/attach it to a customer at the same time
This is done by setting setup_future_usage on the PaymentIntent as documented here: https://stripe.com/docs/payments/save-during-payment
If you don't charge them immediately, you can use the SetupIntent API for this instead as documented here https://stripe.com/docs/payments/save-and-reuse which lets you for example do 3D Secure and such upfront
Gotcha. Ya we save the card for later use
The idea for the $1 charge is they put up a card on file where then it would be used to confirm a potentially much larger payment
So customer has card on file
Customer contacts a service provider, service provider provides the server, which could range heavily in end price. Then we charge the customer and pay the service provider a portion of the proceeds
If we are discouraged to do a $1 confirmation charge, what else can be done to reduce risk or a "bad card"?
Nothing can be done
it's really easy for someone to have a card that they temporarily allow $1 authorization on
so that doesn't really prove much about the card itself
what you want is SetupIntent to configure the card upfront and we would potentially ask the bank if the card is valid (but we don't always) but overall even a valid card can be canceled and so whatever you're doing for the charge at a later date you need to be resilient to the charge failing
Hmm that is a business idea risk.
I see, I'll pass that on.
But I'll take your advice on setup_future_usage , and I'll try to convince them to just take the business risk for now ๐
Thanks for your help
sounds good!
I seem to still be getting this issue
Here is what I am doing on the backend in this order.
let paymentMethod = await stripe.paymentMethods.attach(paymentMethodId, {
customer: customerData.customer_id,
});```
2.
```js
let intent = await stripe.setupIntents.create({
customer: customerData.customer_id,
payment_method_types: ["card"],
usage: "on_session",
setup_future_usage: "on_session",
});```
A sample request id that failed: req_EMDJa0mIa2QauP
Hello! @elder valve had to step away, but I'd be happy to help! Let me get caught up...
hey aright. thanks ๐
Okay, so the very first thing you need to do is use the Setup Intent. Our recommended flow is:
- Create the Setup Intent and specify the Customer (create the Customer before this if needed)
- Send the Setup Intent's
client_secretto your client-side code - Use
stripe.confirmCardSetupto confirm the Setup Intent
Once the Setup Intent is successfully confirmed it will automatically attach the card Payment Method to the Customer and then you can reuse it again later.
Also, it's important to know that if you're not collecting an initial payment Setup Intents are the right choice, but if you are collecting an initial payment you should be using a Payment Intent with setup_future_usage and not a Setup Intent.
Ah yes, I am not collecting $ at the initial setup
Okay, so you don't need a Payment Intent at all in the beginning.
You only create a Payment Intent later when you're ready to collect payment.
correct ya
- I am currently setting up customer earlier
- Have difficulty implementing it like this... I tried to avoid a node server. Currently using "Firebase Functions" (which triggers on some database data change.. and not a true webhook). So i saved an intent for future use on all accounts.
What difficulty are you having exactly?
I think it's a problem with my flow after abit of debugging. Some of the intents that I created earlier was "old" and didn't have the fields I have now.
I'll try to mimic your flow suggestion 1/2/3.
If there's anything else I can do to help let me know!