Country() public method

public Country ( $iban = '' )
Exemplo n.º 1
0
 $myCountry = new IBANCountry($countrycode);
 # start section
 print "[{$countrycode}: " . $myCountry->Name() . "]\n";
 # output remaining country properties
 print "Is a SEPA member? ";
 if ($myCountry->IsSEPA()) {
     print "Yes";
 } else {
     print "No";
 }
 print ".\n";
 # 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();
 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');
     }
 }