Get notified when payment method is added/updated
Problem Statement
This article explains how to get notified when a payment method is added or updated for a customer, and how to assign payment roles (primary or backup) when this happens.
Solution
Use webhooks to listen for payment_source_added and payment_source_updated events. When these events occur, extract the payment method ID and customer ID from the payload, then call the Assign payment role API to set the role (primary, backup, or none).
Steps to Set It Up
- Set up a server endpoint to receive webhooks. See Webhook settings.
- When creating or editing the webhook, select Payment source added and Payment source updated.
- Parse the webhook payload to get
payment_source_idandcustomer_id. - Call the Assign payment role API with:
- payment_source_id: The payment source to assign the role to
- role:
primary,backup, ornone
Was this article helpful?