Docs

Log into read the version of docs relevant to your site.

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

  1. Set up a server endpoint to receive webhooks. See Webhook settings.
  2. When creating or editing the webhook, select Payment source added and Payment source updated.
  3. Parse the webhook payload to get payment_source_id and customer_id.
  4. Call the Assign payment role API with:
    • payment_source_id: The payment source to assign the role to
    • role: primary, backup, or none

Was this article helpful?