ChargebeeAPI

Assign payment role

Idempotency Supported
Try in API Explorer

Assign 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:

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 status of the payment source. Check the status of 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 backup payment source to primary or none.
  • You cannot set the role of a primary payment source to either backup or none.

Implementation Notes

Before you call this API, ensure the following:

Sample Request

URL Format

POST https://[site].chargebee.com/api/v2/customers/{customer-id}/assign_payment_role

Input Parameters

payment_source_id
required, string, max chars=40

Payment source id this role will be assigned to.

role
required, enumerated string

Indicates whether the payment source is Primary, Backup, or neither.

Possible Enum Values
primary

Primary

backup

Backup

none

None

Returns

customerCustomer object
Resource object representing customer
payment_sourcePayment source object
Resource object representing payment_source