POST /payment_sources/create_using_permanent_token
Creates a payment source for a customer using a permanent token obtained from the payment gateway.
Use this API to add a payment method that has already been vaulted in your gateway account. The permanent token enables Chargebee to securely link the payment method to the customer. This enables payment collection for future charges (both recurring and one-time) without requiring the customer to re-enter their payment details.
Prerequisites & Constraints
- The permanent token must belong to a gateway account configured in Chargebee.
- The token should be a permanent/vault token, not a single-use token.
- When multiple gateway accounts are configured in Chargebee Billing, you must pass the
gateway_account_idparameter if:- Smart Routing is not configured for the payment method.
- Smart Routing is configured for the payment method, but the selected gateway account does not match the provided token.
Impacts
Pass the replace_primary_payment_source parameter as true to update the customer's primary_payment_source_id. Otherwise, the existing primary payment source will remain unchanged.
Servers
- {protocol}://{site}.{environment}:{port}/api/v2
- {protocol}://{site}-test.{environment}:{port}/api/v2
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 Valid values:
|
chargebee-business-entity-id |
String | No |
If the site has multiple business entities, you can use this custom HTTP header to specify the business entity for which Chargebee should perform the operation. |
chargebee-event-actions |
String | No |
skip all actions to be done on the events Valid 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-request-origin-user is ignored. |
chargebee-event-email |
String | No |
skip only emails Valid values:
|
Request body fields
| Name | Type | Required | Description |
|---|---|---|---|
payment_method_token |
String | No |
An identifier provided by the gateway or card vault for the specific payment method resource. Note:
|
customer_profile_token |
String | No |
A unique identifier associated with a customer`s profile within a payment gateway. Note:
|
card |
Object | No |
Parameters of tokenized card details |
card.iin |
String | No |
The Issuer Identification Number, i.e. the first six digits of the card number |
card.funding_type |
String | No |
Card Funding type * not_known - An unknown card. * prepaid - A prepaid card. * debit - A debit card. * credit - A credit card. * not_applicable - Used for ACH. Not applicable for cards Valid values:
|
card.brand |
String | No |
Card brand * jcb - A JCB card. * pay_by_bank - Pay By Bank * cabal - A Cabal card. * hipercard - An Hipercard. * other - Card belonging to types other than those listed above. * trustly - Trustly * electronic_payment_standard - Electronic Payment Standard * cartes_bancaires - A Cartes Bancaires card. * american_express - An American Express card. * visa - A Visa card. * cencosud - A Cencosud card. * bancontact - A Bancontact card. * cmr_falabella - A CMR Falabella card. * not_applicable - Used for offline entries in transactions. Not applicable for cards * rupay - A Rupay card. * maestro - A Maestro card. * carnet - A Carnet card. * nativa - A Nativa card. * discover - A Discover card. * argencard - An Argencard. * dankort - A Dankort card. * tarjeta_naranja - A Tarjeta Naranja card. * kbc_payment_button - KBC Payment Button * elo - A Elo card. * diners_club - A Diner's Club card. * mastercard - A MasterCard. Valid values:
|
card.expiry_year |
Integer | No |
Card expiry year. |
card.last4 |
String | No |
Last four digits of the card number |
card.expiry_month |
Integer | No |
Card expiry month. |
additional_information |
Object | No |
|
replace_primary_payment_source |
Boolean | No |
Indicates whether the primary payment source should be replaced with this payment source. In case of Create Subscription for Customer endpoint, the default value is True. Otherwise, the default value is False. Default value: false |
reference_id |
String | No |
The reference id. In the case of Amazon and PayPal, this will be the billing agreement ID. For GoCardless direct debit this will be Note:
|
customer_id |
String | Yes |
Identifier of the customer with whom this payment source is associated. |
gateway_account_id |
String | No |
The gateway account to which the payment source is associated. |
type |
String | Yes |
The type of payment method. For more details refer Update payment method for a customer API under Customer resource. * direct_debit - Represents bank account for which the direct debit or ACH agreement/mandate is created. * unionpay - Payments made via UnionPay. * faster_payments - Payments made via Faster Payments * google_pay - Payments made via Google Pay. * sepa_instant_transfer - Payments made via Sepa Instant Transfer * dotpay - Payments made via Dotpay. * pay_to - Payments made via PayTo * generic - Payments made via Generic Payment Method. * giropay - Payments made via giropay. * klarna_pay_now - Payments made via Klarna Pay Now * automated_bank_transfer - Represents virtual bank account using which the payment will be done. * stablecoin - Payments made via Stablecoin * paypal_express_checkout - Payments made via PayPal Express Checkout. * alipay - Payments made via Alipay. Payments made via Venmo * sofort - Payments made via Sofort. * pix - Payments made via Pix * wechat_pay - Payments made via WeChat Pay. Payments made via iDEAL. * trustly - Trustly * netbanking_emandates - Netbanking (eMandates) Payments. * upi - UPI Payments. * bancontact - Payments made via Bancontact Card. * kbc_payment_button - KBC Payment Button * card - Card based payment including credit cards and debit cards. Details about the card can be obtained from the card resource. * payconiq_by_bancontact - Payments made via Payconiq by Bancontact * amazon_payments - Payments made via Amazon Payments. * pay_by_bank - Pay By Bank * apple_pay - Payments made via Apple Pay. * electronic_payment_standard - Electronic Payment Standard Valid values:
|
issuing_country |
String | No |
2-letter (alpha2) ISO country code. Indicates your customer's payment method country of issuance. Applicable for PayPal via Braintree. |
mandate_id |
String | No |
An identifier of mandates which is an authorization given by the payer (usually a customer or account holder) to allow a third party such as a merchant or service provider to initiate payments from their account. Note:
|
skip_retrieval |
Boolean | No |
By default, the value is Note:
Currently, the Default value: false |
network_transaction_id |
String | No |
An identifier of the payment or authorization transaction at the gateway initiated using this payment method. Note:
|
billing_address |
Object | No |
Parameters for billing_address |
billing_address.line2 |
String | No |
Address line 2 |
billing_address.line1 |
String | No |
Address line 1 |
billing_address.email |
String | No |
The email address. |
billing_address.last_name |
String | No |
The last name of the billing contact. |
billing_address.line3 |
String | No |
Address line 3 |
billing_address.state_code |
String | No |
The ISO 3166-2 state/province code
without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set |
billing_address.zip |
String | No |
Zip or postal code. The number of characters is validated according to the rules specified here . |
billing_address.first_name |
String | No |
The first name of the billing contact. |
billing_address.state |
String | No |
The state/province name. Is set by Chargebee automatically for US, Canada and India If |
billing_address.country |
String | No |
The billing address country of the customer. Must be one of ISO 3166 alpha-2 country code . Brexit If you have enabled EU VAT in 2021 or later, or have manually enable the Brexit configuration, then |
billing_address.city |
String | No |
The name of the city. |
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.