sepa_king_extended 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +30 -0
  5. data/CONTRIBUTING.md +38 -0
  6. data/Gemfile +2 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +267 -0
  9. data/Rakefile +6 -0
  10. data/gemfiles/Gemfile-activemodel-3.0.x +5 -0
  11. data/gemfiles/Gemfile-activemodel-3.1.x +5 -0
  12. data/gemfiles/Gemfile-activemodel-3.2.x +5 -0
  13. data/gemfiles/Gemfile-activemodel-4.0.x +5 -0
  14. data/gemfiles/Gemfile-activemodel-4.1.x +5 -0
  15. data/gemfiles/Gemfile-activemodel-4.2.x +5 -0
  16. data/gemfiles/Gemfile-activemodel-5.0.x +5 -0
  17. data/gemfiles/Gemfile-activemodel-5.1.x +5 -0
  18. data/lib/schema/pain.001.001.03.xsd +921 -0
  19. data/lib/schema/pain.001.002.03.xsd +450 -0
  20. data/lib/schema/pain.001.003.03.xsd +474 -0
  21. data/lib/schema/pain.008.001.02.xsd +879 -0
  22. data/lib/schema/pain.008.002.02.xsd +597 -0
  23. data/lib/schema/pain.008.003.02.xsd +614 -0
  24. data/lib/sepa_king/account/creditor_account.rb +8 -0
  25. data/lib/sepa_king/account/debtor_account.rb +5 -0
  26. data/lib/sepa_king/account.rb +19 -0
  27. data/lib/sepa_king/converter.rb +51 -0
  28. data/lib/sepa_king/message/credit_transfer.rb +99 -0
  29. data/lib/sepa_king/message/direct_debit.rb +151 -0
  30. data/lib/sepa_king/message.rb +135 -0
  31. data/lib/sepa_king/transaction/credit_transfer_transaction.rb +30 -0
  32. data/lib/sepa_king/transaction/direct_debit_transaction.rb +45 -0
  33. data/lib/sepa_king/transaction.rb +44 -0
  34. data/lib/sepa_king/validator.rb +68 -0
  35. data/lib/sepa_king/version.rb +3 -0
  36. data/lib/sepa_king.rb +16 -0
  37. data/sepa_king_extended.gemspec +32 -0
  38. data/spec/account_spec.rb +42 -0
  39. data/spec/converter_spec.rb +74 -0
  40. data/spec/credit_transfer_spec.rb +364 -0
  41. data/spec/credit_transfer_transaction_spec.rb +58 -0
  42. data/spec/creditor_account_spec.rb +23 -0
  43. data/spec/debtor_account_spec.rb +12 -0
  44. data/spec/direct_debit_spec.rb +469 -0
  45. data/spec/direct_debit_transaction_spec.rb +69 -0
  46. data/spec/examples/pain.001.001.03.xml +89 -0
  47. data/spec/examples/pain.001.002.03.xml +89 -0
  48. data/spec/examples/pain.001.003.03.xml +89 -0
  49. data/spec/examples/pain.008.002.02.xml +134 -0
  50. data/spec/examples/pain.008.003.02.xml +134 -0
  51. data/spec/message_spec.rb +88 -0
  52. data/spec/spec_helper.rb +33 -0
  53. data/spec/support/active_model.rb +30 -0
  54. data/spec/support/custom_matcher.rb +60 -0
  55. data/spec/support/factories.rb +24 -0
  56. data/spec/support/validations.rb +27 -0
  57. data/spec/transaction_spec.rb +88 -0
  58. data/spec/validation_spec.rb +25 -0
  59. data/spec/validator_spec.rb +99 -0
  60. metadata +254 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 68e290efdadafcefde07e7dfd18d52d0f028984a
4
+ data.tar.gz: 8ee6a6c2e0c2fe238eb29a76c90380fcf5b9e533
5
+ SHA512:
6
+ metadata.gz: df42581c1870f90fa12c018d5eb5ab86561fe7a00be3ce14aaf7ffd8be268e2543407d9c4c9ba1e9f41d95d3be9b1d31a75534360c185d577d814fed54e963cd
7
+ data.tar.gz: bd9b798d22a70f1869dd7ed70cc6bd25fb062b1874f40ea6adae1ece7427ea5ce60462c3e95b824439ce482eb21c068c1c8097154808151e23daafbac149aacf
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ nbproject/*
2
+ .rvmrc
3
+ coverage/*
4
+ rdoc/*
5
+ pkg/*
6
+ .DS_Store
7
+ Gemfile.lock
8
+ # tmp disable
9
+ docs/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,30 @@
1
+ rvm:
2
+ - 2.0.0
3
+ - 2.1.10
4
+ - 2.2.8
5
+ - 2.3.5
6
+ - 2.4.2
7
+ gemfile:
8
+ - gemfiles/Gemfile-activemodel-3.0.x
9
+ - gemfiles/Gemfile-activemodel-3.1.x
10
+ - gemfiles/Gemfile-activemodel-3.2.x
11
+ - gemfiles/Gemfile-activemodel-4.0.x
12
+ - gemfiles/Gemfile-activemodel-4.1.x
13
+ - gemfiles/Gemfile-activemodel-4.2.x
14
+ - gemfiles/Gemfile-activemodel-5.0.x
15
+ - gemfiles/Gemfile-activemodel-5.1.x
16
+ matrix:
17
+ exclude:
18
+ - rvm: 2.0.0
19
+ gemfile: gemfiles/Gemfile-activemodel-5.1.x
20
+ - rvm: 2.1.10
21
+ gemfile: gemfiles/Gemfile-activemodel-5.1.x
22
+ - rvm: 2.0.0
23
+ gemfile: gemfiles/Gemfile-activemodel-5.0.x
24
+ - rvm: 2.1.10
25
+ gemfile: gemfiles/Gemfile-activemodel-5.0.x
26
+ - rvm: 2.4.2
27
+ gemfile: gemfiles/Gemfile-activemodel-4.1.x
28
+ - rvm: 2.4.2
29
+ gemfile: gemfiles/Gemfile-activemodel-4.2.x
30
+ sudo: false
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,38 @@
1
+ We love pull requests. Here's a quick guide:
2
+
3
+ 1. Fork the repo.
4
+
5
+ 2. Run the tests. We only take pull requests with passing tests, and it's great
6
+ to know that you have a clean slate: `bundle && rake`
7
+
8
+ 3. Add a test for your change. Only refactoring and documentation changes
9
+ require no new tests. If you are adding functionality or fixing a bug, we need
10
+ a test!
11
+
12
+ 4. Make the test pass.
13
+
14
+ 5. Push to your fork and submit a pull request.
15
+
16
+
17
+ At this point you're waiting on us. We like to at least comment on, if not
18
+ accept, pull requests within three business days (and, typically, one business
19
+ day). We may suggest some changes or improvements or alternatives.
20
+
21
+ Some things that will increase the chance that your pull request is accepted,
22
+ taken straight from the Ruby on Rails guide:
23
+
24
+ * Use Rails idioms and helpers
25
+ * Include tests that fail without your code, and pass with it
26
+ * Update the documentation, the surrounding one, examples elsewhere, guides,
27
+ whatever is affected by your contribution
28
+
29
+ Syntax:
30
+
31
+ * Two spaces, no tabs.
32
+ * No trailing whitespace. Blank lines should not have any space.
33
+ * Prefer &&/|| over and/or.
34
+ * MyClass.my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
35
+ * a = b and not a=b.
36
+ * Follow the conventions you see used in the source already.
37
+
38
+ And in case we didn't emphasize it enough: we love tests!
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013-2017 Georg Leciejewski (Sales King GmbH) & Georg Ledermann
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,267 @@
1
+ # Ruby gem for creating SEPA XML files
2
+
3
+ [![Build Status](https://travis-ci.org/salesking/sepa_king.svg)](http://travis-ci.org/salesking/sepa_king)
4
+ [![Code Climate](https://codeclimate.com/github/salesking/sepa_king/badges/gpa.svg)](https://codeclimate.com/github/salesking/sepa_king)
5
+ [![Coverage Status](https://coveralls.io/repos/salesking/sepa_king/badge.svg?branch=master)](https://coveralls.io/r/salesking/sepa_king?branch=master)
6
+ [![Gem Version](https://badge.fury.io/rb/sepa_king.svg)](http://badge.fury.io/rb/sepa_king)
7
+ [![Dependency Status](https://gemnasium.com/salesking/sepa_king.svg)](https://gemnasium.com/salesking/sepa_king)
8
+
9
+ We love building payment applications! So after developing the [DTAUS library for Ruby](https://github.com/salesking/king_dtaus) we move on with SEPA.
10
+
11
+
12
+ ## Features
13
+
14
+ This gem implements the following two messages out of the ISO 20022 standard:
15
+
16
+ * Credit Transfer Initiation (`pain.001.003.03`, `pain.001.002.03` and `pain.001.001.03`)
17
+ * Direct Debit Initiation (`pain.008.003.02`, `pain.008.002.02` and `pain.008.001.02`)
18
+
19
+ It handles the _Specification of Data Formats_ v2.7 (2013-11-04).
20
+
21
+ BTW: **pain** is a shortcut for **Pa**yment **In**itiation.
22
+
23
+
24
+ ## Requirements
25
+
26
+ * Ruby 2.0.0 or newer
27
+ * ActiveModel 3.0 or newer
28
+
29
+
30
+ ## Installation
31
+
32
+ gem install sepa_king
33
+
34
+
35
+ ## Usage
36
+
37
+ How to create the XML for **Direct Debit Initiation** (in German: "Lastschriften")
38
+
39
+ ```ruby
40
+ # First: Create the main object
41
+ sdd = SEPA::DirectDebit.new(
42
+ # Name of the initiating party and creditor, in German: "Auftraggeber"
43
+ # String, max. 70 char
44
+ name: 'Gläubiger GmbH',
45
+
46
+ # OPTIONAL: Business Identifier Code (SWIFT-Code) of the creditor
47
+ # String, 8 or 11 char
48
+ bic: 'BANKDEFFXXX',
49
+
50
+ # International Bank Account Number of the creditor
51
+ # String, max. 34 chars
52
+ iban: 'DE87200500001234567890',
53
+
54
+ # Creditor Identifier, in German: Gläubiger-Identifikationsnummer
55
+ # String, max. 35 chars
56
+ creditor_identifier: 'DE98ZZZ09999999999'
57
+ )
58
+
59
+ # Second: Add transactions
60
+ sdd.add_transaction(
61
+ # Name of the debtor, in German: "Zahlungspflichtiger"
62
+ # String, max. 70 char
63
+ name: 'Zahlemann & Söhne GbR',
64
+
65
+ # OPTIONAL: Business Identifier Code (SWIFT-Code) of the debtor's account
66
+ # String, 8 or 11 char
67
+ bic: 'SPUEDE2UXXX',
68
+
69
+ # International Bank Account Number of the debtor's account
70
+ # String, max. 34 chars
71
+ iban: 'DE21500500009876543210',
72
+
73
+ # Amount
74
+ # Number with two decimal digit
75
+ amount: 39.99,
76
+
77
+ # OPTIONAL: Currency, EUR by default (ISO 4217 standard)
78
+ # String, 3 char
79
+ currency: 'EUR',
80
+
81
+ # OPTIONAL: Instruction Identification, will not be submitted to the debtor
82
+ # String, max. 35 char
83
+ instruction: '12345',
84
+
85
+ # OPTIONAL: End-To-End-Identification, will be submitted to the debtor
86
+ # String, max. 35 char
87
+ reference: 'XYZ/2013-08-ABO/6789',
88
+
89
+ # OPTIONAL: Unstructured remittance information, in German "Verwendungszweck"
90
+ # String, max. 140 char
91
+ remittance_information: 'Vielen Dank für Ihren Einkauf!',
92
+
93
+ # Mandate identifikation, in German "Mandatsreferenz"
94
+ # String, max. 35 char
95
+ mandate_id: 'K-02-2011-12345',
96
+
97
+ # Mandate Date of signature, in German "Datum, zu dem das Mandat unterschrieben wurde"
98
+ # Date
99
+ mandate_date_of_signature: Date.new(2011,1,25),
100
+
101
+ # Local instrument, in German "Lastschriftart"
102
+ # One of these strings:
103
+ # 'CORE' ("Basis-Lastschrift")
104
+ # 'COR1' ("Basis-Lastschrift mit verkürzter Vorlagefrist")
105
+ # 'B2B' ("Firmen-Lastschrift")
106
+ local_instrument: 'CORE',
107
+
108
+ # Sequence type
109
+ # One of these strings:
110
+ # 'FRST' ("Erst-Lastschrift")
111
+ # 'RCUR' ("Folge-Lastschrift")
112
+ # 'OOFF' ("Einmalige Lastschrift")
113
+ # 'FNAL' ("Letztmalige Lastschrift")
114
+ sequence_type: 'OOFF',
115
+
116
+ # OPTIONAL: Requested collection date, in German "Fälligkeitsdatum der Lastschrift"
117
+ # Date
118
+ requested_date: Date.new(2013,9,5),
119
+
120
+ # OPTIONAL: Enables or disables batch booking, in German "Sammelbuchung / Einzelbuchung"
121
+ # True or False
122
+ batch_booking: true
123
+
124
+ # OPTIONAL: Use a different creditor account
125
+ # CreditorAccount
126
+ creditor_account: SEPA::CreditorAccount.new(
127
+ name: 'Creditor Inc.',
128
+ bic: 'RABONL2U',
129
+ iban: 'NL08RABO0135742099',
130
+ creditor_identifier: 'NL53ZZZ091734220000'
131
+ )
132
+ )
133
+ sdd.add_transaction ...
134
+
135
+ # Last: create XML string
136
+ xml_string = sdd.to_xml # Use latest schema pain.008.003.02
137
+ xml_string = sdd.to_xml('pain.008.002.02') # Use former schema pain.008.002.02
138
+ ```
139
+
140
+
141
+ How to create the XML for **Credit Transfer Initiation** (in German: "Überweisungen")
142
+
143
+ ```ruby
144
+ # First: Create the main object
145
+ sct = SEPA::CreditTransfer.new(
146
+ # Name of the initiating party and debtor, in German: "Auftraggeber"
147
+ # String, max. 70 char
148
+ name: 'Schuldner GmbH',
149
+
150
+ # OPTIONAL: Business Identifier Code (SWIFT-Code) of the debtor
151
+ # String, 8 or 11 char
152
+ bic: 'BANKDEFFXXX',
153
+
154
+ # International Bank Account Number of the debtor
155
+ # String, max. 34 chars
156
+ iban: 'DE87200500001234567890'
157
+ )
158
+
159
+ # Second: Add transactions
160
+ sct.add_transaction(
161
+ # Name of the creditor, in German: "Zahlungsempfänger"
162
+ # String, max. 70 char
163
+ name: 'Telekomiker AG',
164
+
165
+ # OPTIONAL: Business Identifier Code (SWIFT-Code) of the creditor's account
166
+ # String, 8 or 11 char
167
+ bic: 'PBNKDEFF370',
168
+
169
+ # International Bank Account Number of the creditor's account
170
+ # String, max. 34 chars
171
+ iban: 'DE37112589611964645802',
172
+
173
+ # Amount
174
+ # Number with two decimal digit
175
+ amount: 102.50,
176
+
177
+ # OPTIONAL: Currency, EUR by default (ISO 4217 standard)
178
+ # String, 3 char
179
+ currency: 'EUR',
180
+
181
+ # OPTIONAL: Instruction Identification, will not be submitted to the creditor
182
+ # String, max. 35 char
183
+ instruction: '12345',
184
+
185
+ # OPTIONAL: End-To-End-Identification, will be submitted to the creditor
186
+ # String, max. 35 char
187
+ reference: 'XYZ-1234/123',
188
+
189
+ # OPTIONAL: Unstructured remittance information, in German "Verwendungszweck"
190
+ # String, max. 140 char
191
+ remittance_information: 'Rechnung vom 22.08.2013',
192
+
193
+ # OPTIONAL: Requested execution date, in German "Ausführungstermin"
194
+ # Date
195
+ requested_date: Date.new(2013,9,5),
196
+
197
+ # OPTIONAL: Enables or disables batch booking, in German "Sammelbuchung / Einzelbuchung"
198
+ # True or False
199
+ batch_booking: true,
200
+
201
+ # OPTIONAL: Urgent Payment
202
+ # One of these strings:
203
+ # 'SEPA' ("SEPA-Zahlung")
204
+ # 'URGP' ("Taggleiche Eilüberweisung")
205
+ service_level: 'URGP'
206
+ )
207
+ sct.add_transaction ...
208
+
209
+ # Last: create XML string
210
+ xml_string = sct.to_xml # Use latest schema pain.001.003.03
211
+ xml_string = sct.to_xml('pain.001.002.03') # Use former schema pain.001.002.03
212
+ ```
213
+
214
+ ## Validations
215
+
216
+ You can rely on our internal validations, raising errors when needed, during
217
+ message creation.
218
+ To validate your models holding SEPA related information (e.g. BIC, IBAN,
219
+ mandate_id) you can use our validator classes or rely on some constants.
220
+
221
+ Examples:
222
+
223
+ ```ruby
224
+ class BankAccount < ActiveRecord::Base
225
+ # IBAN validation, by default it validates the attribute named "iban"
226
+ validates_with SEPA::IBANValidator, field_name: :iban_the_terrible
227
+
228
+ # BIC validation, by default it validates the attribute named "bic"
229
+ validates_with SEPA::BICValidator, field_name: :bank_bic
230
+ end
231
+
232
+ class Payment < ActiveRecord::Base
233
+ validates_inclusion_of :sepa_sequence_type, in: SEPA::DirectDebitTransaction::SEQUENCE_TYPES
234
+
235
+ # Mandate ID validation, by default it validates the attribute named "mandate_id"
236
+ validates_with SEPA::MandateIdentifierValidator, field_name: :mandate_id
237
+ end
238
+ ```
239
+
240
+ **Beware:** The SEPA::IBANValidator is strict - e.g. it does not allow any spaces in the IBAN.
241
+
242
+ Also see:
243
+ * [lib/sepa_king/validator.rb](https://github.com/salesking/sepa_king/blob/master/lib/sepa_king/validator.rb)
244
+ * [lib/sepa_king/transaction/direct_debit_transaction.rb](https://github.com/salesking/sepa_king/blob/master/lib/sepa_king/transaction/direct_debit_transaction.rb)
245
+
246
+
247
+ ## Changelog
248
+
249
+ https://github.com/salesking/sepa_king/releases
250
+
251
+
252
+ ## Contributors
253
+
254
+ https://github.com/salesking/sepa_king/graphs/contributors
255
+
256
+
257
+ ## Resources
258
+
259
+ * http://www.ebics.de/index.php?id=77
260
+ * SalesKing: http://salesking.eu
261
+
262
+
263
+ ## License
264
+
265
+ Released under the MIT license
266
+
267
+ Copyright (c) 2013-2017 Georg Leciejewski (SalesKing), Georg Ledermann (https://github.com/ledermann)
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'activemodel', '~>3.0.20'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'activemodel', '~>3.1.12'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'activemodel', '~>3.2.22.2'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'activemodel', '~>4.0.13'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'activemodel', '~>4.1.15'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'activemodel', '~>4.2.6'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'activemodel', '~> 5.0.0'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'activemodel', '~> 5.1.0'