Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 42dfd05

Browse files
author
Michael Yu
committed
MAGETWO-71765: Impossible perform partial invoice for order placed with taxes and PayPal Payflow Pro
- Refactored _getCaptureAmount($amount) to remove floating point equality comparison in case of precision issue.
1 parent d8d1388 commit 42dfd05

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,15 +391,15 @@ public function authorize(\Magento\Payment\Model\InfoInterface $payment, $amount
391391
/**
392392
* Get capture amount
393393
*
394-
* @param float $amount
394+
* @param string $amount
395395
* @return string|int
396396
*/
397397
protected function _getCaptureAmount($amount)
398398
{
399399
$infoInstance = $this->getInfoInstance();
400-
$amountToPay = $this->formatPrice($amount);
401-
$authorizedAmount = $this->formatPrice($infoInstance->getAmountAuthorized());
402-
return $amountToPay != $authorizedAmount ? $amountToPay : 0;
400+
$amountToPay = $amount;
401+
$authorizedAmount = $infoInstance->getAmountAuthorized();
402+
return abs($amountToPay - $authorizedAmount) < 0.00001 ? 0 : $amountToPay;
403403
}
404404

405405
/**
@@ -424,7 +424,7 @@ public function capture(\Magento\Payment\Model\InfoInterface $payment, $amount)
424424
$request->setOrigid($payment->getParentTransactionId());
425425
$captureAmount = $this->_getCaptureAmount($amount);
426426
if ($captureAmount) {
427-
$request->setAmt($captureAmount);
427+
$request->setAmt($this->formatPrice($captureAmount));
428428
}
429429
$trxType = $this->getInfoInstance()->hasAmountPaid() ? self::TRXTYPE_SALE : self::TRXTYPE_DELAYED_CAPTURE;
430430
$request->setTrxtype($trxType);

0 commit comments

Comments
 (0)