A redirect to the bank is not proof of payment. A reliable CMI integration separates three things: the customer experience, server-side order creation and the provider’s technical confirmation. This checklist walks you through every step, from the merchant file to real-domain testing, so your CMI integration stays solid in production.
Why CMI integration needs a method
Many Moroccan stores discover the problem too late. The form redirects to the bank page, the customer pays, then the browser returns to a success screen. Everything looks fine. Yet nothing proves the server received the confirmation. A serious CMI integration treats the browser return as a convenience, never as evidence.
The risk is concrete: an order marked paid without authorization, a double capture after a repeated notification, or an amount altered inside the browser. Each scenario has a simple defense. You only need to decide, before writing code, who trusts what. In every CMI integration, your server remains the single source of truth.
Understand the three actors in the journey
The customer sees your website, then the hosted CMI payment page. Your server remains responsible for the order: it calculates the amount, creates the identifier, stores context and signs the transmitted fields. CMI handles the card, the bank authentication and the authorization. Finally, the server callback tells your website what happened.
This separation explains most of the rules that follow. The browser displays, the provider authorizes, your server decides. When those roles blur, mistakes appear: a changed price, an invented status, a duplicated order. Keep this mental map throughout the CMI integration.
The browser return page improves the experience; it proves nothing. It can display pending, confirmed or failed according to what your server has already recorded. If the customer closes the browser after paying, the server notification must still update the order.
Prepare the contract and payment gateway access
A CMI integration starts with a complete file. Merchant ID, signing key, test environment and return URLs must match the contract. The website needs public HTTPS to receive the server notification. Keep keys out of source code, screenshots and Git repositories. The documentation and support contacts are on the official CMI website.
The payment gateway works with precise fields: currency, amount, order identifier and return URL. Prepare these values in a private file outside the web root, or in hosting environment variables. A detail like a missing slash can block the callback. Check every value before the first test.
Choose your capture policy as well. A POSTAUTH response can request automatic capture after authorization. A simple approval keeps the authorization pending for a manual action. This choice has commercial and accounting consequences: decide it before testing, not after a real order.
Finally, appoint one owner for the integration. Someone must know where the credentials live, which environment is active and who to call when the callback stops arriving. Shared knowledge that lives in one chat thread disappears quickly.
Create orders on the server
In a CMI integration, the browser must never choose the amount, currency or order ID. The server reads the catalog, creates a unique identifier, stores the amount and signs only the fields expected by the payment gateway. This boundary prevents a visitor from changing the price before redirection.
The stored order should contain the product, calculated amount, currency, language, validated billing details and a random value. Fields sent to CMI are built from this record. On return, the server compares the signature, currency, amount and original identifier. Nothing the browser sends back is taken at face value.
This locking also prevents duplicates. If the same notification arrives twice, the order already exists. The server can acknowledge it without requesting a second capture. Keep an event history: creation, browser return, authorization, failure, requested capture and sent emails.
Secure the online payment on the customer side
On the customer side, a successful CMI integration shows in the details. Online payment reassures when the journey is consistent. Display the amount in MAD, name the provider and explain that the card is entered on the hosted bank page, not on your website. A clear payment screen reduces abandonment as much as good design.
Plan three visible states: confirmed, pending and failed. If the customer closes the browser after paying, your server must still update the order through the notification. The return page only displays the recorded state. It decides nothing.
Polish the error messages too. “Payment declined” explains nothing; “your bank declined the transaction, you can retry or choose another method” guides the customer. Every message in the funnel shapes trust in your checkout.
Trust the signed notification
The server-to-server notification verifies the signature, identifier, amount, currency and return code. A success page only displays the recorded state. Repeated notifications must be acknowledged without creating another order or requesting a second capture. That is the principle of idempotence: the same event processed twice produces the same state.
This is the heart of a robust CMI integration. The callback is the only voice allowed to say “paid”. Everything else — return page, URL parameter, displayed message — belongs to presentation. Treat it that way and your disputes will shrink.
Plan for the case where the notification never arrives. An order stuck in pending should be visible in your back office, not forgotten. An honest intermediate status beats a false success or a silence that leaves the customer without an answer.
Verify the signature before any business decision
Every CMI integration validates the signature before interpreting the result. Excluded fields, sorting order, character escaping and encoding must follow the documentation exactly. An invalid signature ends the request. The system should never “guess” the order from browser data or a partial identifier.
After signature, the authorization return code means a successful payment. Other codes remain failures or unconfirmed states, even if the return page looks positive. Keep technical references such as the transaction ID or the masked card for reconciliation, without ever storing sensitive card data.
Test failures as carefully as success
A CMI integration is tested under unfavorable conditions. Cover a successful authorization, a declined card, a closed browser, a late notification, an altered amount, an unknown order and a forged signature. The event log should let you reconstruct the journey. Customer and internal emails go out after confirmation, never before.
Check the hosting too: available PHP, a writable private directory, working mail delivery, error logs, timezone and HTTPS. On shared hosting, a rewrite rule or an inaccessible folder can prevent the callback from arriving. A complete test covers both code and infrastructure.
Keep the results of each run: which card was used, which response came back, what the order showed and which emails were sent. When a real incident happens months later, these notes separate a five-minute diagnosis from a day of guesswork.
The Moroccan context of online payment Morocco merchants face
For online payment Morocco has its own realities. Settlement usually happens in dirhams, customers often compare card payment with cash on delivery, and trust is built through transparency. Display amounts in MAD everywhere, name the provider and keep a consistent bilingual journey across your storefront.
On the administrative side, prepare your entity’s exact details, a publicly accessible website and a written refund policy. A coherent file speeds up validation. It also reassures the provider about your reliability before the first test transaction.
Remember that many shoppers will still prefer paying on delivery. Card acceptance and COD can coexist: the goal of the CMI integration is to make the card option trustworthy enough that customers choose it willingly, not to force it on every order.
Production checklist
Before opening payments, validate every point of this CMI integration checklist:
- Final HTTPS domain in place with clean redirects.
- Test CMI credentials configured in a private file.
- One successful and one declined test transaction.
- Public-domain callback received and signature verified.
- Order storage outside the web root, without card data.
- Customer and administrator emails delivered.
- Capture mode selected and documented.
- Refund, dispute and support procedures defined.
- Production credentials kept separate from test credentials.
Once these points are validated, change only the environment values: merchant ID, signing key and production URL. Never leave a test configuration active on a store collecting real payments.
Questions to ask before activation
A well-prepared CMI integration file asks the right questions early. Confirm the merchant ID, environment, signing key, allowed URLs, currency, hosted page method and capture policy. Ask how to review transactions, process a refund and reach support.
Also verify whether IP addresses or domains must be registered for the callback. Write every answer in an internal document. These questions avoid back-and-forth on launch day. The person maintaining the store in six months will thank you.
A reasonable action plan
Deploy on an HTTPS domain first, configure the private keys, then run one successful and one declined test transaction. Inspect the stored order, the events and the emails. This first cycle gives you a faithful picture of the CMI integration before opening to the public.
Next, document the production switch procedure and keep a copy of useful logs without exposing the key or card data. Finally, schedule a review by someone who did not write the code. A fresh eye quickly spots an active test URL or an email sent too early.
Document the CMI integration for maintenance
Document the architecture while it is fresh: where the keys live, how the order is created, which fields are signed, how the callback is verified and how the production switch works. Note the PHP version, the dependencies and the person responsible.
A documented CMI integration survives hosting changes, updates and staff departures. Without documentation, every incident becomes an investigation. With it, maintenance becomes routine.
Keep the document close to the code and review it twice a year. A page that explains the flow in plain language is worth more than a perfect diagram nobody opens. New developers should understand the CMI integration in fifteen minutes, not discover it by reading logs during an outage.
Plan refunds, disputes and support
The CMI integration does not end at authorization. A customer may request a refund, dispute a transaction or report a wrong amount. Your team must know where to look up the transaction, how to trigger a refund and which timelines to communicate.
Prepare a short internal guide: who replies to the customer, who acts in the merchant interface, who keeps the evidence. Event logs become concrete here. They let you trace the order, the authorization and the sent emails without digging through code.
Keep security habits after launch
The work continues after the first successful transaction. Rotate credentials when team members change, review the event log after each deploy and retest the callback after any hosting modification. A configuration that worked in January can silently break in June.
Schedule a quarterly review: one test authorization, one declined card, a check of stored orders and a look at the error log. Thirty minutes of routine prevents the discovery of a broken checkout by a customer.
Common mistakes to avoid
Most CMI integration incidents come from shortcuts. Never place the signing key in JavaScript, a public repository or a file under the web root. Do not treat the success URL as payment proof. Do not accept an order ID your server did not create. Do not mark a payment captured before the callback is verified.
Also avoid logging full card data or sending a “payment received” email before the order is updated. The safest implementation is boring: strict fields, signature first, idempotent updates, clear history and a tested production switch.
Keep the journey consistent across languages
Your store probably speaks French and English, sometimes Arabic. Payment funnel messages must follow the language the customer chose: amount, errors, confirmation and email. A CMI integration that returns a French message to an English-speaking customer creates doubt at the worst moment.
Prepare the three state texts in every language before testing. Check that the confirmation email uses the order’s language, not the back office’s. These details look minor; they decide trust at the exact moment of payment.
Monitor the CMI integration after launch
The work continues after the first successful transaction. Rotate credentials when the team changes, review the event log after each deployment and retest the callback after any hosting modification. A configuration that worked in January can silently break in June.
Schedule a quarterly review: one test authorization, one declined card, a check of stored orders and a look at the error log. Thirty minutes of routine prevents a customer from discovering a broken checkout for you. A monitored CMI integration ages well; a forgotten CMI integration eventually costs sales.
What a weak CMI integration costs
A sloppy CMI integration does not show on a screenshot. It appears in disputes, double captures, missing orders and emails sent for payments never confirmed. Every incident mobilizes support, erodes trust and can freeze funds while it is resolved.
A clean CMI integration, by contrast, becomes invisible: orders confirm themselves, statuses stay honest and support works from a clear log. That calm is exactly what you buy by following this checklist to the end.
Manage order states in your back office
Your admin must mirror the technical reality: pending, authorized, captured, failed, refunded. A “paid” state displayed before the signed notification misleads the whole team. A “failed” state applied too early discourages a customer whose confirmation arrives a minute late.
Define who can change a status manually and under which conditions. A manual capture, a refund or a cancellation must leave a trace in the log. These habits make your CMI integration explainable to a customer, a dispute or an internal audit.
Handing your CMI integration to a team
A CMI integration touches code, hosting, emails and accounting. If your team is small, outsourcing can cost less than a production incident. At Terial, we deliver stores whose payment funnel is verified end to end: server orders, signed callbacks, honest states and usable logging.
Our ecommerce support covers the store structure, while our web development team handles the site and hosting. To compare providers before committing, read our payment gateways guide and our COD or card analysis. You can also reach us through the contact page to scope your project.
When to replatform instead of patching
Sometimes the honest answer is structural. If the checkout lives inside a theme file, if orders are created by the browser or if nobody knows where the key is stored, patching will not fix the foundation. Rebuilding the payment slice cleanly is often cheaper than accumulating workarounds.
Treat that decision as scoping, not failure. List what works, what is risky and what is undocumented. Then rebuild the order creation, the signature check and the callback first, and migrate the rest progressively.
The sign that the integration is ready
The integration is ready when success, failure, interruption and duplication have been observed on the real domain. A simple form redirecting to CMI is not enough. The order must exist before departure, the authorization must be verified after the provider’s response and the customer must receive an honest status. That discipline is what turns a fragile CMI integration into reliable payment collection.