Skip to content

Commit

Permalink
Merge pull request #87 from spryker-eco/bugfix/frw-7293-add-transacti…
Browse files Browse the repository at this point in the history
…on-cancelling-when-amount-not-zero

FRW-7293 Fixed transaction cancelling when amount is greater than zero.
  • Loading branch information
spryker-release-bot authored Feb 29, 2024
2 parents 962ec1c + 2793bdd commit 932646c
Showing 1 changed file with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,7 @@ public function __construct(
*/
public function capturePayment(PayoneCaptureTransfer $captureTransfer): CaptureResponseTransfer
{
$distributedPriceOrderTransfer = $this->orderPriceDistributor->distributeOrderPrice(
$captureTransfer->getOrder()
);
$captureTransfer->setOrder($distributedPriceOrderTransfer);
$captureTransfer->setAmount($distributedPriceOrderTransfer->getTotals()->getGrandTotal());
$captureTransfer = $this->addDataToCaptureTransferFromDistributedOrder($captureTransfer);

$paymentEntity = $this->getPaymentEntity($captureTransfer->getPayment()->getFkSalesOrder());
$paymentMethodMapper = $this->getPaymentMethodMapper($paymentEntity);
Expand Down Expand Up @@ -145,6 +141,26 @@ public function capturePayment(PayoneCaptureTransfer $captureTransfer): CaptureR
return $this->captureResponseMapper->getCaptureResponseTransfer($responseContainer);
}

/**
* @param \Generated\Shared\Transfer\PayoneCaptureTransfer $captureTransfer
*
* @return \Generated\Shared\Transfer\CaptureResponseTransfer
*/
protected function addDataToCaptureTransferFromDistributedOrder(PayoneCaptureTransfer $captureTransfer): CaptureResponseTransfer
{
$distributedPriceOrderTransfer = $this->orderPriceDistributor->distributeOrderPrice(
$captureTransfer->getOrder()
);

$captureTransfer->setOrder($distributedPriceOrderTransfer);

if ($captureTransfer->getAmount() === null) {
$captureTransfer->setAmount($distributedPriceOrderTransfer->getTotals()->getGrandTotal());
}

return $captureTransfer;
}

/**
* @param \Orm\Zed\Payone\Persistence\SpyPaymentPayoneApiLog $apiLogEntity
* @param \SprykerEco\Zed\Payone\Business\Api\Response\Container\CaptureResponseContainer $responseContainer
Expand Down

0 comments on commit 932646c

Please sign in to comment.