Skip to content

Commit

Permalink
Merge pull request #11 from madmuffin1/master
Browse files Browse the repository at this point in the history
ensure two digit checksum length
  • Loading branch information
kewisch committed Jul 20, 2015
2 parents 34c5d72 + f6924b5 commit 91bbc69
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/sepa.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@
function checksumIBAN(iban) {
var ibrev = iban.substr(4) + iban.substr(0, 2) + "00";
var mod = _txtMod97(_replaceChars(ibrev));
return iban.substr(0, 2) + (98 - mod) + iban.substr(4);
return iban.substr(0, 2) + ("0" + (98 - mod)).substr(-2,2) + iban.substr(4);
}

/**
Expand All @@ -496,7 +496,7 @@
function checksumCreditorID(cid) {
var cidrev = cid.substr(7) + cid.substr(0, 2) + "00";
var mod = _txtMod97(_replaceChars(cidrev));
return cid.substr(0, 2) + (98 - mod) + cid.substr(4);
return cid.substr(0, 2) + ("0" + (98 - mod)).substr(-2,2) + cid.substr(4);
}

// --- Various private functions follow --- //
Expand Down
2 changes: 1 addition & 1 deletion lib/sepa.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 91bbc69

Please sign in to comment.