Gnosis
Gnosis

Reputation: 1

Problems passing id values to Stripe API objects using cfhttp

I am able to pass field values to Stripe's Customer object using the code

<cfhttp   method = "POST"  url="https://api.stripe.com/v1/customers">

    <cfhttpparam type="header" name="Authorization" value="Bearer sk_test_....."> 
    <cfhttpparam type="FormField" name="id" value = "cust_admin_18">
    <cfhttpparam type="FormField"   name="address[country]"  value = "US">
........
</cfhttp>

However when I try similar code with other Stripe objects, for example Payment_Method, I get an error with the id field. So

<cfhttp   method = "POST"  url="https://api.stripe.com/v1/payment_methods">

    <cfhttpparam type="header" name="Authorization" value="Bearer sk_test_....."> 
    <cfhttpparam type="FormField" name="id" value = "pm_123">

    <cfhttpparam type="FormField" name="type" value = "card">

    <cfhttpparam type="FormField"   name="card[number]"  value = "4242424242424242">
.......
</cfhttp>

produces an error parameter_unknown - id

Changing "FormField" to "header" stops the error, but then the id value is not passed.

Thanks in advance for comments.

Upvotes: 0

Views: 85

Answers (1)

koopajah
koopajah

Reputation: 25552

The code you are sharing is calling the Create Payment Method API. You are passing card details like the card number there. You can not pass the id parameter, it is not a valid parameter in the API and it's what the error message tells you. So you need to remove that part since it doesn't make sense to create a PaymentMethod while passing the id of an existing one.

Upvotes: 0

Related Questions