Added Iban&Bic Validation to Address/Form
This commit is contained in:
@@ -686,47 +686,13 @@ class AddressController extends mfBaseController {
|
||||
return false;
|
||||
}
|
||||
|
||||
$creds = TT_IBAN_VALIDATOR_USER.":".TT_IBAN_VALIDATOR_PASS;
|
||||
$b64creds = base64_encode($creds);
|
||||
|
||||
$ctx = stream_context_create([
|
||||
"http" => [
|
||||
"header" => "Authorization: Basic $b64creds"
|
||||
]
|
||||
]);
|
||||
|
||||
$url = TT_IBAN_VALIDATOR_BASEURL.$iban;
|
||||
$resp = file_get_contents($url, false, $ctx);
|
||||
|
||||
if($resp) {
|
||||
$data = json_decode($resp);
|
||||
$result = IbanValidator::validate($iban, $bic);
|
||||
if(is_array($result) && $result) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$iban_correct = false;
|
||||
$iban_sus = false;
|
||||
$bic_correct = false;
|
||||
$potential_bics = [];
|
||||
return false;
|
||||
|
||||
if($data->result == "passed") {
|
||||
$iban_correct = true;
|
||||
}
|
||||
|
||||
if(is_array($data->all_bic_candidates) && count($data->all_bic_candidates)) {
|
||||
foreach($data->all_bic_candidates as $bic_candidate) {
|
||||
if(!$bic_candidate->bic) continue;
|
||||
$potential_bics[] = $bic_candidate->bic;
|
||||
|
||||
if($bic_candidate->bic == $bic) {
|
||||
$bic_correct = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($data->iban_listed) {
|
||||
$iban_sus = $data->iban_listed;
|
||||
}
|
||||
|
||||
return ["iban" => $data->iban, "bic" => $potential_bics, "iban_correct" => $iban_correct, "iban_sus" => $iban_sus, "bic_correct" => $bic_correct];
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user