Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 3
0
def _generate_bban(data):
    country = data.get("country_code")
    bban = bban_format.get(country, {}).get("composition").format(**data)
    return bban
Ejemplo n.º 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]])
Ejemplo n.º 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]])
Ejemplo n.º 6
0
def _generate_bban(data):
    country = data.get("country_code")
    bban = bban_format.get(country, {}).get("composition").format(**data)
    return bban
Ejemplo n.º 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]])
Ejemplo n.º 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]])