OpenCart plugin
The TapPay extension for OpenCart opens a hosted checkout session for each order and marks the order as paid when TapPay confirms the payment. If you prefer to connect your shop with code, follow the checkout guide instead.
Requirements
| Plugin version | Minimum platform | Minimum runtime |
|---|---|---|
0.1.0 | OpenCart 4.1.0.0 | PHP 8.1 |
- An OpenCart 4.1.0.x shop with PHP 8.1 or newer, and the currency set to MNT. The extension offers TapPay only for orders in MNT.
- A merchant account in TapPay, with at least one terminal. With one-click connect, the extension gets its key and webhook for you. For manual setup, you need a sandbox secret key. The key needs the
checkout:write,payments:writeandrefunds:writescopes. Thewebhooks:managescope is optional: with it, the extension can also check your webhook endpoint. - A public HTTPS address for your shop, so that TapPay can send webhooks to it.
Install
The extension is not in the OpenCart marketplace yet. Download it from the merchant portal.
- In the merchant portal, open Connections › TapPay systems › Online store and choose Download plugin (.zip) for OpenCart. You get the file
tappay.ocmod.zip. - In the OpenCart admin, open Extensions > Installer, choose Upload and select the file, then choose Install for TapPay.
- Open Extensions > Extensions, choose the type Payments, find TapPay, and choose Install.
- Choose Edit to open the settings.
Configure
Connect in one click
- In the TapPay settings, choose Connect to TapPay for the
Sandboxmode. - The merchant portal opens. Sign in if it asks. The
Sandboxmode opens the sandbox portal, and theProductionmode opens the production portal. - Check the site address on the page. The connection belongs to one terminal: if your business has several, choose one.
- Choose Approve. In production, the portal may ask for two-step verification first. After it, choose Approve again.
- The portal sends you back to the extension. The extension saves the keys and shows Connected.
The connection creates a secret key with the checkout:write, payments:write, refunds:write and webhooks:manage scopes. It also creates a webhook endpoint with the events that the extension needs. To approve, you need the permissions to manage API keys and webhooks.
To go live, choose Connect to TapPay for the Production mode, then switch Mode to Production. The production connection is separate from the sandbox one.
To disconnect, choose Disconnect in the extension, or open the system under Developers › API keys & webhooks in the merchant portal and choose Disable. Both revoke the key and disable the webhook endpoint.
Manual setup (fallback)
Use these steps when you cannot use one-click connect. In the TapPay settings, the fields are under Manual setup.
- Sign in to the merchant portal in the sandbox and create a secret key. Your sandbox key looks like
sk_test_YOUR_SECRET_KEY, and it starts withsk_test_. - In the TapPay settings, copy the Webhook URL. It has the form
https://your-shop.example/index.php?route=extension/tappay/payment/tappay.webhook. - In the merchant portal, open Developers › API keys & webhooks and create a webhook endpoint. Paste the URL exactly as the settings show it. Do not change the scheme, host, path or query. Choose these events:
payment.succeeded,payment.overpaid,payment.failed,payment.processing,invoice.expired,invoice.partially_paid,refund.succeededandrefund.failed. - Copy the webhook secret of the endpoint. It starts with
whsec_and the portal shows it once. - In the settings, keep Mode on
Sandbox, enter the sandbox secret key and the sandbox webhook secret, and save. The extension refuses a key with the wrong prefix, such as ask_live_key in the sandbox field. - Choose Check connection. The extension reads your account with the key. If the key has the
webhooks:managescope, it also looks for an active webhook endpoint with exactly the URL of the extension.
Optional fields: the Terminal ID is needed when your key does not belong to one terminal. The Request signing secret is needed when TapPay signs requests for your account. You can also choose the order statuses for paid, pending, failed, cancelled and refunded orders.
After you save, the extension shows a secret only as its last characters. Leave a secret field empty to keep the saved value.
Go live
When the sandbox works, switch the extension to production. The go-live checklist applies:
- Create a production secret key, and enter it in the production field.
- Create a separate production webhook endpoint with the same URL and the same events. Enter its own webhook secret. The sandbox secret does not work in production.
- Add the outgoing IP address of your server to the system’s IP restriction under Developers › API keys & webhooks in the merchant portal.
- If your account uses request signing, enter the request signing secret.
- Switch Mode to
Production, save, and choose Check connection.
The extension does not take the page that the customer sees after paying as proof of payment. It sends an Idempotency-Key with every request, so you do nothing more for those two points.
Test in sandbox
- Add a product to the cart and choose TapPay at checkout.
- On the hosted page, pay with the test card
4242 4242 4242 4242. The testing page lists more cards, and the simulator lets you create other outcomes. - After the redirect to your shop, the order gets the paid status. The payment id appears in the TapPay section of the order.
- If the order stays in the pending status, the webhook has not arrived. See Troubleshooting below.
Refunds
A refund starts in the TapPay section of the order page in Sales > Orders, because OpenCart has no core refund API. The section shows the amount paid, the amount refunded (including pending refunds) and the amount you can still refund. Enter the amount, and choose Refund via TapPay. It is asynchronous: TapPay confirms the refund with the refund.succeeded webhook. If TapPay sends refund.failed, the extension removes the refund from the total and adds a note to the order history. When the full amount is refunded, the order gets the refunded status. See the refunds guide for the rules of the API.
Troubleshooting
- The order stays in the pending status. The webhook URL in the portal does not equal the URL in the settings. Copy it again, exactly, including the
?route=extension/tappay/payment/tappay.webhookquery. Also check that the endpoint has the events listed above, and that the webhook secret is the one of this endpoint and this mode. See the webhooks guide. - The webhook returns
401. The signature does not match. The webhook secret is wrong, or a proxy, a redirect or a changed URL alters the request. Enter the secret of this endpoint again. - “Invalid key” or error
EVT-206orEVT-207. The key belongs to the other mode. Use ask_test_key and a sandbox endpoint inSandboxmode, and ask_live_key inProductionmode. - TapPay is not offered at checkout. The extension works only with orders in MNT, and only when the selected mode has a valid secret key and webhook secret. Set the shop currency to MNT and complete the settings.
- The refund shows an error with
503, a timeout,429or403. A refund is asynchronous. After a temporary error, the extension remembers the refund. Repeat it with exactly the same amount. The extension rejects a different amount, so that the customer is not refunded twice. - “An earlier refund attempt was not confirmed by TapPay”. The extension repeats a remembered refund only within 23 hours, because TapPay keeps an idempotency key for 24 hours. After that it stops, so that the customer is not refunded twice. Check the payment in the TapPay dashboard. If the refund is not there, choose Clear unconfirmed attempt in the TapPay section of the order, and refund again.
- “Development override”. The
TAPPAY_API_BASE_OVERRIDEconstant is for TapPay platform developers only. Remove it fromconfig.php.
Changelog
The latest version is shown in the table in Requirements. The full history is in the CHANGELOG.md file of the plugin repository.