#more-paymentintent-error

1 messages ยท Page 1 of 1 (latest)

elder valve
#

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

potent frigate
#

Ah

#

So just add the card normally

elder valve
#

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

potent frigate
#

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"?

elder valve
#

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

potent frigate
#

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

elder valve
#

sounds good!

potent frigate
#

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

hollow tapir
#

Hello! @elder valve had to step away, but I'd be happy to help! Let me get caught up...

potent frigate
#

hey aright. thanks ๐Ÿ˜„

hollow tapir
#

Okay, so the very first thing you need to do is use the Setup Intent. Our recommended flow is:

  1. Create the Setup Intent and specify the Customer (create the Customer before this if needed)
  2. Send the Setup Intent's client_secret to your client-side code
  3. Use stripe.confirmCardSetup to 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.

potent frigate
hollow tapir
#

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.

potent frigate
#

correct ya

#
  1. I am currently setting up customer earlier
  2. 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.
hollow tapir
#

What difficulty are you having exactly?

potent frigate
#

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.

hollow tapir
#

If there's anything else I can do to help let me know!