Accept SADAD Pay in your Magento 2 store.
The SADAD Pay module for Magento 2 adds SADAD Pay to your Magento checkout. Customers choose SADAD Pay, pay on the SADAD Pay payment page with KNET, card or Apple Pay, and return to your store's order success page.
| Item | Details |
|---|---|
| Package | sadad-payment/magento2-module |
| Source code | github.com/sadad-pay/magento |
| Module name | Sadad_Gateway |
| Latest version | 1.0.0 |
| Requirements | Magento 2 installed with Composer, PHP with the curl and json extensions. Installs the PHP Library as a dependency. |
| Price | Free |
Before you start
- You have SSH access to your Magento server and can run
composerandbin/magento. - You have your Client Key and Client Secret from the SADAD Pay portal, under Profile → Update Profile → API. If they are not there, email [email protected] to enable API access.
- Start with your Sandbox keys. See Sandbox & Live Accounts.
Test on a staging copy first
Installing a module runs
setup:upgradeand recompiles your store. Do it on a staging copy first, or put your store in maintenance mode while you install.
Step 1: Install the module
From your Magento root folder, run:
composer require sadad-payment/magento2-module
php bin/magento module:enable Sadad_Gateway --clear-static-content
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush
Check that the module is enabled:
php bin/magento module:status Sadad_Gateway
Step 2: Configure the module
- In your Magento admin, go to Stores → Configuration → Sales → Payment Methods.
- Open Sadad Payment.
- Fill in the settings and click Save Config.
| Setting | What to enter |
|---|---|
| Enabled | Yes to show SADAD Pay at checkout |
| Title | The name customers see at checkout. Default: Sadad Payment. |
| Client Key | Your Client Key, for the environment you choose below |
| Client Secret | Your Client Secret, for the environment you choose below |
| Environment | Test for Sandbox, Live for real payments. Default: Test. |
| Sort Order | Where SADAD Pay appears in the list of payment methods. 1 shows it first. |
When you click Save Config, the module connects to SADAD Pay with your keys and stores a refresh token. If the keys are wrong, or do not match the Environment, checkout fails with an error.
You do not need to set Success and Fail URLs
The module sends its own return address (
/sadad_gateway/payment/callback/) with every invoice. You do not need to change the Success URL or Fail URL in the SADAD Pay portal for Magento.
Step 3: Set your Webhook URL
The webhook updates the order even if the customer closes the browser before coming back to your store.
- Log in to the SADAD Pay portal.
- Go to Profile → Update Profile → API.
- In WebhookURL, enter:
https://yourstore.com/sadad_gateway/payment/webhook/
- Click Update.
Replace yourstore.com with your store's base URL. See Webhooks.
Step 4: Test a payment
- Check that Environment is Test and you are using your Sandbox keys.
- In your store, add a product to the cart and go to checkout.
- Choose Sadad Payment and click Place Order. You are taken to the SADAD Pay payment page.
- Pay with a test card.
- You come back to the order success page.
- In Sales → Orders, the order is Processing. The order comments say Payment completed, with the transaction ID and the SADAD Pay invoice ID, and Magento has created an invoice for it.
Also try a failed payment, for example by cancelling on the KNET page. You come back to the cart with an error message, the items are still in the cart, and the order is Canceled.
Step 5: Go live
- In Stores → Configuration → Sales → Payment Methods → Sadad Payment, set Environment to Live.
- Replace the Client Key and Client Secret with your Live keys, and click Save Config.
- Set the Webhook URL in your Live SADAD Pay portal as well.
- Flush the cache:
php bin/magento cache:flush. - Place one small real order to check everything works.
See the Go-Live Checklist.
How orders are updated
| What happens | Order state in Magento |
|---|---|
| Customer places the order and goes to the payment page | Pending Payment |
| Payment succeeds (customer returns, or the webhook arrives) | Processing, with a Magento invoice and the SADAD Pay transaction ID |
| Payment fails or is cancelled | Canceled, and the customer's cart is restored |
Before it changes the order, the module asks SADAD Pay for the invoice and checks that it is Paid and that its reference number (ref_Number) is the Magento order number. You can find the invoice in the SADAD Pay portal under Invoices by searching for the order number.
The payment page opens in the language of the store view, for example Arabic for an Arabic store view.
Currencies
SADAD Pay charges in KWD. If your store's base currency is not KWD, the module converts the order total to KWD with SADAD Pay's exchange rate before it creates the invoice.
Use KWD as your base currency if you can
The module rounds the amount to 2 decimal places, and it reads your base currency. If you sell in KWD (3 decimal places) or show prices in several currencies, test a few orders in Sandbox and check that the amount on the SADAD Pay payment page matches the order total.
Refunds
The module does not refund from Magento. To refund an order:
- Refund the invoice in the SADAD Pay portal under Invoices. See Refunds.
- In Magento, open the order's invoice and create an offline Credit Memo (Refund Offline). This records the refund and updates your stock and reports, but does not move money.
Troubleshooting
| Problem | What to check |
|---|---|
| Sadad Payment does not appear in the configuration | Run php bin/magento module:status Sadad_Gateway, then setup:upgrade and cache:flush. |
| An error after Place Order, and the customer is sent back to the cart | The Client Key or Client Secret is wrong, or does not match Environment. Check them and click Save Config again. |
| Payment succeeds but the order stays Pending Payment | The customer closed the browser before returning, and the webhook is not set or not reaching your store. Check the Webhook URL, and that your firewall or WAF allows requests to /sadad_gateway/payment/webhook/. |
| "Payment return: Invoice is not Paid" | The payment failed or was cancelled. The order is canceled and the cart is restored, so the customer can try again. |
| The amount on the payment page is different from the order total | See Currencies. |
Next steps
- Other platforms: see the Plugins Overview.
- Learn how payment statuses work in Payment Status Guidelines.

