How to use the fints.segments.FinTS3Segment function in fints

To help you get started, we’ve selected a few fints examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github raphaelm / python-fints / fints / segments / message.py View on Github external
import time

from fints.utils import fints_escape
from . import FinTS3Segment


class HNHBK(FinTS3Segment):
    """
    HNHBK (Nachrichtenkopf)
    Section B.5.2
    """
    type = 'HNHBK'
    version = 3

    HEADER_LENGTH = 29

    def __init__(self, msglen, dialogid, msgno):

        if len(str(msglen)) != 12:
            msglen = str(int(msglen) + self.HEADER_LENGTH + len(str(dialogid)) + len(str(msgno))).zfill(12)

        data = [
            msglen,
github raphaelm / python-fints / fints / segments / debit.py View on Github external
def __init__(self, segno, account: SEPAAccount, pain_msg):
        self.version = 1
        sepa_descriptor = 'urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.008.003.02'
        msg = ':'.join([
            account.iban,
            account.bic
        ])
        data = [
            msg,
            sepa_descriptor,
            '@{}@{}'.format(len(pain_msg), pain_msg)
        ]
        super().__init__(segno, data)


class HKDME(FinTS3Segment):
    """
    HKDME (Einreichung terminierter SEPA-Sammellastschrift)
    Section C.10.3.2.2.1
    """
    type = 'HKDME'

    def __init__(self, segno, account: SEPAAccount, pain_msg, control_sum, currency, book_as_single):
        self.version = 1
        sepa_descriptor = 'urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.008.003.02'
        msg = ':'.join([
            account.iban,
            account.bic
        ])
        data = [
            msg,
            str(control_sum).replace('.', ',') + ':' + currency,
github raphaelm / python-fints / fints / segments / message.py View on Github external
':'.join(['PIN', str(profile_version)]),
            security_function,
            secref,
            self.SECURITY_BOUNDARY,
            self.SECURITY_SUPPLIER_ROLE,
            ':'.join(['1', '', str(systemid)]),
            1,
            ':'.join(['1', time.strftime('%Y%m%d'), time.strftime('%H%M%S')]),
            ':'.join(['1', '999', '1']),  # Negotiate hash algorithm
            ':'.join(['6', '10', '16']),  # RSA mode
            ':'.join([str(self.country_code), blz, username, 'S', '0', '0']),
        ]
        super().__init__(segno, data)


class HNVSK(FinTS3Segment):
    """
    HNVSK (Verschlüsslungskopf)
    Section B.5.3
    """
    type = 'HNVSK'
    version = 3

    COMPRESSION_NONE = 0
    SECURITY_SUPPLIER_ROLE = 1  # ISS

    def __init__(self, segno, blz, username, systemid, profile_version):
        data = [
            ':'.join(['PIN', str(profile_version)]),
            998,
            self.SECURITY_SUPPLIER_ROLE,
            ':'.join(['1', '', str(systemid)]),
github raphaelm / python-fints / fints / segments / depot.py View on Github external
from . import FinTS3Segment


class HKWPD(FinTS3Segment):
    """
    HKWPD (Depotaufstellung anfordern)
    Section C.4.3.1
    Example: HKWPD:3:7+23456::280:10020030+USD+2'
    """
    type = 'HKWPD'

    def __init__(self, segno, version, account):
        self.version = version
        data = [
            account
            # The spec allows the specification of currency and
            # quality of valuations, as shown in the docstring above.
            # However, both 1822direkt and CortalConsors reject the
            # call if these two are present, claiming an invalid input.
            # 'EUR'        # Währung der Depotaufstellung"
github raphaelm / python-fints / fints / segments / dialog.py View on Github external
from . import FinTS3Segment


class HKEND(FinTS3Segment):
    """
    HKEND (Dialogende)
    Section C.4.1.2
    """
    type = 'HKEND'
    version = 1

    def __init__(self, segno, dialogid):
        data = [
            dialogid,
        ]
        super().__init__(segno, data)
github raphaelm / python-fints / fints / segments / debit.py View on Github external
from . import FinTS3Segment
from ..models import SEPAAccount


class HKDSE(FinTS3Segment):
    """
    HKDSE (Einreichung terminierter SEPA-Einzellastschrift)
    Section C.10.2.5.4.1
    """
    type = 'HKDSE'

    def __init__(self, segno, account: SEPAAccount, pain_msg):
        self.version = 1
        sepa_descriptor = 'urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.008.003.02'
        msg = ':'.join([
            account.iban,
            account.bic
        ])
        data = [
            msg,
            sepa_descriptor,
github raphaelm / python-fints / fints / segments / message.py View on Github external
def __init__(self, segno, blz, username, systemid, profile_version):
        data = [
            ':'.join(['PIN', str(profile_version)]),
            998,
            self.SECURITY_SUPPLIER_ROLE,
            ':'.join(['1', '', str(systemid)]),
            ':'.join(['1', time.strftime('%Y%m%d'), time.strftime('%H%M%S')]),
            ':'.join(['2', '2', '13', '@8@00000000', '5', '1']),  # Crypto algorithm
            ':'.join([str(self.country_code), blz, username, 'S', '0', '0']),
            self.COMPRESSION_NONE
        ]
        super().__init__(segno, data)


class HNVSD(FinTS3Segment):
    """
    HNVSD (Verschlüsselte Daten)
    Section B.5.4
    """
    type = 'HNVSD'
    version = 1

    def __init__(self, segno, encoded_data):
        self.encoded_data = encoded_data
        data = [
            '@{}@{}'.format(len(encoded_data), encoded_data)
        ]
        super().__init__(segno, data)

    def set_data(self, encoded_data):
        self.encoded_data = encoded_data
github raphaelm / python-fints / fints / segments / message.py View on Github external
def __init__(self, segno, encoded_data):
        self.encoded_data = encoded_data
        data = [
            '@{}@{}'.format(len(encoded_data), encoded_data)
        ]
        super().__init__(segno, data)

    def set_data(self, encoded_data):
        self.encoded_data = encoded_data
        self.data = [
            '@{}@{}'.format(len(encoded_data), encoded_data)
        ]


class HNSHA(FinTS3Segment):
    """
    HNSHA (Signaturabschluss)
    Section B.5.2
    """
    type = 'HNSHA'
    version = 2

    SECURITY_FUNC = 999
    SECURITY_BOUNDARY = 1  # SHM
    SECURITY_SUPPLIER_ROLE = 1  # ISS
    PINTAN_VERSION = 1  # 1-step

    def __init__(self, segno, secref, pin, tan=None):
        pintan = fints_escape(pin)
        if tan:
            pintan += ':' + fints_escape(tan)
github raphaelm / python-fints / fints / segments / message.py View on Github external
SECURITY_SUPPLIER_ROLE = 1  # ISS
    PINTAN_VERSION = 1  # 1-step

    def __init__(self, segno, secref, pin, tan=None):
        pintan = fints_escape(pin)
        if tan:
            pintan += ':' + fints_escape(tan)
        data = [
            secref,
            '',
            pintan,
        ]
        super().__init__(segno, data)


class HNHBS(FinTS3Segment):
    """
    HNHBS (Nachrichtenabschluss)
    Section B.5.3
    """
    type = 'HNHBS'
    version = 1

    def __init__(self, segno, msgno):
        data = [
            str(msgno)
        ]
        super().__init__(segno, data)
github raphaelm / python-fints / fints / segments / accounts.py View on Github external
from . import FinTS3Segment


class HKSPA(FinTS3Segment):
    """
    HKSPA (SEPA-Kontoverbindung anfordern)
    Section C.10.1.3
    """
    type = 'HKSPA'
    version = 1

    def __init__(self, segno, accno, subaccfeature, blz):
        data = [
            ':'.join([
                accno, subaccfeature,
                self.country_code, blz
            ]) if accno is not None else ''
        ]
        super().__init__(segno, data)