Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NTR: apple pay direct, ask for phone number if not required #812

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Service/SettingsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<mixed> $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;
Expand Down
16 changes: 16 additions & 0 deletions src/Setting/MollieSettingStruct.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@ class MollieSettingStruct extends Struct
*/
protected $phoneNumberFieldRequired = false;

/**
* @var bool
*/
protected $showPhoneNumberField = false;

/**
* @var string
*/
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/Subscriber/ApplePayDirectSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Loading