#Peter Boyd - Incomplete Payments
1 messages ยท Page 1 of 1 (latest)
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,
}
});
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.
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
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.
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?
Gotcha, so this is the guide I would recommend you follow: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements
(Fixed the link.)
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
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?
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
Ah, okay, so this is a better guide for your use case then: https://stripe.com/docs/payments/save-during-payment
You don't use a Setup Intent at all. You use a Payment Intent with setup_future_usage instead.
Happy to help!
thanks man! I'll ping you if I run into issues
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
๐ 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)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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
Yup!
ok great, that makes sense
And when you have a saved payment method you can also pass in confirm: true to attempt payment - we go into more specifics later in the doc that rubeus sent over earlier - https://stripe.com/docs/payments/save-during-payment#ios-charge-saved-payment-method