-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathPatch-Amazon_AmazonPay-select_payment_method.patch
126 lines (120 loc) · 5.11 KB
/
Patch-Amazon_AmazonPay-select_payment_method.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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/Model/OrderInformationManagement.php
+++ b/vendor/amzn/amazon-pay-module/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/Plugin/ConfirmOrderReference.php b/vendor/amzn/amazon-pay-module/Plugin/ConfirmOrderReference.php
index 6bad468..14b1264 100644
--- 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;
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/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/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()
});
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()