name: chargily-pay-integration
description: >-
Integrate Chargily Pay V2 (Algerian payment gateway — EDAHABIA, CIB, and
Chargily App) into any store, SaaS, marketplace, or web/mobile app. Use this
skill WHENEVER the user wants to accept online payments in Algeria, add a
checkout or "pay" button, collect money from customers, sell products or
subscriptions, generate payment links, or wire up Chargily — even if they only
say "add payments to my store", "accept EDAHABIA/CIB", "Chargily", "Chargily
Pay", "DZD payments", or "Algerian payment gateway" without naming an endpoint.
Also use it for handling payment webhooks (confirming a paid order, updating
order status), verifying webhook signatures, building products/prices/customers
in Chargily, or debugging a Chargily integration. The skill works for any
language or framework (PHP/Laravel, Node/Express, Python/Django/Flask, etc.)
and is written so a developer who has never touched Chargily can ship a working,
secure integration. Prefer this skill over guessing the API from memory.
Chargily Pay V2 Integration
This skill turns "I want to accept payments" into a working, secure Chargily Pay
integration. It covers the full V2 REST API (checkouts, payment links, products,
prices, customers, balance) and — most importantly — the webhook flow that
actually marks orders as paid.
Chargily Pay is an Algerian payment gateway. It lets a store/SaaS charge
customers via EDAHABIA, CIB, and the Chargily App (QR code), settling
in DZD (USD/EUR wallets also exist for balance).
Golden rules (read before writing any code)
- Money is in the smallest unit, as an integer.
amount: 2500 means 2500.00
DZD here (Chargily uses whole DZD as integers — 2500 = 2500 DZD, not cents).
Never send floats. Always send integers.
- The secret key lives ONLY on the server. Never put it in front-end code,
mobile apps, git, or a public repo. It authenticates every request as
Authorization: Bearer <secret_key>.
- The redirect to
success_url is NOT proof of payment. A user can hit that
URL without paying. Only a verified checkout.paid webhook confirms money
moved. Fulfill orders on the webhook, not on the redirect.
- Test mode vs live mode is chosen by the base URL + key together. A test key
only works against the test base URL; a live key only against the live base URL.
Build and test entirely in test mode first.
- Always verify the webhook signature before trusting a webhook. Unsigned or
mismatched requests must be rejected.
Base URLs
| Mode |
Base URL |
| Test |
https://pay.chargily.net/test/api/v2 |
| Live |
https://pay.chargily.net/api/v2 |
Get keys (test_sk_... / live_sk_...) from the Developers Corner in the
Chargily Pay Dashboard (pay.chargily.com/dashboard/developers-corner).
The two integration patterns — pick one
Ask the user (or infer from context) which they need, then follow that path.
Pattern A — Dynamic checkout (most common for stores & SaaS)
Your backend creates a Checkout on the fly for each order/cart, redirects the
customer to the returned checkout_url, then waits for the checkout.paid
webhook to fulfill. Best when the amount, customer, or cart changes per order.
This is the default recommendation.
Pattern B — Reusable Payment Link
You pre-build Products → Prices → a Payment Link once. The link is a fixed
URL you share anywhere (social bio, email, button) and reuse for many customers.
Best for a fixed-price product, a donation page, or a "Buy now" button that never
changes. Still confirmed via webhooks.
Most stores use Pattern A. A "share this link" / "sell one fixed item" request
points to Pattern B.
End-to-end flow for Pattern A (the happy path)
- (Optional) Create or reuse a Customer to attach buyer info. Skip if you
only need a one-off charge.
- Create a Checkout — either with an
amount + currency, or with items
(Price IDs + quantities). Include success_url (required), failure_url, and
ideally webhook_endpoint. Save the returned checkout id against your
internal order.
- Redirect the customer to the
checkout_url from the response.
- Customer pays on Chargily's hosted page (EDAHABIA / CIB / Chargily App QR).
- Chargily POSTs a webhook to your endpoint with
type: "checkout.paid"
(or checkout.failed).
- Your endpoint verifies the signature, marks the order paid, returns 200.
- Customer is redirected to your
success_url (cosmetic — do not fulfill here).
For exact request/response fields of every endpoint, read
references/api-reference.md. For the webhook receiver (signature verification +
handler) in multiple languages, read references/webhooks.md. For copy-paste
client code, see scripts/chargily_client.py and scripts/chargily_client.js.
Choosing how to build the Checkout body
- Quick one-off charge → send
amount (integer) + currency: "dzd".
- Reusable catalog / line items / receipts → send
items: [{ price, quantity }]
built from Price IDs (create Products and Prices first).
payment_method defaults to "edahabia"; can be "cib" or "chargily_app".
With "chargily_app" the response also returns a qr_code_url. The customer can
switch method on the checkout page regardless.
chargily_pay_fees_allocation: "merchant" (you pay fees), "customer" (buyer
pays), or "split". (pass_fees_to_customer is deprecated.)
locale: "ar", "en", or "fr" for the checkout page language.
Implementation checklist (use this to drive the build)
Security must-dos (don't ship without these)
- Reject webhooks with a missing
signature header (HTTP 400) and with a
mismatched signature (HTTP 403). Compare using a constant-time / timing-safe
comparison.
- Verify the HMAC against the raw, unparsed request body bytes — parsing to
JSON first and re-serializing will change the bytes and break verification.
- Treat the redirect to
success_url as untrusted; reconcile real state by
re-fetching the checkout (GET /checkouts/{id}) or trusting only the webhook.
- Keep test and live keys separate; never log secret keys.
Reference files (read on demand)
references/api-reference.md — every endpoint: method, path, parameters,
example bodies and responses, list/pagination behavior, object shapes.
references/webhooks.md — webhook payload structure, event types, and complete
signature-verifying receiver examples (Python/Django, Node/Express, PHP, Go).
scripts/chargily_client.py — minimal, dependency-light Python client.
scripts/chargily_client.js — minimal Node.js (fetch) client.
These are accurate to Chargily Pay V2. When in doubt about a field, open the
reference file rather than guessing.
1---2name: chargily-pay-integration3description: Integrate Chargily Pay V2 (Algerian payment gateway — EDAHABIA, CIB, and Chargily App) into any store, SaaS, marketplace, or web/mobile app. Use this skill WHEN4---5---6name: chargily-pay-integration7description: >-8 Integrate Chargily Pay V2 (Algerian payment gateway — EDAHABIA, CIB, and9 Chargily App) into any store, SaaS, marketplace, or web/mobile app. Use this10 skill WHENEVER the user wants to accept online payments in Algeria, add a11 checkout or "pay" button, collect money from customers, sell products or12 subscriptions, generate payment links, or wire up Chargily — even if they only13 say "add payments to my store", "accept EDAHABIA/CIB", "Chargily", "Chargily14 Pay", "DZD payments", or "Algerian payment gateway" without naming an endpoint.15 Also use it for handling payment webhooks (confirming a paid order, updating16 order status), verifying webhook signatures, building products/prices/customers17 in Chargily, or debugging a Chargily integration. The skill works for any18 language or framework (PHP/Laravel, Node/Express, Python/Django/Flask, etc.)19 and is written so a developer who has never touched Chargily can ship a working,20 secure integration. Prefer this skill over guessing the API from memory.21---2223# Chargily Pay V2 Integration2425This skill turns "I want to accept payments" into a working, secure Chargily Pay26integration. It covers the full V2 REST API (checkouts, payment links, products,27prices, customers, balance) and — most importantly — the webhook flow that28actually marks orders as paid.2930Chargily Pay is an Algerian payment gateway. It lets a store/SaaS charge31customers via **EDAHABIA**, **CIB**, and the **Chargily App** (QR code), settling32in DZD (USD/EUR wallets also exist for balance).3334## Golden rules (read before writing any code)35361. **Money is in the smallest unit, as an integer.** `amount: 2500` means 2500.0037 DZD here (Chargily uses whole DZD as integers — `2500` = 2500 DZD, not cents).38 Never send floats. Always send integers.392. **The secret key lives ONLY on the server.** Never put it in front-end code,40 mobile apps, git, or a public repo. It authenticates every request as41 `Authorization: Bearer <secret_key>`.423. **The redirect to `success_url` is NOT proof of payment.** A user can hit that43 URL without paying. **Only a verified `checkout.paid` webhook confirms money44 moved.** Fulfill orders on the webhook, not on the redirect.454. **Test mode vs live mode is chosen by the base URL + key together.** A test key46 only works against the test base URL; a live key only against the live base URL.47 Build and test entirely in test mode first.485. **Always verify the webhook signature** before trusting a webhook. Unsigned or49 mismatched requests must be rejected.5051## Base URLs5253| Mode | Base URL |54|------|----------|55| Test | `https://pay.chargily.net/test/api/v2` |56| Live | `https://pay.chargily.net/api/v2` |5758Get keys (`test_sk_...` / `live_sk_...`) from the Developers Corner in the59Chargily Pay Dashboard (`pay.chargily.com/dashboard/developers-corner`).6061## The two integration patterns — pick one6263Ask the user (or infer from context) which they need, then follow that path.6465### Pattern A — Dynamic checkout (most common for stores & SaaS)66Your backend creates a **Checkout** on the fly for each order/cart, redirects the67customer to the returned `checkout_url`, then waits for the `checkout.paid`68webhook to fulfill. Best when the amount, customer, or cart changes per order.69This is the default recommendation.7071### Pattern B — Reusable Payment Link72You pre-build **Products → Prices → a Payment Link** once. The link is a fixed73URL you share anywhere (social bio, email, button) and reuse for many customers.74Best for a fixed-price product, a donation page, or a "Buy now" button that never75changes. Still confirmed via webhooks.7677Most stores use Pattern A. A "share this link" / "sell one fixed item" request78points to Pattern B.7980## End-to-end flow for Pattern A (the happy path)81821. **(Optional) Create or reuse a Customer** to attach buyer info. Skip if you83 only need a one-off charge.842. **Create a Checkout** — either with an `amount` + `currency`, or with `items`85 (Price IDs + quantities). Include `success_url` (required), `failure_url`, and86 ideally `webhook_endpoint`. Save the returned checkout `id` against your87 internal order.883. **Redirect the customer** to the `checkout_url` from the response.894. **Customer pays** on Chargily's hosted page (EDAHABIA / CIB / Chargily App QR).905. **Chargily POSTs a webhook** to your endpoint with `type: "checkout.paid"`91 (or `checkout.failed`).926. **Your endpoint verifies the signature, marks the order paid, returns 200.**937. Customer is redirected to your `success_url` (cosmetic — do not fulfill here).9495For exact request/response fields of every endpoint, read96`references/api-reference.md`. For the webhook receiver (signature verification +97handler) in multiple languages, read `references/webhooks.md`. For copy-paste98client code, see `scripts/chargily_client.py` and `scripts/chargily_client.js`.99100## Choosing how to build the Checkout body101102- Quick one-off charge → send `amount` (integer) + `currency: "dzd"`.103- Reusable catalog / line items / receipts → send `items: [{ price, quantity }]`104 built from Price IDs (create Products and Prices first).105- `payment_method` defaults to `"edahabia"`; can be `"cib"` or `"chargily_app"`.106 With `"chargily_app"` the response also returns a `qr_code_url`. The customer can107 switch method on the checkout page regardless.108- `chargily_pay_fees_allocation`: `"merchant"` (you pay fees), `"customer"` (buyer109 pays), or `"split"`. (`pass_fees_to_customer` is deprecated.)110- `locale`: `"ar"`, `"en"`, or `"fr"` for the checkout page language.111112## Implementation checklist (use this to drive the build)113114- [ ] Confirm framework/language and Pattern A vs B with the user.115- [ ] Store the secret key in an env var / secret manager — never in code.116- [ ] Build a tiny server-side API client (see `scripts/`) with the Bearer header.117- [ ] Implement the create-checkout (or create-payment-link) call.118- [ ] Redirect the customer to `checkout_url`.119- [ ] Implement the webhook endpoint: read the raw body, verify the `signature`120 header (HMAC-SHA256 of the raw body with the secret key), switch on121 `event.type`, update the order, return 200.122- [ ] Register the webhook URL in the dashboard, or pass `webhook_endpoint` per123 checkout. Test locally with a tunnel (e.g. ngrok) since Chargily can't reach124 `localhost`.125- [ ] Verify in test mode end-to-end before swapping to the live base URL + key.126127## Security must-dos (don't ship without these)128129- Reject webhooks with a missing `signature` header (HTTP 400) and with a130 mismatched signature (HTTP 403). Compare using a constant-time / timing-safe131 comparison.132- Verify the HMAC against the **raw, unparsed request body bytes** — parsing to133 JSON first and re-serializing will change the bytes and break verification.134- Treat the redirect to `success_url` as untrusted; reconcile real state by135 re-fetching the checkout (`GET /checkouts/{id}`) or trusting only the webhook.136- Keep test and live keys separate; never log secret keys.137138## Reference files (read on demand)139140- `references/api-reference.md` — every endpoint: method, path, parameters,141 example bodies and responses, list/pagination behavior, object shapes.142- `references/webhooks.md` — webhook payload structure, event types, and complete143 signature-verifying receiver examples (Python/Django, Node/Express, PHP, Go).144- `scripts/chargily_client.py` — minimal, dependency-light Python client.145- `scripts/chargily_client.js` — minimal Node.js (fetch) client.146147These are accurate to Chargily Pay V2. When in doubt about a field, open the148reference file rather than guessing.