So if say we have more than 100 orders. Our cron logic will fetch 50 orders. The logic to check expiry will call charge API for 20 orders only (equals to $refreshCounter). The function will return expired = true for remaining orders, because that’s the default value of the function isExpired.
To fix this, we changed ->setPageSize(50) to ->setPageSize($this->refreshCounter). This will fetches the same number of orders as the refreshCounter.
3. Quality assurance
Go to Magento Backend : Sales > Order. There should be orders with status “pending/processing”.
From Terminal/CMD, execute command php bin/magento cron:run --group=omise
Wait for approximate of 5 minutes. Order status of expired charge orders will be updated to Canceled
🔧 Environments:
Specify the details of your test environments, including, for each, the platform version (on which the plugin was run), the Omise plugin version, and the versions of your system software such as PHP or Ruby.
i.e.
Platform version: Magento CE 2.1.5.
Omise plugin version: Omise-Magento 2.1.
PHP version: 7.0.16.
✏️ Details:
Explain how to manually test this feature.
For example if changes were made in the UI or in the API, explain where and if any specific access is needed.
4. Impact of the change
List the steps that must be taken for this PR to work.
E.g.: rake yak:shave, Add "yak_key" to environment variables, ...
Be sure to include all systems that needs to be changed or which system is affected by the change
(Ex: Requires Elastic search to be installed and configured in secrets.yml).
Note: Please provide a screenshot if your changed impact to UI.
5. Priority of change
Normal, High or Immediate.
6. Additional Notes
Any further information that you would like to add.
1. Objective
Fix the issue of orders getting cancelled via cron even though the charge is successful.
Jira Ticket: #1429
2. Description of change
The issue occurred due to the different value in $refreshCounter = 20 and the orders we are fetching with ->setPageSize(50). Inside the isExpired() method, we have a check $this->refreshCounter > 0 and at the end, we are decreasing the refresh count.
So if say we have more than 100 orders. Our cron logic will fetch 50 orders. The logic to check expiry will call charge API for 20 orders only (equals to $refreshCounter). The function will return expired = true for remaining orders, because that’s the default value of the function isExpired.
To fix this, we changed
->setPageSize(50)
to->setPageSize($this->refreshCounter)
. This will fetches the same number of orders as the refreshCounter.3. Quality assurance
🔧 Environments:
Specify the details of your test environments, including, for each, the platform version (on which the plugin was run), the Omise plugin version, and the versions of your system software such as PHP or Ruby.
i.e.
✏️ Details:
Explain how to manually test this feature. For example if changes were made in the UI or in the API, explain where and if any specific access is needed.
4. Impact of the change
List the steps that must be taken for this PR to work. E.g.: rake yak:shave, Add "yak_key" to environment variables, ...
Be sure to include all systems that needs to be changed or which system is affected by the change (Ex: Requires Elastic search to be installed and configured in secrets.yml).
Note: Please provide a screenshot if your changed impact to UI.
5. Priority of change
Normal, High or Immediate.
6. Additional Notes
Any further information that you would like to add.