Stripe webhooks: disputes, failed payments and payouts as signals
Point a Stripe event destination at a Pulso webhook source and turn disputes, failed payments and failed payouts into signals, each with the steps to handle it.
Stripe sends an event for everything that happens in your account. Send the ones that need a person to a Pulso webhook source and each becomes a signal with a playbook: a dispute to answer before its deadline, a customer whose card keeps failing, a payout that didn’t reach the bank.
Connect Stripe#
Add Stripe to Pulso to create a webhook source called Stripe; it shows these steps with the source’s URL and takes its signing secret, then creates the monitors below that you pick, with their playbooks and a report. To start from scratch instead, create a webhook data source called Stripe.
- In Stripe, open the Webhooks tab in Workbench and click Create an event destination.
- Select Your account.
- Choose the Snapshot payload format and an API version. Stripe recommends Thin for new code, but a thin event only carries the event type and the id of the object it’s about, with no amount, status or reason for a monitor to filter on.
- Select the event types, such as those on this page, then Webhook endpoint as the destination type.
- Paste the source’s Endpoint URL,
https://hooks.pulso.run/webhooks/<id>/<token>, as the destination’s Endpoint URL and save. - Open the destination, reveal its Signing secret (
whsec_…) and paste it as the source’s signing secret: below these steps in Add to Pulso, or from scratch in its signature settings with the Stripe scheme.
Through Stripe’s API, the same destination is a POST /v2/core/event_destinations with "type": "webhook_endpoint", "event_payload": "snapshot", the event types in enabled_events and the Pulso URL in webhook_endpoint.url.
One source can take every Stripe event: each event carries its type, and each monitor picks its own with a filter. To try it, create the destination in a sandbox and trigger an event with the Stripe CLI, for example stripe trigger payment_intent.succeeded; it shows up under the source’s Recent events.
What arrives#
A snapshot event is the whole Event object, with the object it’s about in data.object. This is Stripe’s Event example with its Dispute example as data.object, trimmed:
{
"id": "evt_1NG8Du2eZvKYlo2CUI79vXWy",
"object": "event",
"api_version": "2019-02-19",
"created": 1686089970,
"data": {
"object": {
"id": "du_1MtJUT2eZvKYlo2CNaw2HvEv",
"object": "dispute",
"amount": 1000,
"balance_transactions": [],
"charge": "ch_1AZtxr2eZvKYlo2CJDX8whov",
"currency": "usd",
"evidence_details": {
"due_by": 1682294399,
"has_evidence": false,
"past_due": false,
"submission_count": 0
},
"metadata": {},
"payment_intent": null,
"reason": "general",
"status": "warning_needs_response"
}
},
"livemode": false,
"pending_webhooks": 0,
"request": { "id": null, "idempotency_key": null },
"type": "charge.dispute.created"
}
Its monitors see these columns:
| Column | Value |
|---|---|
id |
evt_1NG8Du2eZvKYlo2CUI79vXWy |
type |
charge.dispute.created |
created |
1686089970 |
data.object.id |
du_1MtJUT2eZvKYlo2CNaw2HvEv |
data.object.amount |
1000 |
data.object.currency |
usd |
data.object.charge |
ch_1AZtxr2eZvKYlo2CJDX8whov |
data.object.reason |
general |
data.object.status |
warning_needs_response |
data.object.evidence_details.due_by |
1682294399 |
data.object.evidence_details.has_evidence |
false |
data.object.balance_transactions |
[], the whole list in one column |
data.object.metadata |
{} |
data.object.payment_intent |
null |
livemode |
false |
request.id |
null |
Amounts are integers in the currency’s smallest unit, so 1000 is $10.00, and times are Unix timestamps in seconds.
Monitors to build#
Disputes to answer#
- Filters:
typeequalscharge.dispute.created. - Uniq by:
data.object.id, so a dispute delivered twice opens one signal. - Playbook: assign it to whoever handles chargebacks, a task to gather the order, the delivery proof and the customer’s emails, and an approval before submitting the evidence in Stripe. The deadline,
{{signal.data.object.evidence_details.due_by}}, goes in the task’s text.
Large failed payments#
- Filters:
typeequalspayment_intent.payment_failed,data.object.amountgreater than50000($500.00). - Uniq by:
data.object.id: one signal per payment, however many attempts fail. - Playbook: the reason is in
data.object.last_payment_error.code,.decline_codeand.message. A question step asks whether to contact the customer, and an email step writes to{{signal.data.object.receipt_email}}when it’s set.
Subscriptions that keep failing#
- Filters:
typeequalsinvoice.payment_failed,data.object.attempt_countgreater than2. - Uniq by:
data.object.id, one signal per invoice. - Playbook: email
{{signal.data.object.customer_email}}the invoice’s{{signal.data.object.hosted_invoice_url}}to update the card, then a task to call them if it’s still unpaid.
Failed payouts#
- Filters:
typeequalspayout.failed. - Uniq by:
data.object.id. - Playbook: a Slack notification to finance with
data.object.amount,data.object.failure_codeanddata.object.failure_message, and a task to fix the bank account in Stripe.
Heartbeat: payments stop arriving#
Add payment_intent.succeeded to the destination’s events and create a heartbeat monitor on the source: filters type equals payment_intent.succeeded, Frequency hourly, a grace period of 30 minutes. If an hour goes by without a successful payment, it raises a signal, which catches a broken checkout as well as a destination Stripe disabled. Pick hours your shop actually sells in with a custom schedule, like 0 9-21 * * *.
Limits#
- Signatures. With the destination’s signing secret and the Stripe scheme, Pulso checks
Stripe-Signatureand its timestamp; enforce it before a playbook step moves money. Each destination has its own secret, and a sandbox’s differs from live’s. - Duplicates and order. Stripe may deliver an event more than once and doesn’t guarantee their order. Uniq by the object’s id handles the duplicates; don’t rely on one event arriving before another.
- Snapshots can be stale.
data.objectis the object when the event happened; by the time someone opens the signal, Stripe may have moved on. - Retries. If a delivery fails, Stripe retries for up to three days in live mode and three times over a few hours in a sandbox. It counts a redirect as a failure, so use the URL exactly as Pulso shows it.
- Lists stay whole.
data.object.balance_transactionsorpayment_method_typesare one column each; acontainsfilter searches their text, but a number filter can’t read inside them.
Sources: Stripe’s webhooks guide, how events work, the Event, Dispute and PaymentIntent objects, and the event types.
Add Stripe to Pulso: a webhook source, 5 monitors with their playbooks and a report, then these steps with the source's URL.
- Stripe disputes to answer
- Stripe large failed payments
- Stripe subscriptions that keep failing
- Stripe failed payouts
- Stripe payments stop arriving
- Report: Stripe