Workflows / Stripe / customer.source.expiring

Stripe Card Expiring Notification to Slack & Email

Use the Stripe integration by MagicBell to setup a workflow when customer.source.expiring triggers in Stripe.

Connect Stripe to MagicBell to receive events and trigger workflows. This guide uses the MagicBell CLI.

Add the Stripe integration

Save your Stripe webhook signing secret in MagicBell. See Stripe webhooks.

magicbell integration save_stripe \
  --data '{"webhook_signing_secret":"whsec_xxx"}'

Copy the ID from the response and use it to build your webhook URL:

https://api.magicbell.com/v2/integrations/stripe/webhooks/incoming/{id}

Setup the webhook

Add a workflow

Create a workflow that triggers automatically when Stripe sends this event.

Workflow key

Use this key to trigger the workflow when Stripe sends a customer.source.expiring:

integration.stripe.customer.source.expiring

Example workflow

Remind customers to update their payment method before it expires to avoid service interruption.

{
  "key": "integration.stripe.customer.source.expiring",
  "steps": [
    {
      "command": "broadcast",
      "input": {
        "content": "Your {{payload.data.object.brand}} card ending in {{payload.data.object.last4}} expires {{payload.data.object.exp_month}}/{{payload.data.object.exp_year}}. Please update your payment method to avoid service interruption.",
        "recipients": [
          {
            "external_id": "{{payload.data.object.customer}}"
          }
        ],
        "title": "Card expiring soon"
      }
    }
  ]
}

Save with the CLI

Use the MagicBell CLI to save this workflow to your project. You can also use the Workflows API endpoint instead.

magicbell workflow save \
  --data '{"key":"integration.stripe.customer.source.expiring","steps":[{"command":"broadcast","input":{"content":"Your {{payload.data.object.brand}} card ending in {{payload.data.object.last4}} expires {{payload.data.object.exp_month}}/{{payload.data.object.exp_year}}. Please update your payment method to avoid service interruption.","recipients":[{"external_id":"{{payload.data.object.customer}}"}],"title":"Card expiring soon"}}]}'

Event payload

Sample payload for the customer.source.expiring event. Use liquid templates to access fields in your workflow.

{
  "api_version": "2023-10-16",
  "created": 1694109741,
  "data": {
    "object": {
      "brand": "visa",
      "customer": "cus_Na6dX7aXxi11N4",
      "exp_month": 12,
      "exp_year": 2024,
      "funding": "credit",
      "id": "card_1NqIlRLkdIwHu7ixCcM5No8p",
      "last4": "4242",
      "object": "card"
    }
  },
  "id": "evt_1NqIlSLkdIwHu7ixBbL4Mn7o",
  "livemode": false,
  "object": "event",
  "type": "customer.source.expiring"
}
View all Stripe workflows →