From 10566371165f0ac03b7956b6250596ada680c94b Mon Sep 17 00:00:00 2001 From: Tom Erskine Date: Fri, 1 May 2020 12:10:25 -0500 Subject: [PATCH 1/6] BUNDLE-2554: [Amazon Pay] Unable to switch credit card during checkout - patch for BUNDLE-2554 fix for Amazon-pay VBE v3.4.1 on M2.3.5 --- patches.json | 5 + ...-2554_set_payment_info_bug_fix_3.4.1.patch | 126 ++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 patches/BUNDLE-2554_set_payment_info_bug_fix_3.4.1.patch diff --git a/patches.json b/patches.json index 4ba0374..6691fc9 100644 --- a/patches.json +++ b/patches.json @@ -311,6 +311,11 @@ "3.2.0": "MAGECLOUD-4407__fix_namespace_vertex_tax__3.2.0.patch" } }, + "amzn/amazon-pay-and-login-magento-2-module": { + "Set Payment info bug": { + "3.4.1": "BUNDLE-2554_set_payment_info_bug_fix_3.4.1" + } + }, "magento/magento2-ee-base": { "Fix pagebuilder module": { "2.3.1": "PB-319__fix_pagebuilder_module__2.3.1.patch", diff --git a/patches/BUNDLE-2554_set_payment_info_bug_fix_3.4.1.patch b/patches/BUNDLE-2554_set_payment_info_bug_fix_3.4.1.patch new file mode 100644 index 0000000..9334eb5 --- /dev/null +++ b/patches/BUNDLE-2554_set_payment_info_bug_fix_3.4.1.patch @@ -0,0 +1,126 @@ +diff --git a/vendor/amzn/amazon-pay-module/Payment/Model/OrderInformationManagement.php b/vendor/amzn/amazon-pay-module/Payment/Model/OrderInformationManagement.php +index 540b357..c18ef91 100644 +--- a/vendor/amzn/amazon-pay-module/Payment/Model/OrderInformationManagement.php ++++ b/vendor/amzn/amazon-pay-module/Payment/Model/OrderInformationManagement.php +@@ -144,24 +144,11 @@ public function saveOrderInformation($amazonOrderReferenceId, $allowedConstraint + ]; + + $responseParser = $this->clientFactory->create($storeId)->setOrderReferenceDetails($data); +- try { +- $response = $this->amazonSetOrderDetailsResponseFactory->create( +- [ +- 'response' => $responseParser +- ] +- ); ++ $response = $this->amazonSetOrderDetailsResponseFactory->create([ ++ 'response' => $responseParser ++ ]); + +- $this->validateConstraints($response, $allowedConstraints); +- } catch (AmazonServiceUnavailableException $e) { +- if($e->getApiErrorCode() == 'OrderReferenceNotModifiable') { +- $this->logger->warning( +- "Could not modify Amazon order details for $amazonOrderReferenceId: " +- . $e->getApiErrorMessage() +- ); +- } else { +- throw $e; +- } +- } ++ $this->validateConstraints($response, $allowedConstraints); + } catch (LocalizedException $e) { + throw $e; + } catch (Exception $e) { +diff --git a/vendor/amzn/amazon-pay-module/Payment/Plugin/ConfirmOrderReference.php b/vendor/amzn/amazon-pay-module/Payment/Plugin/ConfirmOrderReference.php +index 6bad468..14b1264 100644 +--- a/vendor/amzn/amazon-pay-module/Payment/Plugin/ConfirmOrderReference.php ++++ b/vendor/amzn/amazon-pay-module/Payment/Plugin/ConfirmOrderReference.php +@@ -25,6 +25,7 @@ + use Amazon\Payment\Model\OrderInformationManagement; + use Magento\Quote\Api\Data\PaymentInterface; + use Magento\Quote\Api\Data\AddressInterface; ++use Magento\Framework\Webapi\Rest\Request; + use Magento\Framework\Exception\LocalizedException; + use Amazon\Payment\Gateway\Config\Config as GatewayConfig; + use Magento\Quote\Api\CartRepositoryInterface; +@@ -41,6 +42,11 @@ class ConfirmOrderReference + */ + private $checkoutSession; + ++ /** ++ * @var Request ++ */ ++ private $request; ++ + /** + * @var OrderInformationManagement + */ +@@ -54,19 +60,31 @@ class ConfirmOrderReference + /** + * ConfirmOrderReference constructor. + * @param Session $checkoutSession ++ * @param Request $request + * @param OrderInformationManagement $orderInformationManagement + * @param CartRepositoryInterface $quoteRepository + */ + public function __construct( + Session $checkoutSession, ++ Request $request, + OrderInformationManagement $orderInformationManagement, + CartRepositoryInterface $quoteRepository + ) { + $this->checkoutSession = $checkoutSession; ++ $this->request = $request; + $this->orderInformationManagement = $orderInformationManagement; + $this->quoteRepository = $quoteRepository; + } + ++ /** ++ * @return boolean ++ */ ++ protected function canConfirmOrderReference() ++ { ++ $data = $this->request->getRequestData(); ++ return !empty($data['confirmOrder']); ++ } ++ + /** + * @param PaymentMethodManagementInterface $subject + * @param $result +@@ -94,10 +112,12 @@ public function afterSet( + $this->orderInformationManagement->saveOrderInformation($amazonOrderReferenceId); + } + +- $this->orderInformationManagement->confirmOrderReference( +- $amazonOrderReferenceId, +- $quote->getStoreId() +- ); ++ if ($this->canConfirmOrderReference()) { ++ $this->orderInformationManagement->confirmOrderReference( ++ $amazonOrderReferenceId, ++ $quote->getStoreId() ++ ); ++ } + } + } + +diff --git a/vendor/amzn/amazon-pay-module/Payment/view/frontend/web/js/action/place-order.js b/vendor/amzn/amazon-pay-module/Payment/view/frontend/web/js/action/place-order.js +index 63caadf..a254c3d 100644 +--- a/vendor/amzn/amazon-pay-module/Payment/view/frontend/web/js/action/place-order.js ++++ b/vendor/amzn/amazon-pay-module/Payment/view/frontend/web/js/action/place-order.js +@@ -40,6 +40,7 @@ define( + quoteId: quote.getQuoteId() + }); + payload = { ++ confirmOrder: true, + cartId: quote.getQuoteId(), + email: quote.guestEmail, + paymentMethod: paymentData, +@@ -48,6 +49,7 @@ define( + } else { + serviceUrl = urlBuilder.createUrl('/carts/mine/set-payment-information', {}); + payload = { ++ confirmOrder: true, + cartId: quote.getQuoteId(), + paymentMethod: paymentData, + billingAddress: quote.billingAddress() \ No newline at end of file From 5cce499eb24e461c4f99e8ba5c4a99f079e04436 Mon Sep 17 00:00:00 2001 From: Tom Erskine Date: Fri, 1 May 2020 12:31:36 -0500 Subject: [PATCH 2/6] BUNDLE-2554: [Amazon Pay] Unable to switch credit card during checkout --- ...1.patch => BUNDLE-2554__set_payment_info_bug_fix__3.4.1.patch} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename patches/{BUNDLE-2554_set_payment_info_bug_fix_3.4.1.patch => BUNDLE-2554__set_payment_info_bug_fix__3.4.1.patch} (100%) diff --git a/patches/BUNDLE-2554_set_payment_info_bug_fix_3.4.1.patch b/patches/BUNDLE-2554__set_payment_info_bug_fix__3.4.1.patch similarity index 100% rename from patches/BUNDLE-2554_set_payment_info_bug_fix_3.4.1.patch rename to patches/BUNDLE-2554__set_payment_info_bug_fix__3.4.1.patch From 62cd6669c01ba35a987d9ea614dae696e6bf7fe3 Mon Sep 17 00:00:00 2001 From: Oleg Posyniak Date: Fri, 1 May 2020 14:05:15 -0500 Subject: [PATCH 3/6] Update patches.json --- patches.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches.json b/patches.json index 6691fc9..03c9875 100644 --- a/patches.json +++ b/patches.json @@ -313,7 +313,7 @@ }, "amzn/amazon-pay-and-login-magento-2-module": { "Set Payment info bug": { - "3.4.1": "BUNDLE-2554_set_payment_info_bug_fix_3.4.1" + "3.4.1": "BUNDLE-2554__set_payment_info_bug_fix__3.4.1" } }, "magento/magento2-ee-base": { From a5bfc4c0eefbf57d7c06e310532bb814f68cf9d6 Mon Sep 17 00:00:00 2001 From: Oleg Posyniak Date: Fri, 1 May 2020 16:43:20 -0500 Subject: [PATCH 4/6] Update BUNDLE-2554__set_payment_info_bug_fix__3.4.1.patch --- patches/BUNDLE-2554__set_payment_info_bug_fix__3.4.1.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/BUNDLE-2554__set_payment_info_bug_fix__3.4.1.patch b/patches/BUNDLE-2554__set_payment_info_bug_fix__3.4.1.patch index 9334eb5..e5cbff1 100644 --- a/patches/BUNDLE-2554__set_payment_info_bug_fix__3.4.1.patch +++ b/patches/BUNDLE-2554__set_payment_info_bug_fix__3.4.1.patch @@ -123,4 +123,4 @@ index 63caadf..a254c3d 100644 + confirmOrder: true, cartId: quote.getQuoteId(), paymentMethod: paymentData, - billingAddress: quote.billingAddress() \ No newline at end of file + billingAddress: quote.billingAddress() From 0cf14a9d138f8b4fca849261fd11d3a29dcf5ad5 Mon Sep 17 00:00:00 2001 From: Tom Erskine Date: Fri, 1 May 2020 16:51:33 -0500 Subject: [PATCH 5/6] Fix pathing on patchfile BUNDLE-2554__set_payment_info_bug_fix__3.4.1.patch --- ...2554__set_payment_info_bug_fix__3.4.1.patch | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/patches/BUNDLE-2554__set_payment_info_bug_fix__3.4.1.patch b/patches/BUNDLE-2554__set_payment_info_bug_fix__3.4.1.patch index e5cbff1..f68ecee 100644 --- a/patches/BUNDLE-2554__set_payment_info_bug_fix__3.4.1.patch +++ b/patches/BUNDLE-2554__set_payment_info_bug_fix__3.4.1.patch @@ -1,7 +1,7 @@ -diff --git a/vendor/amzn/amazon-pay-module/Payment/Model/OrderInformationManagement.php b/vendor/amzn/amazon-pay-module/Payment/Model/OrderInformationManagement.php +diff --git a/vendor/amzn/amazon-pay-module/Model/OrderInformationManagement.php b/vendor/amzn/amazon-pay-module/Model/OrderInformationManagement.php index 540b357..c18ef91 100644 ---- a/vendor/amzn/amazon-pay-module/Payment/Model/OrderInformationManagement.php -+++ b/vendor/amzn/amazon-pay-module/Payment/Model/OrderInformationManagement.php +--- a/vendor/amzn/amazon-pay-module/Model/OrderInformationManagement.php ++++ b/vendor/amzn/amazon-pay-module/Model/OrderInformationManagement.php @@ -144,24 +144,11 @@ public function saveOrderInformation($amazonOrderReferenceId, $allowedConstraint ]; @@ -31,10 +31,10 @@ index 540b357..c18ef91 100644 } catch (LocalizedException $e) { throw $e; } catch (Exception $e) { -diff --git a/vendor/amzn/amazon-pay-module/Payment/Plugin/ConfirmOrderReference.php b/vendor/amzn/amazon-pay-module/Payment/Plugin/ConfirmOrderReference.php +diff --git a/vendor/amzn/amazon-pay-module/Plugin/ConfirmOrderReference.php b/vendor/amzn/amazon-pay-module/Plugin/ConfirmOrderReference.php index 6bad468..14b1264 100644 ---- a/vendor/amzn/amazon-pay-module/Payment/Plugin/ConfirmOrderReference.php -+++ b/vendor/amzn/amazon-pay-module/Payment/Plugin/ConfirmOrderReference.php +--- a/vendor/amzn/amazon-pay-module/Plugin/ConfirmOrderReference.php ++++ b/vendor/amzn/amazon-pay-module/Plugin/ConfirmOrderReference.php @@ -25,6 +25,7 @@ use Amazon\Payment\Model\OrderInformationManagement; use Magento\Quote\Api\Data\PaymentInterface; @@ -104,10 +104,10 @@ index 6bad468..14b1264 100644 } } -diff --git a/vendor/amzn/amazon-pay-module/Payment/view/frontend/web/js/action/place-order.js b/vendor/amzn/amazon-pay-module/Payment/view/frontend/web/js/action/place-order.js +diff --git a/vendor/amzn/amazon-pay-module/view/frontend/web/js/action/place-order.js b/vendor/amzn/amazon-pay-module/view/frontend/web/js/action/place-order.js index 63caadf..a254c3d 100644 ---- a/vendor/amzn/amazon-pay-module/Payment/view/frontend/web/js/action/place-order.js -+++ b/vendor/amzn/amazon-pay-module/Payment/view/frontend/web/js/action/place-order.js +--- a/vendor/amzn/amazon-pay-module/view/frontend/web/js/action/place-order.js ++++ b/vendor/amzn/amazon-pay-module/view/frontend/web/js/action/place-order.js @@ -40,6 +40,7 @@ define( quoteId: quote.getQuoteId() }); From 37c8ef0604a4e4d5cca924b48ae17a485f8fa368 Mon Sep 17 00:00:00 2001 From: Tom Erskine Date: Thu, 7 May 2020 11:05:01 -0500 Subject: [PATCH 6/6] BUNDLE-2554__set_payment_info_bug_fix__3.4.1.patch - added file extension to patches.json file for BUNDLE-2554 --- patches.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches.json b/patches.json index 03c9875..7f93633 100644 --- a/patches.json +++ b/patches.json @@ -313,7 +313,7 @@ }, "amzn/amazon-pay-and-login-magento-2-module": { "Set Payment info bug": { - "3.4.1": "BUNDLE-2554__set_payment_info_bug_fix__3.4.1" + "3.4.1": "BUNDLE-2554__set_payment_info_bug_fix__3.4.1.patch" } }, "magento/magento2-ee-base": {