#gunwant_PaymentMethod
1 messages ยท Page 1 of 1 (latest)
This is expected because the PaymentMethod is already been used once.
You should attach the PaymentMethod to a customer before using it for payment,
Is there any way set this payment method for customer?
OKay.
Let me check.
https://stripe.com/docs/api/invoices/create?lang=node#create_invoice-default_payment_method Yes you can set a default_payment_method for the invoice
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
At that time I don't have a payment method.
I have got a payment method after confirmPayment.
My working flow.
- create customer
- Create invoice items
- Create an invoice
- finalize the invoice
when the invoice finalize I have used payment_intent.client_secret for initializing the stripe payment element and paying it usingconfirmPayment.
After successful payment, I have set the payment method for the customer.
OK. I'll suggest to change your flow a bit
- Create a customer
- Use SetupIntent API to collect a PaymentMethod for this customer
- Set the collected PaymentMethod to customer's
invoice_settings.default_payment_method - Create invoice items
- Create the invoice with customer and set
auto_advanceto true - Finalize the invoice -> the invoice will be paid with the default Payment method.
There's another flow that you can consider
- create customer
- Create invoice items
- Create an invoice
- finalize the invoice
- Set the invoice's PaymentIntent's
setup_future_usagetooff_session - Proceed with your current implementation and call stripe.confirmPayment at frontend
- The paymentmethod will be automatically attached to the customer
Please open this thread.
I'll try out this.
and let you know if any problems occur.
Hello
I have tried this flow.
Payment method attached of the customer.
But it doesn't set as the default payment method
๐ Taking over from Jack
Yup, above steps are to attach a payment method to a customer, but not making it as a default. You'll still need to update customer's default payment with invoice_settings.default_payment_method using Customers update API: https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method
Awesome! Great to hear that it works for you ๐
Thanks again.
Nice to talk with you.