Payu Opencart 3
PayU Payment Gateway for OpenCart 3.x
#PayU extension for OpenCart 3.0.2.0
#Difference between this and the original repo
- Shows error on fail (instead of a success message — on the
checkout/successroute) - Czech and Slovak translations
- Lets you use the sandbox environment
- Lets you send customers email notifications
- Supports secondary credentials
- Important: hardcoded country checks to prevent using PayU with foreign (EU) billing address + VAT no. This can be removed or customized, see
upload/catalog/model/extension/payu.php::getMethod()
The repo is primarily for internal use but I made it public in case it helps anyone. There's no guarantee of support or long-term maintenance.
To differentiate between this repo and the original one, we use our own versioning, starting from 1.0.0.
You can view all of the changes here: bfcfc5b...HEAD
#Installation
Download the latest release from here (.ocmod.zip file in the Assets section).
Or, download this repo as a zip, extract the folder, and then compress the contents of that folder into a new zip that ends in .ocmod.zip. Meaning: install.xml should be at the root of the zip file.
Alternatively, you can clone the repo and run ./build.sh (if you're on Mac/Linux) to create payu.ocmod.zip.
#Customer notifications
One of the features this fork adds is notifying customers when the PayU status of their order changes.
To enable this, simple fill out the PayU Notifications email fields in the extension config, for each status that you want to notify the customer about.
A few notes:
- Per the docs: "To enable
WAITING_FOR_CONFIRMATIONstatus, payment methods on your POS need to have auto-receive turned off. Otherwise, all successful payments for an order will automatically triggerCOMPLETEDstatus.". This means that if you have auto-receive enabled (you most likely do), you won't receive theWAITING_FOR_CONFIRMATIONstatus at all. - On successful payments, the flow is like this:
Status of the new transactionset- After the customer makes a payment:
PayU Notifications Status: Pendingis set - Immediately afterwards:
PayU Notifications Status: Completedis set - Therefore: you likely don't want to be sending notifications for the Pending status
- The same happens with unsuccessful payments. The only difference is that the last notification is for
Canceledinstead ofCompleted, but the rest of the flow is identical (includingPendingbeing sent first).
If the PayU Notifications email field is empty (for any status), the extension will not notify the customer about the status being set, and it will use PayU Notification as the comment, to make it clear that the status comes from PayU.
#Secondary credentials
Another feature of this fork is secondary credentials/POS. This lets you use one different POS for a specified region.
This can be helpful when you have a secondary POS for a different country and want to receive money in their local currency. In this case PayU sends you an additional contract and creates a special POS in your account.
To use this feature, simply fill out the [SECONDARY] credentials and pick the geo zone that they should be used in.
Important: your primary geo zone (the one specified for the extension as a whole) must be a superset of the secondary geo zone. In other words, it must include both the main region/regions and the secondary region that has a special POS.
This is because the extension's geo zone is used by OpenCart to determine whether the payment method should be offered at all, whereas the secondary geo zone is used inside the extension to determine which credentials should be used.
#Testing cards
| Card number | Expiration | CVV | Behavior |
|---|---|---|---|
| 4444333322221111 | 12/29 | 123 | Pass |
| 5100052384536818 | 02/32 | 123 | Lets you fail if you deny the 3DS |
For more, see the official docs.
#Sandbox credentials
The sandbox credentials mentioned in the docs are:
| Key | Value |
|---|---|
| POS ID | 145227 |
| Second key (MD5) | 13a980d4f851f3d9a1cfc792fb1f5e50 |
| OAuth client_id | 145227 |
| OAuth client_secret | 12f071174cb7eb79d4aac5bc2f07563f |
However, these don't seem to work on my end. So I use a custom POS created in the sandbox environment.
Since I use ngrok (see the section below), I have to create a new POS every time I have a new ngrok subdomain.
#Local development
To play with the sandbox environment locally, I do this:
- host the site using simple
php -S(/opt/homebrew/Cellar/php@7.3/7.3.33_4/bin/php -S localhost:8888since I'm using a specific binary to match OC's PHP version) - share the site using
ngrok http 8888 - modify
config.phpto use theHTTP_HOSTforHTTP_SERVER&HTTPS_SERVER
- define('HTTP_SERVER', 'http://opencart.test/'); + define('HTTP_SERVER', isset($_SERVER['HTTP_HOST']) ? ('http://' . $_SERVER['HTTP_HOST'] . '/') : 'http://opencart.test/'); - define('HTTPS_SERVER', 'http://opencart.test/'); + define('HTTPS_SERVER', isset($_SERVER['HTTP_HOST']) ? ('https://' . $_SERVER['HTTP_HOST'] . '/') : 'https://opencart.test/');
(opencart.test being the local domain I use to visit the site without ngrok)
To test email, I use Mailtrap.
#Development notes
- The repo uses
canceledandcancelledinconsistently. I kept the inconsistency for backwards compatibility with the old repo (and old config data).CANCELEDis used in the context of PayU responsescancelledis used in the context of language strings, config keys, and everything that relates to the extension settings page
- If you're using Cloudflare in production, make sure the
/index.php?route=extension/payment/payu/ordernotifypath has disabled Browser Integrity Check in Page Rules.
#Future improvements
- Possibly ignore CANCELED notifications when the order has already been paid. This can happen when there are multiple transactions for one order and the store admin cancels the ones that weren't used.
- Line ~63 in
install.xmlwith the note about the rare edge case that can happen with the fail message session and retry links from the admin panel
(Original README follows)
Jeżeli masz jakiekolwiek pytania lub chcesz zgłosić błąd zapraszamy do kontaktu z naszym wsparciem technicznym.
- Jeżeli używasz OpenCart w wersji 2.3.x proszę skorzystać z pluginu w wersji 3.2.x
- Jeżeli używasz OpenCart w wersji 2.0.x, 2.1.x lub 2.2.x proszę skorzystać z pluginu w wersji 3.1.x
#Spis treści
#Cechy i kompatybilność
Moduł płatności PayU dodaje do OpenCart opcję płatności PayU i umożliwia:
- Utworzenie płatności (wraz z rabatami)
- Automatyczne odbieranie powiadomień i zmianę statusów zamówienia
#Wymagania
Ważne: Moduł ta działa tylko z punktem płatności typu REST API (Checkout), jeżeli nie posiadasz jeszcze konta w systemie PayU - Zarejestruj się
Do prawidłowego funkcjonowania modułu wymagane są następujące rozszerzenia PHP: cURL i hash.
#Instalacja
- Pobierz moduł z repozytorium GitHub jako plik zip.
- Rozpakuj pobrany plik.
- Połącz się z serwerem ftp i skopiuj zawartość katalogu
uploadz rozpakowanego pliku do katalogu głównego swojego sklepu OpenCart. - Przejdź do strony administracyjnej swojego sklepu OpenCart [http://adres-sklepu/admin].
- Przejdź
Extensions»Extensions. - Ustaw filtr na
Payments. - Znajdź na liście
PayUi kliknij w ikonęInstall.
#Konfiguracja
- Przejdź do strony administracyjnej swojego sklepu OpenCart [http://adres-sklepu/admin].
- Przejdź
Extensions»Extensions. - Ustaw filtr na
Payments. - Znajdź na liście
PayUi kliknij w ikonęEdit.
#Parametry konfiguracyjne
| Parameter | Opis |
|---|---|
| Status | Określa czy metoda płatności PayU będzie dostępna w sklepie na liście płatności. |
| Kolejność | Określa na której pozycji ma być wyświetlana metoda płatności PayU dostępna w sklepie na liście płatności. |
| Suma zamówienia | Minimalna wartość zamówienia, od której metoda płatności PayU dostępna w sklepie na liście płatności. |
| Strefa Geo | Strefa Geo, dla której metoda płatności PayU dostępna w sklepie na liście płatności. |
| Id punktu płatności | Identyfikator POS-a z systemu PayU |
| Drugi klucz (MD5) | Drugi klucz MD5 z systemu PayU |
| Protokół OAuth - client_id | client_id dla protokołu OAuth z systemu PayU |
| Protokół OAuth - client_secret | client_secret for OAuth z systemu PayU |
#Patametry statusów
Określa relacje pomiędzy statusami zamówienia w PayU a statusami zamówienia w OpenCart.