Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PT-895] Improve Error handling in order creation process. #96

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Helpers/ABTesting/ABTesting.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public function formatApiResult($result)
{
$body = $result['body'];

if ($result['error']) {
return $result;
}

$response = [
'error' => $result['error'],
'message' => $result['message'],
Expand Down
14 changes: 13 additions & 1 deletion Model/Request/Transactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Mondu\Mondu\Model\Ui\ConfigProvider;
use Magento\Framework\UrlInterface;
use Magento\Framework\Locale\Resolver;
use Mondu\Mondu\Helpers\Logger\Logger as MonduFileLogger;

class Transactions extends CommonRequest implements RequestInterface
{
Expand Down Expand Up @@ -58,6 +59,11 @@ class Transactions extends CommonRequest implements RequestInterface
*/
private $store;

/**
* @var MonduFileLogger
*/
private $monduFileLogger;

/**
* @param Curl $curl
* @param CartTotalRepository $cartTotalRepository
Expand All @@ -75,7 +81,8 @@ public function __construct(
OrderHelper $orderHelper,
UrlInterface $urlBuilder,
BuyerParamsInterface $buyerParams,
Resolver $store
Resolver $store,
MonduFileLogger $monduFileLogger
) {
$this->_checkoutSession = $checkoutSession;
$this->_cartTotalRepository = $cartTotalRepository;
Expand All @@ -85,6 +92,7 @@ public function __construct(
$this->urlBuilder = $urlBuilder;
$this->buyerParams = $buyerParams;
$this->store = $store;
$this->monduFileLogger = $monduFileLogger;
}

/**
Expand Down Expand Up @@ -129,6 +137,10 @@ public function request($_params = []): array
];
}
} catch (\Exception $e) {
$this->monduFileLogger->error('Error while creating an order', [
'message' => $e->getMessage(),
'trace' => $e->getTrace()
]);
return [
'error' => 1,
'body' => null,
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "mondu_gmbh/magento2-payment",
"description": "Mondu payment method for magento 2",
"type": "magento2-module",
"version": "2.3.0",
"version": "2.3.1",
"license": [
"MIT"
],
Expand Down
Loading