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

PHP8.x Compatibility - Deprecated Functionality: strpos() #1224

Open
samuelebau opened this issue Nov 2, 2023 · 2 comments
Open

PHP8.x Compatibility - Deprecated Functionality: strpos() #1224

samuelebau opened this issue Nov 2, 2023 · 2 comments

Comments

@samuelebau
Copy link

samuelebau commented Nov 2, 2023

What I Expected

I expected to refund an order paid with Amazon via API requests

What happened instead

Exception: Deprecated Functionality: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /var/www/current/vendor/amzn/amazon-pay-magento-2-module/Plugin/OrderCurrencyComment.php on line 66
When I try to refund an order with different base_currency_code and order_currency_code

Steps to reproduce the issue

  • Place an Order (the order must have different base_currency_code and order_currency_code
  • Refund that order (via API or backoffice)

Your setup

  • Magento version: 2.4.4-p4
  • Amazon Pay Extension Version: 5.14.1 (bug also present on 5.16.1)
  • Magento Edition: Enterprise
  • PHP Version: 8.1.23
@samuelebau
Copy link
Author

I also resolved this issue with the patch below, please include this fix in the upcoming version.

diff --git a/vendor/amzn/amazon-pay-magento-2-module/Plugin/OrderCurrencyComment.php b/vendor/amzn/amazon-pay-magento-2-module/Plugin/OrderCurrencyComment.php
--- a/vendor/amzn/amazon-pay-magento-2-module/Plugin/OrderCurrencyComment.php
+++ b/vendor/amzn/amazon-pay-magento-2-module/Plugin/OrderCurrencyComment.php	(date 1698229883874)
@@ -61,9 +61,11 @@
         if ($subject->getMethod() == Config::CODE) {
             $order = $subject->getOrder();
             if ($order->getBaseCurrencyCode() != $order->getOrderCurrencyCode() &&
-                (($subject->getMessage() instanceof Phrase
-                && $subject->getMessage()->getText() == 'Canceled order online')
-                || strpos($subject->getTransactionId(), '-void') !== false)
+                (
+                    ($subject->getMessage() instanceof Phrase
+                    && $subject->getMessage()->getText() == 'Canceled order online')
+                    || strpos($subject->getTransactionId() ?? '', '-void') !== false
+                )
             ) {
                 return $result .' ['. $order->formatPriceTxt($subject->getAmountOrdered()) .']';
             }

@samuelebau samuelebau reopened this Nov 2, 2023
@sgabhart22
Copy link
Contributor

sgabhart22 commented Nov 13, 2023

Hello @samuelebau ,

I'm afraid I was unable to reproduce this issue on a clean 2.4.4-p4 EE instance running on PHP 8.1. The base currency was EUR and the order currency was SEK:

image

The underlying problem seems to be that, for some reason, there is no transaction ID associated with the Payment on your order(s) that need to be refunded. There shouldn't ever be a point where an Amazon Pay order has no transaction ID set on the Payment if it's been authorized, and especially if it's been captured; are there any customizations or third party extensions that might be affecting the way the Amazon Pay module records these transaction IDs?

Thanks,
Spencer

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

2 participants