POST /customers/{customer-id}/update_payment_method
Updates payment method details for a customer.
Note: If you wish to pass the card number, CVV, or the single-use card tokens provided by gateways like Stripe, then use the Update card for a customer API under Cards resource. This API is not supported for Chargebee Test Gateway, which is provided to help you understand the billing workflow in Chargebee.
PayPal Express Checkout
You can use this API if you are directly integrating PayPal Express Checkout in your website instead of using Chargebee's hosted pages. When your customer updates his payment method using PayPal Express Checkout, you will be provided with the Billing Agreement ID by PayPal. You can update the payment method for that customer in Chargebee by passing type
as paypal_express_checkout
and reference_id
with the Billing Agreement ID.
Login and Pay with Amazon
You can use this API if you are directly integrating Login and Pay with Amazon in your website instead of using Chargebee's hosted pages. When your customer updates Amazon as a payment method, you will be provided with the Billing Agreement ID by Amazon. You can update the payment method for that customer in Chargebee by passing type
as amazon_payments
and reference_id
with the Billing Agreement ID.
Card Payments
When the card details of your customer are stored in the vault of gateways such as Stripe or Braintree, you can use this API to update the reference id provided by them in Chargebee. To use this API, pass
type
ascard
.gateway
with the gateway associated with the card. If the gateway is not specified, the default gateway will be used.reference_id
with the identifier provided by the gateway/Spreedly to reference that specific card.
Reference id format for Card Payments
The format of reference_id will differ based on where the card is stored.
Stripe: In case of Stripe, the reference_id consists of combination of Stripe Customer ID and Stripe Card ID separated by forward slash (e.g. cus_63MnDn0t6kfDW7/card_6WjCF20vT9WN1G ). If you are passing Stripe Customer ID alone, then Chargebee will store the card marked as active for that customer in Stripe.
Braintree: In case of Braintree, the reference_id consists of combination of Braintree Customer ID and Braintree Payment Method Token separated by forward slash (e.g. cus_63MnDn0t6kfDW7/card_6WjCF20vT9WN1G ). If you are passing Braintree Customer ID alone, then Chargebee will store the card marked as default for that customer in Braintree.
Spreedly Card vault: If the card details are stored in Spreedly vault, then you need to provide the Spreedly token as reference_id
.
Direct Debit Payments
When the bank account details of your customer is stored in the vault of Authorize.Net, you can use this API to update the reference id provided by them in Chargebee. To use this API, pass
type
asdirect_debit
.gateway
with the gateway where the bank account details are stored (e.g. authorize_net). If the gateway is not specified, the gateway supporting the direct debit will be used.reference_id
with the identifier provided by the gateway to reference the customer's bank account details.
Reference id format for Direct Debit Payments
The reference_id consists of combination of Authorize.Net's Customer Profile ID and Payment Profile ID separated by forward slash (e.g. 2384383/34834382). If you are passing Authorize.Net's Customer Profile ID alone, then Chargebee will store the first bank account details present in payment profile list of that customer in Authorize.Net.
Note: While using this API to update payment method details, Card Verification will not happen even if it is enabled for that particular gateway.
Servers
- {protocol}://{site}.{environment}:{port}/api/v1
- {protocol}://{site}-test.{environment}:{port}/api/v1
Path parameters
Name | Type | Required | Description |
---|---|---|---|
customer-id |
String | Yes |
Request headers
Name | Type | Required | Description |
---|---|---|---|
chargebee-request-origin-device |
String | No |
The device from which the customer has made the request |
Content-Type |
String | Yes |
The media type of the request body.
Default value: "application/x-www-form-urlencoded" |
chargebee-event-webhook |
String | No |
skip only webhooks Possible values:
|
chargebee-event-actions |
String | No |
skip all actions to be done on the events Possible values:
|
chargebee-request-origin-user |
String | No |
The email address of your customer/user. Use this when the email address has only ASCII characters. |
chargebee-request-origin-ip |
String | No |
The IP address of the customer where the request originated |
chargebee-request-origin-user-encoded |
String | No |
The Base64-encoded email address of your customer/user. Use this if the email address has UTF-8 characters. When this header is provided, the header |
chargebee-event-email |
String | No |
skip only emails Possible values:
|
Request body fields
Name | Type | Required | Description |
---|---|---|---|
payment_method |
Object | No |
Parameters for payment_method |
payment_method.gateway |
String | No |
Name of the gateway the payment method is associated with. * braintree - Braintree is a payment gateway. * chargebee - Chargebee test gateway. * nmi - NMI is a payment gateway. * ogone - Ingenico ePayments (formerly known as Ogone) is a payment gateway. * stripe - Stripe is a payment gateway. * eway - eWAY Account is a payment gateway. * first_data_global - First Data Global Gateway Virtual Terminal Account * paymill - PAYMILL is a payment gateway. * authorize_net - Authorize.net is a payment gateway * paypal_payflow_pro - PayPal Payflow Pro is a payment gateway. * paypal_pro - PayPal Pro Account is a payment gateway. * bluepay - BluePay is a payment gateway. * not_applicable - Indicates that payment gateway is not applicable for this resource. * tco - 2Checkout is a payment gateway. * hdfc - HDFC Account is a payment gateway. * balanced_payments - Balanced is a payment gateway * sage_pay - Sage Pay is a payment gateway. * wirecard - WireCard Account is a payment service provider. * worldpay - WorldPay is a payment gateway * pin - Pin is a payment gateway * eway_rapid - eWAY Rapid is a payment gateway. * migs - MasterCard Internet Gateway Service payment gateway. * beanstream - Bambora(formerly known as Beanstream) is a payment gateway. * elavon - Elavon Virtual Merchant is a payment solution. Possible values:
|
payment_method.type |
String | Yes |
The type of payment method. For more details refer Update payment method for a customer API under Customer resource. * card - Card based payment including credit cards and debit cards. Details about the card can be obtained from the card resource. * direct_debit - Represents bank account for which the direct debit or ACH agreement/mandate is created. * automated_bank_transfer - Represents virtual bank account using which the payment will be done. * amazon_payments - Payments made via Amazon Payments. * paypal_express_checkout - Payments made via PayPal Express Checkout. Possible values:
|
payment_method.reference_id |
String | Yes |
The reference id. In the case of Amazon and Paypal this will be the billing agreement id . In the case of card this will be the identifier provided by the gateway/card vault for the specific payment method resource. Note: This is not the one time temporary token provided by gateways like Stripe. |
How to start integrating
- Add HTTP Task to your workflow definition.
- Search for the API you want to integrate with and click on the name.
- This loads the API reference documentation and prepares the Http request settings.
- Click Test request to test run your request to the API and see the API's response.