YouCan
@akadli/provider-youcan provides seamless integration with the YouCan (.shop) e-commerce platform for Algerian merchants. It parses single-page COD checkout forms where custom Wilaya and commune dropdowns are stored in extra_fields or custom_fields.
Installation
pnpm add @akadli/provider-youcanYouCan Seller Area Setup Guide
1. Generate an API Access Token
- Log into your seller-area.youcan.shop dashboard.
- Navigate to Settings -> API & Integrations.
- Generate a new API Access Token and grant full permissions for Orders.
- Store this token securely as
YOUCAN_ACCESS_TOKEN.
2. Configure the Order Webhook
- In Settings -> Webhooks, click Add Webhook.
- Event: Select
order.created. - Target URL: Enter your backend URL (e.g.,
https://your-domain.com/api/webhooks/youcan). - Copy the generated Webhook Secret (used to verify the
x-youcan-signatureheader).
3. Algerian 1-Page COD Checkout Support
Algerian YouCan store owners commonly use single-page checkout templates with custom dropdowns for Wilayas and Communes. YouCan passes these values inside:
extra_fieldscustom_fields- Standard
shipping_address
@akadli/provider-youcan inspects all three data sources, normalizes the Wilaya to official 2026 codes (01–69), and resolves the delivery commune via @akadli/dz-geo.
Credentials Schema
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
accessToken | string | Yes | — | YouCan API Access Token |
baseUrl | string | No | "https://api.youcan.shop" | YouCan REST API base URL |
closeOnRefused | string | No | "true" | Cancels/closes the order when status is REFUSED |
Code Example
import { YouCanProvider } from "@akadli/provider-youcan";
const provider = new YouCanProvider();
// 1. Verify Webhook HMAC hex signature (x-youcan-signature)const isValid = await provider.verifyWebhook( headers, rawBody, process.env.YOUCAN_WEBHOOK_SECRET!);
// 2. Parse standardized Algerian COD orderconst order = await provider.parseWebhookOrder(JSON.parse(rawBody));
// 3. Mutate YouCan order after confirmation callconst result = await provider.applyOrderDecision( order.orderId, { orderId: order.orderId, status: "CONFIRMED", reasonOrNotes: "Confirmed in Darja via voice call" }, { accessToken: process.env.YOUCAN_ACCESS_TOKEN! });