Stripe Invoice Payment Notification to Slack & Email
Use the Stripe integration by MagicBell to setup a workflow when invoice.payment.succeeded 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
- Setup a webhook in Stripe with the URL from the last step.
- Select the invoice.payment.succeeded event.
- If you already have a webhook configured, make sure it includes this event.
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 invoice.payment.succeeded:
integration.stripe.invoice.payment_succeededExample workflow
Send invoice payment confirmation with a link to view or download the invoice.
{
"key": "integration.stripe.invoice.payment_succeeded",
"steps": [
{
"command": "broadcast",
"input": {
"action_url": "{{payload.data.object.hosted_invoice_url}}",
"content": "Your invoice {{payload.data.object.number}} for ${{payload.data.object.amount_paid}} has been paid. Thank you!",
"recipients": [
{
"external_id": "{{payload.data.object.customer}}"
}
],
"title": "Invoice paid"
}
}
]
}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.invoice.payment_succeeded","steps":[{"command":"broadcast","input":{"action_url":"{{payload.data.object.hosted_invoice_url}}","content":"Your invoice {{payload.data.object.number}} for ${{payload.data.object.amount_paid}} has been paid. Thank you!","recipients":[{"external_id":"{{payload.data.object.customer}}"}],"title":"Invoice paid"}}]}'Event payload
Sample payload for the invoice.payment.succeeded event. Use liquid templates to access fields in your workflow.
{
"api_version": "2023-10-16",
"created": 1694109081,
"data": {
"object": {
"amount_due": 1000,
"amount_paid": 1000,
"amount_remaining": 0,
"billing_reason": "subscription_cycle",
"collection_method": "charge_automatically",
"created": 1679609767,
"currency": "usd",
"customer": "cus_Na6dX7aXxi11N4",
"customer_email": "customer@example.com",
"customer_name": "Jenny Rosen",
"hosted_invoice_url": "https://invoice.stripe.com/i/acct_1M2JTkLkdIwHu7ix/live_YWNjdF8xTTJKVGtMa2RJd0h1N2l4",
"id": "in_1MowQVLkdIwHu7ixeRlqHVzs",
"invoice_pdf": "https://pay.stripe.com/invoice/acct_1M2JTkLkdIwHu7ix/live_YWNjdF8xTTJKVGtMa2RJd0h1N2l4/pdf",
"livemode": false,
"number": "INV-0001",
"object": "invoice",
"period_end": 1682288167,
"period_start": 1679609767,
"status": "paid",
"subscription": "sub_1MowQVLkdIwHu7ixeRlqHVzs"
}
},
"id": "evt_1NqIaSLkdIwHu7ixKlV8Wx1y",
"livemode": false,
"object": "event",
"type": "invoice.payment_succeeded"
}