Skip to content

Commit

Permalink
Merge pull request #119 from Olympic1/patch-1
Browse files Browse the repository at this point in the history
Fix national checksum calculation for Belgium
  • Loading branch information
globalcitizen authored Aug 10, 2022
2 parents 3bb6a22 + b6c2234 commit d474287
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions php-iban.php
Original file line number Diff line number Diff line change
Expand Up @@ -714,13 +714,13 @@ function _iso7064_mod97_10($str) {
}

# Implement the national checksum for a Belgium (BE) IBAN
# (Credit: @gaetan-be)
# (Credit: @gaetan-be, fixed by @Olympic1)
function _iban_nationalchecksum_implementation_be($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);
$account = iban_get_account_part($iban);
$account_less_checksum = substr($account,strlen($account)-2);
$expected_nationalchecksum = $account_less_checksum % 97;
$bban = iban_get_bban_part($iban);
$bban_less_checksum = substr($bban, 0, -strlen($nationalchecksum));
$expected_nationalchecksum = $bban_less_checksum % 97;
if($mode=='find') {
return $expected_nationalchecksum;
}
Expand Down

0 comments on commit d474287

Please sign in to comment.