This repository was archived by the owner on Apr 29, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +73
-1
lines changed
app/code/Magento/Paypal/Model/Api
dev/tests/integration/testsuite/Magento/Paypal Expand file tree Collapse file tree 3 files changed +73
-1
lines changed Original file line number Diff line number Diff line change @@ -991,7 +991,7 @@ public function callRefundTransaction()
991
991
{
992
992
$ request = $ this ->_exportToRequest ($ this ->_refundTransactionRequest );
993
993
if ($ this ->getRefundType () === \Magento \Paypal \Model \Config::REFUND_TYPE_PARTIAL ) {
994
- $ request ['AMT ' ] = $ this ->getAmount ();
994
+ $ request ['AMT ' ] = $ this ->formatPrice ( $ this -> getAmount () );
995
995
}
996
996
$ response = $ this ->call (self ::REFUND_TRANSACTION , $ request );
997
997
$ this ->_importFromResponse ($ this ->_refundTransactionResponse , $ response );
Original file line number Diff line number Diff line change @@ -118,6 +118,48 @@ public function testRequestTotalsAndLineItemsWithFPT()
118
118
$ this ->nvpApi ->callSetExpressCheckout ();
119
119
}
120
120
121
+ /**
122
+ * Test that the refund request to Paypal sends the correct data
123
+ *
124
+ * @magentoDataFixture Magento/Paypal/_files/order_express_with_tax.php
125
+ */
126
+ public function testCallRefundTransaction ()
127
+ {
128
+ /** @var \Magento\Sales\Model\Order $order */
129
+ $ order = $ this ->objectManager ->create (\Magento \Sales \Model \Order::class);
130
+ $ order ->loadByIncrementId ('100000001 ' );
131
+
132
+ /** @var \Magento\Sales\Model\Order\Payment $payment */
133
+ $ payment = $ order ->getPayment ();
134
+
135
+ $ this ->nvpApi ->setPayment (
136
+ $ payment
137
+ )->setTransactionId (
138
+ 'fooTransactionId '
139
+ )->setAmount (
140
+ $ payment ->formatAmount ($ order ->getBaseGrandTotal ())
141
+ )->setCurrencyCode (
142
+ $ order ->getBaseCurrencyCode ()
143
+ )->setRefundType (
144
+ Config::REFUND_TYPE_PARTIAL
145
+ );
146
+
147
+ $ httpQuery = 'TRANSACTIONID=fooTransactionId&REFUNDTYPE=Partial '
148
+ .'&CURRENCYCODE=USD&AMT=145.98&METHOD=RefundTransaction '
149
+ .'&VERSION=72.0&BUTTONSOURCE=Magento_Cart_ ' ;
150
+
151
+ $ this ->httpClient ->expects ($ this ->once ())->method ('write ' )
152
+ ->with (
153
+ 'POST ' ,
154
+ 'https://api-3t.paypal.com/nvp ' ,
155
+ '1.1 ' ,
156
+ [],
157
+ $ httpQuery
158
+ );
159
+
160
+ $ this ->nvpApi ->callRefundTransaction ();
161
+ }
162
+
121
163
/**
122
164
* Gets quote by reserved order id.
123
165
*
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+
7
+ use Magento \Framework \ObjectManagerInterface ;
8
+ use Magento \Sales \Model \OrderRepository ;
9
+ use Magento \TestFramework \Helper \Bootstrap ;
10
+
11
+ require __DIR__ . '/order_express.php ' ;
12
+
13
+ /** @var ObjectManagerInterface $objectManager */
14
+ $ objectManager = Bootstrap::getObjectManager ();
15
+
16
+ $ subTotal = 121 ;
17
+ $ taxRate = .0825 ;
18
+ $ taxAmount = $ subTotal * $ taxRate ;
19
+ $ shippingAmount = 15 ;
20
+ $ totalAmount = $ subTotal + $ taxAmount + $ shippingAmount ;
21
+
22
+ $ order ->setSubtotal ($ subTotal );
23
+ $ order ->setBaseSubtotal ($ subTotal );
24
+ $ order ->setGrandTotal ($ totalAmount );
25
+ $ order ->setBaseGrandTotal ($ totalAmount );
26
+ $ order ->setTaxAmount ($ taxAmount );
27
+
28
+ /** @var OrderRepository $orderRepository */
29
+ $ orderRepository = $ objectManager ->get (OrderRepository::class);
30
+ $ orderRepository ->save ($ order );
You can’t perform that action at this time.
0 commit comments