Verify() public method

public Verify ( $iban = '', $machine_format_only = false )
示例#1
0
 # get example iban
 $myIban = new IBAN($myCountry->IBANExample());
 # output example iban properties one by one
 print "Example IBAN: " . $myIban->HumanFormat() . "\n";
 print " - country  " . $myIban->Country() . "\n";
 print " - checksum " . $myIban->Checksum() . "\n";
 print " - bban     " . $myIban->BBAN() . "\n";
 print " - bank     " . $myIban->Bank() . "\n";
 print " - branch   " . $myIban->Branch() . "\n";
 print " - account  " . $myIban->Account() . "\n";
 # output all properties
 #$parts = $myIban->Parts();
 #print_r($parts);
 # verify
 print "\nChecking validity... ";
 if ($myIban->Verify()) {
     print "IBAN {$myIban->iban} is valid.\n";
 } else {
     print "ERROR: IBAN {$myIban->iban} is invalid.\n";
     $correct = $myIban->SetChecksum();
     if ($correct == $iban) {
         print "       (checksum is correct, structure must have issues.)\n";
         $machine_iban = $myIban->MachineFormat();
         print "        (machine format is: '{$machine_iban}')\n";
         $country = $myIban->Country();
         print "        (country is: '{$country}')\n";
         $myCountry = new IBANCountry($country);
         if (strlen($machine_iban) != $myCountry->IBANLength()) {
             print "        (ERROR: length of '" . strlen($machine_iban) . "' does not match expected length for country's IBAN '" . $myCountry->IBANLength() . "'.)";
         }
         $regex = '/' . $myCountry->IBANFormatRegex() . '/';
 public function validate_fields()
 {
     if (!$this->is_available() || !isset($_POST['payment_method']) || $_POST['payment_method'] != $this->id) {
         return;
     }
     $iban = isset($_POST['direct_debit_account_iban']) ? wc_clean($_POST['direct_debit_account_iban']) : '';
     $holder = isset($_POST['direct_debit_account_holder']) ? wc_clean($_POST['direct_debit_account_holder']) : '';
     $bic = isset($_POST['direct_debit_account_bic']) ? wc_clean($_POST['direct_debit_account_bic']) : '';
     $country = isset($_POST['billing_country']) ? wc_clean($_POST['billing_country']) : WC()->countries->get_base_country();
     if (empty($iban) || empty($holder) || empty($bic)) {
         wc_add_notice(__('Please insert your SEPA account data.', 'woocommerce-germanized'), 'error');
         return false;
     }
     // Validate IBAN
     include_once WC_germanized()->plugin_path() . '/includes/libraries/iban/oophp-iban.php';
     $iban_validator = new IBAN($iban);
     if (!$iban_validator->Verify()) {
         wc_add_notice(__('Your IBAN seems to be invalid.', 'woocommerce-germanized'), 'error');
     } else {
         if ($iban_validator->Country() != $country) {
             wc_add_notice(__('Your IBAN\'s country code doesn’t match with your billing country.', 'woocommerce-germanized'), 'error');
         }
     }
     // Validate BIC
     if (!preg_match('/^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$/', $bic)) {
         wc_add_notice(__('Your BIC seems to be invalid.', 'woocommerce-germanized'), 'error');
     }
 }
示例#3
0
/**
 *      Check IBAN number informations for a bank account.
 *
 *      @param  Account     $account    A bank account
 *      @return boolean                 True if informations are valid, false otherwise
 */
function checkIbanForAccount($account)
{
    require_once DOL_DOCUMENT_ROOT . '/includes/php-iban/oophp-iban.php';
    $iban = new IBAN($account->iban);
    $check = $iban->Verify();
    if ($check) {
        return true;
    } else {
        return false;
    }
}
 public function Verify($iban = '')
 {
     $_iban = str_replace(' ', '', $iban);
     _iban_load_registry();
     return parent::Verify($_iban);
 }