omise / omise-magento

Omise Magento Plugin
https://docs.opn.ooo/magento-plugin
MIT License
34 stars 19 forks source link

[MIT-1429]: Fetch the same number of orders as the value of refresh counter #437

Closed aashishgurung closed 1 year ago

aashishgurung commented 1 year ago

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.

sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication