# Shopify

> Count every paid Shopify order toward your campaigns, with no code and no app to install.

Source: https://docs.onari.xyz/docs/shopify

Connect a Shopify store and every paid order becomes an `order.paid` event for the customer who placed it, with the order total as the amount. Campaigns can then reward order challenges, streaks and leaderboards straight away.

## Connect

<Steps>
<Step>

### Create the connection in Onari

In the dashboard, go to **Developers → Website & stores → Shopify** and click **Connect Shopify**. Use **Sandbox** first with a development store, then do the same in **Live**. Onari adds `order.paid` ("pays for an order") to your events list.

</Step>
<Step>

### Add the webhook in Shopify

In Shopify admin, open **Settings → Notifications → Webhooks** and click **Create webhook**:

- **Event:** Order payment
- **Format:** JSON
- **URL:** the webhook URL from Onari (`https://api.onari.xyz/v1/connect/shopify/…`)

</Step>
<Step>

### Paste Shopify's signing key into Onari

Under the webhooks list, Shopify shows "Your webhooks will be signed with …". Copy that key into **Shopify signing key** in Onari and save. Onari refuses any order it can't verify with this key.

</Step>
<Step>

### Send a test

Click **Send test notification** next to the webhook in Shopify. Within seconds the Shopify card in Onari shows it. In live, Shopify's sample order isn't counted; in sandbox it is, so you can try a campaign.

</Step>
</Steps>

## What's counted

| Shopify | Onari event |
|---|---|
| `customer.id` | `player_id` |
| `current_total_price` (or `total_price`) | `amount`, in minor units for the order's currency |
| `currency` | `properties.currency` |
| `id` | `properties.order_id`; also the idempotency key, so each order counts once however often Shopify retries |

- **Guest checkouts aren't counted:** there's no customer to reward. Shopify lets you require or encourage customer accounts in **Settings → Customer accounts**.
- **Test orders** (Shopify's Bogus gateway) count in sandbox only.
- **Refunds don't undo rewards** already won.
- Plan limits apply as for API events. If a delivery can't be counted (for example your Free plan's monthly players are used up), Onari replies 200 so Shopify doesn't keep retrying, and the Shopify card shows why.

## Show rewards on your store

Add the [website embed](/docs/website-embed#shopify) to your theme so customers can see their progress and rewards. It uses the same `customer.id`, so orders and the Hub line up.

## Disconnect

**⋯ → Disconnect** on the Shopify card stops orders from counting. Delete the webhook in Shopify too.
