Commit 198c4a4d authored by iWallet Dev's avatar iWallet Dev

Automated Phone Code Omitter

parent 4ca26f90
...@@ -167,6 +167,11 @@ class EasyPaymentLinkAPI extends System { ...@@ -167,6 +167,11 @@ class EasyPaymentLinkAPI extends System {
$this -> logDetails("{$this -> getColumnData($account, PARAM_USER_ACCOUNT)}\n{$callbck}"); $this -> logDetails("{$this -> getColumnData($account, PARAM_USER_ACCOUNT)}\n{$callbck}");
$telnum = preg_replace("/(\-| |\(|\))/", NO_STRING, $this -> getColumnData($account, PARAM_TEL));
$country_code = $this -> getColumnData($account, PARAM_COUNTRY);
$mobile_num = $this -> omittedPhoneNumber($telnum, $country_code);
$this -> payload = json_encode([ $this -> payload = json_encode([
"customer" => [ "customer" => [
"first_name" => $this -> getColumnData($account, PARAM_FIRST_NAME), "first_name" => $this -> getColumnData($account, PARAM_FIRST_NAME),
...@@ -177,11 +182,11 @@ class EasyPaymentLinkAPI extends System { ...@@ -177,11 +182,11 @@ class EasyPaymentLinkAPI extends System {
"city_municipality" => $this -> getColumnData($account, PARAM_CITY), "city_municipality" => $this -> getColumnData($account, PARAM_CITY),
"zip" => $this -> getColumnData($account, PARAM_ZIP_CODE), "zip" => $this -> getColumnData($account, PARAM_ZIP_CODE),
"state_province_region" => $this -> getColumnData($account, PARAM_STATE), "state_province_region" => $this -> getColumnData($account, PARAM_STATE),
"country_code" => $this -> getColumnData($account, PARAM_COUNTRY) "country_code" => $country_code
], ],
"contact" => [ "contact" => [
"email" => $this -> getColumnData($account, PARAM_MAIL), "email" => $this -> getColumnData($account, PARAM_MAIL),
"mobile" => preg_replace("/(\-| |\(|\))/", NO_STRING, $this -> getColumnData($account, PARAM_TEL)) "mobile" => $mobile_num
] ]
], ],
"payment" => [ "payment" => [
...@@ -235,6 +240,48 @@ class EasyPaymentLinkAPI extends System { ...@@ -235,6 +240,48 @@ class EasyPaymentLinkAPI extends System {
curl_close($handle); curl_close($handle);
} }
protected function omittedPhoneNumber($tel, $country){
$country = $this -> getRowData($this -> accessSelect("SELECT_MST_COUNTRY", [$country]));
// omit the + sign if included
$phoneNum = strpos($tel, "+") === 0 ? substr($tel, 1) : $tel;
$found = "";
if($this -> beginsWith($country["phone_code"], $phoneNum, $found)){
return "0".substr($phoneNum, strlen($found));
}
return $tel;
}
protected function beginsWith($beginsWith, $phrase, &$found = null){
if(is_array($beginsWith)){
foreach($beginsWith as $begin){
if(substr($phrase, 0, strlen($begin)) === $begin){
if($found !== null){
$found = $beginsWith;
}
return true;
}
}
}else if(is_string($beginsWith)){
if(strpos($beginsWith, ",") !== false){
$beginsWith = explode(",", $beginsWith);
return $this -> beginsWith($beginsWith, $phrase, $found);
}
if(substr($phrase, 0, strlen($beginsWith)) === $beginsWith){
if($found !== null){
$found = $beginsWith;
}
return true;
}
}
}
public function getHttpCode(){ public function getHttpCode(){
return $this -> httpcode; return $this -> httpcode;
} }
......
...@@ -7078,6 +7078,7 @@ WHERE ...@@ -7078,6 +7078,7 @@ WHERE
, country , country
, langage , langage
, country_code , country_code
, phone_code
FROM FROM
t_mst_country t_mst_country
WHERE WHERE
...@@ -7086,6 +7087,21 @@ WHERE ...@@ -7086,6 +7087,21 @@ WHERE
country country
</LIST_MST_COUNTRY> </LIST_MST_COUNTRY>
<SELECT_MST_COUNTRY>
SELECT
c_id
, country
, langage
, country_code
, phone_code
FROM
t_mst_country
WHERE
country_code = '__ELEMENT01__'
ORDER BY
country
</SELECT_MST_COUNTRY>
<!-- <!--
通貨マスタの取得 通貨マスタの取得
条 件:なし 条 件:なし
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment