Skip to content

Commit 0c651cc

Browse files
committed
MAGETWO-99035: Payflow Field format error: 10413-The totals of the cart item amounts do not match order amounts.
1 parent 952d857 commit 0c651cc

File tree

4 files changed

+52
-31
lines changed

4 files changed

+52
-31
lines changed

app/code/Magento/Paypal/Model/Cart.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
/**
1111
* PayPal-specific model for shopping cart items and totals
12+
*
1213
* The main idea is to accommodate all possible totals into PayPal-compatible 4 totals and line items
1314
*/
1415
class Cart extends \Magento\Payment\Model\Cart

app/code/Magento/Paypal/Model/Payflow/Transparent.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\Paypal\Model\Payflow;
89

@@ -134,6 +135,8 @@ public function __construct(
134135
}
135136

136137
/**
138+
* Gets response validator instance.
139+
*
137140
* @return ResponseValidator
138141
*/
139142
public function getResponceValidator()
@@ -189,6 +192,7 @@ public function authorize(InfoInterface $payment, $amount)
189192

190193
try {
191194
$this->responseValidator->validate($response, $this);
195+
// phpcs:ignore Magento2.Exceptions.DirectThrow
192196
} catch (LocalizedException $exception) {
193197
$payment->setParentTransactionId($response->getData(self::PNREF));
194198
$this->void($payment);
@@ -214,10 +218,12 @@ public function getConfigInterface()
214218
}
215219

216220
/**
221+
* Creates vault payment token.
222+
*
217223
* @param Payment $payment
218224
* @param string $token
219-
* @throws LocalizedException
220225
* @return void
226+
* @throws \Exception
221227
*/
222228
protected function createPaymentToken(Payment $payment, $token)
223229
{
@@ -236,8 +242,11 @@ protected function createPaymentToken(Payment $payment, $token)
236242
}
237243

238244
/**
245+
* Generates CC expiration date by year and month provided in payment.
246+
*
239247
* @param Payment $payment
240248
* @return string
249+
* @throws \Exception
241250
*/
242251
private function getExpirationDate(Payment $payment)
243252
{
@@ -256,6 +265,8 @@ private function getExpirationDate(Payment $payment)
256265
}
257266

258267
/**
268+
* Returns payment extension attributes instance.
269+
*
259270
* @param Payment $payment
260271
* @return \Magento\Sales\Api\Data\OrderPaymentExtensionInterface
261272
*/

app/code/Magento/Paypal/Test/Unit/Model/CartTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
use Magento\Paypal\Model\Cart;
99

10+
/**
11+
* @see \Magento\Paypal\Model\Cart
12+
*/
1013
class CartTest extends \PHPUnit\Framework\TestCase
1114
{
1215
/**

app/code/Magento/Paypal/Test/Unit/Model/Payflow/TransparentTest.php

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,22 @@ public function setUp()
103103
public function testValidAuthorizeRequest(DataObject $validAuthorizeRequest)
104104
{
105105
$this->scopeConfig->method('getValue')
106-
->willReturnMap([
107-
['payment/payflowpro/user', ScopeInterface::SCOPE_STORE, null, 'user'],
108-
['payment/payflowpro/vendor', ScopeInterface::SCOPE_STORE, null, 'vendor'],
109-
['payment/payflowpro/partner', ScopeInterface::SCOPE_STORE, null, 'partner'],
110-
['payment/payflowpro/pwd', ScopeInterface::SCOPE_STORE, null, 'pwd'],
111-
['payment/payflowpro/verbosity', ScopeInterface::SCOPE_STORE, null, 'verbosity'],
112-
]);
106+
->willReturnMap(
107+
[
108+
['payment/payflowpro/user', ScopeInterface::SCOPE_STORE, null, 'user'],
109+
['payment/payflowpro/vendor', ScopeInterface::SCOPE_STORE, null, 'vendor'],
110+
['payment/payflowpro/partner', ScopeInterface::SCOPE_STORE, null, 'partner'],
111+
['payment/payflowpro/pwd', ScopeInterface::SCOPE_STORE, null, 'pwd'],
112+
['payment/payflowpro/verbosity', ScopeInterface::SCOPE_STORE, null, 'verbosity'],
113+
]
114+
);
113115
$this->paymentConfig->method('getBuildNotationCode')->willReturn('BUTTONSOURCE');
114116
$this->payment->method('getAdditionalInformation')
115-
->willReturnMap([
116-
[Payflowpro::PNREF, 'XXXXXXXXXXXX'],
117-
]);
117+
->willReturnMap(
118+
[
119+
[Payflowpro::PNREF, 'XXXXXXXXXXXX'],
120+
]
121+
);
118122
$this->order->method('getIncrementId')->willReturn('000000001');
119123
$this->order->method('getBaseCurrencyCode')->willReturn('USD');
120124
$this->payPalCart->method('getSubtotal')->willReturn(5.00);
@@ -136,26 +140,28 @@ public function validAuthorizeRequestDataProvider(): array
136140
{
137141
return [
138142
[
139-
new DataObject([
140-
'user' => 'user',
141-
'vendor' => 'vendor',
142-
'partner' => 'partner',
143-
'pwd' => 'pwd',
144-
'verbosity' => 'verbosity',
145-
'BUTTONSOURCE' => 'BUTTONSOURCE',
146-
'tender' => 'C',
147-
'custref' => '000000001',
148-
'invnum' => '000000001',
149-
'comment_1' => '000000001',
150-
'trxtype' => 'A',
151-
'origid' => 'XXXXXXXXXXXX',
152-
'amt' => '10.00',
153-
'currency' => 'USD',
154-
'itemamt' => '5.00',
155-
'taxamt' => '5.00',
156-
'freightamt' => '5.00',
157-
'discount' => '5.00',
158-
]),
143+
new DataObject(
144+
[
145+
'user' => 'user',
146+
'vendor' => 'vendor',
147+
'partner' => 'partner',
148+
'pwd' => 'pwd',
149+
'verbosity' => 'verbosity',
150+
'BUTTONSOURCE' => 'BUTTONSOURCE',
151+
'tender' => 'C',
152+
'custref' => '000000001',
153+
'invnum' => '000000001',
154+
'comment1' => '000000001',
155+
'trxtype' => 'A',
156+
'origid' => 'XXXXXXXXXXXX',
157+
'amt' => '10.00',
158+
'currency' => 'USD',
159+
'itemamt' => '5.00',
160+
'taxamt' => '5.00',
161+
'freightamt' => '5.00',
162+
'discount' => '5.00',
163+
]
164+
),
159165
]
160166
];
161167
}

0 commit comments

Comments
 (0)