Idempotency Supported
Try in API ExplorerAssign or unassign the primary or backup payment role for a payment source.
Set role when creating a payment source
You can also assign a payment source as primary when you create it using APIs such as:
- Create a payment source using payment intent
- Create a payment source using temporary token
- Create a payment source using permanent token
Payment collection precedence
Chargebee uses the following precedence to determine which payment source to use when it collects payments for a subscription:
- The payment source attached to the subscription, if available.
- The primary payment source of the customer.
- The backup payment source of the customer, if available.
Prerequisites & Constraints
- The payment source must belong to the customer and must not be
deleted. - The payment source must not be the current primary payment source of the customer.
- This operation doesn't validate the
statusof the payment source. Check thestatusof the payment source before you assign it to the primary or backup role.
Impacts
Payment collection
The roles that you set using this API apply to all payments collected for the customer, except for subscriptions that have a payment source attached to them. Chargebee continues to collect such payments using the payment source attached to the subscription.
Customer
- When you assign a payment source as primary, Chargebee unassigns the existing primary payment source and doesn't affect the backup payment source.
- When you assign a payment source as backup, Chargebee unassigns the existing backup payment source and doesn't affect the primary payment source.
- You can set the role of a
backuppayment source toprimaryornone. - You cannot set the role of a
primarypayment source to eitherbackupornone.
Implementation Notes
Before you call this API, ensure the following:
- The
payment_source.customer_idmatches theidof the customer. - The
payment_source_idisn't the same as thecustomer.primary_payment_source_id. - Since this API doesn't validate the
statusof the payment source, check thepayment_source.statusto ensure it isn'texpired,invalid, orpending_verification.
Sample Request
URL Format
POST https://[site].chargebee.com/api/v2/customers/{customer-id}/assign_payment_role
Input Parameters
Returns
customerCustomer object
Resource object representing customer
payment_sourcePayment source object
Resource object representing payment_source