Skip to content

Commit

Permalink
Accept 06 and turn into +316
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed May 21, 2024
1 parent 698f28d commit 7e4c757
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Gateway/GatewayModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ public function switchFields($data)

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

public function addPhoneWhenRest($arrayContext)
Expand Down
15 changes: 14 additions & 1 deletion src/Payment/MollieOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1226,9 +1226,22 @@ protected function getFormatedPhoneNumber(string $phone)
{
//remove whitespaces and all non numerical characters except +
$phone = preg_replace('/[^0-9+]+/', '', $phone);
if (!is_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;
}

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

0 comments on commit 7e4c757

Please sign in to comment.