#coreyw - confirmCardPayment
1 messages ยท Page 1 of 1 (latest)
You will need to make the separate attach call
I don't believe there is currently a way to configure it such that the attach happens automatically
Thank you for that clarification, @hexed narwhal . Is there a situation in which it would be desirable to not have the customer associated with the payment method like this?
Just so I understand the use cases
Apologies, I was completely wrong about that. You can use setup_future_usage to automatically attach the payment methods https://stripe.com/docs/api/payment_intents/update#update_payment_intent-setup_future_usage
https://stripe.com/docs/js/payment_intents/confirm_card_payment#stripe_confirm_card_payment-data-setup_future_usage
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
If you want to re-use the payment method, you will definitely want to attach it to a Customer object.
Not attaching is for things like one time payments
Ah, I see. Does it only automatically attach the customer to the payment method if off_session is specified?
Or does it attach it for on_session too, as long as I specify a value for setup_future_usage
off_session is a separate setting, indicating whether the user is currently sitting at their computer putting in the info or not
If the user is currently putting in their CC info, you will want to use on session
Yup, I'm just wondering if the customer record gets associated with the payment method regardless of on_session or off_session
Oh interesting, you can't actually attach a payment method to a customer after it's been used. If you try, this error is returned:
This PaymentMethod was previously used without being attached to a Customer or was detached from a Customer, and may not be used again. So even stripe.paymentMethods.attach() won't work here. So if we have no intention of reusing a payment method, we actually can't attach it to the customer.
I decided against using setup_future_usage since we don't plan to reuse the payment methods. At this point I was just hoping to attacht the payment method to the customer for data completeness and perhaps troubleshooting purposes
Gotcha. Yes that is the intended behavior, to be able to reuse them you would need to set that when initially confirming the payment. Glad you have your answers and know what you want to do going forward
Ugh, I can't even add metadata to the payment method if it isn't attached to the customer ๐ฆ
I am surprised that you can't. Can you send me the request ID (req_123) from when you got that error?
The end goal here is still debugging?
Sure thing: req_0AbujFrQfzVtiM
Yeah, this is just for debugging purposes, though I'm ready to accept that I just can't do much with the payment method in these single-use cases.
I'm adding metadata to the paymentIntent instead, and I can still get to the customer and payment method through the payment intent if I need to.
We just like to connect all of the resources we can to make troubleshooting easier down the road ๐
Gotcha. This info will still be on the failed Charge object from when the payment fails. So it can still be looked up/linked to the customer if you don't record it when the failure happens, it will just take an extra step or two.