Beispiel #1
0
def validate_iban(iban):
    # check if country code is valid,
    # then check if iban length is correct for that country
    country_code = iban[:2].upper()
    length_for_country = bban_format.get(country_code, {}).get("length", 0)
    if not length_for_country or len(iban) != length_for_country:
        return False
    return _to_base_10_Str(iban) % 97 == 1
Beispiel #2
0
def validate_iban(iban):
    # check if country code is valid,
    # then check if iban length is correct for that country
    country_code = iban[:2].upper()
    length_for_country = bban_format.get(country_code, {}).get("length", 0)
    if not length_for_country or len(iban) != length_for_country:
        return False
    return _to_base_10_Str(iban) % 97 == 1
Beispiel #3
0
def _generate_bban(data):
    country = data.get("country_code")
    bban = bban_format.get(country, {}).get("composition").format(**data)
    return bban
Beispiel #4
0
def extract_account_number(iban):
    if validate_iban(iban):
        country_code = iban[:2]
        snippet = bban_format.get(country_code).get("account_number")
        return int(iban[snippet[0]:snippet[1]])
Beispiel #5
0
def extract_bank_code(iban):
    if validate_iban(iban):
        country_code = iban[:2]
        snippet = bban_format.get(country_code).get("bank_code")
        return int(iban[snippet[0]:snippet[1]])
Beispiel #6
0
def _generate_bban(data):
    country = data.get("country_code")
    bban = bban_format.get(country, {}).get("composition").format(**data)
    return bban
Beispiel #7
0
def extract_account_number(iban):
    if validate_iban(iban):
        country_code = iban[:2]
        snippet = bban_format.get(country_code).get("account_number")
        return int(iban[snippet[0]:snippet[1]])
Beispiel #8
0
def extract_bank_code(iban):
    if validate_iban(iban):
        country_code = iban[:2]
        snippet = bban_format.get(country_code).get("bank_code")
        return int(iban[snippet[0]:snippet[1]])