#Nebojsa
1 messages · Page 1 of 1 (latest)
Attaching the Payment Method to the Customer object is a separate step (usually): https://stripe.com/docs/api/payment_methods/attach
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
You would have the Payment Method ID before you attach it in this case
I'm sorry, can you clarify? If I want to offer multiple payment methods how would I access the payment method ID required to attach it to a customer?
If you're using multiple payment method types (e.g. ACH, SEPA, card, Google Pay, etc.) I would recommend using either Stripe Checkout or the Stripe Payment Element.
Checkout is a low-code option: https://stripe.com/docs/checkout/quickstart
Payment Element is a high-code option, but is more customizable: https://stripe.com/docs/payments/quickstart
Yep, I'm using Element
What I'm asking is, how can I attach their payment method after they finish payment?
I see that on the intent successful webhook I get the payment method id back. I suppose I can just tie it to the customer then
Correct. You would retrieve the Customer object and/or the Payment Method object and use customer.id and payment_method.id to attach the payment method to the customer using the server-side API call I referenced above: https://stripe.com/docs/api/payment_methods/attach
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Awesome. Thank you
Still not working
Here's an excerpt from the paymentIntent create docs
ID of the Customer this PaymentIntent belongs to, if one exists.
Payment methods attached to other Customers cannot be used with this PaymentIntent.
If present in combination with setup_future_usage, this PaymentIntent’s payment method will be attached to the Customer after the PaymentIntent has been confirmed and any required actions from the user are complete.
Meaning it should automatically attach this payment method, but it does not?
I've tried calling the attach function you linked above on a payment method after a succesful payment but I still don't seem to be getting it when I retrieve customer by ID
I've made sure to inlcude source in the customer response
Try using this endpoint: https://stripe.com/docs/api/payment_methods/customer_list
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Does the payment method show up?
Yep!
So creating a payment intent, if I want to make it off_session, I need to have confirm set to true and also provide a payment method id?
As well as a customer id I suppose