#coreyw - confirmCardPayment

1 messages ยท Page 1 of 1 (latest)

hexed narwhal
#

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

sonic sapphire
#

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

hexed narwhal
#
#

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

sonic sapphire
#

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

hexed narwhal
#

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

sonic sapphire
#

Yup, I'm just wondering if the customer record gets associated with the payment method regardless of on_session or off_session

sonic sapphire
#

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

hexed narwhal
#

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

sonic sapphire
#

Ugh, I can't even add metadata to the payment method if it isn't attached to the customer ๐Ÿ˜ฆ

hexed narwhal
#

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?

sonic sapphire
#

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 ๐Ÿ™‚

hexed narwhal
#

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.

sonic sapphire
#

Ok, noted! Thank you for stepping through all this!

#

I should be all set.