Skip to content

Commit

Permalink
Merge pull request #35 from spryker-eco/bugfix/supesc-180-notificatio…
Browse files Browse the repository at this point in the history
…ns-are-not-processed

Release 3.1.0
  • Loading branch information
alex-galych authored Oct 9, 2020
2 parents 7171e1a + 58e6a7d commit 85e8b47
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 17 deletions.
6 changes: 3 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License
The MIT License (MIT)

Copyright (c) 2017 SPRYKER SYSTEMS GMBH
Copyright (c) 2016-present Spryker Systems GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@
<property name="description" type="string"/>
<property name="type" type="string"/>
<property name="isSuccess" type="bool"/>
<property name="isProcessed" type="bool"/>
</transfer>

</transfers>
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,13 @@ public function notifyAction(Request $request)
->fromArray($responseHeaderTransfer->toArray(), true)
->setType($decryptedArray[ComputopApiConfig::NOTIFICATION_PARAMETER_PAYMENT_TYPE] ?? '');

$this->getClient()->processNotification($computopNotificationTransfer);
$computopNotificationTransfer = $this->getClient()->processNotification($computopNotificationTransfer);

return new Response();
if ($computopNotificationTransfer->getIsProcessed()) {
return new Response();
}

return new Response('', Response::HTTP_NOT_ACCEPTABLE);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,27 @@ public function __construct(ComputopEntityManagerInterface $computopEntityManage
public function processNotification(
ComputopNotificationTransfer $computopNotificationTransfer
): ComputopNotificationTransfer {
$this->getTransactionHandler()->handleTransaction(
function () use ($computopNotificationTransfer): void {
$this->executeSaveComputopNotificationTransaction($computopNotificationTransfer);
return $this->getTransactionHandler()->handleTransaction(
function () use ($computopNotificationTransfer): ComputopNotificationTransfer {
return $this->executeSaveComputopNotificationTransaction($computopNotificationTransfer);
}
);

return $computopNotificationTransfer;
}

/**
* @param \Generated\Shared\Transfer\ComputopNotificationTransfer $computopNotificationTransfer
*
* @return void
* @return \Generated\Shared\Transfer\ComputopNotificationTransfer
*/
protected function executeSaveComputopNotificationTransaction(
ComputopNotificationTransfer $computopNotificationTransfer
): void {
): ComputopNotificationTransfer {
$this->computopEntityManager->savePaymentComputopNotification($computopNotificationTransfer);
$this->computopEntityManager->updatePaymentComputopOrderItemPaymentConfirmation($computopNotificationTransfer);
$isProcessed = $this->computopEntityManager
->updatePaymentComputopOrderItemPaymentConfirmation($computopNotificationTransfer);

$computopNotificationTransfer->setIsProcessed($isProcessed);

return $computopNotificationTransfer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public function savePaymentComputopNotification(ComputopNotificationTransfer $co
/**
* @param \Generated\Shared\Transfer\ComputopNotificationTransfer $computopNotificationTransfer
*
* @return void
* @return bool
*/
public function updatePaymentComputopOrderItemPaymentConfirmation(
ComputopNotificationTransfer $computopNotificationTransfer
): void {
): bool {
$paymentComputopOrderItemEntities = $this->getFactory()
->createPaymentComputopOrderItemQuery()
->useSpyPaymentComputopQuery()
Expand All @@ -51,9 +51,15 @@ public function updatePaymentComputopOrderItemPaymentConfirmation(
->endUse()
->find();

if (!$paymentComputopOrderItemEntities->count()) {
return false;
}

foreach ($paymentComputopOrderItemEntities as $paymentComputopOrderItemEntity) {
$paymentComputopOrderItemEntity->setIsPaymentConfirmed($computopNotificationTransfer->getIsSuccess());
$paymentComputopOrderItemEntity->save();
}

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public function savePaymentComputopNotification(ComputopNotificationTransfer $co
/**
* @param \Generated\Shared\Transfer\ComputopNotificationTransfer $computopNotificationTransfer
*
* @return void
* @return bool
*/
public function updatePaymentComputopOrderItemPaymentConfirmation(
ComputopNotificationTransfer $computopNotificationTransfer
): void;
): bool;
}

0 comments on commit 85e8b47

Please sign in to comment.