Skip to content

Commit

Permalink
Release 1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Emil Leszczak committed Feb 24, 2022
1 parent 1406d04 commit 7feff14
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 21 deletions.
5 changes: 4 additions & 1 deletion Controller/Payment/Notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ public function execute()
);
$this->getResponse()->setHttpResponseCode(400);
} catch (OrderHasBeenAlreadyPaidException $exception) {
$this->logger->info($exception->getMessage() . ' Skip processing the notification.');
$this->logger->info(
$exception->getMessage() . ' Skip processing the notification.',
$notificationData
);
$this->getResponse()->setHttpResponseCode(200);
}
}
Expand Down
6 changes: 4 additions & 2 deletions Gateway/Http/Client/PaymentAuthorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ public function placeRequest(TransferInterface $transferObject)
];
} catch (PaynowException $exception) {
$this->logger->error(
$exception->getMessage(),
'An error occurred during payment authorization',
array_merge($loggerContext, [
'service' => 'Payment',
'action' => 'authorize'
'action' => 'authorize',
'message' => $exception->getMessage(),
'errors' => $exception->getPrevious()->getErrors()
])
);
foreach ($exception->getErrors() as $error) {
Expand Down
19 changes: 12 additions & 7 deletions Gateway/Http/Client/PaymentCapture.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,18 @@ public function placeRequest(TransferInterface $transferObject)
);
} catch (PaynowException $exception) {
$response['errors'] = $exception->getMessage();
$this->logger->error($exception->getMessage(), array_merge(
$loggerContext,
[
'service' => 'Payment',
'action' => 'status'
]
));
$this->logger->error(
'An error occurred during payment authorization',
array_merge(
$loggerContext,
[
'service' => 'Payment',
'action' => 'status',
'message' => $exception->getMessage(),
'errors' => $exception->getPrevious()->getErrors()
]
)
);
}

return $response;
Expand Down
9 changes: 5 additions & 4 deletions Gateway/Http/Client/PaymentRefund.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ public function placeRequest(TransferInterface $transferObject)
])
);
try {
$service = new Refund($this->client);
$apiResponseObject = $service->create(
$apiResponseObject = (new Refund($this->client))->create(
$data[PaymentField::PAYMENT_ID_FIELD_NAME],
$transferObject->getHeaders()[PaymentField::IDEMPOTENCY_KEY_FIELD_NAME],
$data[RefundField::AMOUNT_FIELD_NAME]
Expand All @@ -78,10 +77,12 @@ public function placeRequest(TransferInterface $transferObject)
];
} catch (PaynowException $exception) {
$this->logger->error(
$exception->getMessage(),
'An error occurred during refund create',
array_merge($loggerContext, [
'service' => 'Refund',
'action' => 'create'
'action' => 'create',
'message' => $exception->getMessage(),
'errors' => $exception->getPrevious()->getErrors()
])
);
foreach ($exception->getErrors() as $error) {
Expand Down
12 changes: 8 additions & 4 deletions Helper/NotificationProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@ public function process($paymentId, $status, $externalId)

$this->logger->debug(
"Current order state",
array_merge($this->loggerContext, [
'currentStatus' => $orderPaymentStatus
])
array_merge(
[
'currentStatus' => $orderPaymentStatus
],
$this->loggerContext
)
);

if ($finalPaymentStatus) {
Expand Down Expand Up @@ -212,7 +215,7 @@ private function paymentRejected()
$this->order->addCommentToStatusHistory($message);
}

$this->order->getPayment()->setIsClosed(true);
$this->order->getPayment()->setIsClosed(true);
}

/**
Expand Down Expand Up @@ -250,6 +253,7 @@ private function isCorrectStatus($previousStatus, $nextStatus): bool
{
$paymentStatusFlow = [
Status::STATUS_NEW => [
Status::STATUS_NEW,
Status::STATUS_PENDING,
Status::STATUS_ERROR,
Status::STATUS_EXPIRED,
Expand Down
2 changes: 1 addition & 1 deletion Model/Exception/OrderHasBeenAlreadyPaidException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
class OrderHasBeenAlreadyPaidException extends Exception
{
const EXCEPTION_MESSAGE = 'Order %s has been already paid in %s.';
const EXCEPTION_MESSAGE = 'An order %s has been already paid in %s.';

public function __construct($orderId, $paymentId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function testHandle()
PaymentField::PAYMENT_ID_FIELD_NAME => 'testPaymentId',
PaymentField::STATUS_FIELD_NAME => 'NEW',
PaymentField::REDIRECT_URL_FIELD_NAME => 'testRedirectUrl',
PaymentField::EXTERNAL_ID_FIELD_NAME => 'testExternalId',
];

$paymentDO->expects(static::atLeastOnce())
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": "pay-now/paynow-magento2",
"description": "Module for Paynow payments",
"type": "magento2-module",
"version": "1.1.1",
"version": "1.1.2",
"license": "MIT",
"keywords": [
"paynow",
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Paynow_PaymentGateway" setup_version="1.1.1">
<module name="Paynow_PaymentGateway" setup_version="1.1.2">
<sequence>
<module name="Magento_Sales"/>
<module name="Magento_Payment"/>
Expand Down

0 comments on commit 7feff14

Please sign in to comment.