Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture request for invoice payment method always fails for tax-free orders and notifications are stuck in processing due to Throwable not handled #552

Open
AndreasA opened this issue Sep 26, 2024 · 1 comment

Comments

@AndreasA
Copy link
Contributor

AndreasA commented Sep 26, 2024

Describe the bug
If an order is tax free, the capture request cannot be built for the line items as determining the tax-rate fails with

Call to a member function getPercentage() on null in ProcessNotifications (if done through notifications - same for manual capture).

As this is a \Throwable which is not caught by \Exception, it will also not be handled by the catch block in the notifications handler
https://github.com/Adyen/adyen-shopware6/blob/develop/src/ScheduledTask/ProcessNotificationsHandler.php#L247

for v3.15.0 https://github.com/Adyen/adyen-shopware6/blob/3.15.0/src/ScheduledTask/ProcessNotificationsHandler.php#L242

This could be changed to \Throwable as that will catch excpetions an throwables.

Therefore, the notification is stuck in processing state, and the error does not show up in any log. Only if one is running the corresponding command, will it show up in the output.

The error itself occurs due to the line $lineItem->getPrice()->getTaxRules()->highestRate()->getPercentage() * 10 in the capture service: https://github.com/Adyen/adyen-shopware6/blob/develop/src/Service/CaptureService.php#L341

for v3.15.0 https://github.com/Adyen/adyen-shopware6/blob/3.15.0/src/Service/CaptureService.php#L341

For tax free orders, the tax rules are empty, therefore, the highest rate is null. In new PHP version, this could be fixed like this:

($lineItem->getPrice()->getTaxRules()->highestRate()?->getPercentage() ?? 0) * 10.

So two changes are necessary (see above) to fully fix the issues.

Versions
Shopware version: 6.5.8.14
Plugin version: 3.15.0

@AndreasA
Copy link
Contributor Author

Created PR #553

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant