Moyasar Payment Gateway
The ECOSIRE Moyasar Payment Gateway module wires Moyasar -- Saudi Arabia's leading SAMA-licensed, PCI DSS Level 1 certified payment processor -- into Odoo's native payment.provider framework. It handles the full card lifecycle: 3-D Secure 2 redirect checkout, authorize-then-capture, full and partial refunds, hosted invoice links, and real-time webhook event processing with HMAC-SHA256 signature verification. Amounts are converted between SAR and halalas transparently so Odoo operators never touch raw minor-unit arithmetic.
Compatibility: Odoo 17 / 18 / 19 Price: $249 (one-time) License: LGPL-3
A live demo is available at demo.ecosire.com. Contact [email protected] for a demo walkthrough on sandbox.
Key Features
- Native Odoo
payment.providerintegration (provider code:moyasar) - mada (Saudi domestic debit) and Visa / Mastercard credit-debit card support
- 3-D Secure 2 redirect flow -- mandatory for mada under SAMA mandate
- SAR / halalas conversion handled automatically (1 SAR = 100 halalas)
- Full and partial refunds initiated directly from the Odoo payment transaction
- Authorize / capture two-step flow for deferred settlement
- Hosted invoice (payment link) support via Moyasar
/invoicesendpoint - Webhook handler with HMAC-SHA256 signature verification (
X-Moyasar-Signature) - Single API host for both test and live modes -- environment selected by key prefix
- ECOSIRE license enforcement on credential saves
Honest scope note: Apple Pay and STC Pay wallet flows are present in the Moyasar API but require additional merchant-side configuration (Apple Pay domain association; STC Pay OTP flow) that has not been verified against a live account. Both are guarded with a clear UserError rather than silently failing. Webhook CRUD management may be dashboard-only -- the module instructs you to register the URL manually in the Moyasar dashboard.
Prerequisites
| Requirement | Details |
|---|---|
| Odoo version | 17, 18, or 19 (Community or Enterprise) |
| ECOSIRE license | Active license for ecosire_payment_moyasar |
| Moyasar merchant account | Live account from dashboard.moyasar.com (required for real charges) |
| mada acceptance | Must be explicitly enabled on your Moyasar account by Moyasar support |
| Currency | SAR only (Moyasar KSA gateway; multi-currency not supported) |
Odoo payment module | Included in Odoo core -- no separate install needed |
Installation
- Download the module ZIP from your ECOSIRE Dashboard.
- Extract it to your Odoo addons directory:
unzip ecosire-payment-moyasar-*.zip -d /opt/odoo/addons/ - Restart the Odoo service:
sudo systemctl restart odoo - Navigate to Apps, click Update Apps List.
- Search for "ECOSIRE Payment | Moyasar" and click Install.
- Activate your ECOSIRE license when prompted (see Configuration -- Step 1).
Configuration
Step 1: Activate Your ECOSIRE License
Before the provider accepts API credentials, the license must be active.
- Navigate to Settings > ECOSIRE License.
- Enter your license key received after purchase.
- Click Activate. The status should show Active.
Saving Moyasar API keys on the provider record without an active license raises a UserError.
Step 2: Obtain Moyasar API Keys
- Log in to the Moyasar Dashboard.
- Go to Account Settings > API Keys.
- Copy your Publishable Key -- it starts with
pk_test_(sandbox) orpk_live_(production). - Copy your Secret Key -- it starts with
sk_test_(sandbox) orsk_live_(production). - Both keys are required. The publishable key is used in the payment form; the secret key authenticates all server-side API calls via HTTP Basic Auth (key as username, empty password).
Test keys (sk_test_* / pk_test_*) work against the same Moyasar API host as production -- no separate sandbox URL. You must have an approved live Moyasar merchant account before switching to sk_live_* keys and accepting real payments.
Step 3: Configure the Payment Provider in Odoo
- Navigate to Accounting > Configuration > Payment Providers (or Website > Configuration > Payment Providers for eCommerce).
- Click Moyasar in the provider list (or click Create and select Moyasar).
- Enter the following fields (visible only to System Administrators):
| Field | Where to find it | Notes |
|---|---|---|
Moyasar Publishable Key | Moyasar Dashboard > API Keys | Starts with pk_test_ or pk_live_ |
Moyasar Secret Key | Moyasar Dashboard > API Keys | Starts with sk_test_ or sk_live_; stored as a password field |
Moyasar Webhook Secret | You choose; set same value in Moyasar Dashboard | Used to verify X-Moyasar-Signature on webhook requests |
- Set the State:
- Test Mode -- use
sk_test_*/pk_test_*keys. No real charges. - Enabled -- use
sk_live_*/pk_live_*keys for live transactions.
- Test Mode -- use
- Click Save.
Step 4: Register the Webhook and Return URL in Moyasar Dashboard
The module exposes two public endpoints on your Odoo installation:
| Endpoint | URL pattern | Purpose |
|---|---|---|
| Return (3DS callback) | https://<your-domain>/payment/moyasar/return | Customer is redirected here after 3DS authentication |
| Webhook | https://<your-domain>/payment/moyasar/webhook | Receives signed event notifications (payment.paid, payment.failed, etc.) |
To register the webhook:
- In the Moyasar Dashboard, go to Developers > Webhooks.
- Add a new webhook with the URL
https://<your-domain>/payment/moyasar/webhook. - Choose the events to receive (at minimum:
payment.paid,payment.failed,payment.authorized,payment.captured,payment.refunded). - Copy the Webhook Secret Moyasar generates and paste it into the
Moyasar Webhook Secretfield on the Odoo provider record.
The callback_url (return URL) is passed automatically with each payment creation request -- no manual registration in the Moyasar dashboard is required for it.
Step 5: Publish the Provider
- On the provider record, click Published to make it visible on your checkout or payment pages.
- For eCommerce, navigate to your Shop to verify the Moyasar option appears at checkout.
Usage
Checkout Flow (3DS Redirect)
- Customer selects Moyasar / mada / card at checkout.
- Odoo creates a payment transaction and posts to Moyasar
POST /paymentswithcallback_urlset to/payment/moyasar/return. - Moyasar returns a
transaction_url(status:initiated). The customer is redirected there for 3DS authentication. - After 3DS, Moyasar redirects the customer to
/payment/moyasar/return?id=<payment_id>&status=<status>. - The return controller fetches the authoritative payment object via
GET /payments/{id}and updates the Odoo transaction state.
Authorize and Capture
When the provider is configured for two-step capture:
- Payment is created in
authorizedstate -- a hold is placed on the card but funds are not settled. - From the Odoo payment transaction, click Capture to trigger
POST /payments/{id}/captureand settle funds. - Authorized holds expire after the gateway's hold period (typically 7 days for cards) if not captured.
Refunds
- Open the paid payment transaction in Accounting > Accounting > Payments or from the sales order.
- Click Refund.
- Enter the amount (full or partial). Partial refund sends
amountin halalas toPOST /payments/{id}/refund. - The transaction state updates to
cancel/ refunded on success.
Hosted Invoice (Payment Link)
For B2B invoice collection without embedding a checkout form:
- From the payment provider configuration, use the hosted invoice feature.
- Odoo calls
POST /invoicesand returns a Moyasar-hosted payment URL. - Share the URL with your customer. They pay on Moyasar's hosted page without entering card details on your site.
API Details
| Field | Value |
|---|---|
| Auth method | HTTP Basic Auth (Secret Key as username, empty password) |
| API base URL | https://api.moyasar.com/v1 (same for test and live) |
| Test vs live | Determined by key prefix: sk_test_* = sandbox, sk_live_* = live |
| Supported currency | SAR only (amounts in halalas: multiply SAR by 100) |
| 3DS flow | transaction_url redirect on POST /payments |
| Return URL | /payment/moyasar/return |
| Webhook URL | /payment/moyasar/webhook |
| Webhook signature | HMAC-SHA256 of raw request body; header X-Moyasar-Signature |
| Key config fields | moyasar_publishable_key, moyasar_secret_key, moyasar_webhook_secret |
Payment Status Mapping
| Moyasar status | Odoo transaction state |
|---|---|
initiated | pending |
paid | done |
captured | done |
authorized | authorized |
failed | cancel |
refunded | cancel |
voided | cancel |
Troubleshooting
| Issue | Cause | Solution |
|---|---|---|
| Webhook signature verification failed (403) | Webhook Secret mismatch between Odoo and Moyasar dashboard | Ensure the Moyasar Webhook Secret on the Odoo provider exactly matches the secret shown in the Moyasar dashboard webhook configuration |
UserError: Moyasar secret key is not configured | Secret key field empty | Go to Accounting > Configuration > Payment Providers > Moyasar and enter sk_test_* or sk_live_* key |
ValidationError: key must start with sk_test_ or sk_live_ | Incorrect key pasted | Keys are case-sensitive; copy directly from the Moyasar dashboard API Keys page |
Payment stays in pending / never reaches done | Return URL not reachable or 3DS not completed | Confirm https://<your-domain>/payment/moyasar/return is publicly accessible; check Odoo logs for return-handler errors |
UserError: Moyasar action not available for Apple Pay | Apple Pay gated pending merchant config | Apple Pay requires Moyasar merchant-session configuration and Apple Pay domain verification -- contact [email protected] |
STC Pay OTP flow raises UserError | STC Pay confirm endpoint not yet verified | STC Pay OTP flow is gated pending official endpoint documentation; contact [email protected] |
| Currency error at checkout | Non-SAR currency on provider | Moyasar only accepts SAR; set the Odoo company currency to SAR or restrict the provider to SAR-denominated transactions |
| mada card declined | mada not enabled on Moyasar account | Contact Moyasar support to enable mada acceptance on your merchant account; 3DS2 is mandatory for mada by SAMA mandate |
| License not active error on credential save | ECOSIRE license inactive | Verify your license at Settings > ECOSIRE License |
| Webhook events not received | Webhook URL not registered in Moyasar dashboard | Register https://<your-domain>/payment/moyasar/webhook in Moyasar Dashboard > Developers > Webhooks |