Playbook · E-commerce

How to integrate CMI with WooCommerce in Morocco in 7 days

TL;DR — Wiring the CMI gateway into WooCommerce in Morocco takes 7 days: 2 days opening the merchant contract (acquiring bank + CMI file), 1 day plugin install, 2 days 3DS + return URLs setup, 1 day CMI sandbox testing, 1 day production cutover. Typical merchant fees: 1.5–2.2% per transaction depending on volume.

CMI, the gateway to accept MAD payments

In Morocco, accepting card payments in dirhams on an e-commerce site almost always goes through CMI (Centre Monétique Interbancaire) — the national operator that routes payments to acquiring banks (Attijariwafa Bank, BMCE/Bank of Africa, BP, CIH, Société Générale Maroc, Crédit du Maroc).

Alternatives (Stripe, PayPal, Adyen) don't process MAD natively and charge in foreign currency with unfavorable FX. For an e-commerce targeting the local market, CMI is not optional: it's the default payment rail.

Pre-requisites before you start

A registered Moroccan company (RC, ICE, IF, business license), a corporate bank account with an acquiring bank, a WooCommerce site over HTTPS with a valid SSL certificate, and published terms and refund policy. CMI verifies these before activating the gateway in production.

Technical: WordPress 6+ and WooCommerce 8+, SFTP/SSH access to the server, and a staging environment for sandbox testing.

The 6 integration steps

Pre-requisites

  • Registered Moroccan company (RC, ICE, IF)
  • Corporate bank account with a Moroccan acquiring bank
  • WooCommerce 8+ site over HTTPS with valid SSL
  • Published terms and refund policy
  • SFTP/SSH access to the production server
  1. Step 1

    Days 1–2 — Opening the merchant contract

    File submitted to the acquiring bank: RC extract, articles, director KYC, RIB, site URL, business description. The bank forwards to CMI which returns a Store ID, Store Key and sandbox access within 48–72 business hours.

  2. Step 2

    Day 3 — Install CMI plugin for WooCommerce

    Install an official or actively maintained plugin (several open-source options exist). Configure sandbox credentials first. Enable debug mode to trace requests during testing.

  3. Step 3

    Day 4 — 3D Secure and return URLs setup

    Enable mandatory 3DS (otherwise issuer banks decline). Configure three URLs: OkUrl (success), FailUrl (failure), CallbackUrl (server-to-server notification). CallbackUrl must return HTTP 200 with no redirect.

  4. Step 4

    Day 5 — CMI sandbox testing

    Test bench with CMI-provided test cards: success, 3DS failure, timeout, bank decline, double submission. Verify each case creates the correct WooCommerce order with the correct status (processing, failed, on-hold).

  5. Step 5

    Day 6 — CMI validation and production cutover

    Submit test screenshots to CMI for validation. Once approved, CMI switches credentials to production. Update the plugin with prod credentials, disable sandbox mode.

  6. Step 6

    Day 7 — Monitoring and first real payment

    First real payment by a team member (minimum amount). Verify the CMI → acquiring bank transfer (D+1 to D+3 depending on bank). Set up alerts on payment failures (Slack, WhatsApp, email).

Questions fréquentes

How much does CMI integration cost?+
CMI side: no install fee, but 1.5–2.2% merchant fee per transaction depending on volume negotiated with the bank. Integration side: 8,000–25,000 MAD depending on complexity (single vs multi-currency, subscriptions, partial refunds).
How long does merchant account opening take?+
Count 5–15 business days depending on the acquiring bank and file completeness. Attijariwafa Bank and CIH have historically been fastest; BMCE/Bank of Africa and BP may request additional supporting documents from new merchants.
Does CMI accept Visa, Mastercard and Amex?+
National Visa and Mastercard (cards issued in Morocco) are always accepted. International cards require separate activation with CMI (slightly higher fees, around 2.5%). Amex requires a dedicated American Express Morocco contract, outside CMI.
Can we run recurring payments (subscriptions) via CMI?+
Yes, via CMI tokenization which stores the card on CMI side (never on merchant). Compatible with WooCommerce Subscriptions through a dedicated connector. 3DS must be validated on first transaction, then is only replayed on card change.
What if the CallbackUrl receives nothing?+
Most common cause: a WAF (Cloudflare, Wordfence) blocking CMI IPs. Fix: whitelist documented CMI IP ranges, disable any HTTP→HTTPS redirect on the CallbackUrl, and verify the server returns 200 OK in under 30 seconds.

/ À lire ensuite

Un brief technique sur ce sujet ?

Atelier de cadrage gratuit. Un fondateur, pas un commercial.