Skip to content

Commit

Permalink
Phone and birthdate not required in checkout with in3
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed May 18, 2024
1 parent c5651d1 commit 9142ecb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 46 deletions.
29 changes: 0 additions & 29 deletions resources/js/blocks/molliePaymentMethod.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,35 +161,6 @@ const MollieComponent = (props) => {

}, [activePaymentMethod, onCheckoutValidation, billing.billingData, item, companyNameString, inputCompany]);

useEffect(() => {
let phoneLabel = getPhoneField()?.labels?.[0] ?? null;
if (!phoneLabel || phoneLabel.length === 0) {
return
}
if (activePaymentMethod === 'mollie_wc_gateway_in3') {
phoneLabel.innerText = item.phonePlaceholder
} else {
if (phoneString !== false) {
phoneLabel.innerText = phoneString
}
}
let isBirthdateEmpty = inputBirthdate === ''
const unsubscribeProcessing = onCheckoutValidation(

() => {
if (activePaymentMethod === 'mollie_wc_gateway_in3' && isBirthdateEmpty) {
return {
errorMessage: item.errorMessage,
};
}
}
);
return () => {
unsubscribeProcessing()
};

}, [activePaymentMethod, onCheckoutValidation, billing.billingData, shippingData.shippingAddress, item, phoneString, inputBirthdate, inputPhone]);

onSubmitLocal = onSubmit
const updateIssuer = ( changeEvent ) => {
selectIssuer( changeEvent.target.value )
Expand Down
19 changes: 2 additions & 17 deletions src/Gateway/GatewayModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -655,11 +655,8 @@ public function in3FieldsMandatory($fields, $errors)
{
$gatewayName = "mollie_wc_gateway_in3";
$phoneField = 'billing_phone_in3';
$birthdateField = self::FIELD_IN3_BIRTHDATE;
$phoneLabel = __('Phone', 'mollie-payments-for-woocommerce');
$birthDateLabel = __('Birthdate', 'mollie-payments-for-woocommerce');
$fields = $this->addPaymentMethodMandatoryFieldsPhoneVerification($fields, $gatewayName, $phoneField, $phoneLabel, $errors);
return $this->addPaymentMethodMandatoryFields($fields, $gatewayName, $birthdateField, $birthDateLabel, $errors);
return $this->addPaymentMethodMandatoryFieldsPhoneVerification($fields, $gatewayName, $phoneField, $phoneLabel, $errors);
}

/**
Expand All @@ -673,18 +670,6 @@ public function in3FieldsMandatoryPayForOrder($order)
return;
}

$birthdateValue = filter_input(INPUT_POST, self::FIELD_IN3_BIRTHDATE, FILTER_SANITIZE_SPECIAL_CHARS) ?? false;
$birthDateLabel = __('Birthdate', 'mollie-payments-for-woocommerce');

if (!$birthdateValue) {
wc_add_notice(
sprintf(
__('%s is a required field.', 'woocommerce'),
"<strong>$birthDateLabel</strong>"
),
'error'
);
}
$phoneValue = filter_input(INPUT_POST, 'billing_phone_in3', FILTER_SANITIZE_SPECIAL_CHARS) ?? false;
$phoneValid = $phoneValue && $this->isPhoneValid($phoneValue) ? $phoneValue : null;

Expand Down Expand Up @@ -800,7 +785,7 @@ public function switchFields($data)

private function isPhoneValid($billing_phone)
{
return preg_match('/^\+[1-9]\d{10,13}$/', $billing_phone);
return preg_match('/^\+[1-9]\d{10,13}$|^[1-9]\d{9,13}$/', $billing_phone);
}

public function addPhoneWhenRest($arrayContext)
Expand Down

0 comments on commit 9142ecb

Please sign in to comment.