This article covers
How to assign payment roles for a customer when a payment method is added or updated?
How can we get notified if a customer adds a payment method?
This article will help you with getting notified when a payment method is added or changed for a customer.
You need a server to receive the webhooks to be able to listen to the events sent by Chargebee.
Refer to https://support.chargebee.com/a/solutions/articles/237887 to create webhooks in Chargebee.
If you have selected only a few events while creating a webhook, make sure to select Payment source added and payment source updated events as well.
Extract the Payment method ID and customer id from the above events.
Make an assign payment roles API call to assign the payment role as required.
You can make use of the Assign payment Role API call to mark a payment method as Primary or back-up using API. It is necessary to pass the below parameters
Payment_source_id : Payment source id this role will be assigned to.
Role : primary, backup,none.
Related articles and Documentation