sepa 0.0.8.1 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,8 +1,21 @@
1
1
  # Sepa
2
2
 
3
- An implementation of pain.008.001.04 CustomerDirectDebitInitiation. WARNING: NO WARRANTY, USE AT YOUR OWN RISK AND PERIL.
3
+ An implementation of pain.008.001 CustomerDirectDebitInitiation - versions 02 and 04. WARNING:
4
+ NO WARRANTY, USE AT YOUR OWN RISK AND PERIL. By using this software, you warrant and represent
5
+ and declare that having studied and examined and tested the source, you are satisfied, sure, and
6
+ certain that the version you use does exactly what you want it to do. This
4
7
 
5
- I wanted to make it as easy as possible to define message types and components so this library will be easy to grow to implement the entire standard.
8
+ MORE WARNING: This is alpha-quality software. The API is not yet stable. New versions will break
9
+ compatibility in unpredictable ways. Use at your own risk and peril.
10
+
11
+ ANOTHER WARNING: While I aim for ISO-20022 compatibility in all its glorious detail, this gem
12
+ implements only a subset of ISO-20022, and possibly does so incorrectly. On top of that, your
13
+ bank's interpretation of ISO-20022 may differ from mine, may require some fields that are
14
+ optional in the ISO specification, and may ignore some other fields that are mandatory in the
15
+ specification.
16
+
17
+ I wanted to make it as easy as possible to define message types and components so this library
18
+ will be easy to grow to implement the entire standard.
6
19
 
7
20
  Implementations of other messages are welcome.
8
21
 
@@ -22,38 +35,43 @@ Or install it yourself as:
22
35
 
23
36
  ## Usage
24
37
 
25
- The simplest way to generate a pain.008.001.04 xml message is to use the DirectDebitOrder module which exposes only the bare essentials. Which
26
- is still a lot, but hey, this is a banking standard, what do you expect.
38
+ The simplest way to generate a pain.008.001 xml message is to use the DirectDebitOrder module
39
+ which exposes only the bare essentials. Which is still a lot, but hey, this is a banking
40
+ standard, what do you expect.
27
41
 
28
- Here's an example, ripped off from the spec, of a direct debit order for payments to a single creditor. You need to provide a list of direct
29
- debits, each with information about the amount, the bank account to debit, and the name and contact details of the debtor. You also need to
30
- provide a "creditor" and "initiator" object, which also contain bank account and contact details. Finally, you need to supply a message identifier.
42
+ Please see the spec for an up-to-date example of api usage. In the pseudo-ruby example below,
43
+ you need to supply a list of direct-debit objects, a creditor object, an initiator object, and
44
+ a message-id.
31
45
 
32
46
  def create_sepa_direct_debit_order direct_debits, creditor, initiator, message_id
33
47
  dd_list = []
34
48
 
35
49
  # for each direct debit you want to order ...
36
50
 
37
- for(each direct_debit to order) do | ... |
38
- bank_account = Sepa::DirectDebitOrder::BankAccount.new direct_debit.iban, direct_debit.bic
39
- debtor = Sepa::DirectDebitOrder::Party.new direct_debit.name, direct_debit.addr, nil, direct_debit.postcode, direct_debit.town, direct_debit.country, direct_debit.contact, direct_debit.phone, direct_debit.email
40
- dd_list << Sepa::DirectDebitOrder::DirectDebit.new debtor, bank_account, end_to_end_id(direct_debit), direct_debit.amount, "EUR"
51
+ for(each dd in direct_debits) do | ... |
52
+ bank_account = Sepa::DirectDebitOrder::BankAccount.new dd.iban, dd.bic
53
+ debtor = Sepa::DirectDebitOrder::Party.new dd.name, dd.addr, nil, dd.postcode, dd.town, dd.country, dd.contact, dd.phone, dd.email
54
+ mandate = Sepa::DirectDebitOrder::MandateInformation.new dd.mandate_id, dd.sig_date, dd.sequence_type
55
+ dd_list << Sepa::DirectDebitOrder::DirectDebit.new debtor, bank_account, dd.end_to_end_id, dd.amount, "EUR", mandate
41
56
  end
42
57
 
43
58
  creditor = Sepa::DirectDebitOrder::Party.new creditor.name, creditor.address, nil, creditor.postcode, creditor.town, creditor.country, creditor.contact, creditor.phone, creditor.email
44
59
 
45
60
  creditor_account = Sepa::DirectDebitOrder::BankAccount.new creditor.iban, creditor.bic
46
61
 
47
- payment = Sepa::DirectDebitOrder::CreditorPayment.new creditor, creditor_account, payment_identifier, collection_date, dd_list
62
+ sepa_identifier = Sepa::DirectDebitOrder::PrivateSepaIdentifier.new creditor.sepa_identifier
63
+
64
+ payment = Sepa::DirectDebitOrder::CreditorPayment.new creditor, creditor_account, payment_identifier, collection_date, sepa_identifier, dd_list
48
65
 
49
66
  initiator = Sepa::DirectDebitOrder::Party.new initiator.identifier, initiator.address, nil, initiator.postcode, initiator.town, initiator.country, initiator.contact, initiator.phone, initiator.email
50
67
 
51
68
  order = Sepa::DirectDebitOrder::Order.new message_id, initiator, [payment]
52
69
 
53
- order.to_xml
70
+ order.to_xml pain_008_001_version: "04"
54
71
  end
55
72
 
56
- The last line returns a string that you will then need to send to your bank one way or another. For example, you might use an EBICS client.
73
+ The last line returns a string that you will then need to send to your bank one way or another. For example, you might use an EBICS client. Or your bank might provide
74
+ software to send the file. Or perhaps you can upload it via their website.
57
75
 
58
76
 
59
77
  ## Contributing
@@ -170,11 +170,17 @@ class Sepa::DirectDebitOrder
170
170
  end
171
171
  end
172
172
 
173
+ class MandateInformation < Struct.new(:identification, :signature_date, :sequence_type); end
174
+
173
175
  class DirectDebit
174
- attr_accessor :debtor, :debtor_account, :end_to_end_id, :amount, :currency, :sequence_type, :mandate_identification
176
+ attr_accessor :debtor, :debtor_account, :end_to_end_id, :amount, :currency, :mandate_info
177
+
178
+ def initialize debtor, debtor_account, end_to_end_id, amount, currency, mandate_info
179
+ @debtor, @debtor_account, @end_to_end_id, @amount, @currency, @mandate_info = debtor, debtor_account, end_to_end_id, amount, currency, mandate_info
180
+ end
175
181
 
176
- def initialize debtor, debtor_account, end_to_end_id, amount, currency, sequence_type, mandate_identification
177
- @debtor, @debtor_account, @end_to_end_id, @amount, @currency, @sequence_type, @mandate_identification = debtor, debtor_account, end_to_end_id, amount, currency, sequence_type, mandate_identification
182
+ def sequence_type
183
+ mandate_info.sequence_type
178
184
  end
179
185
 
180
186
  def to_properties prefix, opts
@@ -182,13 +188,14 @@ class Sepa::DirectDebitOrder
182
188
  "#{prefix}.payment_identification.end_to_end_identification" => end_to_end_id,
183
189
  "#{prefix}.instructed_amount" => ("%.2f" % amount),
184
190
  "#{prefix}.instructed_amount_currency" => "EUR",
185
- "#{prefix}.direct_debit_transaction.mandate_related_information.mandate_identification" => mandate_identification
191
+ "#{prefix}.direct_debit_transaction.mandate_related_information.mandate_identification" => mandate_info.identification,
192
+ "#{prefix}.direct_debit_transaction.mandate_related_information.date_of_signature" => mandate_info.signature_date
186
193
  }
187
194
  hsh = hsh.merge debtor.to_properties("#{prefix}.debtor", opts)
188
195
  hsh = hsh.merge debtor_account.to_properties("#{prefix}.debtor", opts)
189
196
 
190
197
  if opts[:pain_008_001_version] == "04"
191
- hsh["#{prefix}.payment_type_information.sequence_type"] = sequence_type
198
+ hsh["#{prefix}.payment_type_information.sequence_type"] = mandate_info.sequence_type
192
199
  end
193
200
 
194
201
  hsh
data/lib/sepa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sepa
2
- VERSION = "0.0.8.1"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -8,18 +8,21 @@ describe Sepa::DirectDebitOrder do
8
8
  def order sepa_identifier_class
9
9
  bank_account0 = Sepa::DirectDebitOrder::BankAccount.new "FRZIZIPAPARAZZI345789", "FRZZPPKOOKOO"
10
10
  debtor0 = Sepa::DirectDebitOrder::Party.new "DALTON/CONANMR", "64, Livva de Getamire", nil, "30005", "RENNES", "FR", "Conan DALTON", "01234567890", "conan@dalton.sepa.i.hope.this.works"
11
- dd00 = Sepa::DirectDebitOrder::DirectDebit.new debtor0, bank_account0, "MONECOLE REG F13789 PVT 3", 1231.31, "EUR", "RCUR", "mandate-id-0"
12
- dd01 = Sepa::DirectDebitOrder::DirectDebit.new debtor0, bank_account0, "MONECOLE REG F13791 PVT 3", 1133.33, "EUR", "RCUR", "mandate-id-0"
11
+ mandate0 = Sepa::DirectDebitOrder::MandateInformation.new("mandate-id-0", Date.parse("2010-11-18"), "RCUR")
12
+ dd00 = Sepa::DirectDebitOrder::DirectDebit.new debtor0, bank_account0, "MONECOLE REG F13789 PVT 3", 1231.31, "EUR", mandate0
13
+ dd01 = Sepa::DirectDebitOrder::DirectDebit.new debtor0, bank_account0, "MONECOLE REG F13791 PVT 3", 1133.33, "EUR", mandate0
13
14
 
14
15
  bank_account1 = Sepa::DirectDebitOrder::BankAccount.new "FRQUIQUIWIGWAM947551", "FRQQWIGGA"
15
16
  debtor1 = Sepa::DirectDebitOrder::Party.new "ADAMS/SAMUELMR", "256, Livva de Getamire", nil, "75048", "PARIS", "FR", "Samuel ADAMS", "09876543210", "samuel@adams.sepa.i.hope.this.works"
16
- dd10 = Sepa::DirectDebitOrder::DirectDebit.new debtor1, bank_account1, "MONECOLE REG F13790 PVT 3", 1732.32, "EUR", "FRST", "mandate-id-1"
17
- dd11 = Sepa::DirectDebitOrder::DirectDebit.new debtor1, bank_account1, "MONECOLE REG F13792 PVT 3", 1034.34, "EUR", "FRST", "mandate-id-1"
17
+ mandate1 = Sepa::DirectDebitOrder::MandateInformation.new("mandate-id-1", Date.parse("2012-01-19"), "FRST")
18
+ dd10 = Sepa::DirectDebitOrder::DirectDebit.new debtor1, bank_account1, "MONECOLE REG F13790 PVT 3", 1732.32, "EUR", mandate1
19
+ dd11 = Sepa::DirectDebitOrder::DirectDebit.new debtor1, bank_account1, "MONECOLE REG F13792 PVT 3", 1034.34, "EUR", mandate1
18
20
 
19
21
  bank_account2 = Sepa::DirectDebitOrder::BankAccount.new "FRQUIQUIWIGWAM947551", "FRQQWIGGA"
20
22
  debtor2 = Sepa::DirectDebitOrder::Party.new "ADAMS/SAMUELMR", "512, Livva de Meet Agir", nil, "75099", "PARIS", "FR", "Johann S. BACH", "09876543210", "js@bach.sepa.i.hope.this.works"
21
- dd20 = Sepa::DirectDebitOrder::DirectDebit.new debtor2, bank_account2, "MONECOLE REG F13793 PVT 3", 1935.35, "EUR", "RCUR", "mandate-id-1"
22
- dd21 = Sepa::DirectDebitOrder::DirectDebit.new debtor2, bank_account2, "MONECOLE REG F13794 PVT 3", 1236.36, "EUR", "RCUR", "mandate-id-1"
23
+ mandate2 = Sepa::DirectDebitOrder::MandateInformation.new("mandate-id-2", Date.parse("2013-06-08"), "RCUR")
24
+ dd20 = Sepa::DirectDebitOrder::DirectDebit.new debtor2, bank_account2, "MONECOLE REG F13793 PVT 3", 1935.35, "EUR", mandate2
25
+ dd21 = Sepa::DirectDebitOrder::DirectDebit.new debtor2, bank_account2, "MONECOLE REG F13794 PVT 3", 1236.36, "EUR", mandate2
23
26
 
24
27
  sepa_now = Time.strptime "1992-02-28T18:30:00", "%Y-%m-%dT%H:%M:%S"
25
28
  Time.stub(:now).and_return sepa_now
@@ -81,6 +81,7 @@
81
81
  <DrctDbtTx>
82
82
  <MndtRltdInf>
83
83
  <MndtId>mandate-id-1</MndtId>
84
+ <DtOfSgntr>2012-01-19</DtOfSgntr>
84
85
  </MndtRltdInf>
85
86
  </DrctDbtTx>
86
87
  <DbtrAgt>
@@ -116,6 +117,7 @@
116
117
  <DrctDbtTx>
117
118
  <MndtRltdInf>
118
119
  <MndtId>mandate-id-1</MndtId>
120
+ <DtOfSgntr>2012-01-19</DtOfSgntr>
119
121
  </MndtRltdInf>
120
122
  </DrctDbtTx>
121
123
  <DbtrAgt>
@@ -204,6 +206,7 @@
204
206
  <DrctDbtTx>
205
207
  <MndtRltdInf>
206
208
  <MndtId>mandate-id-0</MndtId>
209
+ <DtOfSgntr>2010-11-18</DtOfSgntr>
207
210
  </MndtRltdInf>
208
211
  </DrctDbtTx>
209
212
  <DbtrAgt>
@@ -239,6 +242,7 @@
239
242
  <DrctDbtTx>
240
243
  <MndtRltdInf>
241
244
  <MndtId>mandate-id-0</MndtId>
245
+ <DtOfSgntr>2010-11-18</DtOfSgntr>
242
246
  </MndtRltdInf>
243
247
  </DrctDbtTx>
244
248
  <DbtrAgt>
@@ -273,7 +277,8 @@
273
277
  <InstdAmt Ccy="EUR">1935.35</InstdAmt>
274
278
  <DrctDbtTx>
275
279
  <MndtRltdInf>
276
- <MndtId>mandate-id-1</MndtId>
280
+ <MndtId>mandate-id-2</MndtId>
281
+ <DtOfSgntr>2013-06-08</DtOfSgntr>
277
282
  </MndtRltdInf>
278
283
  </DrctDbtTx>
279
284
  <DbtrAgt>
@@ -308,7 +313,8 @@
308
313
  <InstdAmt Ccy="EUR">1236.36</InstdAmt>
309
314
  <DrctDbtTx>
310
315
  <MndtRltdInf>
311
- <MndtId>mandate-id-1</MndtId>
316
+ <MndtId>mandate-id-2</MndtId>
317
+ <DtOfSgntr>2013-06-08</DtOfSgntr>
312
318
  </MndtRltdInf>
313
319
  </DrctDbtTx>
314
320
  <DbtrAgt>
@@ -83,6 +83,7 @@
83
83
  <DrctDbtTx>
84
84
  <MndtRltdInf>
85
85
  <MndtId>mandate-id-0</MndtId>
86
+ <DtOfSgntr>2010-11-18</DtOfSgntr>
86
87
  </MndtRltdInf>
87
88
  </DrctDbtTx>
88
89
  <DbtrAgt>
@@ -121,6 +122,7 @@
121
122
  <DrctDbtTx>
122
123
  <MndtRltdInf>
123
124
  <MndtId>mandate-id-0</MndtId>
125
+ <DtOfSgntr>2010-11-18</DtOfSgntr>
124
126
  </MndtRltdInf>
125
127
  </DrctDbtTx>
126
128
  <DbtrAgt>
@@ -159,6 +161,7 @@
159
161
  <DrctDbtTx>
160
162
  <MndtRltdInf>
161
163
  <MndtId>mandate-id-1</MndtId>
164
+ <DtOfSgntr>2012-01-19</DtOfSgntr>
162
165
  </MndtRltdInf>
163
166
  </DrctDbtTx>
164
167
  <DbtrAgt>
@@ -197,6 +200,7 @@
197
200
  <DrctDbtTx>
198
201
  <MndtRltdInf>
199
202
  <MndtId>mandate-id-1</MndtId>
203
+ <DtOfSgntr>2012-01-19</DtOfSgntr>
200
204
  </MndtRltdInf>
201
205
  </DrctDbtTx>
202
206
  <DbtrAgt>
@@ -234,7 +238,8 @@
234
238
  <InstdAmt Ccy="EUR">1935.35</InstdAmt>
235
239
  <DrctDbtTx>
236
240
  <MndtRltdInf>
237
- <MndtId>mandate-id-1</MndtId>
241
+ <MndtId>mandate-id-2</MndtId>
242
+ <DtOfSgntr>2013-06-08</DtOfSgntr>
238
243
  </MndtRltdInf>
239
244
  </DrctDbtTx>
240
245
  <DbtrAgt>
@@ -272,7 +277,8 @@
272
277
  <InstdAmt Ccy="EUR">1236.36</InstdAmt>
273
278
  <DrctDbtTx>
274
279
  <MndtRltdInf>
275
- <MndtId>mandate-id-1</MndtId>
280
+ <MndtId>mandate-id-2</MndtId>
281
+ <DtOfSgntr>2013-06-08</DtOfSgntr>
276
282
  </MndtRltdInf>
277
283
  </DrctDbtTx>
278
284
  <DbtrAgt>
@@ -83,6 +83,7 @@
83
83
  <DrctDbtTx>
84
84
  <MndtRltdInf>
85
85
  <MndtId>mandate-id-0</MndtId>
86
+ <DtOfSgntr>2010-11-18</DtOfSgntr>
86
87
  </MndtRltdInf>
87
88
  </DrctDbtTx>
88
89
  <DbtrAgt>
@@ -121,6 +122,7 @@
121
122
  <DrctDbtTx>
122
123
  <MndtRltdInf>
123
124
  <MndtId>mandate-id-0</MndtId>
125
+ <DtOfSgntr>2010-11-18</DtOfSgntr>
124
126
  </MndtRltdInf>
125
127
  </DrctDbtTx>
126
128
  <DbtrAgt>
@@ -159,6 +161,7 @@
159
161
  <DrctDbtTx>
160
162
  <MndtRltdInf>
161
163
  <MndtId>mandate-id-1</MndtId>
164
+ <DtOfSgntr>2012-01-19</DtOfSgntr>
162
165
  </MndtRltdInf>
163
166
  </DrctDbtTx>
164
167
  <DbtrAgt>
@@ -197,6 +200,7 @@
197
200
  <DrctDbtTx>
198
201
  <MndtRltdInf>
199
202
  <MndtId>mandate-id-1</MndtId>
203
+ <DtOfSgntr>2012-01-19</DtOfSgntr>
200
204
  </MndtRltdInf>
201
205
  </DrctDbtTx>
202
206
  <DbtrAgt>
@@ -234,7 +238,8 @@
234
238
  <InstdAmt Ccy="EUR">1935.35</InstdAmt>
235
239
  <DrctDbtTx>
236
240
  <MndtRltdInf>
237
- <MndtId>mandate-id-1</MndtId>
241
+ <MndtId>mandate-id-2</MndtId>
242
+ <DtOfSgntr>2013-06-08</DtOfSgntr>
238
243
  </MndtRltdInf>
239
244
  </DrctDbtTx>
240
245
  <DbtrAgt>
@@ -272,7 +277,8 @@
272
277
  <InstdAmt Ccy="EUR">1236.36</InstdAmt>
273
278
  <DrctDbtTx>
274
279
  <MndtRltdInf>
275
- <MndtId>mandate-id-1</MndtId>
280
+ <MndtId>mandate-id-2</MndtId>
281
+ <DtOfSgntr>2013-06-08</DtOfSgntr>
276
282
  </MndtRltdInf>
277
283
  </DrctDbtTx>
278
284
  <DbtrAgt>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sepa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8.1
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-11 00:00:00.000000000 Z
12
+ date: 2013-11-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: builder