Shopify webhooks: big orders, fraud, chargebacks and refunds as signals

Send a Shopify store's webhooks to Pulso and turn large orders, orders cancelled as fraud, chargebacks and refunds into signals, and know when orders stop coming in.

Shopify sends a webhook for each order, refund and chargeback in a store. Sent to Pulso, the ones that need a decision become signals: an order large enough to check before it ships, an order cancelled as fraud, a chargeback with a deadline.

Connect Shopify#

Add Shopify to Pulso to create a webhook source called Shopify; 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 Shopify.

Shopify names the topic, such as orders/create, only in the X-Shopify-Topic header, and an order looks the same whether it was just created or just cancelled. Pulso keeps the header as the http_headers.x_shopify_topic column, so one webhook source can take every topic of a store, and each monitor picks its topic with a filter.

  1. In the Shopify admin, go to Settings > Notifications > Webhooks and click Create webhook.
  2. Pick the event, set Format to JSON and paste the source’s Endpoint URL, https://hooks.pulso.run/webhooks/<id>/<token>. An XML delivery arrives in Pulso as an empty event.
  3. Pick the latest Webhook API version and save. Repeat for each event, with the same URL.
  4. Below the list of webhooks, Shopify shows the key they’re signed with. Paste it as the source’s signing secret: below these steps in Add to Pulso, or from scratch in its signature settings with the Shopify scheme. An app’s subscriptions are signed with the app’s client secret instead.
  5. Send a test notification from the webhook’s row and check the source’s Recent events.

An app subscribes in shopify.app.toml or with the GraphQL Admin API’s webhookSubscriptionCreate, with the source’s URL as the uri:

[[webhooks.subscriptions]]
topics = ["orders/create", "orders/cancelled", "refunds/create", "disputes/create"]
uri = "https://hooks.pulso.run/webhooks/<id>/<token>"

What arrives#

This is Shopify’s sample payload for orders/create, trimmed:

{
  "id": 820982911946154508,
  "name": "#9999",
  "order_number": 1234,
  "email": "jon@example.com",
  "created_at": "2021-12-31T19:00:00-05:00",
  "currency": "USD",
  "total_price": "404.95",
  "total_price_set": {
    "shop_money": { "amount": "404.95", "currency_code": "USD" },
    "presentment_money": { "amount": "404.95", "currency_code": "USD" }
  },
  "financial_status": "voided",
  "fulfillment_status": null,
  "cancel_reason": "customer",
  "cancelled_at": "2021-12-31T19:00:00-05:00",
  "test": true,
  "tags": "tag1, tag2",
  "source_name": "web",
  "payment_gateway_names": ["visa", "bogus"],
  "discount_codes": [],
  "customer": {
    "id": 115310627314723954,
    "email": "john@example.com"
  },
  "line_items": [
    { "id": 487817672276298554, "title": "Aviator sunglasses", "quantity": 1, "price": "89.99" }
  ]
}

Its monitors see these columns:

Column Value
id 820982911946154508
name #9999
email jon@example.com
total_price 404.95, a string a number filter still reads
total_price_set.shop_money.amount 404.95
total_price_set.shop_money.currency_code USD
financial_status voided
fulfillment_status null
cancel_reason customer
test true
tags tag1, tag2, one string
payment_gateway_names ["visa", "bogus"], the whole list in one column
customer.id 115310627314723954
customer.email john@example.com
line_items the whole list of items in one column
http_headers.x_shopify_topic orders/create
http_headers.x_shopify_shop_domain example.myshopify.com
http_headers.x_shopify_webhook_id the delivery’s id, the same when Shopify sends it again

Monitors to build#

Large orders to check before shipping#

Orders cancelled as fraud#

Chargebacks#

Refunds to review#

Heartbeat: orders stop coming in#

On the source, a heartbeat monitor with Frequency custom, 0 9-21 * * *, in the store’s time zone, and a grace period of 15 minutes. If an hour of opening time goes by without an order, it raises a signal: a broken checkout, a payment gateway down or a webhook Shopify removed. Filter on http_headers.x_shopify_topic equals orders/create, and add test is false so test orders don’t count.

Limits#

Sources: Shopify’s webhooks overview, delivery structure, troubleshooting webhooks, the webhook topics reference with each topic’s sample payload, and the Order resource.


Add Shopify to Pulso: a webhook source, 5 monitors with their playbooks and a report, then these steps with the source's URL.

Add to Pulso

See the monitors, their playbooks and the report