Skip to content

Commit 4367388

Browse files
Merge pull request #3 from nofrixion/PLU16-production-mode-fix
Plu16 production mode fix
2 parents fc5a581 + e165b31 commit 4367388

File tree

6 files changed

+30
-11
lines changed

6 files changed

+30
-11
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
vendor/
2+
.vscode/

Controller/Webhook/In.php

+5
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,19 @@ public function execute()
3838
$resultJson = $this->resultJsonFactory->create();
3939

4040
if ($paymentRequestId) {
41+
42+
$this->logger->info('Nofrixion_Payments: success callback for payment request ' . $paymentRequestId);
43+
4144
$paymentRequest = $this->nofrixionHelper->getPaymentRequest($paymentRequestId, $storeId);
4245
$order = $this->nofrixionHelper->processPayment($paymentRequest);
4346

4447
// Send order confirmation email on success.
48+
$this->logger->info('Nofrixion_Payments: Sending order email for order #: ' . $order->getIncrementId());
4549
$this->orderSender->send($order, true);
4650

4751
return $resultJson->setData(['order_id' => (int)$order->getId(), 'order_increment_id' => $order->getIncrementId(), 'order_state' => $order->getState(), 'order_status' => $order->getStatus()]);
4852
} else {
53+
$this->logger->error('Nofrixion_Payments: received success callback with missing payment request Id.');
4954
$resultJson->setStatusHeader(400);
5055
return $resultJson->setData(['error_msg' => 'Missing querystring parameter "id"']);
5156
}

Helper/Data.php

+13-8
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ public function getPaymentRequestClient(?int $storeId = null): PaymentRequest
6969

7070
public function isProductionMode(?int $storeId = null): bool
7171
{
72-
return $this->scopeConfig->isSetFlag('payment/nofrixion/is_production', ScopeInterface::SCOPE_STORE, $storeId);
72+
$paymentMode = $this->scopeConfig->getValue('payment/nofrixion/mode', ScopeInterface::SCOPE_STORE, $storeId);
73+
if ($paymentMode === '1') {
74+
return true;
75+
} else {
76+
return false;
77+
}
7378
}
7479

7580
public function getApiBaseUrl(): string
@@ -84,7 +89,7 @@ public function getApiBaseUrl(): string
8489

8590
public function createPaymentRequest(Order $order): array
8691
{
87-
$storeId = (int)$order->getStoreId();
92+
$storeId = (int) $order->getStoreId();
8893
$amount = $order->getTotalDue();
8994
$customerEmail = $order->getCustomerEmail();
9095
$currency = $order->getOrderCurrencyCode();
@@ -93,9 +98,9 @@ public function createPaymentRequest(Order $order): array
9398
$originUrl = $this->url->getBaseUrl(['_store' => $storeId]);
9499
$nofrixionOrderId = $this->encodeOrderId($order);
95100
$callbackUrl = $this->url->getUrl('nofrixion/redirect/returnAfterPayment', ['_store' => $storeId, '_secure' => true, 'nofrixion_order_id' => $nofrixionOrderId]);
96-
$amount = PreciseNumber::parseString((string)$amount);
101+
$amount = PreciseNumber::parseString((string) $amount);
97102
if ($order->getCustomerId()) {
98-
$customerId = (string)$order->getCustomerId();
103+
$customerId = (string) $order->getCustomerId();
99104
} else {
100105
$customerId = null;
101106
}
@@ -157,7 +162,7 @@ public function processPayment(array $paymentRequest): OrderInterface
157162

158163
if ($isPaid && $newStatus && $order->getTotalDue() > 0) {
159164

160-
if($newStatus !== $order->getStatus()) {
165+
if ($newStatus !== $order->getStatus()) {
161166
if ($createInvoice) {
162167
$msg = 'Customer paid ' . $paymentRequest['amount'] . ' ' . $paymentRequest['currency'] . ' using the NoFrixion payment request with ID ' . $paymentRequest['id'];
163168
} else {
@@ -216,11 +221,11 @@ public function refund(\Magento\Payment\Model\InfoInterface $payment, $amount)
216221
$paymentRequestId = $invoice->getTransactionId();
217222

218223
$order = $payment->getOrder();
219-
$storeId = (int)$order->getStoreId();
224+
$storeId = (int) $order->getStoreId();
220225

221226
$client = $this->getPaymentRequestClient($storeId);
222227
// Magento stores decimals with 4 places, so we do the same
223-
if ($amount === null || round((float)$amount, 4) === round((float)$creditmemo->getGrandTotal(), 4)) {
228+
if ($amount === null || round((float) $amount, 4) === round((float) $creditmemo->getGrandTotal(), 4)) {
224229
$client->voidAllPaymentsForPaymentRequest($paymentRequestId);
225230
} else {
226231
throw new \RuntimeException('Cannot void the payment request with ID ' . $paymentRequestId . ' because only full refunds are supported and not partial ones.');
@@ -261,4 +266,4 @@ private function fixOrderState(OrderInterface $order): void
261266
}
262267

263268

264-
}
269+
}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ It is recommended to use the `composer` PHP package manager for production magen
1414

1515
### Installation ###
1616

17-
- Install the NoFrixion payments module using composer by running the following commands:
17+
Install the NoFrixion payments module using composer by running the following commands:
1818

1919
```bash
2020
composer require nofrixion/magento2-payments-module

etc/module.xml

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
<?xml version="1.0" ?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
3-
<module name="Nofrixion_Payments" setup_version="1.0.3"/>
3+
<module name="Nofrixion_Payments" setup_version="1.0.3">
4+
<sequence>
5+
<module name="Magento_Sales"/>
6+
<module name="Magento_Payment"/>
7+
<module name="Magento_Checkout"/>
8+
<module name="Magento_Directory" />
9+
<module name="Magento_Config" />
10+
</sequence>
11+
</module>
412
</config>

view/frontend/web/template/payment/nofrixion.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<!-- BEGIN Nofrixion tooltip -->
99
<span id="spacer"></span>
1010
<span class="nofrixion-tooltip">
11-
<a href="#" class="tooltip-toggle" data-bind="text: 'What is ' + getTitle() + '?'"></a>
11+
<a href="javascript:void(0)" class="tooltip-toggle" data-bind="text: 'What is ' + getTitle() + '?'"></a>
1212
<span class="tooltip-content">
1313
<span style="display: inline-block; vertical-align: top; padding: 1em">
1414
<p>Pay by bank allows you to make a payment directly from your bank account without using a credit

0 commit comments

Comments
 (0)