Example #1
0
            $country_sepa = 0;
        }
        # set registry edition
        $registry_edition = date('Y-m-d');
        # now prepare generate our registry lines...
        $to_generate = array($country_code => $country_name);
        if ($country_code == 'DK') {
            $to_generate = array('DK' => $country_name, 'FO' => 'Faroe Islands', 'GL' => 'Greenland');
        } elseif ($country_code == 'FR') {
            $to_generate = array('FR' => $country_name, 'GF' => 'French Guyana', 'GP' => 'Guadelope', 'MQ' => 'Martinique', 'RE' => 'Reunion', 'PF' => 'French Polynesia', 'TF' => 'French Southern Territories', 'YT' => 'Mayotte', 'NC' => 'New Caledonia', 'PM' => 'Saint Pierre et Miquelon', 'WF' => 'Wallis and Futuna Islands');
        }
        # output loop
        foreach ($to_generate as $country_code => $country_name) {
            # fixes for fields duplicating country code
            #print "CHECKSUM-BEFORE[$country_code] = $iban_electronic_example\n";
            $iban_electronic_example = iban_set_checksum($country_code . substr($iban_electronic_example, 2));
            #print "CHECKSUM-AFTER[$country_code]  = $iban_electronic_example\n";
            $iban_structure = $country_code . substr($iban_structure, 2);
            $iban_regex = '^' . $country_code . substr($iban_regex, 3);
            # output
            print "{$country_code}|{$country_name}|{$domestic_example}|{$bban_example}|{$bban_structure}|{$bban_regex}|{$bban_length}|{$iban_electronic_example}|{$iban_structure}|{$iban_regex}|{$iban_length}|{$bban_bankid_start_offset}|{$bban_bankid_stop_offset}|{$bban_branchid_start_offset}|{$bban_branchid_stop_offset}|{$registry_edition}|{$country_sepa}\n";
        }
    }
}
# swift_to_regex()
#  converts the SWIFT IBAN format specifications to regular expressions
#  eg: 4!n6!n1!n -> ^(\d{4})(\d{6})(\d{1})$
function swift_to_regex($swift)
{
    # first find tokens
    $matches = swift_tokenize($swift);
Example #2
0
         print "    (ERROR: iban_set_nationalchecksum('{$iban}') returned '{$fixed_iban}')\n";
         exit(1);
     } else {
         print "    (Correction of national checksum functionality validated.)\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);
         print "        (country is: '{$country}')\n";
         if (strlen($machine_iban) != iban_country_get_iban_length($country)) {
             print "        (ERROR: length of '" . strlen($machine_iban) . "' does not match expected length for country's IBAN '" . iban_country_get_iban_length($country) . "'.)";
         }
         $regex = '/' . iban_country_get_iban_format_regex($country) . '/';
         if (!preg_match($regex, $machine_iban)) {
             print "        (ERROR: did not match regular expression '" . $regex . "')\n";
         }
     } else {
         print "       (correct checksum version would be '" . $correct . "')\n";
Example #3
0
function iban_set_nationalchecksum($iban)
{
    $result = _iban_nationalchecksum_implementation($iban, 'set');
    if ($result != '') {
        $result = iban_set_checksum($result);
        # recalculate IBAN-level checksum
    }
    return $result;
}
Example #4
0
 public function SetChecksum()
 {
     $this->iban = iban_set_checksum($this->iban);
 }
Example #5
0
 public static function getIbanFromBban($bankAccount = '', $bankAccountCode = '')
 {
     if ($bankAccount == '' || $bankAccountCode == '') {
         return false;
     }
     $iban = 'SK00' . $bankAccountCode . '000000' . str_pad($bankAccount, 10, '0', STR_PAD_LEFT);
     include_once __DIR__ . '/../extensions/iban/php-iban.php';
     return iban_set_checksum($iban);
 }