#Peter Boyd - Incomplete Payments

1 messages ยท Page 1 of 1 (latest)

river isle
#

Hello! Can you provide more details, like a Payment Intent ID?

ocean zinc
#

pi_3KpxARJYMOMTx4nT1JIYwUz2

#
      const paymentIntent = await stripe.paymentIntents.create({
      customer: cashSender.stripeCustomerId,
      payment_method: cashSender.stripePaymentMethodId,
      amount: totalAmount,
      currency: 'usd',
      application_fee_amount: feeAmount,
      transfer_data: {
        destination: cashRecipient.stripeAccountId,
      }
    });
river isle
#

You're creating the Payment Intent here, but you're not confirming it. Payment Intents need to be confirmed in order to attempt the actual payment.

ocean zinc
#

after looking at the docs, I may need to add this:

      automatic_payment_methods: {
        enabled: true,
      }
#

how do we confirm using code?

#

the customer has already confirmed the transaction before this step

#

in our UI

river isle
#

We recommend you confirm the Payment Intent client-side so the customer can handle any async steps, like 3D Secure. You would pass the Payment Intent's client secret to your frontend and use Stripe.js to confirm.

ocean zinc
#

hmm.. I see

#

ok I'll try to reconfigure the add payment screen to make this work

river isle
#

I'd be happy to point you in the right direction if I can. Can you tell me more about what you're building and what from Stripe you're using? Are you using Stripe Elements, for example?

ocean zinc
#

yeah

#

we

#

we're building a marketplace where customers buy and sell virtual items

river isle
#

Can you provide more details?

#

Are you using Stripe Elements? If so, which one(s)?

ocean zinc
#

hey yeah

#

just PaymentElement

river isle
#

(Fixed the link.)

ocean zinc
#

ok got it, thats what I used but yeah I need to update the front-end flow

#

right now I'm getting the client secret by creating a setupIntent and then creating the paymentIntent after they added the payment info

river isle
#

To clarify, a Setup Intent should only be used if you want to collect payment information without taking a payment.

#

You would charged the collected payment info later on (like hours/days/weeks/months later). Is that the flow you want?

#

Or are you taking payment immediately?

ocean zinc
#

taking payment immediately, so yeah thats the better solution

#

create the paymentIntent , then have them add payment info using the client-secret that's returned from that specific paymentIntent

river isle
#

You don't use a Setup Intent at all. You use a Payment Intent with setup_future_usage instead.

ocean zinc
#

got it

#

that's helpful

river isle
#

Happy to help!

ocean zinc
#

thanks man! I'll ping you if I run into issues

ocean zinc
#

hey quick question

if a customer goes through a paymentIntent and adds payment info, will a future paymentintent request they add payment method again?

#

or will stripe automatically use the payment method they already added

polar cave
#

๐Ÿ‘‹ Rubeus had to head out but I'm hopping in to help!

#

If a Payment Method has been attached to a customer and set to invoice_settings.default_payment_method (see https://stripe.com/docs/api/customers/create#create_customer-invoice_settings-default_payment_method) then that Payment Method will be automatically used just for payments made for Invoices and Subscriptions.

For a plain old Payment Intent (created directly through /v1/payment_intents) Stripe won't automatically use the default, but you can specify that you want to use it in the request by setting it as payment_method (see https://stripe.com/docs/api/payment_intents/create#create_payment_intent-payment_method)

ocean zinc
#

ok so it'll be like

if a customer has a payment method id (saved to our DB)

    const paymentIntent = await stripe.paymentIntents.create({
      customer: cashSender.stripeCustomerId,
      payment_method: cashSender.stripePaymentMethodId,
      ...rest
    });

else

    const paymentIntent = await stripe.paymentIntents.create({
      customer: cashSender.stripeCustomerId,
      ...rest
    });
#

so include payment_method if it exists, otherwise leave it empty and have them go through the add-payment-method flow

polar cave
#

Yup!

ocean zinc
#

ok great, that makes sense

polar cave
ocean zinc
#

awesome

#

thanks