sepa_king_codeur 0.12.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +37 -0
  5. data/CONTRIBUTING.md +38 -0
  6. data/Gemfile +2 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +297 -0
  9. data/Rakefile +6 -0
  10. data/gemfiles/Gemfile-activemodel-3.1.x +5 -0
  11. data/gemfiles/Gemfile-activemodel-3.2.x +5 -0
  12. data/gemfiles/Gemfile-activemodel-4.0.x +5 -0
  13. data/gemfiles/Gemfile-activemodel-4.1.x +5 -0
  14. data/gemfiles/Gemfile-activemodel-4.2.x +5 -0
  15. data/gemfiles/Gemfile-activemodel-5.0.x +5 -0
  16. data/gemfiles/Gemfile-activemodel-5.1.x +5 -0
  17. data/gemfiles/Gemfile-activemodel-5.2.x +5 -0
  18. data/gemfiles/Gemfile-activemodel-6.0.x +5 -0
  19. data/lib/schema/pain.001.001.03.ch.02.xsd +1212 -0
  20. data/lib/schema/pain.001.001.03.xsd +921 -0
  21. data/lib/schema/pain.001.002.03.xsd +450 -0
  22. data/lib/schema/pain.001.003.03.xsd +474 -0
  23. data/lib/schema/pain.008.001.02.xsd +879 -0
  24. data/lib/schema/pain.008.002.02.xsd +597 -0
  25. data/lib/schema/pain.008.003.02.xsd +614 -0
  26. data/lib/sepa_king.rb +19 -0
  27. data/lib/sepa_king/account.rb +19 -0
  28. data/lib/sepa_king/account/creditor_account.rb +8 -0
  29. data/lib/sepa_king/account/creditor_address.rb +37 -0
  30. data/lib/sepa_king/account/debtor_account.rb +5 -0
  31. data/lib/sepa_king/account/debtor_address.rb +37 -0
  32. data/lib/sepa_king/converter.rb +51 -0
  33. data/lib/sepa_king/error.rb +4 -0
  34. data/lib/sepa_king/message.rb +169 -0
  35. data/lib/sepa_king/message/credit_transfer.rb +137 -0
  36. data/lib/sepa_king/message/direct_debit.rb +207 -0
  37. data/lib/sepa_king/transaction.rb +56 -0
  38. data/lib/sepa_king/transaction/credit_transfer_transaction.rb +31 -0
  39. data/lib/sepa_king/transaction/direct_debit_transaction.rb +56 -0
  40. data/lib/sepa_king/validator.rb +57 -0
  41. data/lib/sepa_king/version.rb +3 -0
  42. data/sepa_king.gemspec +33 -0
  43. data/spec/account_spec.rb +42 -0
  44. data/spec/converter_spec.rb +74 -0
  45. data/spec/credit_transfer_spec.rb +520 -0
  46. data/spec/credit_transfer_transaction_spec.rb +74 -0
  47. data/spec/creditor_account_spec.rb +23 -0
  48. data/spec/debtor_account_spec.rb +12 -0
  49. data/spec/debtor_address_spec.rb +12 -0
  50. data/spec/direct_debit_spec.rb +657 -0
  51. data/spec/direct_debit_transaction_spec.rb +69 -0
  52. data/spec/examples/pain.001.001.03.ch.02.xml +172 -0
  53. data/spec/examples/pain.001.001.03.xml +89 -0
  54. data/spec/examples/pain.001.002.03.xml +89 -0
  55. data/spec/examples/pain.001.003.03.xml +89 -0
  56. data/spec/examples/pain.008.002.02.xml +134 -0
  57. data/spec/examples/pain.008.003.02.xml +134 -0
  58. data/spec/message_spec.rb +128 -0
  59. data/spec/spec_helper.rb +33 -0
  60. data/spec/support/active_model.rb +30 -0
  61. data/spec/support/custom_matcher.rb +60 -0
  62. data/spec/support/factories.rb +24 -0
  63. data/spec/support/validations.rb +27 -0
  64. data/spec/transaction_spec.rb +134 -0
  65. data/spec/validation_spec.rb +25 -0
  66. data/spec/validator_spec.rb +99 -0
  67. metadata +250 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 57f71b7126e13285e3c08f47dd860f2144924a9f87e9ec4eb3eb121b2a36aa57
4
+ data.tar.gz: 861c233545df462a3bd4ca9d2f3756bc79cefaec0b0c69a967ab0e51f005665b
5
+ SHA512:
6
+ metadata.gz: 32c1f3589e7cf1ff64eafeed22763099ae549aa0ab5053257872868861a50e4f3c35e8066379a3144afb54307c0b0f186b98eb0b490f0c8b08c43622d4db2219
7
+ data.tar.gz: 17b71ed8d94489b00bd90ae0be98eac5fbf8d9f35566e532c3b9ea45328de194ed743a179ec394aebe7daa42a9c6a677b2499445cd0c7fd12c3a9c6ac87e33fd
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,37 @@
1
+ rvm:
2
+ - 2.2.10
3
+ - 2.3.8
4
+ - 2.4.6
5
+ - 2.5.5
6
+ - 2.6.3
7
+ gemfile:
8
+ - gemfiles/Gemfile-activemodel-3.1.x
9
+ - gemfiles/Gemfile-activemodel-3.2.x
10
+ - gemfiles/Gemfile-activemodel-4.0.x
11
+ - gemfiles/Gemfile-activemodel-4.1.x
12
+ - gemfiles/Gemfile-activemodel-4.2.x
13
+ - gemfiles/Gemfile-activemodel-5.0.x
14
+ - gemfiles/Gemfile-activemodel-5.1.x
15
+ - gemfiles/Gemfile-activemodel-5.2.x
16
+ - gemfiles/Gemfile-activemodel-6.0.x
17
+ matrix:
18
+ exclude:
19
+ - rvm: 2.2.10
20
+ gemfile: gemfiles/Gemfile-activemodel-6.0.x
21
+ - rvm: 2.3.8
22
+ gemfile: gemfiles/Gemfile-activemodel-6.0.x
23
+ - rvm: 2.4.6
24
+ gemfile: gemfiles/Gemfile-activemodel-4.1.x
25
+ - rvm: 2.4.6
26
+ gemfile: gemfiles/Gemfile-activemodel-4.2.x
27
+ - rvm: 2.4.6
28
+ gemfile: gemfiles/Gemfile-activemodel-6.0.x
29
+ - rvm: 2.5.5
30
+ gemfile: gemfiles/Gemfile-activemodel-4.1.x
31
+ - rvm: 2.5.5
32
+ gemfile: gemfiles/Gemfile-activemodel-4.2.x
33
+ - rvm: 2.6.3
34
+ gemfile: gemfiles/Gemfile-activemodel-4.1.x
35
+ - rvm: 2.6.3
36
+ gemfile: gemfiles/Gemfile-activemodel-4.2.x
37
+ 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-2019 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,297 @@
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.2 or newer
27
+ * ActiveModel 3.1 or newer (including 6.0)
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
+ # OPTIONAL: Specify the country & address of the debtor (REQUIRED for SEPA debits outside of EU. The individually required fields depend on the target country)
134
+ debtor_address: SEPA::DebtorAddress.new(
135
+ country_code: 'CH',
136
+ # Not required if individual fields are used
137
+ address_line1: 'Mustergasse 123a',
138
+ address_line2: '1234 Musterstadt'
139
+ # Not required if address_line1 and address_line2 are used
140
+ street_name: 'Mustergasse',
141
+ building_number: '123a',
142
+ post_code: '1234',
143
+ town_name: 'Musterstadt'
144
+ )
145
+ )
146
+ sdd.add_transaction ...
147
+
148
+ # Last: create XML string
149
+ xml_string = sdd.to_xml # Use latest schema pain.008.003.02
150
+ xml_string = sdd.to_xml('pain.008.002.02') # Use former schema pain.008.002.02
151
+ ```
152
+
153
+
154
+ How to create the XML for **Credit Transfer Initiation** (in German: "Überweisungen")
155
+
156
+ ```ruby
157
+ # First: Create the main object
158
+ sct = SEPA::CreditTransfer.new(
159
+ # Name of the initiating party and debtor, in German: "Auftraggeber"
160
+ # String, max. 70 char
161
+ name: 'Schuldner GmbH',
162
+
163
+ # OPTIONAL: Business Identifier Code (SWIFT-Code) of the debtor
164
+ # String, 8 or 11 char
165
+ bic: 'BANKDEFFXXX',
166
+
167
+ # International Bank Account Number of the debtor
168
+ # String, max. 34 chars
169
+ iban: 'DE87200500001234567890'
170
+ )
171
+
172
+ # Second: Add transactions
173
+ sct.add_transaction(
174
+ # Name of the creditor, in German: "Zahlungsempfänger"
175
+ # String, max. 70 char
176
+ name: 'Telekomiker AG',
177
+
178
+ # OPTIONAL: Business Identifier Code (SWIFT-Code) of the creditor's account
179
+ # String, 8 or 11 char
180
+ bic: 'PBNKDEFF370',
181
+
182
+ # International Bank Account Number of the creditor's account
183
+ # String, max. 34 chars
184
+ iban: 'DE37112589611964645802',
185
+
186
+ # Amount
187
+ # Number with two decimal digit
188
+ amount: 102.50,
189
+
190
+ # OPTIONAL: Currency, EUR by default (ISO 4217 standard)
191
+ # String, 3 char
192
+ currency: 'EUR',
193
+
194
+ # OPTIONAL: Instruction Identification, will not be submitted to the creditor
195
+ # String, max. 35 char
196
+ instruction: '12345',
197
+
198
+ # OPTIONAL: End-To-End-Identification, will be submitted to the creditor
199
+ # String, max. 35 char
200
+ reference: 'XYZ-1234/123',
201
+
202
+ # OPTIONAL: Unstructured remittance information, in German "Verwendungszweck"
203
+ # String, max. 140 char
204
+ remittance_information: 'Rechnung vom 22.08.2013',
205
+
206
+ # OPTIONAL: Requested execution date, in German "Ausführungstermin"
207
+ # Date
208
+ requested_date: Date.new(2013,9,5),
209
+
210
+ # OPTIONAL: Enables or disables batch booking, in German "Sammelbuchung / Einzelbuchung"
211
+ # True or False
212
+ batch_booking: true,
213
+
214
+ # OPTIONAL: Urgent Payment
215
+ # One of these strings:
216
+ # 'SEPA' ("SEPA-Zahlung")
217
+ # 'URGP' ("Taggleiche Eilüberweisung")
218
+ service_level: 'URGP'
219
+
220
+ # OPTIONAL: Unstructured information to indicate the purpose of the payment
221
+ # String, max. 4 char
222
+ category_purpose: 'SALA',
223
+
224
+ # OPTIONAL: Specify the country & address of the creditor (REQUIRED for SEPA debits outside of EU. The individually required fields depend on the target country)
225
+ creditor_address: SEPA::CreditorAddress.new(
226
+ country_code: 'CH',
227
+ # Not required if individual fields are used
228
+ address_line1: 'Mustergasse 123a',
229
+ address_line2: '1234 Musterstadt'
230
+ # Not required if address_line1 and address_line2 are used
231
+ street_name: 'Mustergasse',
232
+ building_number: '123a',
233
+ post_code: '1234',
234
+ town_name: 'Musterstadt'
235
+ )
236
+ )
237
+ sct.add_transaction ...
238
+
239
+ # Last: create XML string
240
+ xml_string = sct.to_xml # Use latest schema pain.001.003.03
241
+ xml_string = sct.to_xml('pain.001.002.03') # Use former schema pain.001.002.03
242
+ ```
243
+
244
+ ## Validations
245
+
246
+ You can rely on our internal validations, raising errors when needed, during
247
+ message creation.
248
+ To validate your models holding SEPA related information (e.g. BIC, IBAN,
249
+ mandate_id) you can use our validator classes or rely on some constants.
250
+
251
+ Examples:
252
+
253
+ ```ruby
254
+ class BankAccount < ActiveRecord::Base
255
+ # IBAN validation, by default it validates the attribute named "iban"
256
+ validates_with SEPA::IBANValidator, field_name: :iban_the_terrible
257
+
258
+ # BIC validation, by default it validates the attribute named "bic"
259
+ validates_with SEPA::BICValidator, field_name: :bank_bic
260
+ end
261
+
262
+ class Payment < ActiveRecord::Base
263
+ validates_inclusion_of :sepa_sequence_type, in: SEPA::DirectDebitTransaction::SEQUENCE_TYPES
264
+
265
+ # Mandate ID validation, by default it validates the attribute named "mandate_id"
266
+ validates_with SEPA::MandateIdentifierValidator, field_name: :mandate_id
267
+ end
268
+ ```
269
+
270
+ **Beware:** The SEPA::IBANValidator is strict - e.g. it does not allow any spaces in the IBAN.
271
+
272
+ Also see:
273
+ * [lib/sepa_king/validator.rb](https://github.com/salesking/sepa_king/blob/master/lib/sepa_king/validator.rb)
274
+ * [lib/sepa_king/transaction/direct_debit_transaction.rb](https://github.com/salesking/sepa_king/blob/master/lib/sepa_king/transaction/direct_debit_transaction.rb)
275
+
276
+
277
+ ## Changelog
278
+
279
+ https://github.com/salesking/sepa_king/releases
280
+
281
+
282
+ ## Contributors
283
+
284
+ https://github.com/salesking/sepa_king/graphs/contributors
285
+
286
+
287
+ ## Resources
288
+
289
+ * http://www.ebics.de/index.php?id=77
290
+ * SalesKing: http://salesking.eu
291
+
292
+
293
+ ## License
294
+
295
+ Released under the MIT license
296
+
297
+ Copyright (c) 2013-2019 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.1.12'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'activemodel', '~>3.2.22.2'