# Sales

How Whop payments become Purchase events, how refunds change them, and how to tie each sale to the ad that brought it.

Each payment on the connected Whop account becomes one `Purchase` event worth what the buyer paid, net of refunds. It counts in [campaign results](/guides/campaign-results) and [ad rules](/guides/ad-rules) once it is tied to a campaign.

## Before you start

The Account API key you connect with needs the `developer:manage_webhook` permission, so Zernio can add its own webhook, and the read permissions Whop lists for payment and refund webhooks.

A key without the webhook permission still connects and installs the Whop Pixel, but its sales are not counted: the connect call answers `salesWebhookRegistered: false`. Connect again with a key that has it.

Once an account receives sales, a reconnect with a key that cannot add the webhook fails and the current connection stays as it is.

## Tie a sale to its ad

Pass the visitor id the [Zernio tag](/products/server-side-tracking) keeps in its `_zid` cookie in the checkout configuration's `metadata` as `zernio_visitor_id`; Whop copies it to the payment, and Zernio adds the click ids of that visit.

You can also pass the visit's `zrn`, `gclid`, `fbclid` and `utm_*` keys, and `landing_url` for the page it landed on.

```bash
curl -X POST "https://api.whop.com/api/v1/checkout_configurations" \
  -H "Authorization: Bearer $WHOP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "plan_id": "plan_XXXXXXXX", "metadata": { "zernio_visitor_id": "ZID_COOKIE_VALUE", "utm_campaign": "fall-sale" } }'
```

A sale without any of these is still stored and counts in totals, but not on a campaign.

## Read the sales

Whop sales are events with source `whop`. Read them with `GET /v1/events?source=whop`, or per campaign in campaign results. On **Connections**, **View sales** on the Whop account lists the latest ones with their campaign.

Each event's `eventId` is `whop:` followed by the Zernio account id and the Whop payment id (`pay_...`).

## Send sales to ad platforms

Off by default. Turn it on with **Send to ad platforms** in **View sales**, or:

```bash
curl -X PATCH "https://zernio.com/api/v1/accounts/ACCOUNT_ID/whop-settings" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "forwardSales": true }'
```

Only sales paid after you turn it on are sent, through the profile's [forwarding rules](/conversions/create-forwarding-rule) that take the `whop` source:

| Payment | Sent as |
|---|---|
| A one-off purchase | `Purchase` |
| A membership's first payment (`billing_reason` `subscription_create`, or the first charge after a free trial) | `Subscribe`, not also `Purchase`, so a platform never counts it twice |
| A renewal, a plan change or a refund | Nothing |

## How it behaves

- A payment counts when Whop sends `payment.succeeded`. Its value is the payment's total (after discounts, tax included, buyer fees left out).
- A refund counts once Whop reports it `succeeded`: Zernio reads the payment back and stores it at what the buyer kept. A full refund retracts it.
- Every Whop purchase opens a membership, a one-off one too, so only the payment's billing reason marks it as a subscription.
- Whop sales never go to a Whop destination: Whop already has them.
- Deliveries are signed (Standard Webhooks) and checked against the webhook's secret, which Zernio keeps encrypted. Disconnecting removes the webhook.

## Related

- [Connect a Whop account](/connect/connect-whop-ads-credentials)
- [Conversions API](/products/conversions-api)
- [Campaign results](/guides/campaign-results)