Skip to content

Commit

Permalink
ECO-961 edge case of wrong payment processing fix
Browse files Browse the repository at this point in the history
  • Loading branch information
profuel committed Nov 2, 2017
1 parent af6e31f commit e81e582
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,16 @@ protected function allowPartialProcessing()
{
return true;
}

/**
* @param \Generated\Shared\Transfer\AmazonpayCallTransfer $payment
*
* @return bool
*/
protected function isPaymentSuccess(AmazonpayCallTransfer $payment)
{
return $payment->getAmazonpayPayment()
&& $payment->getAmazonpayPayment()->getResponseHeader()
&& $payment->getAmazonpayPayment()->getResponseHeader()->getIsSuccess();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function execute(AmazonpayCallTransfer $amazonpayCallTransfer)

$amazonpayCallTransfer = parent::execute($amazonpayCallTransfer);

if (!$amazonpayCallTransfer->getAmazonpayPayment()->getResponseHeader()->getIsSuccess()) {
if (!$this->isPaymentSuccess($amazonpayCallTransfer)) {
return $amazonpayCallTransfer;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function execute(AmazonpayCallTransfer $amazonpayCallTransfer)

$amazonpayCallTransfer = parent::execute($amazonpayCallTransfer);

if (!$amazonpayCallTransfer->getAmazonpayPayment()->getResponseHeader()->getIsSuccess()) {
if (!$this->isPaymentSuccess($amazonpayCallTransfer)) {
return $amazonpayCallTransfer;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function execute(AmazonpayCallTransfer $amazonpayCallTransfer)

$amazonpayCallTransfer = parent::execute($amazonpayCallTransfer);

if (!$amazonpayCallTransfer->getAmazonpayPayment()->getResponseHeader()->getIsSuccess()) {
if (!$this->isPaymentSuccess($amazonpayCallTransfer)) {
return $amazonpayCallTransfer;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function execute(AmazonpayCallTransfer $amazonpayCallTransfer)
{
$amazonpayCallTransfer = parent::execute($amazonpayCallTransfer);

if ($amazonpayCallTransfer->getAmazonpayPayment()->getResponseHeader()->getIsSuccess()) {
if ($this->isPaymentSuccess($amazonpayCallTransfer)) {
$amazonpayCallTransfer->setShippingAddress($this->apiResponse->getShippingAddress());

if ($this->apiResponse->getBillingAddress()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public function execute(AmazonpayCallTransfer $amazonpayCallTransfer)

$amazonpayCallTransfer = parent::execute($amazonpayCallTransfer);

$amazonPayment = $amazonpayCallTransfer->getAmazonpayPayment();

if (!$amazonPayment->getResponseHeader()->getIsSuccess()) {
if (!$this->isPaymentSuccess($amazonpayCallTransfer)) {
return $amazonpayCallTransfer;
}

$amazonPayment = $amazonpayCallTransfer->getAmazonpayPayment();
$status = $amazonPayment->getAuthorizationDetails()->getAuthorizationStatus();

if ($amazonPayment->getAuthorizationDetails()->getIdList()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace SprykerEco\Zed\Amazonpay\Communication\Plugin\Oms\Command;

use ArrayObject;
use Generated\Shared\Transfer\AmazonpayCallTransfer;
use Orm\Zed\Sales\Persistence\SpySalesOrder;
use Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject;
use SprykerEco\Shared\Amazonpay\AmazonpayConfig;
Expand All @@ -29,7 +30,7 @@ public function run(array $salesOrderItems, SpySalesOrder $orderEntity, ReadOnly
);
$result = $this->getFacade()->captureOrder($amazonpayCallTransfer);

if ($result->getAmazonpayPayment()->getResponseHeader()->getIsSuccess()) {
if ($this->isPaymentSuccess($result)) {
$wasSuccessful = true;
}
}
Expand All @@ -56,4 +57,16 @@ protected function getAffectingRequestedAmountItemsStateFlag()
{
return AmazonpayConfig::OMS_FLAG_NOT_CAPTURED;
}

/**
* @param \Generated\Shared\Transfer\AmazonpayCallTransfer $payment
*
* @return bool
*/
protected function isPaymentSuccess(AmazonpayCallTransfer $payment)
{
return $payment->getAmazonpayPayment() &&
$payment->getAmazonpayPayment()->getResponseHeader() &&
$payment->getAmazonpayPayment()->getResponseHeader()->getIsSuccess();
}
}

0 comments on commit e81e582

Please sign in to comment.