<commit_before># Ruby gem for creating SEPA XML files

[![Build Status](https://secure.travis-ci.org/salesking/sepa_king.png)](http://travis-ci.org/salesking/sepa_king)
[![Code Climate](https://codeclimate.com/github/salesking/sepa_king.png)](https://codeclimate.com/github/salesking/sepa_king)
[![Coverage Status](https://coveralls.io/repos/salesking/sepa_king/badge.png)](https://coveralls.io/r/salesking/sepa_king)

We love building payment applications! So after developing the [DTAUS library for Ruby](https://github.com/salesking/king_dtaus) we move on with SEPA.


## Features

* Credit transfer initiation (pain.001.002.03)
* Debit transfer initiation (pain.008.002.02)
* Tested with Ruby 1.9.3 and 2.0.0


## Installation

    gem install sepa_king


## Usage

How to create the XML for **Direct Debit Initiation** (in German: "Lastschriften")

```ruby
# First: Create the main object
sdd = SEPA::DirectDebit.new(
  name:       'Gläubiger GmbH',
  # Name of the initiating party and creditor, in German: "Auftraggeber"
  # String, max. 70 char

  bic:        'BANKDEFFXXX',
  # Business Identifier Code (SWIFT-Code) of the creditor
  # String, 8 or 11 char

  iban:       'DE87200500001234567890',
  # International Bank Account Number of the creditor
  # String, max. 34 chars

  creditor_identifier: 'DE98ZZZ09999999999'
  # Creditor Identifier, in German: Gläubiger-Identifikationsnummer
  # String, max. 35 chars
)

# Second: Add transactions
sdd.add_transaction(
  name:                      'Zahlemann & <NAME>',
  # Name of the debitor, in German: "Zahlungspflichtiger"
  # String, max. 70 char

  bic:                       'SPUEDE2UXXX',
  # Business Identifier Code (SWIFT-Code) of the debitor's account
  # String, 8 or 11 char

  iban:                      'DE21500500009876543210',
  # International Bank Account Number of the debitor's account
  # String, max. 34 chars

  amount:                    39.99,
  # Amount in EUR
  # Number with two decimal digit

  reference:                 'XYZ/2013-08-ABO/6789',
  # OPTIONAL: End-To-End-Identification, will be submitted to the debitor
  # String, max. 35 char

  remittance_information:    'Vielen Dank für Ihren Einkauf!',
  # OPTIONAL: Unstructured remittance Information, in German "Verwendungszweck"
  # String, max. 140 char

  mandate_id:                'K-02-2011-12345',
  # Mandate identifikation, in German "Mandatsreferenz"
  # String, max. 35 char

  mandate_date_of_signature: Date.new(2011,1,25)
  # Mandate Date of signature, in German "Datum, zu dem das Mandat unterschrieben wurde"
  # Date
)
sdd.add_transaction ...

# Last: create XML string
xml_string = sdd.to_xml
```


How to create the XML for **Credit Transfer Initiation** (in german: "Überweisungen")

```ruby
# First: Create the main object
sct = SEPA::CreditTransfer.new(
  name: 'Schuldner GmbH',
  # Name of the initiating party and debitor, in German: "Auftraggeber"<commit_msg>Readme: More options documented<commit_after># Ruby gem for creating SEPA XML files

[![Build Status](https://secure.travis-ci.org/salesking/sepa_king.png)](http://travis-ci.org/salesking/sepa_king)
[![Code Climate](https://codeclimate.com/github/salesking/sepa_king.png)](https://codeclimate.com/github/salesking/sepa_king)
[![Coverage Status](https://coveralls.io/repos/salesking/sepa_king/badge.png)](https://coveralls.io/r/salesking/sepa_king)

We love building payment applications! So after developing the [DTAUS library for Ruby](https://github.com/salesking/king_dtaus) we move on with SEPA.


## Features

* Credit transfer initiation (pain.001.002.03)
* Debit transfer initiation (pain.008.002.02)
* Tested with Ruby 1.9.3 and 2.0.0


## Installation

    gem install sepa_king


## Usage

How to create the XML for **Direct Debit Initiation** (in German: "Lastschriften")

```ruby
# First: Create the main object
sdd = SEPA::DirectDebit.new(
  name:       'Gläubiger GmbH',
  # Name of the initiating party and creditor, in German: "Auftraggeber"
  # String, max. 70 char

  bic:        'BANKDEFFXXX',
  # Business Identifier Code (SWIFT-Code) of the creditor
  # String, 8 or 11 char

  iban:       'DE87200500001234567890',
  # International Bank Account Number of the creditor
  # String, max. 34 chars

  creditor_identifier: 'DE98ZZZ09999999999'
  # Creditor Identifier, in German: Gläubiger-Identifikationsnummer
  # String, max. 35 chars
)

# Second: Add transactions
sdd.add_transaction(
  name:                      'Zahlemann & <NAME>',
  # Name of the debitor, in German: "Zahlungspflichtiger"
  # String, max. 70 char

  bic:                       'SPUEDE2UXXX',
  # Business Identifier Code (SWIFT-Code) of the debitor's account
  # String, 8 or 11 char

  iban:                      'DE21500500009876543210',
  # International Bank Account Number of the debitor's account
  # String, max. 34 chars

  amount:                    39.99,
  # Amount in EUR
  # Number with two decimal digit

  reference:                 'XYZ/2013-08-ABO/6789',
  # OPTIONAL: End-To-End-Identification, will be submitted to the debitor
  # String, max. 35 char

  remittance_information:    'Vielen Dank für Ihren Einkauf!',
  # OPTIONAL: Unstructured remittance Information, in German "Verwendungszweck"
  # String, max. 140 char

  mandate_id:                'K-02-2011-12345',
  # Mandate identifikation, in German "Mandatsreferenz"
  # String, max. 35 char

  mandate_date_of_signature: Date.new(2011,1,25)
  # Mandate Date of signature, in German "Datum, zu dem das Mandat unterschrieben wurde"
  # Date

  local_instrument: 'CORE'
  # Local instrument, in German "Lastschriftart"
  # One of this strings:
  #   'CORE' ("Basis-Lastschrift")
  #   'B2B' ("Firmen-Lastschrift")

  sequence_type: 'OOFF'
  # Sequence type
  # One of this strings:
  #   'FRST' ("Erst-Lastschrift")
  #   'RCUR' ("Folge-Lastschrift")
  #   'OOFF' ("Einmalige Lastschrift")
  #   'FNAL' ("Letztmalige Lastschrift")

  requested_date: Date.new(2013,9,5)
  # OPTIONAL: Requested collection date, in German "Fälligkeitsdatum der Lastschrift"
  # Date

  batch_booking: true
  # OPTIONAL: Enables or disables batch booking, in German "Sammelbuchung / Einzelbuchung"
)
sdd.add_transaction ...

# Last: create XML string
xml_string = sdd.to_xml
```


How to create the XML for **Credit Transfer Initiation** (in german: "Überweisungen")

```ruby
# First: Create the main object
sct = SEPA::CreditTransfer.new(
  name: '<NAME>',
  # Name of the initiating party and debitor, in German: "Auftraggeber"
{'fraction_non_alphanumeric': 0.10884249309180227, 'fraction_numerical': 0.041295670862757136, 'mean_word_length': 3.5243055555555554, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '842408', 'n_tokens_mistral': 2460, 'n_tokens_neox': 2164, 'n_words': 622}