print ', or '; } print "'" . $suggestion . "'"; $done++; } print "?)"; } } } else { print "ok"; $result = iban_verify_nationalchecksum($iban); if ($result === '') { print " (no national checksum)"; } elseif ($result != true) { print " (but national checksum FAILED! "; print "expected '" . iban_find_nationalchecksum($iban) . "', contains '" . iban_get_nationalchecksum_part($iban) . "'. bank code is '" . iban_get_bank_part($iban) . "')"; $errors++; } #$parts = iban_get_parts($iban); #foreach($parts as $name=>$value) { # print " $name: $value\n"; #} } print "\n"; } } if ($errors == 0) { exit(0); } exit(10 + $errors); function usage()
print " - iban_to_human_format() test #{$i}... "; $received_output = iban_to_human_format($input); if ($received_output != $expected_output) { print "FAILED (expected '{$expected_output}', received '{$received_output}')\n"; exit(1); } else { print "OK.\n"; } $i++; } # === iban_get_nationalchecksum_part ======================== $test_data = array('AL47212110090000000235698741' => '9', 'ES9121000418450200051332' => '45', 'BE68 5390 0754 7034' => '34'); $i = 0; foreach ($test_data as $input => $expected_output) { print " - iban_get_nationalchecksum_part() test #{$i}... "; $received_output = iban_get_nationalchecksum_part($input); if ($received_output != $expected_output) { print "FAILED (expected '{$expected_output}', received '{$received_output}')\n"; exit(1); } else { print "OK.\n"; } $i++; } # === iban_country_get_iana ================================== $test_data = array('AA' => '', 'XK' => '', 'BL' => '', 'MF' => '', 'MQ' => 'mq', 'GB' => 'uk'); $i = 0; foreach ($test_data as $input => $expected_output) { print " - iban_country_get_iana() test #{$i}... "; $received_output = iban_country_get_iana($input); if ($received_output != $expected_output) {
print "None."; } else { print $official_currency; } print "\n"; # get example iban $iban = $country['iban_example']; # output example iban properties one by one print "Example IBAN: " . iban_to_human_format($iban) . "\n"; print " - country " . iban_get_country_part($iban) . "\n"; print " - checksum " . iban_get_checksum_part($iban) . "\n"; print " - bban " . iban_get_bban_part($iban) . "\n"; print " - bank " . iban_get_bank_part($iban) . "\n"; print " - branch " . iban_get_branch_part($iban) . "\n"; print " - account " . iban_get_account_part($iban) . "\n"; $nationalchecksum = iban_get_nationalchecksum_part($iban); print " - natcksum " . $nationalchecksum . "\n"; # if a national checksum was present, validate it $supposed_checksum = iban_find_nationalchecksum($iban); if ($supposed_checksum != '') { if ($supposed_checksum != $nationalchecksum) { print " (INVALID! Should be '" . $supposed_checksum . "'!)\n"; exit(1); } else { print " (National checksum manually validated.)\n"; } } # also check 'verify' codepath $result = iban_verify_nationalchecksum($iban); if ($result != '') { if ($result != true) {
public function NationalChecksum($iban = '') { return iban_get_nationalchecksum_part($this->iban); }
function iban_get_parts($iban) { return array('country' => iban_get_country_part($iban), 'checksum' => iban_get_checksum_part($iban), 'bban' => iban_get_bban_part($iban), 'bank' => iban_get_bank_part($iban), 'country' => iban_get_country_part($iban), 'branch' => iban_get_branch_part($iban), 'account' => iban_get_account_part($iban), 'nationalchecksum' => iban_get_nationalchecksum_part($iban)); }
function _iban_nationalchecksum_implementation_tl($iban, $mode) { if ($mode != 'set' && $mode != 'find' && $mode != 'verify') { return ''; } # blank value on return to distinguish from correct execution $nationalchecksum = iban_get_nationalchecksum_part($iban); $bban = iban_get_bban_part($iban); $bban_less_checksum = substr($bban, 0, strlen($bban) - 2); $expected_nationalchecksum = _iso7064_mod97_10_generated($bban_less_checksum); if ($mode == 'find') { return $expected_nationalchecksum; } elseif ($mode == 'set') { return _iban_nationalchecksum_set($iban, $expected_nationalchecksum); } elseif ($mode == 'verify') { return $nationalchecksum == $expected_nationalchecksum; } }
print "Yes"; } else { print "No"; } print ".\n"; # get example iban $iban = $country['iban_example']; # output example iban properties one by one print "Example IBAN: " . iban_to_human_format($iban) . "\n"; print " - country " . iban_get_country_part($iban) . "\n"; print " - checksum " . iban_get_checksum_part($iban) . "\n"; print " - bban " . iban_get_bban_part($iban) . "\n"; print " - bank " . iban_get_bank_part($iban) . "\n"; print " - branch " . iban_get_branch_part($iban) . "\n"; print " - account " . iban_get_account_part($iban) . "\n"; print " - natcksum " . iban_get_nationalchecksum_part($iban) . "\n"; # output all properties #$parts = iban_get_parts($iban); #print_r($parts); # verify print "\nChecking validity... "; if (verify_iban($iban)) { print "IBAN {$iban} is valid.\n"; } else { print "ERROR: IBAN {$iban} is invalid.\n"; $correct = iban_set_checksum($iban); if ($correct == $iban) { print " (checksum is correct, structure must have issues.)\n"; $machine_iban = iban_to_machine_format($iban); print " (machine format is: '{$machine_iban}')\n"; $country = iban_get_country_part($machine_iban);