Skip to content

Commit

Permalink
Accept 06 and turn into +316 in paypage
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed May 22, 2024
1 parent 7e4c757 commit a38da28
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
14 changes: 14 additions & 0 deletions inc/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,17 @@ function mollieDeleteWPTranslationFiles()
}
}
}

function transformPhoneToNLFormat($phone)
{
$startsWith06 = preg_match('/^06/', $phone);
if ($startsWith06) {
$prefix = '+316';
$phone = substr($phone, 2);
if (!$phone) {
return null;
}
$phone = $prefix . $phone;
}
return $phone;
}
1 change: 1 addition & 0 deletions src/Gateway/GatewayModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ public function in3FieldsMandatoryPayForOrder($order)
}

$phoneValue = filter_input(INPUT_POST, 'billing_phone_in3', FILTER_SANITIZE_SPECIAL_CHARS) ?? false;
$phoneValue = transformPhoneToNLFormat($phoneValue);
$phoneValid = $phoneValue && $this->isPhoneValid($phoneValue) ? $phoneValue : null;

if ($phoneValid) {
Expand Down
10 changes: 1 addition & 9 deletions src/Payment/MollieOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1230,15 +1230,7 @@ protected function getFormatedPhoneNumber(string $phone)
return null;
}
//check if phone starts with 06 and replace with +316
$startsWith06 = preg_match('/^06/', $phone);
if ($startsWith06) {
$prefix = '+316';
$phone = substr($phone, 2);
if (!$phone) {
return null;
}
$phone = $prefix . $phone;
}
$phone = transformPhoneToNLFormat($phone);

//check that $phone is in E164 format or can be changed by api
if (preg_match('/^\+[1-9]\d{10,13}$|^[1-9]\d{9,13}$/', $phone)) {
Expand Down

0 comments on commit a38da28

Please sign in to comment.