PrestaShop
QPay V2 payment module for PrestaShop 8.x. Extends PaymentModule and hooks into PrestaShop’s checkout flow to provide QPay payment with QR codes, bank app deep links, and webhook-based order confirmation.
- GitHub: qpay-sdk/qpay-prestashop
- Version: 1.0.0
- License: MIT
- Marketplace: GitHub only (PrestaShop Addons requires EU seller account)
Requirements
| Requirement | Version |
|---|---|
| PrestaShop | 8.0+ |
| PHP | 8.0+ |
| cURL extension | Required |
Installation
Via Back Office Upload
- Download the repository and create a ZIP archive of the
qpay/folder (the folder containingqpay.phpandclasses/) - In the PrestaShop admin panel, go to Modules > Module Manager
- Click Upload a module and select the ZIP file
- The module will be installed automatically
- Click Configure to enter your QPay credentials
Manual Installation
- Download or clone the repository:
git clone https://github.com/qpay-sdk/qpay-prestashop.git - Copy the entire folder to
/modules/qpay/in your PrestaShop installation - Go to Modules > Module Manager, find QPay Payment, and click Install
- Click Configure to set up your credentials
Configuration
After installing the module, click Configure or go to Modules > Module Manager > QPay Payment > Configure.
| Setting | Description | Default |
|---|---|---|
| API Base URL | QPay API endpoint | https://merchant.qpay.mn |
| Username | QPay merchant username | — |
| Password | QPay merchant password | — |
| Invoice Code | QPay merchant invoice code | — |
| Callback URL | Webhook URL for payment notifications | — |
Configuration values are stored using PrestaShop’s Configuration class:
| Configuration Key | Description |
|---|---|
QPAY_BASE_URL | API base URL |
QPAY_USERNAME | Merchant username |
QPAY_PASSWORD | Merchant password |
QPAY_INVOICE_CODE | Invoice code |
QPAY_CALLBACK_URL | Webhook callback URL |
For sandbox testing, set the API Base URL to:
https://merchant-sandbox.qpay.mnHow It Works
Payment Flow
- Checkout: The module registers a payment option via the
paymentOptionshook. QPay appears as “QPay-eer toloh” on the checkout payment step - Payment Page: When the customer selects QPay, they are redirected to the module’s payment controller. The controller creates a QPay invoice using the
QPayApiclass - QR Display: The payment template displays the QR code and bank app deep links
- Client-side Polling: JavaScript polls the payment status every 3 seconds
- Confirmation: When payment is confirmed:
- The order status is updated
- The
paymentReturnhook displays a confirmation message
- Webhook: QPay also sends a server-side callback to the configured callback URL
Registered Hooks
The module registers these PrestaShop hooks during installation:
| Hook | Purpose |
|---|---|
paymentOptions | Adds QPay as a payment option at checkout |
paymentReturn | Displays payment confirmation after successful payment |
Invoice Data Mapping
| QPay Field | PrestaShop Source |
|---|---|
invoice_code | Configuration::get('QPAY_INVOICE_CODE') |
sender_invoice_no | Cart/Order ID |
amount | Cart total |
callback_url | Configuration::get('QPAY_CALLBACK_URL') |
Webhook Setup
Set the callback URL in the module configuration. The recommended format is:
https://yourstore.com/module/qpay/callbackThe webhook receives a JSON POST body with invoice_id, verifies the payment via POST /v2/payment/check, and updates the order status.
Ensure the callback URL is publicly accessible and not blocked by PrestaShop’s security features or .htaccess rules.
Customization
Hooks
You can interact with the module’s hooks from other modules:
// Listen for QPay payment completion
public function hookPaymentReturn($params)
{
$order = $params['order'];
// Custom logic after QPay payment
}API Client
The QPayApi class (classes/QPayApi.php) reads credentials from PrestaShop’s Configuration system. It can be instantiated independently:
require_once _PS_MODULE_DIR_ . 'qpay/classes/QPayApi.php';
$api = new QPayApi();
$invoice = $api->createInvoice([
'invoice_code' => Configuration::get('QPAY_INVOICE_CODE'),
'sender_invoice_no' => 'CUSTOM-001',
'amount' => 25000,
'callback_url' => 'https://yourstore.com/callback',
]);
$result = $api->checkPayment($invoiceId);Token management is automatic — the access token is cached in memory and refreshed 30 seconds before expiry.
Configuration Form
The admin configuration form is built using PrestaShop’s HelperForm class in the renderForm() method of qpay.php. To add new settings:
- Add the field to the
$fieldsarray inrenderForm() - Add the
Configuration::updateValue()call ingetContent()for saving - Add
Configuration::deleteByName()inuninstall()for cleanup - Add the default value to
$helper->fields_value
Uninstallation Cleanup
The module cleans up all configuration values on uninstall:
public function uninstall()
{
Configuration::deleteByName('QPAY_BASE_URL');
Configuration::deleteByName('QPAY_USERNAME');
Configuration::deleteByName('QPAY_PASSWORD');
Configuration::deleteByName('QPAY_INVOICE_CODE');
Configuration::deleteByName('QPAY_CALLBACK_URL');
return parent::uninstall();
}Troubleshooting
QPay not appearing at checkout
- Verify the module is installed and active in Modules > Module Manager
- Check that the
paymentOptionshook is registered: go to Design > Positions and search forpaymentOptions - Clear PrestaShop caches from Advanced Parameters > Performance
- Re-register hooks by uninstalling and reinstalling the module
”Invoice creation failed” error
- Verify your QPay credentials in the module configuration
- Check that the API Base URL is correct
- Ensure your server can make outbound HTTPS requests (cURL must be enabled)
- Check PrestaShop error logs in
var/logs/
Configuration not saving
- Verify you have admin permissions to modify module settings
- Check for JavaScript errors on the configuration page
- Ensure the
submitQPayModuleform action is properly submitted
Webhook not receiving callbacks
- Confirm the callback URL is publicly accessible
- Test the URL with a manual POST request
- Check for
.htaccessrules or web server configuration blocking the endpoint - Verify no security modules (e.g., mod_security) are rejecting JSON POST requests
File Structure
qpay/
├── qpay.php # Main module class (PaymentModule extension)
├── classes/
│ └── QPayApi.php # QPay V2 API client (auth, invoice, check)
├── .github/
│ └── workflows/
│ └── ci.yml # CI configuration
└── README.mdLinks
- GitHub: https://github.com/qpay-sdk/qpay-prestashop
- QPay API Reference: /api-reference
- PrestaShop Module Development: https://devdocs.prestashop-project.org/8/modules/