Copy link to clipboard
Copied
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.
You're almost there. You forgot the 'attach' command.
<cfhttp method = "POST" url="https://api.stripe.com/v1/payment_methods/pm_1LCuutGKxC2502V8WNrkE3Ja/attach" result = "result">
<cfhttpparam type="header" name="Authorization" value="Bearer sk_test_51....">
<cfhttpparam type="FormField" name="customer" value = "cust_admin_1">
.....
</cfhttp>
Copy link to clipboard
Copied
You're almost there. You forgot the 'attach' command.
<cfhttp method = "POST" url="https://api.stripe.com/v1/payment_methods/pm_1LCuutGKxC2502V8WNrkE3Ja/attach" result = "result">
<cfhttpparam type="header" name="Authorization" value="Bearer sk_test_51....">
<cfhttpparam type="FormField" name="customer" value = "cust_admin_1">
.....
</cfhttp>
Copy link to clipboard
Copied
Many thanks. This code works.