Clover inventory price sync (webhook)
Clover inventory price sync (webhook)
Section titled “Clover inventory price sync (webhook)”IndochinaPOS can listen for Clover Inventory webhook events and update local catalog prices for products whose sku_code equals the Clover item ID (same mapping as Import Clover Excel).
Prerequisites
Section titled “Prerequisites”- Products imported from Clover (or manually set
sku_code= Clover item ID). - Clover app with Read inventory permission on the merchant.
- Public HTTPS API base URL on the server (
PUBLIC_API_BASE_URLorAPP_URL).
Webhook URL
Section titled “Webhook URL”Single endpoint for all stores:
{PUBLIC_API_BASE_URL}/api/v1/integrations/clover/webhookExample: https://api.example.com/api/v1/integrations/clover/webhook
The vendor Store configuration → General tab shows this URL when the env var is set.
Clover Developer Dashboard
Section titled “Clover Developer Dashboard”Follow Clover — Use webhooks:
- App Settings → Webhooks — paste the callback URL above (HTTPS only).
- Send Verification Code — Clover POSTs
{ "verificationCode": "…" }; the backend responds200 OK(code is logged server-side). - Paste the verification code in the dashboard and Verify.
- Subscribe to Inventory events (object key
I). - Copy the Clover Auth Code shown after verification (sent as header
X-Clover-Authon each notification).
Store configuration (vendor dashboard)
Section titled “Store configuration (vendor dashboard)”On Stores → Configuration → General → Clover price sync:
| Field | Purpose |
|---|---|
| Merchant ID (mId) | Must match the merchant key in webhook payloads |
| API environment | Sandbox vs production Clover API host |
| Enable price sync | Gate processing for this store |
| Clover Auth Code | Must match X-Clover-Auth |
| API access token | Used to GET /v3/merchants/{mId}/items/{itemId} after each webhook |
Save the section after changing secrets.
Runtime behavior
Section titled “Runtime behavior”- Webhook payload chỉ có
objectId(ví dụI:GHIVJT2ABCRSC) — backend gọiGET /v3/merchants/{mId}/items/{itemId}để lấy item hiện tại (tên, giá cents, sku, …). - Log server:
Clover item fetched … name=… price=…và response webhook{ ok: true, sync: { details: [{ remoteItem, priceDecimal, localMatches, outcome }] } }. - Matching
itemsrows for the store (store_id+sku_code) updatepriceand default variation price when applicable. DELETEinventory events are ignored (price sync only).- Price changes are recorded in
items_selling_price_historywith automated actor id0.
clover-webhook-payload.util.spec.tsclover-webhook.service.spec.tsclover-inventory-price-sync.service.spec.tsvendor-store-configuration.service.spec.ts(Clover PATCH)vendor-store-configuration-sections.spec.ts(Clover section PATCH)