Skip to content

Commit 7f39efd

Browse files
authored
MCLOUD-5930: BUNDLE-2554: [Amazon Pay] Unable to switch credit card during checkout (#42)
1 parent 358483a commit 7f39efd

File tree

2 files changed

+131
-0
lines changed

2 files changed

+131
-0
lines changed

patches.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,11 @@
314314
"3.2.0": "MAGECLOUD-4407__fix_namespace_vertex_tax__3.2.0.patch"
315315
}
316316
},
317+
"amzn/amazon-pay-and-login-magento-2-module": {
318+
"Set Payment info bug": {
319+
"3.4.1": "BUNDLE-2554__set_payment_info_bug_fix__3.4.1.patch"
320+
}
321+
},
317322
"magento/magento2-ee-base": {
318323
"Fix pagebuilder module": {
319324
"2.3.1": "PB-319__fix_pagebuilder_module__2.3.1.patch",
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
diff --git a/vendor/amzn/amazon-pay-module/Model/OrderInformationManagement.php b/vendor/amzn/amazon-pay-module/Model/OrderInformationManagement.php
2+
index 540b357..c18ef91 100644
3+
--- a/vendor/amzn/amazon-pay-module/Model/OrderInformationManagement.php
4+
+++ b/vendor/amzn/amazon-pay-module/Model/OrderInformationManagement.php
5+
@@ -144,24 +144,11 @@ public function saveOrderInformation($amazonOrderReferenceId, $allowedConstraint
6+
];
7+
8+
$responseParser = $this->clientFactory->create($storeId)->setOrderReferenceDetails($data);
9+
- try {
10+
- $response = $this->amazonSetOrderDetailsResponseFactory->create(
11+
- [
12+
- 'response' => $responseParser
13+
- ]
14+
- );
15+
+ $response = $this->amazonSetOrderDetailsResponseFactory->create([
16+
+ 'response' => $responseParser
17+
+ ]);
18+
19+
- $this->validateConstraints($response, $allowedConstraints);
20+
- } catch (AmazonServiceUnavailableException $e) {
21+
- if($e->getApiErrorCode() == 'OrderReferenceNotModifiable') {
22+
- $this->logger->warning(
23+
- "Could not modify Amazon order details for $amazonOrderReferenceId: "
24+
- . $e->getApiErrorMessage()
25+
- );
26+
- } else {
27+
- throw $e;
28+
- }
29+
- }
30+
+ $this->validateConstraints($response, $allowedConstraints);
31+
} catch (LocalizedException $e) {
32+
throw $e;
33+
} catch (Exception $e) {
34+
diff --git a/vendor/amzn/amazon-pay-module/Plugin/ConfirmOrderReference.php b/vendor/amzn/amazon-pay-module/Plugin/ConfirmOrderReference.php
35+
index 6bad468..14b1264 100644
36+
--- a/vendor/amzn/amazon-pay-module/Plugin/ConfirmOrderReference.php
37+
+++ b/vendor/amzn/amazon-pay-module/Plugin/ConfirmOrderReference.php
38+
@@ -25,6 +25,7 @@
39+
use Amazon\Payment\Model\OrderInformationManagement;
40+
use Magento\Quote\Api\Data\PaymentInterface;
41+
use Magento\Quote\Api\Data\AddressInterface;
42+
+use Magento\Framework\Webapi\Rest\Request;
43+
use Magento\Framework\Exception\LocalizedException;
44+
use Amazon\Payment\Gateway\Config\Config as GatewayConfig;
45+
use Magento\Quote\Api\CartRepositoryInterface;
46+
@@ -41,6 +42,11 @@ class ConfirmOrderReference
47+
*/
48+
private $checkoutSession;
49+
50+
+ /**
51+
+ * @var Request
52+
+ */
53+
+ private $request;
54+
+
55+
/**
56+
* @var OrderInformationManagement
57+
*/
58+
@@ -54,19 +60,31 @@ class ConfirmOrderReference
59+
/**
60+
* ConfirmOrderReference constructor.
61+
* @param Session $checkoutSession
62+
+ * @param Request $request
63+
* @param OrderInformationManagement $orderInformationManagement
64+
* @param CartRepositoryInterface $quoteRepository
65+
*/
66+
public function __construct(
67+
Session $checkoutSession,
68+
+ Request $request,
69+
OrderInformationManagement $orderInformationManagement,
70+
CartRepositoryInterface $quoteRepository
71+
) {
72+
$this->checkoutSession = $checkoutSession;
73+
+ $this->request = $request;
74+
$this->orderInformationManagement = $orderInformationManagement;
75+
$this->quoteRepository = $quoteRepository;
76+
}
77+
78+
+ /**
79+
+ * @return boolean
80+
+ */
81+
+ protected function canConfirmOrderReference()
82+
+ {
83+
+ $data = $this->request->getRequestData();
84+
+ return !empty($data['confirmOrder']);
85+
+ }
86+
+
87+
/**
88+
* @param PaymentMethodManagementInterface $subject
89+
* @param $result
90+
@@ -94,10 +112,12 @@ public function afterSet(
91+
$this->orderInformationManagement->saveOrderInformation($amazonOrderReferenceId);
92+
}
93+
94+
- $this->orderInformationManagement->confirmOrderReference(
95+
- $amazonOrderReferenceId,
96+
- $quote->getStoreId()
97+
- );
98+
+ if ($this->canConfirmOrderReference()) {
99+
+ $this->orderInformationManagement->confirmOrderReference(
100+
+ $amazonOrderReferenceId,
101+
+ $quote->getStoreId()
102+
+ );
103+
+ }
104+
}
105+
}
106+
107+
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
108+
index 63caadf..a254c3d 100644
109+
--- a/vendor/amzn/amazon-pay-module/view/frontend/web/js/action/place-order.js
110+
+++ b/vendor/amzn/amazon-pay-module/view/frontend/web/js/action/place-order.js
111+
@@ -40,6 +40,7 @@ define(
112+
quoteId: quote.getQuoteId()
113+
});
114+
payload = {
115+
+ confirmOrder: true,
116+
cartId: quote.getQuoteId(),
117+
email: quote.guestEmail,
118+
paymentMethod: paymentData,
119+
@@ -48,6 +49,7 @@ define(
120+
} else {
121+
serviceUrl = urlBuilder.createUrl('/carts/mine/set-payment-information', {});
122+
payload = {
123+
+ confirmOrder: true,
124+
cartId: quote.getQuoteId(),
125+
paymentMethod: paymentData,
126+
billingAddress: quote.billingAddress()

0 commit comments

Comments
 (0)