Sepa Reason Codes GEM
Working with Ebics (Electronic Banking Internet Communication Standard) and European banking transactions, you may have come across with SEPA Reason Codes.
I am not going to explain their role within Ebics as it’s already very well explained by European council here.
Basically, they are codes that are used in exception handling of bank transactions. When something goes wrong, they have a code for it.
When I was working with a client, I had to parse and update transactions in their system by reading their bank statements within a Rails application. I had to:
- Parse the bank statement and find the reason code
- Identify what the code actually means in order to save it in the transactions table
I had a hard time for finding a complete list, parsing and using information about SEPA Reason Codes.
After digging a little while, found this source, fixed a few typos here and there and finished the feature.
Solution - SepaReasonCodes GEM
So, I created
SepaReasonCodes gem today in case you also have this problem and can make use of it.
Add this to your gemfile
No magic here! Just pass in the reason code and get back a SepaReasonCodes::Code instance with all required information.
reason_code = SepaReasonCodes.find("AC01") puts reason_code.code # AC01 puts reason_code.iso_name # Incorrect Account Number puts reason_code.description # Account number is invalid or missing. puts reason_code.probable_status # declined
SepaReasonCodes does not have any dependency or magic. Just check lib/reason_codes.yml to see the list of all reason codes.
You can also retrieve the complete list of codes by running:
which will return a collection of
Thank you for checking
SepaReasonCodes out and hope it can be of any use for you or your project!