Skip to content

Commit

Permalink
Merge pull request #148 from mundipagg/bug-MOD-950-change-webhook-sta…
Browse files Browse the repository at this point in the history
…tus-code

Change webhook status code
  • Loading branch information
GabrielDeveloper authored Feb 18, 2020
2 parents ca32b43 + 19fcf79 commit 47ff182
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Webhook/Exceptions/UnprocessableWebhookException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class UnprocessableWebhookException extends AbstractMundipaggCoreException
/**
* UnprocessableWebhookException constructor.
*/
public function __construct($message)
public function __construct($message, $code = 422)
{
parent::__construct($message, 422);
parent::__construct($message, $code);
}
}
2 changes: 2 additions & 0 deletions src/Webhook/Services/ChargeHandlerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Mundipagg\Core\Kernel\ValueObjects\OrderStatus;
use Mundipagg\Core\Kernel\ValueObjects\TransactionType;
use Mundipagg\Core\Webhook\Aggregates\Webhook;
use Mundipagg\Core\Webhook\Exceptions\UnprocessableWebhookException;

final class ChargeHandlerService extends AbstractHandlerService
{
Expand All @@ -27,6 +28,7 @@ final class ChargeHandlerService extends AbstractHandlerService
*/
protected function handlePaid(Webhook $webhook)
{

//magento\sales\model\order\payment\interceptor
$orderRepository = new OrderRepository();
$chargeRepository = new ChargeRepository();
Expand Down
3 changes: 2 additions & 1 deletion src/Webhook/Services/OrderHandlerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ private function canBePaid($order)
if ($canBePaid === false) {
$chargesStatuses = json_encode($chargesStatuses);
throw new UnprocessableWebhookException(
"One or more charges of the order are in a state that is not compatible with an paid order. Charge Statuses: $chargesStatuses"
"One or more charges of the order are in a state that is not compatible with an paid order. Charge Statuses: $chargesStatuses",
500
);
}
}
Expand Down

0 comments on commit 47ff182

Please sign in to comment.