English Deutsch

Initialize a new EBICS user

from fintech.ebics import EbicsKeyRing, EbicsBank, EbicsUser, EbicsClient

keyring = EbicsKeyRing(keys='~/mykeys', passphrase='mysecret')
bank = EbicsBank(keyring=keyring, hostid='MYBANK', url='https://www.mybank.de/ebics')
user = EbicsUser(keyring=keyring, partnerid='CUSTOMER123', userid='USER1')

# Create new keys for this user
user.create_keys(keyversion='A006', bitlength=2048)
# Create self-signed certificates
# Only if the initialization is based on certificates!
user.create_certificates(
    commonName='John Doe',
    organizationName='My organization',
    countryName='FR',
    emailAddress='my@email.address',
)

client = EbicsClient(bank, user)
# Send the public electronic signature key to the bank.
client.INI()
# Send the public authentication and encryption keys to the bank.
client.HIA()

# Create an INI-letter which must be printed and sent to the bank.
user.create_ini_letter(bankname='MyBank AG', path='~/ini_letter.pdf')

# After the account has been activated the public bank keys
# must be downloaded and checked for consistency.
print(client.HPB())

# Finally the bank keys must be activated.
bank.activate_keys()