Skip to content

Commit 6823a30

Browse files
committed
Making Adyen Payments compatible with Magento 2.4.8 version and PHP 8.1+
1 parent b5bfa49 commit 6823a30

31 files changed

Lines changed: 129 additions & 130 deletions

Controller/Return/Index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ protected function validateRedirectResponse(array $redirectResponse): bool
173173
/**
174174
* @throws LocalizedException
175175
*/
176-
private function getOrder(string $incrementId = null): Order
176+
private function getOrder(?string $incrementId = null): Order
177177
{
178178
if ($incrementId !== null) {
179179
$order = $this->orderFactory->create()->loadByIncrementId($incrementId);

Helper/Config.php

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -78,28 +78,28 @@ public function __construct(
7878
}
7979

8080
/**
81-
* @param $mode
82-
* @param mixed $storeId
81+
* @param string $mode
82+
* @param int|string|null $storeId
8383
* @return string
8484
*/
85-
public function getApiKey($mode, $storeId = null): string
85+
public function getApiKey(string $mode, int|string|null $storeId = null): string
8686
{
8787
$apiKey = $this->getConfigData('api_key_' . $mode, self::XML_ADYEN_ABSTRACT_PREFIX, $storeId);
8888

8989
return $this->encryptor->decrypt($apiKey);
9090
}
9191

9292
/**
93-
* @param $mode
94-
* @param $storeId
93+
* @param string $mode
94+
* @param int|string|null $storeId
9595
* @return string|null
9696
*/
97-
public function getClientKey($mode, $storeId = null): ?string
97+
public function getClientKey(string $mode, int|string|null $storeId = null): ?string
9898
{
9999
return $this->getConfigData('client_key_' . $mode, self::XML_ADYEN_ABSTRACT_PREFIX, $storeId);
100100
}
101101

102-
public function getIsPaymentMethodsActive($storeId = null): bool
102+
public function getIsPaymentMethodsActive(int|string|null $storeId = null): bool
103103
{
104104
return $this->getConfigData(
105105
self::XML_PAYMENT_METHODS_ACTIVE,
@@ -109,10 +109,10 @@ public function getIsPaymentMethodsActive($storeId = null): bool
109109
}
110110

111111
/**
112-
* @param int|null $storeId
112+
* @param int|string|null $storeId
113113
* @return string|null
114114
*/
115-
public function getMerchantAccount($storeId = null): ?string
115+
public function getMerchantAccount(int|string|null $storeId = null): ?string
116116
{
117117
return $this->getConfigData(
118118
self::XML_MERCHANT_ACCOUNT,
@@ -122,10 +122,10 @@ public function getMerchantAccount($storeId = null): ?string
122122
}
123123

124124
/**
125-
* @param $storeId
125+
* @param int|string|null $storeId
126126
* @return array|null
127127
*/
128-
public function getMotoMerchantAccounts($storeId = null): ?array
128+
public function getMotoMerchantAccounts(int|string|null $storeId = null): ?array
129129
{
130130
$serializedData = $this->getConfigData(
131131
self::XML_MOTO_MERCHANT_ACCOUNTS,
@@ -137,10 +137,10 @@ public function getMotoMerchantAccounts($storeId = null): ?array
137137
}
138138

139139
/**
140-
* @param $storeId
140+
* @param int|string|null $storeId
141141
* @return bool|mixed
142142
*/
143-
public function isMotoPaymentMethodEnabled($storeId = null): bool
143+
public function isMotoPaymentMethodEnabled(int|string|null $storeId = null): bool
144144
{
145145
return $this->getConfigData('active', Config::XML_ADYEN_MOTO, $storeId, true);
146146
}
@@ -149,11 +149,11 @@ public function isMotoPaymentMethodEnabled($storeId = null): bool
149149
* Returns the properties of a MOTO merchant account in an array (API Key, Client Key, Demo Mode)
150150
*
151151
* @param string $motoMerchantAccount
152-
* @param $storeId
152+
* @param int|string|null $storeId
153153
* @return array
154154
* @throws AdyenException
155155
*/
156-
public function getMotoMerchantAccountProperties(string $motoMerchantAccount, $storeId = null) : array
156+
public function getMotoMerchantAccountProperties(string $motoMerchantAccount, int|string|null $storeId = null) : array
157157
{
158158
$motoMerchantAccounts = $this->getMotoMerchantAccounts($storeId);
159159

@@ -165,10 +165,10 @@ public function getMotoMerchantAccountProperties(string $motoMerchantAccount, $s
165165
}
166166

167167
/**
168-
* @param int|null $storeId
168+
* @param int|string|null $storeId
169169
* @return string|null
170170
*/
171-
public function getNotificationsUsername($storeId = null): ?string
171+
public function getNotificationsUsername(int|string|null $storeId = null): ?string
172172
{
173173
return $this->getConfigData(
174174
self::XML_NOTIFICATIONS_USERNAME,
@@ -178,10 +178,10 @@ public function getNotificationsUsername($storeId = null): ?string
178178
}
179179

180180
/**
181-
* @param int|null $storeId
181+
* @param int|string|null $storeId
182182
* @return string|null
183183
*/
184-
public function getNotificationsPassword($storeId = null): ?string
184+
public function getNotificationsPassword(int|string|null $storeId = null): ?string
185185
{
186186
$key = $this->getConfigData(
187187
self::XML_NOTIFICATIONS_PASSWORD,
@@ -196,10 +196,10 @@ public function getNotificationsPassword($storeId = null): ?string
196196
}
197197

198198
/**
199-
* @param mixed $storeId
199+
* @param int|string|null $storeId
200200
* @return string|null
201201
*/
202-
public function getWebhookUrl($storeId = null): ?string
202+
public function getWebhookUrl(int|string|null $storeId = null): ?string
203203
{
204204
return $this->getConfigData(
205205
self::XML_WEBHOOK_URL,
@@ -208,18 +208,18 @@ public function getWebhookUrl($storeId = null): ?string
208208
);
209209
}
210210

211-
public function getWebhookId($storeId = null): ?string
211+
public function getWebhookId(int|string|null $storeId = null): ?string
212212
{
213213
return $this->getConfigData('webhook_id', self::XML_ADYEN_ABSTRACT_PREFIX, $storeId);
214214
}
215215

216216
/**
217217
* Retrieve flag for notifications_can_cancel
218218
*
219-
* @param mixed $storeId
219+
* @param int|null $storeId
220220
* @return bool
221221
*/
222-
public function getNotificationsCanCancel($storeId = null): bool
222+
public function getNotificationsCanCancel(int|string|null $storeId = null): bool
223223
{
224224
return (bool)$this->getConfigData(
225225
self::XML_NOTIFICATIONS_CAN_CANCEL_FIELD,
@@ -232,10 +232,10 @@ public function getNotificationsCanCancel($storeId = null): bool
232232
/**
233233
* Retrieve key for notifications_hmac_key
234234
*
235-
* @param mixed $storeId
235+
* @param int|string|null $storeId
236236
* @return string|null
237237
*/
238-
public function getNotificationsHmacKey($storeId = null): ?string
238+
public function getNotificationsHmacKey(int|string|null $storeId = null): ?string
239239
{
240240
if ($this->isDemoMode($storeId)) {
241241
$key = $this->getConfigData(
@@ -263,10 +263,10 @@ public function getNotificationsHmacKey($storeId = null): ?string
263263
/**
264264
* Retrieve flag for notifications_ip_check
265265
*
266-
* @param int $storeId
266+
* @param int|string|null $storeId
267267
* @return bool
268268
*/
269-
public function getNotificationsIpCheck(int $storeId = null): bool
269+
public function getNotificationsIpCheck(int|string|null $storeId = null): bool
270270
{
271271
return (bool) $this->getConfigData(
272272
self::XML_NOTIFICATIONS_IP_CHECK,
@@ -276,39 +276,39 @@ public function getNotificationsIpCheck(int $storeId = null): bool
276276
);
277277
}
278278

279-
public function isDemoMode($storeId = null): bool
279+
public function isDemoMode(int|string|null $storeId = null): bool
280280
{
281281
return $this->getConfigData('demo_mode', self::XML_ADYEN_ABSTRACT_PREFIX, $storeId, true);
282282
}
283283

284284
/**
285-
* @param $storeId
285+
* @param int|string|null $storeId
286286
* @return bool|mixed
287287
* @deprecated
288288
*/
289-
public function isAlternativePaymentMethodsEnabled($storeId = null): bool
289+
public function isAlternativePaymentMethodsEnabled(int|string|null $storeId = null): bool
290290
{
291291
return $this->getConfigData('active', Config::XML_ADYEN_HPP, $storeId, true);
292292
}
293293

294294
/**
295295
* Retrieve charged currency selection (base or display)
296296
*
297-
* @param null|int|string $storeId
297+
* @param int|string|null $storeId
298298
* @return mixed
299299
*/
300-
public function getChargedCurrency($storeId = null)
300+
public function getChargedCurrency(int|string|null $storeId = null)
301301
{
302302
return $this->getConfigData(self::XML_CHARGED_CURRENCY, self::XML_ADYEN_ABSTRACT_PREFIX, $storeId);
303303
}
304304

305305
/**
306306
* Retrieve has_holder_name config
307307
*
308-
* @param null|int|string $storeId
308+
* @param int|string|null $storeId
309309
* @return mixed
310310
*/
311-
public function getHasHolderName($storeId = null)
311+
public function getHasHolderName(int|string|null $storeId = null)
312312
{
313313
return $this->getConfigData(self::XML_HAS_HOLDER_NAME, self::XML_ADYEN_ABSTRACT_PREFIX, $storeId, true);
314314
}
@@ -319,7 +319,7 @@ public function getHasHolderName($storeId = null)
319319
* @param null|int|string $storeId
320320
* @return mixed
321321
*/
322-
public function getHouseNumberStreetLine($storeId = null)
322+
public function getHouseNumberStreetLine(int|string|null $storeId = null)
323323
{
324324
return $this->getConfigData(self::XML_HOUSE_NUMBER_STREET_LINE, self::XML_ADYEN_ABSTRACT_PREFIX, $storeId);
325325
}
@@ -330,7 +330,7 @@ public function getHouseNumberStreetLine($storeId = null)
330330
* @param null|int|string $storeId
331331
* @return mixed
332332
*/
333-
public function getHolderNameRequired($storeId = null)
333+
public function getHolderNameRequired(int|string|null $storeId = null)
334334
{
335335
return $this->getConfigData(self::XML_HOLDER_NAME_REQUIRED, self::XML_ADYEN_ABSTRACT_PREFIX, $storeId, true);
336336
}
@@ -464,7 +464,7 @@ public function getSupportMailAddress(int $storeId): ?string
464464
return $this->getConfigData('adyen_support_email_address', self::XML_ADYEN_ABSTRACT_PREFIX, $storeId);
465465
}
466466

467-
public function getAdyenPosCloudConfigData(string $field, int $storeId = null, bool $flag = false)
467+
public function getAdyenPosCloudConfigData(string $field, int|string|null $storeId = null, bool $flag = false)
468468
{
469469
return $this->getConfigData($field, self::XML_ADYEN_POS_CLOUD, $storeId, $flag);
470470
}
@@ -474,7 +474,7 @@ public function getAdyenPosCloudPaymentAction(int $storeId): string
474474
return $this->getAdyenPosCloudConfigData(self::XML_PAYMENT_ACTION, $storeId);
475475
}
476476

477-
public function useQueueProcessor($storeId = null): bool
477+
public function useQueueProcessor(int|string|null $storeId = null): bool
478478
{
479479
return $this->getConfigData(
480480
self::XML_WEBHOOK_NOTIFICATION_PROCESSOR,
@@ -492,12 +492,12 @@ public function getConfigurationMode(int $storeId): string
492492
);
493493
}
494494

495-
public function getAdyenAbstractConfigData(string $field, int $storeId = null): mixed
495+
public function getAdyenAbstractConfigData(string $field, int|string|null $storeId = null): mixed
496496
{
497497
return $this->getConfigData($field, 'adyen_abstract', $storeId);
498498
}
499499

500-
public function getLiveEndpointPrefix(int $storeId = null): ?string
500+
public function getLiveEndpointPrefix(int|string|null $storeId = null): ?string
501501
{
502502
$prefix = $this->getAdyenAbstractConfigData('live_endpoint_url_prefix', $storeId);
503503

@@ -508,37 +508,37 @@ public function getLiveEndpointPrefix(int $storeId = null): ?string
508508
return trim($prefix);
509509
}
510510

511-
public function getAdyenAbstractConfigDataFlag($field, $storeId = null): mixed
511+
public function getAdyenAbstractConfigDataFlag(string $field, int|string|null $storeId = null): mixed
512512
{
513513
return $this->getConfigData($field, 'adyen_abstract', $storeId, true);
514514
}
515515

516-
public function getAdyenCcConfigData($field, $storeId = null): mixed
516+
public function getAdyenCcConfigData(string $field, int|string|null $storeId = null): mixed
517517
{
518518
return $this->getConfigData($field, 'adyen_cc', $storeId);
519519
}
520520

521-
public function getAdyenHppConfigData($field, $storeId = null): mixed
521+
public function getAdyenHppConfigData(string $field, int|string|null $storeId = null): mixed
522522
{
523523
return $this->getConfigData($field, 'adyen_hpp', $storeId);
524524
}
525525

526-
public function getAdyenHppVaultConfigDataFlag($field, $storeId = null): mixed
526+
public function getAdyenHppVaultConfigDataFlag(string $field, int|string|null $storeId = null): mixed
527527
{
528528
return $this->getConfigData($field, 'adyen_hpp_vault', $storeId, true);
529529
}
530530

531-
public function isHppVaultEnabled($storeId = null): mixed
531+
public function isHppVaultEnabled(int|string|null $storeId = null): mixed
532532
{
533533
return $this->getAdyenHppVaultConfigDataFlag('active', $storeId);
534534
}
535535

536-
public function getAdyenOneclickConfigData($field, int $storeId = null): mixed
536+
public function getAdyenOneclickConfigData(string $field, int|string|null $storeId = null): mixed
537537
{
538538
return $this->getConfigData($field, 'adyen_oneclick', $storeId);
539539
}
540540

541-
public function getAdyenOneclickConfigDataFlag($field, int $storeId = null): bool
541+
public function getAdyenOneclickConfigDataFlag(string $field, int|string|null $storeId = null): bool
542542
{
543543
return $this->getConfigData($field, 'adyen_oneclick', $storeId, true);
544544
}
@@ -548,12 +548,12 @@ public function isPerStoreBillingAgreement(int $storeId): bool //Only use of Fla
548548
return !$this->getAdyenOneclickConfigDataFlag('share_billing_agreement', $storeId);
549549
}
550550

551-
public function getAdyenBoletoConfigData(string $field, int $storeId = null): mixed
551+
public function getAdyenBoletoConfigData(string $field, int|string|null $storeId = null): mixed
552552
{
553553
return $this->getConfigData($field, 'adyen_boleto', $storeId);
554554
}
555555

556-
public function getCheckoutFrontendRegion(int $storeId = null): ?string
556+
public function getCheckoutFrontendRegion(int|string|null $storeId = null): ?string
557557
{
558558
$checkoutFrontendRegion = $this->getAdyenAbstractConfigData('checkout_frontend_region', $storeId);
559559

@@ -564,12 +564,12 @@ public function getCheckoutFrontendRegion(int $storeId = null): ?string
564564
return trim($checkoutFrontendRegion);
565565
}
566566

567-
public function getRatePayId(int $storeId = null)
567+
public function getRatePayId(int|string|null $storeId = null)
568568
{
569569
return $this->getConfigData("ratepay_id", self::XML_ADYEN_RATEPAY, $storeId);
570570
}
571571

572-
public function getAllowMultistoreTokens(int $storeId = null): ?bool
572+
public function getAllowMultistoreTokens(int|string|null $storeId = null): ?bool
573573
{
574574
return $this->getConfigData(
575575
self::XML_ALLOW_MULTISTORE_TOKENS,
@@ -582,10 +582,10 @@ public function getAllowMultistoreTokens(int $storeId = null): ?bool
582582
/**
583583
* Returns the preferred ThreeDS authentication type for card and card vault payments.
584584
*
585-
* @param int|null $storeId
585+
* @param int|string|null $storeId
586586
* @return string
587587
*/
588-
public function getThreeDSFlow(int $storeId = null): string
588+
public function getThreeDSFlow(int|string|null $storeId = null): string
589589
{
590590
return $this->getConfigData(
591591
self::XML_THREEDS_FLOW,
@@ -629,7 +629,7 @@ public function getProcessedWebhookRemovalTime(): int
629629
);
630630
}
631631

632-
public function getIsCvcRequiredForRecurringCardPayments(int $storeId = null): bool
632+
public function getIsCvcRequiredForRecurringCardPayments(int|string|null $storeId = null): bool
633633
{
634634
return (bool) $this->getConfigData(
635635
'require_cvc',
@@ -639,7 +639,7 @@ public function getIsCvcRequiredForRecurringCardPayments(int $storeId = null): b
639639
);
640640
}
641641

642-
public function getConfigData(string $field, string $xmlPrefix, ?int $storeId, bool $flag = false): mixed
642+
public function getConfigData(string $field, string $xmlPrefix, int|string|null $storeId, bool $flag = false): mixed
643643
{
644644
$path = implode("/", [self::XML_PAYMENT_PREFIX, $xmlPrefix, $field]);
645645

Helper/ConnectedTerminals.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct(
3131
$this->adyenLogger = $adyenLogger;
3232
}
3333

34-
public function getConnectedTerminals(int $storeId = null): array
34+
public function getConnectedTerminals(?int $storeId = null): array
3535
{
3636
if (!isset($storeId)) {
3737
$storeId = $this->session->getQuote()->getStoreId();

0 commit comments

Comments
 (0)