-
Notifications
You must be signed in to change notification settings - Fork 220
Expand file tree
/
Copy pathConfig.php
More file actions
800 lines (719 loc) · 23.7 KB
/
Copy pathConfig.php
File metadata and controls
800 lines (719 loc) · 23.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
<?php
/**
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2022 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Helper;
use Adyen\AdyenException;
use Adyen\Payment\Model\Config\Source\NotificationProcessor;
use DateTimeInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;
use Magento\Framework\Encryption\EncryptorInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Framework\Serialize\SerializerInterface;
class Config
{
const XML_PAYMENT_PREFIX = "payment";
const XML_ADYEN_ABSTRACT_PREFIX = "adyen_abstract";
const XML_ADYEN_GIVING_PREFIX = "adyen_giving";
const XML_MERCHANT_ACCOUNT = "merchant_account";
const XML_PAYMENT_METHODS_ACTIVE= "payment_methods_active";
const XML_NOTIFICATIONS_USERNAME = "notification_username";
const XML_NOTIFICATIONS_PASSWORD = "notification_password";
const XML_WEBHOOK_URL = "webhook_url";
const XML_NOTIFICATIONS_CAN_CANCEL_FIELD = "notifications_can_cancel";
const XML_NOTIFICATIONS_HMAC_KEY_LIVE = "notification_hmac_key_live";
const XML_NOTIFICATIONS_HMAC_KEY_TEST = "notification_hmac_key_test";
const XML_NOTIFICATIONS_IP_CHECK = "notifications_ip_check";
const XML_CHARGED_CURRENCY = "charged_currency";
const XML_HAS_HOLDER_NAME = "has_holder_name";
const XML_HOLDER_NAME_REQUIRED = "holder_name_required";
const XML_HOUSE_NUMBER_STREET_LINE = "house_number_street_line";
const XML_ADYEN_ONECLICK = 'adyen_oneclick';
const XML_ADYEN_HPP = 'adyen_hpp';
const XML_ADYEN_CC = 'adyen_cc';
const XML_ADYEN_HPP_VAULT = 'adyen_hpp_vault';
const XML_ADYEN_CC_VAULT = 'adyen_cc_vault';
const XML_ADYEN_MOTO = 'adyen_moto';
const XML_ADYEN_RATEPAY = 'adyen_ratepay';
const XML_PAYMENT_ORIGIN_URL = 'payment_origin_url';
const XML_PAYMENT_RETURN_URL = 'payment_return_url';
const XML_STATUS_FRAUD_MANUAL_REVIEW = 'fraud_manual_review_status';
const XML_STATUS_FRAUD_MANUAL_REVIEW_ACCEPT = 'fraud_manual_review_accept_status';
const XML_MOTO_MERCHANT_ACCOUNTS = 'moto_merchant_accounts';
const XML_CONFIGURATION_MODE = 'configuration_mode';
const XML_ADYEN_POS_CLOUD = 'adyen_pos_cloud';
const XML_PAYMENT_ACTION = 'payment_action';
const XML_WEBHOOK_NOTIFICATION_PROCESSOR = 'webhook_notification_processor';
const AUTO_CAPTURE_OPENINVOICE = 'auto';
const XML_CAPTURE_MODE = 'capture_mode';
const XML_RECURRING_CONFIGURATION = 'recurring_configuration';
const XML_ALLOW_MULTISTORE_TOKENS = 'allow_multistore_tokens';
const XML_THREEDS_FLOW = 'threeds_flow';
const XML_REMOVE_PROCESSED_WEBHOOKS = 'remove_processed_webhooks';
const XML_PROCESSED_WEBHOOK_REMOVAL_TIME = 'processed_webhook_removal_time';
const XML_PLATFORM_INTEGRATOR = 'platform_integrator';
const XML_HAS_PLATFORM_INTEGRATOR = 'has_platform_integrator';
const XML_OUTSIDE_CHECKOUT_DATA_COLLECTION = 'outside_checkout_data_collection';
const XML_RELIABILITY_DATA_COLLECTION = 'reliability_data_collection';
const XML_IGNORE_EXPIRE_WEBHOOK = 'ignore_expire_webhook';
const XML_ADYEN_ANALYTICS_PREFIX = "adyen_analytics";
const XML_INSTALLATION_TIME = 'installation_time';
const XML_PAYMENT_METHOD_TITLE_OVERRIDES = 'payment_method_title_overrides';
/**
* @param ScopeConfigInterface $scopeConfig
* @param EncryptorInterface $encryptor
* @param WriterInterface $configWriter
* @param SerializerInterface $serializer
*/
public function __construct(
protected readonly ScopeConfigInterface $scopeConfig,
private readonly EncryptorInterface $encryptor,
private readonly WriterInterface $configWriter,
private readonly SerializerInterface $serializer
) { }
/**
* @param string $mode
* @param mixed $storeId
* @return string
*/
public function getApiKey(string $mode, $storeId = null): string
{
$apiKey = $this->getConfigData('api_key_' . $mode, self::XML_ADYEN_ABSTRACT_PREFIX, $storeId);
return $this->encryptor->decrypt($apiKey);
}
/**
* @param string $mode
* @param null $storeId
* @return string|null
*/
public function getClientKey(string $mode, $storeId = null): ?string
{
return $this->getConfigData('client_key_' . $mode, self::XML_ADYEN_ABSTRACT_PREFIX, $storeId);
}
/**
* @param int|null $storeId
* @return bool
*/
public function getIsPaymentMethodsActive(?int $storeId = null): bool
{
return $this->getConfigData(
self::XML_PAYMENT_METHODS_ACTIVE,
self::XML_ADYEN_ABSTRACT_PREFIX,
$storeId
) === '1';
}
/**
* @param int|null $storeId
* @return string|null
*/
public function getMerchantAccount(?int $storeId = null): ?string
{
return $this->getConfigData(
self::XML_MERCHANT_ACCOUNT,
self::XML_ADYEN_ABSTRACT_PREFIX,
$storeId
);
}
/**
* @param int|null $storeId
* @return array|null
*/
public function getMotoMerchantAccounts(?int $storeId = null): ?array
{
$serializedData = $this->getConfigData(
self::XML_MOTO_MERCHANT_ACCOUNTS,
self::XML_ADYEN_MOTO,
$storeId
);
return $this->serializer->unserialize($serializedData);
}
/**
* @param int|null $storeId
* @return bool
*/
public function isMotoPaymentMethodEnabled(?int $storeId = null): bool
{
return $this->getConfigData('active', Config::XML_ADYEN_MOTO, $storeId, true);
}
/**
* Returns the properties of a MOTO merchant account in an array (API Key, Client Key, Demo Mode)
*
* @param string $motoMerchantAccount
* @param int|null $storeId
* @return array
* @throws AdyenException
*/
public function getMotoMerchantAccountProperties(string $motoMerchantAccount, ?int $storeId = null) : array
{
$motoMerchantAccounts = $this->getMotoMerchantAccounts($storeId);
if (!isset($motoMerchantAccounts[$motoMerchantAccount])) {
throw new AdyenException("Related MOTO merchant account couldn't be found.");
}
return $motoMerchantAccounts[$motoMerchantAccount];
}
/**
* @param int|null $storeId
* @return string|null
*/
public function getNotificationsUsername(?int $storeId = null): ?string
{
return $this->getConfigData(
self::XML_NOTIFICATIONS_USERNAME,
self::XML_ADYEN_ABSTRACT_PREFIX,
$storeId
);
}
/**
* @param int|null $storeId
* @return string|null
*/
public function getNotificationsPassword(?int $storeId = null): ?string
{
$key = $this->getConfigData(
self::XML_NOTIFICATIONS_PASSWORD,
self::XML_ADYEN_ABSTRACT_PREFIX,
$storeId
);
if (is_null($key)) {
return null;
}
return $this->encryptor->decrypt(trim((string) $key));
}
/**
* @param int|null $storeId
* @return string|null
*/
public function getWebhookUrl(?int $storeId = null): ?string
{
return $this->getConfigData(
self::XML_WEBHOOK_URL,
self::XML_ADYEN_ABSTRACT_PREFIX,
$storeId
);
}
/**
* @param int|null $storeId
* @return string|null
*/
public function getWebhookId(?int $storeId = null): ?string
{
return $this->getConfigData('webhook_id', self::XML_ADYEN_ABSTRACT_PREFIX, $storeId);
}
/**
* Retrieve flag for notifications_can_cancel
*
* @param int|null $storeId
* @return bool
*/
public function getNotificationsCanCancel(?int $storeId = null): bool
{
return (bool)$this->getConfigData(
self::XML_NOTIFICATIONS_CAN_CANCEL_FIELD,
self::XML_ADYEN_ABSTRACT_PREFIX,
$storeId,
true
);
}
/**
* Retrieve key for notifications_hmac_key
*
* @param int|null $storeId
* @return string|null
*/
public function getNotificationsHmacKey(?int $storeId = null): ?string
{
if ($this->isDemoMode($storeId)) {
$key = $this->getConfigData(
self::XML_NOTIFICATIONS_HMAC_KEY_TEST,
self::XML_ADYEN_ABSTRACT_PREFIX,
$storeId,
false
);
} else {
$key = $this->getConfigData(
self::XML_NOTIFICATIONS_HMAC_KEY_LIVE,
self::XML_ADYEN_ABSTRACT_PREFIX,
$storeId,
false
);
}
if (is_null($key)) {
return null;
}
return $this->encryptor->decrypt(trim((string) $key));
}
/**
* Retrieve flag for notifications_ip_check
*
* TODO:: `storeId` field should be removed. This field must be configured only on the default level (ECP-9838).
*
* @param int|null $storeId
* @return bool
*/
public function getNotificationsIpCheck(?int $storeId = null): bool
{
return (bool) $this->getConfigData(
self::XML_NOTIFICATIONS_IP_CHECK,
self::XML_ADYEN_ABSTRACT_PREFIX,
$storeId,
true
);
}
/**
* @param int|null $storeId
* @return bool
*/
public function isDemoMode(?int $storeId = null): bool
{
return $this->getConfigData('demo_mode', self::XML_ADYEN_ABSTRACT_PREFIX, $storeId, true);
}
/**
* Retrieve charged currency selection (base or display)
*
* @param int|null $storeId
* @return mixed
*/
public function getChargedCurrency(?int $storeId = null)
{
return $this->getConfigData(self::XML_CHARGED_CURRENCY, self::XML_ADYEN_ABSTRACT_PREFIX, $storeId);
}
/**
* Retrieve has_holder_name config
*
* @param int|null $storeId
* @return mixed
*/
public function getHasHolderName(?int $storeId = null)
{
return $this->getConfigData(self::XML_HAS_HOLDER_NAME, self::XML_ADYEN_ABSTRACT_PREFIX, $storeId, true);
}
/**
* Retrieve house_number_street_line config
*
* @param int|null $storeId
* @return mixed
*/
public function getHouseNumberStreetLine(?int $storeId = null)
{
return $this->getConfigData(self::XML_HOUSE_NUMBER_STREET_LINE, self::XML_ADYEN_ABSTRACT_PREFIX, $storeId);
}
/**
* Retrieve holder_name_required config
*
* @param int|null $storeId
* @return mixed
*/
public function getHolderNameRequired(?int $storeId = null)
{
return $this->getConfigData(self::XML_HOLDER_NAME_REQUIRED, self::XML_ADYEN_ABSTRACT_PREFIX, $storeId, true);
}
/**
* Retrieve payment_origin_url config
*
* @param int|null $storeId
* @return mixed
*/
public function getPWAOriginUrl(?int $storeId = null)
{
return $this->getConfigData(self::XML_PAYMENT_ORIGIN_URL, self::XML_ADYEN_ABSTRACT_PREFIX, $storeId);
}
/**
* @param int|null $storeId
* @return mixed
*/
public function adyenGivingEnabled(?int $storeId = null)
{
return $this->getConfigData('active', self::XML_ADYEN_GIVING_PREFIX, $storeId);
}
/**
* Retrieve payment_return_url config
*
* @param int $storeId
* @return mixed
*/
public function getPWAReturnUrl(int $storeId)
{
return $this->getConfigData(self::XML_PAYMENT_RETURN_URL, self::XML_ADYEN_ABSTRACT_PREFIX, $storeId);
}
/**
* Retrieve the passed fraud status config
*
* @param string $fraudStatus
* @param int $storeId
* @return mixed
*/
public function getFraudStatus(string $fraudStatus, int $storeId)
{
return $this->getConfigData(
$fraudStatus,
Config::XML_ADYEN_ABSTRACT_PREFIX,
$storeId
);
}
/**
* Determine whether or not to send additional riskdata properties in /payments and /authorize requests
* @param int $storeId
* @return bool
*/
public function sendAdditionalRiskData(int $storeId): bool
{
return $this->getConfigData('send_additional_risk_data', self::XML_ADYEN_ABSTRACT_PREFIX, $storeId, true);
}
/**
* @param int $storeId
* @return bool
*/
public function sendLevel23AdditionalData(int $storeId): bool
{
return $this->getConfigData('send_level23_data', self::XML_ADYEN_ABSTRACT_PREFIX, $storeId, true);
}
/**
* @param int $storeId
* @return bool|null
*/
public function isClickToPayEnabled(int $storeId): ?bool
{
return $this->getConfigData('enable_click_to_pay', self::XML_ADYEN_CC, $storeId);
}
/**
* @param int $storeId
* @return bool
*/
public function debugLogsEnabled(int $storeId): bool
{
return $this->getConfigData('debug', self::XML_ADYEN_ABSTRACT_PREFIX, $storeId, true);
}
/**
* @param int $storeId
* @return bool
*/
public function getAutoCaptureOpenInvoice(int $storeId): bool
{
$captureForOpenInvoice = $this->getConfigData(
'capture_for_openinvoice',
self::XML_ADYEN_ABSTRACT_PREFIX,
$storeId
);
return $captureForOpenInvoice === self::AUTO_CAPTURE_OPENINVOICE;
}
public function getSupportMailAddress(int $storeId): ?string
{
return $this->getConfigData('adyen_support_email_address', self::XML_ADYEN_ABSTRACT_PREFIX, $storeId);
}
public function getAdyenPosCloudConfigData(string $field, ?int $storeId = null, bool $flag = false)
{
return $this->getConfigData($field, self::XML_ADYEN_POS_CLOUD, $storeId, $flag);
}
public function getAdyenPosCloudPaymentAction(int $storeId): string
{
return $this->getAdyenPosCloudConfigData(self::XML_PAYMENT_ACTION, $storeId);
}
public function useQueueProcessor(?int $storeId = null): bool
{
return $this->getConfigData(
self::XML_WEBHOOK_NOTIFICATION_PROCESSOR,
self::XML_ADYEN_ABSTRACT_PREFIX,
$storeId
) === NotificationProcessor::QUEUE;
}
public function getConfigurationMode(int $storeId): string
{
return $this->getConfigData(
self::XML_CONFIGURATION_MODE,
self::XML_ADYEN_ABSTRACT_PREFIX,
$storeId
);
}
public function getAdyenAbstractConfigData(string $field, ?int $storeId = null): mixed
{
return $this->getConfigData($field, 'adyen_abstract', $storeId);
}
public function getLiveEndpointPrefix(?int $storeId = null): ?string
{
$prefix = $this->getAdyenAbstractConfigData('live_endpoint_url_prefix', $storeId);
if (is_null($prefix)) {
return null;
}
return trim($prefix);
}
public function getAdyenAbstractConfigDataFlag(string $field, ?int $storeId = null): mixed
{
return $this->getConfigData($field, 'adyen_abstract', $storeId, true);
}
public function getAdyenCcConfigData(string $field, ?int $storeId = null): mixed
{
return $this->getConfigData($field, 'adyen_cc', $storeId);
}
public function getAdyenHppConfigData(string $field, ?int $storeId = null): mixed
{
return $this->getConfigData($field, 'adyen_hpp', $storeId);
}
public function getAdyenHppVaultConfigDataFlag(string $field, ?int $storeId = null): mixed
{
return $this->getConfigData($field, 'adyen_hpp_vault', $storeId, true);
}
public function isHppVaultEnabled(?int $storeId = null): mixed
{
return $this->getAdyenHppVaultConfigDataFlag('active', $storeId);
}
public function getAdyenOneclickConfigData(string $field, ?int $storeId = null): mixed
{
return $this->getConfigData($field, 'adyen_oneclick', $storeId);
}
public function getAdyenOneclickConfigDataFlag(string $field, ?int $storeId = null): bool
{
return $this->getConfigData($field, 'adyen_oneclick', $storeId, true);
}
public function isPerStoreBillingAgreement(?int $storeId): bool //Only use of Flag above
{
return !$this->getAdyenOneclickConfigDataFlag('share_billing_agreement', $storeId);
}
public function getAdyenBoletoConfigData(string $field, ?int $storeId = null): mixed
{
return $this->getConfigData($field, 'adyen_boleto', $storeId);
}
public function getCheckoutFrontendRegion(?int $storeId = null): ?string
{
$checkoutFrontendRegion = $this->getAdyenAbstractConfigData('checkout_frontend_region', $storeId);
if (is_null($checkoutFrontendRegion)) {
return null;
}
return trim($checkoutFrontendRegion);
}
public function getRatePayId(?int $storeId = null)
{
return $this->getConfigData("ratepay_id", self::XML_ADYEN_RATEPAY, $storeId);
}
public function getAllowMultistoreTokens(?int $storeId = null): ?bool
{
return $this->getConfigData(
self::XML_ALLOW_MULTISTORE_TOKENS,
self::XML_ADYEN_ABSTRACT_PREFIX,
$storeId,
true
);
}
/**
* Returns the preferred ThreeDS authentication type for card and card vault payments.
*
* @param int|null $storeId
* @return string
*/
public function getThreeDSFlow(?int $storeId = null): string
{
return $this->getConfigData(
self::XML_THREEDS_FLOW,
self::XML_ADYEN_CC,
$storeId
);
}
/**
* Indicates whether if the processed webhook removal cronjob is enabled or not.
*
* This field can only be configured on default scope level as
* the notification table doesn't have nay relation with the stores.
*
* @return bool
*/
public function getIsProcessedWebhookRemovalEnabled(): bool
{
return $this->getConfigData(
self::XML_REMOVE_PROCESSED_WEBHOOKS,
self::XML_ADYEN_ABSTRACT_PREFIX,
null,
true
);
}
/**
* Returns the configured amount of days a webhook has to be older than in order to be removed.
*
* This field can only be configured on default scope level as
* the notification table doesn't have any relation with the stores.
*
* @return int
*/
public function getProcessedWebhookRemovalTime(): int
{
return (int) $this->getConfigData(
self::XML_PROCESSED_WEBHOOK_REMOVAL_TIME,
self::XML_ADYEN_ABSTRACT_PREFIX,
null
);
}
public function getIsCvcRequiredForRecurringCardPayments(?int $storeId = null): bool
{
return (bool) $this->getConfigData(
'require_cvc',
Config::XML_ADYEN_CC_VAULT,
$storeId,
true
);
}
/**
* Returns true if the store is managed by a system integrator
*
* @return bool
*/
public function getHasPlatformIntegrator(): bool
{
return $this->getConfigData(
Config::XML_HAS_PLATFORM_INTEGRATOR,
Config::XML_ADYEN_ABSTRACT_PREFIX,
null,
true
);
}
/**
* Returns the name of the platform integrator
*
* @return string|null
*/
public function getPlatformIntegratorName(): ?string
{
return $this->getConfigData(
Config::XML_PLATFORM_INTEGRATOR,
Config::XML_ADYEN_ABSTRACT_PREFIX,
null
);
}
/**
* @param int|null $storeId
* @return bool
*/
public function isOutsideCheckoutDataCollectionEnabled(?int $storeId = null): bool
{
return $this->getConfigData(
self::XML_OUTSIDE_CHECKOUT_DATA_COLLECTION,
Config::XML_ADYEN_ABSTRACT_PREFIX,
$storeId,
true
);
}
/**
* Returns true if the reliability data collection is enabled
*
* @param int|null $storeId
* @return bool
*/
public function isReliabilityDataCollectionEnabled(?int $storeId = null): bool
{
return $this->getConfigData(
Config::XML_RELIABILITY_DATA_COLLECTION,
Config::XML_ADYEN_ABSTRACT_PREFIX,
$storeId,
true
);
}
/**
* @param int|null $storeId
* @return bool
*/
public function isExpireWebhookIgnored(?int $storeId = null): bool
{
return $this->getConfigData(
self::XML_IGNORE_EXPIRE_WEBHOOK,
Config::XML_ADYEN_ABSTRACT_PREFIX,
$storeId,
true
);
}
/**
* @param int|null $storeId
* @return string|null
*/
public function getCaptureMode(?int $storeId = null): ?string
{
return $this->getConfigData(self::XML_CAPTURE_MODE, Config::XML_ADYEN_ABSTRACT_PREFIX, $storeId);
}
/**
* @return string|null
*/
public function getInstallationTime(): ?string
{
return $this->getConfigData(
self::XML_INSTALLATION_TIME,
Config::XML_ADYEN_ANALYTICS_PREFIX,
null
);
}
/**
* @param DateTimeInterface $pluginInstallationTime
* @return void
*/
public function setInstallationTime(DateTimeInterface $pluginInstallationTime): void
{
$this->setConfigData(
$pluginInstallationTime->format(DateTimeInterface::ISO8601_EXPANDED),
self::XML_INSTALLATION_TIME,
self::XML_ADYEN_ANALYTICS_PREFIX
);
}
/**
* Returns the payment method title overrides configured by the merchant as a map of
* `[txVariant => customTitle]`. Returns an empty array when no overrides are configured
* or when the stored value cannot be decoded.
*
* @param int|null $storeId
* @return array<string, string>
*/
public function getPaymentMethodTitleOverrides(?int $storeId = null): array
{
$serialized = $this->getConfigData(
self::XML_PAYMENT_METHOD_TITLE_OVERRIDES,
self::XML_ADYEN_ABSTRACT_PREFIX,
$storeId
);
if (empty($serialized)) {
return [];
}
try {
$result = $this->serializer->unserialize($serialized);
return is_array($result) ? $result : [];
} catch (\InvalidArgumentException $e) {
return [];
}
}
public function getConfigData(string $field, string $xmlPrefix, ?int $storeId, bool $flag = false): mixed
{
$path = implode("/", [self::XML_PAYMENT_PREFIX, $xmlPrefix, $field]);
if (!$flag) {
return $this->scopeConfig->getValue($path, ScopeInterface::SCOPE_STORE, $storeId);
} else {
return $this->scopeConfig->isSetFlag($path, ScopeInterface::SCOPE_STORE, $storeId);
}
}
public function setConfigData(
$value,
string $field,
string $xmlPrefix,
string $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
int $scopeId = 0
): void {
$path = implode("/", [self::XML_PAYMENT_PREFIX, $xmlPrefix, $field]);
$this->configWriter->save($path, $value, $scope, $scopeId);
}
/**
* Deletes config data
* @param string $field
* @param string $xmlPrefix
* @param string $scope
* @param int $scopeId
* @return void
*/
public function removeConfigData(
string $field,
string $xmlPrefix,
string $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
int $scopeId = 0
): void {
$path = implode("/", [self::XML_PAYMENT_PREFIX, $xmlPrefix, $field]);
$this->configWriter->delete($path, $scope, $scopeId);
}
}