diff --git a/src/Service/SettingsService.php b/src/Service/SettingsService.php index c1ca33cbb..c6195eecf 100644 --- a/src/Service/SettingsService.php +++ b/src/Service/SettingsService.php @@ -15,6 +15,9 @@ class SettingsService implements PluginSettingsServiceInterface private const SYSTEM_CORE_CART_CONFIG_DOMAIN = 'core.cart'; private const PHONE_NUMBER_FIELD_REQUIRED = 'phoneNumberFieldRequired'; + + private const PHONE_NUMBER_FIELD = 'showPhoneNumberField'; + private const PAYMENT_FINALIZE_TRANSACTION_TIME = 'paymentFinalizeTransactionTime'; const LIVE_API_KEY = 'liveApiKey'; const TEST_API_KEY = 'testApiKey'; @@ -90,6 +93,8 @@ public function getSettings(?string $salesChannelId = null): MollieSettingStruct $structData[self::PHONE_NUMBER_FIELD_REQUIRED] = $coreSettings[self::PHONE_NUMBER_FIELD_REQUIRED] ?? false; + $structData[self::PHONE_NUMBER_FIELD] = $coreSettings[self::PHONE_NUMBER_FIELD] ?? false; + /** @var array $cartSettings */ $cartSettings = $this->systemConfigService->get(self::SYSTEM_CORE_CART_CONFIG_DOMAIN, $salesChannelId); $structData[self::PAYMENT_FINALIZE_TRANSACTION_TIME] = $cartSettings[self::PAYMENT_FINALIZE_TRANSACTION_TIME] ?? 1800; diff --git a/src/Setting/MollieSettingStruct.php b/src/Setting/MollieSettingStruct.php index 48539b026..cfa7eff52 100644 --- a/src/Setting/MollieSettingStruct.php +++ b/src/Setting/MollieSettingStruct.php @@ -250,6 +250,11 @@ class MollieSettingStruct extends Struct */ protected $phoneNumberFieldRequired = false; + /** + * @var bool + */ + protected $showPhoneNumberField = false; + /** * @var string */ @@ -978,6 +983,17 @@ public function setPhoneNumberFieldRequired(bool $phoneNumberFieldRequired): voi $this->phoneNumberFieldRequired = $phoneNumberFieldRequired; } + public function isPhoneNumberFieldShown():bool + { + return $this->showPhoneNumberField; + } + + public function setShowPhoneNumberField(bool $showPhoneNumberField): void + { + $this->showPhoneNumberField = $showPhoneNumberField; + } + + public function getApplePayDirectDomainAllowList(): string { return $this->applePayDirectDomainAllowList; diff --git a/src/Subscriber/ApplePayDirectSubscriber.php b/src/Subscriber/ApplePayDirectSubscriber.php index 609df5311..7c3015087 100644 --- a/src/Subscriber/ApplePayDirectSubscriber.php +++ b/src/Subscriber/ApplePayDirectSubscriber.php @@ -51,7 +51,9 @@ public function onStorefrontRender(StorefrontRenderEvent $event): void $applePayDirectEnabled = $this->applePay->isApplePayDirectEnabled($event->getSalesChannelContext()); - $event->setParameter('mollie_applepaydirect_phonenumber_required', (int)$settings->isPhoneNumberFieldRequired()); + $shoPhoneNumberField = $settings->isPhoneNumberFieldRequired() || $settings->isPhoneNumberFieldShown(); + + $event->setParameter('mollie_applepaydirect_phonenumber_required', (int)$shoPhoneNumberField); $event->setParameter('mollie_applepaydirect_enabled', $applePayDirectEnabled); $event->setParameter('mollie_applepaydirect_restrictions', $settings->getRestrictApplePayDirect()); }