Skip to content

Commit e196830

Browse files
authored
MAG-720: Update documentation
1 parent b89dbf2 commit e196830

2 files changed

Lines changed: 65 additions & 24 deletions

File tree

README.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@
44

55
### Pre-requirements
66

7-
- Adobe Commerce / Magento Open Source **2.4.1 – 2.4.8**
8-
- PHP **8.1 – 8.4**
7+
- Adobe Commerce / Magento Open Source **2.4.1 – 2.4.9**
8+
- PHP **8.1 – 8.5**
99
- PHP extension **openssl** (required)
1010

1111
### Installation via Magento Back Office
1212

13-
You can follow Magento’s instruction provided at
14-
[https://devdocs.magento.com/guides/v2.3/comp-mgr/extens-man/extensman-main-pg.html](https://devdocs.magento.com/guides/v2.3/comp-mgr/extens-man/extensman-main-pg.html)
13+
The Magento Back Office extension installer (Web Setup Wizard / Component Manager) was
14+
deprecated in Magento 2.3.6 and removed in Magento 2.4.0, so it is not available on the
15+
supported versions (2.4.1 – 2.4.9). Install the module via Composer instead (see below).
16+
17+
For reference, Adobe's guide on managing third-party extensions is available at
18+
[https://experienceleague.adobe.com/en/docs/commerce-operations/installation-guide/tutorials/extensions](https://experienceleague.adobe.com/en/docs/commerce-operations/installation-guide/tutorials/extensions)
1519

1620
### Installation via composer
1721

@@ -29,15 +33,14 @@ Run the following commands in Magento root directory:
2933

3034
```
3135
composer require payplug/payplug-magento2 # (*)
32-
composer install
3336
php bin/magento module:enable Payplug_Payments --clear-static-content
3437
php bin/magento setup:upgrade
3538
php bin/magento setup:di:compile
3639
php bin/magento setup:static-content:deploy <languages> # (**)(***)
3740
php bin/magento cache:clean
3841
```
3942

40-
(\*) If you didn’t save them when you installed Magento 2, this command will ask for your Magento authentication keys (https://devdocs.magento.com/guides/v2.3/install-gde/prereq/connect-auth.html).
43+
(\*) If you didn’t save them when you installed Magento 2, this command will ask for your Magento authentication keys (https://experienceleague.adobe.com/en/docs/commerce-operations/installation-guide/prerequisites/authentication-keys).
4144
Login = Public Key
4245
Password = Private Key
4346

@@ -62,16 +65,15 @@ If you get a missing class error message while following the install process:
6265
[ReflectionException] Class Payplug\Authentication does not exist
6366
```
6467

65-
It’s likely that the Payplug PHP library was not installed along with the Magento module. This will happen if you did not run composer to install the module.
66-
To fix it, you should require the missing dependency with composer :
68+
It’s likely that the Payplug PHP library was not installed along with the Magento module.
69+
This normally never happens when installing through Composer, since the module already
70+
declares `payplug/payplug-php` and `giggsey/libphonenumber-for-php` (used to normalize the
71+
customers' phone number) as dependencies. If for any reason they are missing, you can require
72+
them explicitly:
6773

6874
```
69-
composer require payplug/payplug-php:^3.0
70-
```
71-
72-
You will then need to install another library which we use to normalize the customers' phone number
73-
```
74-
composer require giggsey/libphonenumber-for-php:^8.10
75+
composer require payplug/payplug-php:^4.1
76+
composer require giggsey/libphonenumber-for-php:"^8.10|^9.0"
7577
```
7678

7779
### Cron Job Configuration
@@ -93,14 +95,17 @@ For more information on how to properly configure and schedule Magento 2 cron jo
9395
For more information about the new **`payplug_payments_check_order_consistency`** cron, consult
9496
[the Payplug CRON documentation](docs/CRONS.md)
9597

98+
### Additional Documentation
99+
100+
- [Asynchronous order status updates (crons)](docs/CRONS.md)
101+
- [Using Payplug card payment with a headless application](docs/HEADLESS.md)
96102

97103
### Update Payplug Payments Module
98104

99105
Run the following commands in Magento root directory:
100106

101107
```
102108
composer require --update-with-all-dependencies payplug/payplug-magento2:VERSION_YOU_WANT_TO_UPDATE_TO # (*)
103-
composer install
104109
php bin/magento setup:upgrade
105110
php bin/magento setup:di:compile
106111
php bin/magento setup:static-content:deploy <languages> # (**)
@@ -110,7 +115,7 @@ php bin/magento cache:clean
110115
(\*) To determine which value for `VERSION_YOU_WANT_TO_UPDATE_TO`, you can check out our [last releases](https://github.com/payplug/payplug-magento2/releases)
111116
For example, you can run:
112117
```
113-
composer require --update-with-all-dependencies payplug/payplug-magento2:^1.5
118+
composer require --update-with-all-dependencies payplug/payplug-magento2:^4.8
114119
```
115120

116121
(\*\*) With the languages option, you can define for which language you want to generate your static content. Languages should be separated with a space.

docs/CRONS.md

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
# Asynchronous Order Status Updates (from v4.3.0)
1+
# Asynchronous Processing (order statuses, invoices & refunds)
22

3-
Starting with **version 4.3.0**, the Payplug module for Magento introduces an **asynchronous** workflow that runs **in parallel** with the standard (immediate) payment flow. This addition ensures that orders are updated automatically when payment confirmations are delayed by the bank or by Payplug, preventing them from getting stuck in “payment review.”
3+
The Payplug module relies on Magento's cron for **two distinct asynchronous mechanisms**, both of which are required for the module to work correctly:
4+
5+
1. **Order status reconciliation** (from **v4.3.0**) — runs in the **`payplug`** cron group. It ensures that orders are updated automatically when payment confirmations are delayed by the bank or by Payplug, preventing them from getting stuck in “payment review.”
6+
2. **Message queue consumers** for **invoice creation and refunds** — triggered by Magento's native `consumers_runner` job, which lives in the **`default`** cron group. See [Message Queue Consumers (invoices & refunds)](#message-queue-consumers-invoices--refunds) below.
7+
8+
> ⚠️ **Both the `default` and the `payplug` cron groups must run.** Enabling only `payplug` reconciles order statuses but leaves invoices and refunds unprocessed.
9+
>
10+
> **Note:** The **`default`** cron group is not a Payplug-specific requirement — it is a prerequisite of *any* Magento installation. Magento's cron (the `default` group among others) already powers core features such as asynchronous order confirmation emails, reindexing, stock/inventory maintenance and admin grid updates. On a correctly configured store it is therefore **already running**. Before adding a dedicated crontab entry, first verify that it is actually being executed (see [Verifying Cron Execution and Logs](#verifying-cron-execution-and-logs)); only add one if the `default` group is missing.
411
512
---
613

@@ -17,6 +24,28 @@ As of v4.3.0, Magento leverages **Magento’s cron** to periodically check the p
1724

1825
---
1926

27+
## Message Queue Consumers (invoices & refunds)
28+
29+
Beyond order-status reconciliation, the module creates **invoices** and processes **refunds** asynchronously through Magento's message queue. Two consumers are declared in `etc/queue_consumer.xml` (both on the MySQL `db` connection):
30+
31+
| Topic | Consumer | Handler | Purpose |
32+
| --- | --- | --- | --- |
33+
| `payplug.order.invoicing` | `payplug.order.invoicing` | `Payplug\Payments\Service\CreateOrderInvoice::execute` | Creates the invoice for a paid order |
34+
| `payplug.order.refunding` | `payplug.order.refunding` | `Payplug\Payments\Service\CreateOrderRefund::execute` | Creates the credit memo / refund for an order |
35+
36+
When a payment is captured or a refund is received (e.g. via IPN), the module **publishes** a message to the relevant topic instead of processing it inline. The message is then picked up by the corresponding consumer.
37+
38+
Because these consumers use the `db` connection, they are executed by Magento's native **`consumers_runner`** cron job, which belongs to the **`default`** cron group (module `Magento_MessageQueue`). In other words:
39+
40+
- If the **`default`** cron group does **not** run, published messages pile up in the queue and **no invoice or refund is ever created**, even though payments and order statuses look fine.
41+
- This is independent from the `payplug` cron group, which only handles `check_order_consistency` and `auto_capture_deferred_payments`.
42+
43+
> **Note:** `consumers_runner` behavior can be tuned in `app/etc/env.php` (`cron_run`, `max_messages`, `consumers`, `multiple_processes`). Make sure it is not disabled (`cron_run` must not be set to `false`) and, if the `consumers` allow-list is used, that `payplug.order.invoicing` and `payplug.order.refunding` are not excluded.
44+
>
45+
> ⚠️ **Do not configure `multiple_processes` for the Payplug consumers** (`payplug.order.invoicing`, `payplug.order.refunding`). Running several parallel processes for the same consumer can process messages targeting the same order concurrently, leading to race conditions such as duplicated invoices or refunds. Keep these consumers running as a single process.
46+
47+
---
48+
2049
## Prerequisites
2150

2251
1. **Magento’s Cron**
@@ -48,13 +77,19 @@ Some users customize their crontab to run specific cron groups. For example, a c
4877
* * * * * /usr/local/bin/php /var/www/project/magento/bin/magento cron:run --group=default 2>&1 | grep -v "Ran jobs by schedule" >> /var/www/project/magento/var/log/magento.cron.log
4978
```
5079

51-
In such cases, **you must add the `payplug` cron group** to your crontab to ensure that the asynchronous order status updates are processed. For example:
80+
In such cases, **you must make sure that both the `default` and the `payplug` cron groups run**:
81+
82+
- The **`default`** group runs Magento's `consumers_runner` job, which processes the invoice and refund message queue consumers (see [Message Queue Consumers](#message-queue-consumers-invoices--refunds)).
83+
- The **`payplug`** group runs `payplug_payments_check_order_consistency` and `payplug_payments_auto_capture_deferred_payments`.
84+
85+
For example:
5286

5387
```bash
88+
* * * * * /usr/local/bin/php /var/www/project/magento/bin/magento cron:run --group=default 2>&1 | grep -v "Ran jobs by schedule" >> /var/www/project/magento/var/log/magento.cron.log
5489
* * * * * /usr/local/bin/php /var/www/project/magento/bin/magento cron:run --group=payplug 2>&1 | grep -v "Ran jobs by schedule" >> /var/www/project/magento/var/log/magento.cron.log
5590
```
5691

57-
This will ensure that the Payplug cron tasks (`payplug_payments_check_order_consistency` and `payplug_payments_auto_capture_deferred_payments`) are executed according to the schedule defined in your `crontab.xml`.
92+
> ⚠️ Running **only** `--group=payplug` reconciles order statuses but leaves the `default` group's `consumers_runner` unexecuted, so **invoices and refunds will never be created**.
5893
5994
## Dynamic Cron Group Execution
6095

@@ -104,12 +139,13 @@ As an alternative approach, you could dynamically list all cron groups declared
104139
105140
## Summary
106141
107-
- **Change in v4.3.0**: An asynchronous mechanism now reconciles delayed payment confirmations automatically via the `payplug` cron group.
142+
- **Order status reconciliation (v4.3.0)**: An asynchronous mechanism reconciles delayed payment confirmations automatically via the `payplug` cron group.
143+
- **Invoices & refunds**: These are created asynchronously through Magento message queue consumers, executed by the `consumers_runner` job of the **`default`** cron group.
108144
- **No Impact on Standard Workflow**: Orders still follow the immediate confirmation process when payments are processed quickly.
109145
- **Required Merchant Action**:
110-
1. If you use the native Magento cron installation (`bin/magento cron:install`), everything should work automatically.
111-
2. If you have a custom crontab that runs specific groups, ensure that you add an entry for the **`payplug`** cron group.
112-
- **Benefit**: This asynchronous flow helps prevent orders from being stuck in “payment review” due to delayed confirmations.
146+
1. If you use the native Magento cron installation (`bin/magento cron:install`), everything should work automatically (all groups run).
147+
2. If you have a custom crontab that runs specific groups, ensure that **both** the **`default`** group (invoices/refunds via `consumers_runner`) **and** the **`payplug`** group (status reconciliation & auto-capture) are executed.
148+
- **Benefit**: This asynchronous flow prevents orders from being stuck in “payment review” and ensures invoices and refunds are processed reliably.
113149
114150
---
115151

0 commit comments

Comments
 (0)