Saltar al contenido
← Volver a proyectos

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

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_CONFIRMATION status, payment methods on your POS need to have auto-receive turned off. Otherwise, all successful payments for an order will automatically trigger COMPLETED status.". This means that if you have auto-receive enabled (you most likely do), you won't receive the WAITING_FOR_CONFIRMATION status at all.
  • On successful payments, the flow is like this:
    • Status of the new transaction set
    • After the customer makes a payment: PayU Notifications Status: Pending is set
    • Immediately afterwards: PayU Notifications Status: Completed is 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 Canceled instead of Completed, but the rest of the flow is identical (including Pending being 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:8888 since I'm using a specific binary to match OC's PHP version)
  • share the site using ngrok http 8888
  • modify config.php to use the HTTP_HOST for HTTP_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 canceled and cancelled inconsistently. I kept the inconsistency for backwards compatibility with the old repo (and old config data).
    • CANCELED is used in the context of PayU responses
    • cancelled is 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/ordernotify path 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.xml with 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.

#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

  1. Pobierz moduł z repozytorium GitHub jako plik zip.
  2. Rozpakuj pobrany plik.
  3. Połącz się z serwerem ftp i skopiuj zawartość katalogu upload z rozpakowanego pliku do katalogu głównego swojego sklepu OpenCart.
  4. Przejdź do strony administracyjnej swojego sklepu OpenCart [http://adres-sklepu/admin].
  5. Przejdź Extensions » Extensions.
  6. Ustaw filtr na Payments.
  7. Znajdź na liście PayU i kliknij w ikonę Install.

#Konfiguracja

  1. Przejdź do strony administracyjnej swojego sklepu OpenCart [http://adres-sklepu/admin].
  2. Przejdź Extensions » Extensions.
  3. Ustaw filtr na Payments.
  4. Znajdź na liście PayU i 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.

Nueva versión disponible.