Stripe checkout.session.completed Event Notification to Slack & Email
Learn how to listen to the checkout.session.completed webhook event from Stripe to trigger a notification workflow in MagicBell.
Event payload
Sample payload for the checkout.session.completed event.
{
"api_version": "2023-10-16",
"created": 1694109441,
"data": {
"object": {
"amount_total": 2000,
"created": 1694109441,
"currency": "usd",
"customer": "cus_Na6dX7aXxi11N4",
"customer_email": "customer@example.com",
"id": "cs_test_a1b2c3d4e5f6g7h8i9j0",
"livemode": false,
"mode": "payment",
"object": "checkout.session",
"payment_status": "paid",
"status": "complete",
"success_url": "https://example.com/success",
"url": null
}
},
"id": "evt_1NqIgSLkdIwHu7ixQqA3Bc6d",
"livemode": false,
"object": "event",
"type": "checkout.session.completed"
}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 checkout.session.completed 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. Use liquid templates to access fields in your workflow.
Workflow key
Use this key to trigger the workflow when Stripe sends a checkout.session.completed:
integration.stripe.checkout.session.completedExample workflow
Send order confirmation when checkout completes successfully.
{
"key": "integration.stripe.checkout.session.completed",
"steps": [
{
"command": "broadcast",
"input": {
"action_url": "{{payload.data.object.success_url}}",
"content": "Thank you for your purchase! Your order of ${{payload.data.object.amount_total}} has been confirmed.",
"recipients": [
{
"external_id": "{{payload.data.object.customer}}"
}
],
"title": "Order confirmed"
}
}
]
}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.checkout.session.completed","steps":[{"command":"broadcast","input":{"action_url":"{{payload.data.object.success_url}}","content":"Thank you for your purchase! Your order of ${{payload.data.object.amount_total}} has been confirmed.","recipients":[{"external_id":"{{payload.data.object.customer}}"}],"title":"Order confirmed"}}]}'Test the workflow
Use the Stripe CLI to trigger test events and verify your workflow executes correctly.
1. Trigger a test event
Use the Stripe CLI to send a test event:
stripe trigger checkout.session.completed2. Verify the workflow ran
Check that MagicBell received the event and executed the workflow:
magicbell workflow list_runs --workflow_key integration.stripe.checkout.session.completed3. Debug issues
If the workflow failed or you need more details, fetch the run to see step-by-step execution:
magicbell workflow fetch_run --run_id {run_id}