Coder Social home page Coder Social logo

ruby_fints's Introduction

ruby_fints

This is a pure-Ruby implementation of FinTS (formerly known as HBCI), a online-banking protocol commonly supported by German banks.

Limitations

  • Only FinTS 3.0 is supported
  • Only PIN/TAN authentication is supported, no signature cards
  • Only a number of reading operations are currently supported
  • Supports Ruby 2.2+

Banks tested:

  • Sparkasse
  • ING DiBa
  • GLS Bank
  • comdirect

Usage

require 'ruby_fints'
require 'pp'

FinTS::Client.logger.level = Logger::DEBUG
f = FinTS::PinTanClient.new(
    '123456789',  # Your bank's BLZ
    'myusername',
    'mypin',
    'https://mybank.com/...'  # endpoint, e.g.: https://hbci-pintan.gad.de/cgi-bin/hbciservlet
)

accounts = f.get_sepa_accounts
pp accounts
# [{iban: 'DE12345678901234567890', bic: 'ABCDEFGH1DEF', accountnumber: '123456790', subaccount: '', blz: '123456789'}]

balance = f.get_balance(accounts[0])
pp balance
# {:amount=>1234.56,
#  :currency=>"EUR",
#  :date=>#<Date: 2018-08-21 ((2458352j,0s,0n),+0s,2299161j)>}

statement = f.get_statement(accounts[0], Date.new(2017, 4, 3), Date.new(2017, 4, 4))
pp statement.map(&:data)

# [#<Cmxl::Fields::Transaction:0x007fab6b457ec8
#  @data=
#   {"date"=>"170404",
#    "entry_date"=>"0404",
#    "funds_code"=>"C",
#    "currency_letter"=>"R",
#    "amount"=>"96,38",
#    "swift_code"=>"N062",
#    "reference"=>"NONREF",
#    "bank_reference"=>""},
#  @details=
#   #<Cmxl::Fields::StatementDetails:0x007fab6b457838
#    @data=
#     {"transaction_code"=>"166",
#      "details"=>
#       "?00GUTSCHRIFT?109251?20EREF+010F209270562741?21SVWZ+STRIPEX4J1J3?22AWV-MELDEPFLICHT BEACHTEN?23HOTLINE BUNDESBANK.?24(0800) 1234-111?30SXPYDKKK?35DK6689000000010241?32Stripe Payments UK Ltd?34888",
#      "seperator"=>"?"}
#  ]

# for retrieving the holdings of an account (This has not been tested for this implementation yet so it might not work)
holdings = f.get_holdings(accounts[0])

Credits

This is a close port of python-fints library by Raphael Michel which in turn is a port of the fints-hbci-php implementation that was released by Markus Schindler under the MIT license.

Thanks for your work!

ruby_fints's People

Contributors

mkilling avatar nistude avatar plaschczek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ruby_fints's Issues

FinTS::DialogError with ING-DiBa

Hi!

This is basically the same issue as gitviola/ynab-bank-importer#64.

require 'ruby_fints'
FinTS::Client.logger.level = Logger::DEBUG
f = FinTS::PinTanClient.new('50010517', 'my_username', 'my_password', 'https://fints.ing.de/fints/')
f.get_sepa_accounts

Gives me the following output with a FinTS::DialogError 😕

I, [2019-04-25T07:48:39.917712 #29]  INFO -- FinTS::Client: Initialize SYNC
D, [2019-04-25T07:48:39.918193 #29] DEBUG -- FinTS::Client: Sending SYNC: HNHBK:1:3+000000000379+300+0+1'HNVSK:998:3+PIN:1+998+1+1::0+1:20190425:074839+2:2:13:@8@00000000:5:1+280:50010517:REDACTED:S:0:0+0'HNVSD:999:1+@216@HNSHK:2:4+PIN:1+999+6820269+1+1+1::0+1+1:20190425:074839+1:999:1+6:10:16+280:50010517:REDACTED:S:0:0'HKIDN:3:2+280:50010517+REDACTED+0+1'HKVVB:4:3+0+0+1+ruby_fints+0.0.4'HKSYN:5:3+0'HNSHA:6:2+6820269++REDACTED''HNHBS:7:1+1'
I, [2019-04-25T07:48:39.918269 #29]  INFO -- FinTS::Client: Sending Message
D, [2019-04-25T07:48:39.918622 #29] DEBUG -- FinTS::Client: << HNHBK:1:3+000000000379+300+0+1'HNVSK:998:3+PIN:1+998+1+1::0+1:20190425:074839+2:2:13:@8@00000000:5:1+280:50010517:REDACTED:S:0:0+0'HNVSD:999:1+@216@HNSHK:2:4+PIN:1+999+6820269+1+1+1::0+1+1:20190425:074839+1:999:1+6:10:16+280:50010517:REDACTED:S:0:0'HKIDN:3:2+280:50010517+REDACTED+0+1'HKVVB:4:3+0+0+1+ruby_fints+0.0.4'HKSYN:5:3+0'HNSHA:6:2+6820269++REDACTED''HNHBS:7:1+1'
D, [2019-04-25T07:48:42.141609 #29] DEBUG -- FinTS::Client: >> HNHBK:1:3+000000000211+300+000006IJEV7V3RF87QRBNDEIIB2UV4+1+000006IJEV7V3RF87QRBNDEIIB2UV4:1'HIRMG:2:2:+9800::Der Dialog wurde abgebrochen.+9010::Ungültiger Signaturaufbau?: Fehler im Segmentaufbau.'HNHBS:3:1+1'
Traceback (most recent call last):
        7: from /usr/local/bin/irb:23:in `<main>'
        6: from /usr/local/bin/irb:23:in `load'
        5: from /usr/local/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
        4: from (irb):5
        3: from /usr/local/bundle/gems/ruby_fints-0.0.4/lib/fints/client.rb:19:in `get_sepa_accounts'
        2: from /usr/local/bundle/gems/ruby_fints-0.0.4/lib/fints/dialog.rb:39:in `sync'
        1: from /usr/local/bundle/gems/ruby_fints-0.0.4/lib/fints/dialog.rb:83:in `send_msg'
FinTS::DialogError ({"9800"=>"Der Dialog wurde abgebrochen.", "9010"=>"Ung\u00FCltiger Signaturaufbau?: Fehler im Segmentaufbau."})

Apparently this is working fine for others. Is there anything I can do to further debug this issue? I can successfully authenticate to my account via MoneyMoney using the same credentials.

Thanks for any help in advance!

A transaction's entry_date might be a year before its date

I have some transactions that happened late last year (2018) that were booked in 2019. The transaction's entry_date shows up as a year before the actual entry date.

[
    [0] {
                     "sha" => "6935c51e4bcde81c7492431bbdab9f6f4a7830c6b1635ea704de2b53a0b55d2f",
                    "date" => Mon, 31 Dec 2018,
              "entry_date" => Tue, 02 Jan 2018,
                  "amount" => 46.4,
         "amount_in_cents" => 4640,
                    "sign" => -1,
                   "debit" => true,
                  "credit" => false,
                  "storno" => false,
              "funds_code" => "D",
              "swift_code" => "NMSC",
               "reference" => "NONREF",
          "bank_reference" => "",
         "currency_letter" => nil,
                     "bic" => nil,
                    "iban" => nil,
                    "name" => "does not matter",
                    "sepa" => {},
             "information" => "does not matter",
             "description" => "does not matter",
              "sub_fields" => {
            "20" => "does not matter",
            "32" => "does not matter",
            "33" => "does not matter"
        },
        "transaction_code" => "835",
                 "details" => "does not matter"
    }
]

This seems to be related to railslove/cmxl#28 which was resolved in railslove/cmxl#32 as of cmxl 1.4.1. Can you please update the dependency?

"Wrong line format" error with comdirect

Hi,

I just came over from gitviola/ynab-bank-importer#43 where @schurig recommended to open an issue here.

I get the following error:

/usr/local/bundle/gems/cmxl-0.2.1/lib/cmxl/field.rb:51:in `parse': Wrong line format: ":              ?249,999?25FLOSSB.V.STORCH-MUL.OPP.R?26A0M430EUR 1,60?27ABR.BETRAG BRUTTO 13,07 EUR?28STEUERABZUG 2,93- EUR?29Ref. 2PF199999999992/4" (Cmxl::Field::LineFormatError)

(sensitive parts overwritten with 9s)

The transaction seems to be this one in the comdirect web interface:

bildschirmfoto 2019-01-09 um 08 35 36

Any help?

ING-Diba error

When using ruby_fints with ING-Diba it throws this error:

/usr/local/bundle/gems/ruby_fints-0.0.1/lib/fints/response.rb:28:in `get_summary_by_segment': segment HIRMG (FinTS::SegmentNotFoundError)
	from /usr/local/bundle/gems/ruby_fints-0.0.1/lib/fints/response.rb:38:in `successful?'
	from /usr/local/bundle/gems/ruby_fints-0.0.1/lib/fints/dialog.rb:82:in `send_msg'
	from /usr/local/bundle/gems/ruby_fints-0.0.1/lib/fints/dialog.rb:39:in `sync'
	from /usr/local/bundle/gems/ruby_fints-0.0.1/lib/fints/client.rb:19:in `get_sepa_accounts'

Do you have any idea why this happens? I tried it with the php lib and it worked fine.

problem getting statement with Targobank

I'm having a weird issue with Targobank. I can connect, list accounts, get balance, but when I try to get statements it's always empty, whichever date range I use...

I thought about posting debug info here, but a bit hesitating to do it for security reasons. I can sanitize some obvious stuff like my username and password, but not sure what other sensitive information might be encoded in those messages...

When I use Ing Diba, it all works fine for exactly the same code (just different account details obviously)

Any tips on what I could do to debug this? Is this some weird implementation issue on Targo's end?

Broken since PSD2

After PSD2 has been enabled on September 12 the library no longer works although strong authentication has been completed once in the 90-day timeframe. Can you please adjust the code so it works again?

Errors look like this (netbank):

FinTS::DialogError:
       {"9050"=>"Die Nachricht enthält Fehler.", "9075"=>"Starke Kundenauthentifizierung notwendig.", "9800"=>"Dialog abgebrochen", "9340"=>"Ungültige Auftragsnachricht?: Ungültige Signatur."}

Renault Bank:

FinTS::DialogError:
       {"9050"=>"Die Nachricht enthält Fehler. (TRE)", "9075"=>"Starke Kundenauthentifizierung notwendig. (TRE)", "9800"=>"Dialog abgebrochen (TRE)", "9340"=>"Auftrag abgelehnt. (TRE)"}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.