chargebee / chargebee-python

Python library for the Chargebee API.
https://apidocs.chargebee.com/docs/api?lang=python
MIT License
41 stars 32 forks source link

JSON payload issue #54

Open niolap opened 2 years ago

niolap commented 2 years ago

Hi there :)

I would like to send a payload as JSON to Chargebee API but it only works in URL encoded format, not in JSON format. I need to send JSON from the requests Python package without the Chargebee wrapper. Any idea?

As URL encoded: does work

$ curl  https://***********-test.chargebee.com/api/v2/payment_sources/create_card \
>      -u **************************************:\
>      -d customer_id="cbdemo_douglas" \
>      -d card[number]="378282246310005" \
>      -d card[cvv]="100" \
>      -d card[expiry_year]=2022 \
>      -d card[expiry_month]=12
{
    "payment_source": {
        "id": "pm_BTcLSfTGD1TtShje",
        "updated_at": 1662057402,
        "resource_version": 1662057402861,
        ...
        }
    }
}

As JSON: does not work

$ curl https://***********-test.chargebee.com/api/v2/payment_sources/create_card \
>      -u **************************************:\
>      -H 'content-type: application/json' \
>      -H 'accept: application/json' \
>      -d '{
>       "customer_id":"cbdemo_douglas",
>       "card":{
>         "number":"378282246310005",
>         "cvv":"100",
>         "expiry_year":"2022",
>         "expiry_month":"12"
>       }
>     }'
{"message":"customer_id : cannot be blank","type":"invalid_request","api_error_code":"invalid_request","param":"customer_id","error_code":"param_required","error_msg":"cannot be blank","error_param":"customer_id","http_status_code":400}
cb-sriramthiagarajan commented 6 months ago

Hi @niolap, I'm sorry for the delay in response.

We only support URL encoded payload currently. We'll consider supporting JSON payload in the future but I don't have any timeline at the moment.