@@ -69,7 +69,12 @@ public function getPaymentRequestClient(?int $storeId = null): PaymentRequest
69
69
70
70
public function isProductionMode (?int $ storeId = null ): bool
71
71
{
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
+ }
73
78
}
74
79
75
80
public function getApiBaseUrl (): string
@@ -84,7 +89,7 @@ public function getApiBaseUrl(): string
84
89
85
90
public function createPaymentRequest (Order $ order ): array
86
91
{
87
- $ storeId = (int )$ order ->getStoreId ();
92
+ $ storeId = (int ) $ order ->getStoreId ();
88
93
$ amount = $ order ->getTotalDue ();
89
94
$ customerEmail = $ order ->getCustomerEmail ();
90
95
$ currency = $ order ->getOrderCurrencyCode ();
@@ -93,9 +98,9 @@ public function createPaymentRequest(Order $order): array
93
98
$ originUrl = $ this ->url ->getBaseUrl (['_store ' => $ storeId ]);
94
99
$ nofrixionOrderId = $ this ->encodeOrderId ($ order );
95
100
$ 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 );
97
102
if ($ order ->getCustomerId ()) {
98
- $ customerId = (string )$ order ->getCustomerId ();
103
+ $ customerId = (string ) $ order ->getCustomerId ();
99
104
} else {
100
105
$ customerId = null ;
101
106
}
@@ -157,7 +162,7 @@ public function processPayment(array $paymentRequest): OrderInterface
157
162
158
163
if ($ isPaid && $ newStatus && $ order ->getTotalDue () > 0 ) {
159
164
160
- if ($ newStatus !== $ order ->getStatus ()) {
165
+ if ($ newStatus !== $ order ->getStatus ()) {
161
166
if ($ createInvoice ) {
162
167
$ msg = 'Customer paid ' . $ paymentRequest ['amount ' ] . ' ' . $ paymentRequest ['currency ' ] . ' using the NoFrixion payment request with ID ' . $ paymentRequest ['id ' ];
163
168
} else {
@@ -216,11 +221,11 @@ public function refund(\Magento\Payment\Model\InfoInterface $payment, $amount)
216
221
$ paymentRequestId = $ invoice ->getTransactionId ();
217
222
218
223
$ order = $ payment ->getOrder ();
219
- $ storeId = (int )$ order ->getStoreId ();
224
+ $ storeId = (int ) $ order ->getStoreId ();
220
225
221
226
$ client = $ this ->getPaymentRequestClient ($ storeId );
222
227
// 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 )) {
224
229
$ client ->voidAllPaymentsForPaymentRequest ($ paymentRequestId );
225
230
} else {
226
231
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
261
266
}
262
267
263
268
264
- }
269
+ }
0 commit comments