Shopify
@akadli/provider-shopify implements IEcommerceProvider for Shopify stores operating in Algeria. It handles webhook cryptographic verification (HMAC-SHA256 Base64), extracts Algerian addresses from checkout apps or standard forms, and performs REST order updates.
Installation
pnpm add @akadli/provider-shopifyShopify Dev Dashboard Setup Guide (2026)
Follow these steps to connect your custom or headless Shopify app:
1. Create App in Shopify Partners / Dev Dashboard
- Go to dev.shopify.com (or your Shopify Partner Dashboard) -> Apps -> Create an App.
- Select Create app manually.
- Set App Name to
Akadli-AI Voice Confirmation. - App URL: Enter your backend endpoint (e.g.,
https://api.yourdomain.com). - CRITICAL: Leave Embed app in Shopify admin UNCHECKED for headless webhook processing.
2. Configure Scopes & Access Tokens
- In your App settings -> Configuration -> Admin API integration, click Configure.
- Grant the following scopes:
read_orderswrite_ordersread_products(recommended to resolve alternative sizes)
3. Enable Protected Customer Data Access (MANDATORY)
- In API access -> Protected customer data access, request:
- Name
- Address
- Phone
- Important: If this is not granted, Shopify masks customer phone numbers in webhooks and blocks shipping address updates!
4. Create Webhook
- In your Shopify Store Admin -> Settings -> Notifications -> Webhooks (or via Admin API):
- Click Create Webhook:
- Event:
Order creation - Format:
JSON - URL:
https://your-domain.com/api/webhooks/shopify - Webhook API Version:
2025-01or latest
- Event:
- Copy the Webhook Secret key at the bottom of the page.
Algeria Address Fallback (province: null)
Standard Shopify checkout forms hide the province/state dropdown when country_code: "DZ" is selected. Customers typically input their Wilaya into:
- The
cityfield - The
address1field - A 5-digit postal code (
13000-> Wilaya13) - Custom
note_attributesadded by 1-page checkout apps (EasySell, Releasit, CodForm).
@akadli/provider-shopify inspects all of these fields and runs them through @akadli/dz-geo’s 4-stage resolver, correctly extracting Wilayas 01 through 69.
Credentials Schema
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
shopDomain | string | Yes | — | Store myshopify domain (e.g. dz-store.myshopify.com) |
accessToken | string | Optional* | — | Permanent Admin API access token (shpat_...) |
clientId | string | Optional* | — | App Client ID (for OAuth client_credentials flow) |
clientSecret | string | Optional* | — | App Client Secret |
apiVersion | string | No | "2025-01" | Shopify Admin REST API version |
cancelOnRefused | string | No | "true" | Cancels order on REFUSED decision |
*Provide either accessToken OR both clientId and clientSecret.
Code Example
import { ShopifyProvider } from "@akadli/provider-shopify";
const provider = new ShopifyProvider();
// 1. Verify Webhook HMAC signature (Base64)const isValid = await provider.verifyWebhook( headers, rawBody, process.env.SHOPIFY_WEBHOOK_SECRET!);
// 2. Parse standardized Algerian COD orderconst order = await provider.parseWebhookOrder(JSON.parse(rawBody));
// 3. Apply post-call decisionconst result = await provider.applyOrderDecision( order.orderId, { orderId: order.orderId, status: "MODIFIED", finalVariant: "42", finalCommune: "Barika", reasonOrNotes: "Customer updated size to 42" }, { shopDomain: process.env.SHOPIFY_SHOP_DOMAIN!, accessToken: process.env.SHOPIFY_ACCESS_TOKEN! });