Reputation: 1
Following the Stripe documentation, which uses curl, I have tried the code:
<cfhttp method = "POST" url="https://api.stripe.com/v1/payment_methods/pm_1LCuutGKxC2502V8WNrkE3Ja" result = "result">
<cfhttpparam type="header" name="Authorization" value="Bearer sk_test_51....">
<cfhttpparam type="FormField" name="customer" value = "cust_admin_1">
.....
</cfhttp>
where pm_1LCuutGKxC2502V8WNrkE3Ja is the Payment Method id from the JSON response when the card payment method was set up.
The above code gives the error: You cannot attach a PaymentMethod to a Customer during PaymentMethod creation. Please instead create the PaymentMethod and then attach it using the attachment method of the PaymentMethods API.
Of course the PaymentMethod had already been created, and indeed if I change the ID slightly I get the message No such PaymentMethod: pm_1LCuutGKxC2502V8WNrkE3Ja22 as would be expected.
Thanks in advance for any comments.
Upvotes: 0
Views: 1464
Reputation: 1938
The customer
parameter isn't available when updating an existing Payment Method object. If you're looking to attach a Payment Method to a Customer, you should instead use this endpoint.
Please note that the attach endpoint cannot facilitate 3DS authentication flows in the likely event that the bank/issuer requests authentication. It is therefore not recommended you create and attach Payment Methods this way, but instead use Setup Intents.
Upvotes: 0