sepafm 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/README.md +156 -6
- data/lib/danske_get_bank_certificate_test.rb +2 -2
- data/lib/sepa/custom_exceptions.rb +2 -0
- data/lib/sepa/payload.rb +109 -0
- data/lib/sepa/payment.rb +97 -0
- data/lib/sepa/transaction.rb +178 -0
- data/lib/sepa/version.rb +1 -1
- data/lib/sepa/xml_schemas/pain.001.001.02.xsd +784 -0
- data/lib/sepa_client_testing_mika.rb +1 -1
- data/lib/sepa_client_testing_tiere.rb +183 -6
- data/lib/{sepa.rb → sepafm.rb} +4 -0
- data/test/sepa/payload_test.rb +297 -0
- data/test/sepa/payment_test.rb +198 -0
- data/test/sepa/sepa_test.rb +1 -1
- data/test/sepa/transaction_test.rb +362 -0
- data/test/test_helper.rb +3 -4
- metadata +14 -3
@@ -0,0 +1,198 @@
|
|
1
|
+
require File.expand_path('../../test_helper.rb', __FILE__)
|
2
|
+
|
3
|
+
class TestPayment < MiniTest::Test
|
4
|
+
def setup
|
5
|
+
trans_1_params = {
|
6
|
+
instruction_id: '70CEF29BEBA8396A1F806005EDA51DEE4CE',
|
7
|
+
end_to_end_id: '629CADFDAD5246AD915BA24A3C8E9FC3313',
|
8
|
+
amount: '30.75',
|
9
|
+
currency: 'EUR',
|
10
|
+
bic: 'NDEAFIHH',
|
11
|
+
name: 'Testi Saaja Oy',
|
12
|
+
address: 'Kokeilukatu 66',
|
13
|
+
country: 'FI',
|
14
|
+
postcode: '00200',
|
15
|
+
town: 'Helsinki',
|
16
|
+
iban: 'FI7429501800000014',
|
17
|
+
reference: '00000000000000001245',
|
18
|
+
message: 'Maksu'
|
19
|
+
}
|
20
|
+
|
21
|
+
trans_2_params = {
|
22
|
+
instruction_id: 'A552D3EBB207B4AC17DF97C7D548A0571B0',
|
23
|
+
end_to_end_id: 'CDE1206C8745D6FBDCD2BBB02DB6CB6D3BE',
|
24
|
+
amount: '1075.20',
|
25
|
+
currency: 'EUR',
|
26
|
+
bic: 'NDEAFIHH',
|
27
|
+
name: 'Testing Company',
|
28
|
+
address: 'Tynnyrikatu 56',
|
29
|
+
country: 'FI',
|
30
|
+
postcode: '00600',
|
31
|
+
town: 'Helsinki',
|
32
|
+
iban: 'FI7429501800000014',
|
33
|
+
reference: '000000000000000034795',
|
34
|
+
message: 'Siirto'
|
35
|
+
}
|
36
|
+
|
37
|
+
trans_3_params = {
|
38
|
+
instruction_id: '44DB2850ABDFBEF2A32D0EE511BE5AB0B79',
|
39
|
+
end_to_end_id: 'A107CF858A22116D0C8EC1E78B078794B8C',
|
40
|
+
amount: '10000',
|
41
|
+
currency: 'EUR',
|
42
|
+
bic: 'NDEAFIHH',
|
43
|
+
name: 'Best Company Ever',
|
44
|
+
address: 'Banaanikuja 66',
|
45
|
+
country: 'FI',
|
46
|
+
postcode: '00900',
|
47
|
+
town: 'Helsinki',
|
48
|
+
iban: 'FI7429501800000014',
|
49
|
+
reference: '000000000000000013247',
|
50
|
+
message: 'Valuutan siirto toiselle tilille'
|
51
|
+
}
|
52
|
+
|
53
|
+
@debtor = {
|
54
|
+
name: 'Testi Maksaja Oy',
|
55
|
+
address: 'Testing Street 12',
|
56
|
+
country: 'Finland',
|
57
|
+
postcode: '00100',
|
58
|
+
town: 'Helsinki',
|
59
|
+
customer_id: '0987654321',
|
60
|
+
iban: 'FI4819503000000010',
|
61
|
+
bic: 'NDEAFIHH'
|
62
|
+
}
|
63
|
+
|
64
|
+
transactions = []
|
65
|
+
|
66
|
+
transactions.push(Sepa::Transaction.new(trans_1_params))
|
67
|
+
transactions.push(Sepa::Transaction.new(trans_2_params))
|
68
|
+
transactions.push(Sepa::Transaction.new(trans_3_params))
|
69
|
+
|
70
|
+
@params = {
|
71
|
+
payment_info_id: 'F56D46DDA136A981F58C05999479E768C92',
|
72
|
+
execution_date: '2013-08-10',
|
73
|
+
transactions: transactions
|
74
|
+
}
|
75
|
+
|
76
|
+
@payment = Sepa::Payment.new(@debtor, @params)
|
77
|
+
|
78
|
+
@payment_node = @payment.to_node
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_should_initialize_with_proper_params
|
82
|
+
assert Sepa::Payment.new(@debtor, @params)
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_payment_info_id_is_set_correctly
|
86
|
+
assert_equal @params[:payment_info_id],
|
87
|
+
@payment_node.at('/PmtInf/PmtInfId').content
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_execution_date_is_set_correctly
|
91
|
+
assert_equal @params[:execution_date],
|
92
|
+
@payment_node.at('/PmtInf/ReqdExctnDt').content
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_debtor_name_is_set_correctly
|
96
|
+
assert_equal @debtor[:name],
|
97
|
+
@payment_node.at('/PmtInf/Dbtr/Nm').content
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_debtors_first_address_line_is_set_correctly
|
101
|
+
assert_equal @debtor[:address],
|
102
|
+
@payment_node.at('/PmtInf/Dbtr/PstlAdr/AdrLine[1]').content
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_debtors_second_address_line_is_set_correctly
|
106
|
+
assert_equal "#{@debtor[:country]}-#{@debtor[:postcode]} #{@debtor[:town]}",
|
107
|
+
@payment_node.at('/PmtInf/Dbtr/PstlAdr/AdrLine[2]').content
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_debtors_country_is_set_correctly
|
111
|
+
assert_equal @debtor[:country],
|
112
|
+
@payment_node.at('/PmtInf/Dbtr/PstlAdr/Ctry').content
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_debtors_customer_id_is_set_when_present
|
116
|
+
assert_equal @debtor[:customer_id],
|
117
|
+
@payment_node.at('/PmtInf/Dbtr/Id/OrgId').content
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_debtors_iban_is_set_correctly
|
121
|
+
assert_equal @debtor[:iban],
|
122
|
+
@payment_node.at('/PmtInf/DbtrAcct/Id/IBAN').content
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_debtors_bic_is_set_correctly
|
126
|
+
assert_equal @debtor[:bic],
|
127
|
+
@payment_node.at('/PmtInf/DbtrAgt/FinInstnId/BIC').content
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_nr_of_transaction_elements_matches_the_nr_in_hash
|
131
|
+
assert_equal @params[:transactions].count,
|
132
|
+
@payment_node.xpath('/PmtInf/CdtTrfTxInf').count
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_category_purpose_is_set_when_salary_or_pension
|
136
|
+
@params[:salary_or_pension] = true
|
137
|
+
payment = Sepa::Payment.new(@debtor, @params)
|
138
|
+
payment_node = payment.to_node
|
139
|
+
|
140
|
+
assert_equal 'SALA',
|
141
|
+
payment_node.at('/PmtInf/PmtTpInf/CtgyPurp').content
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_raises_key_error_if_payment_info_id_missing
|
145
|
+
@params.delete(:payment_info_id)
|
146
|
+
assert_raises(KeyError) { Sepa::Payment.new(@debtor, @params) }
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_raises_key_error_if_execution_date_missing
|
150
|
+
@params.delete(:execution_date)
|
151
|
+
assert_raises(KeyError) { Sepa::Payment.new(@debtor, @params) }
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_raises_key_error_if_debtor_name_missing
|
155
|
+
@debtor.delete(:name)
|
156
|
+
assert_raises(KeyError) { Sepa::Payment.new(@debtor, @params) }
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_raises_key_error_if_debtor_address_missing
|
160
|
+
@debtor.delete(:address)
|
161
|
+
assert_raises(KeyError) { Sepa::Payment.new(@debtor, @params) }
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_raises_key_error_if_debtor_country_missing
|
165
|
+
@debtor.delete(:country)
|
166
|
+
assert_raises(KeyError) { Sepa::Payment.new(@debtor, @params) }
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_raises_key_error_if_debtor_postcode_missing
|
170
|
+
@debtor.delete(:postcode)
|
171
|
+
assert_raises(KeyError) { Sepa::Payment.new(@debtor, @params) }
|
172
|
+
end
|
173
|
+
|
174
|
+
def test_raises_key_error_if_debtor_town_missing
|
175
|
+
@debtor.delete(:town)
|
176
|
+
assert_raises(KeyError) { Sepa::Payment.new(@debtor, @params) }
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_raises_key_error_if_debtor_customer_id_missing
|
180
|
+
@debtor.delete(:customer_id)
|
181
|
+
assert_raises(KeyError) { Sepa::Payment.new(@debtor, @params) }
|
182
|
+
end
|
183
|
+
|
184
|
+
def test_raises_key_error_if_debtor_iban_missing
|
185
|
+
@debtor.delete(:iban)
|
186
|
+
assert_raises(KeyError) { Sepa::Payment.new(@debtor, @params) }
|
187
|
+
end
|
188
|
+
|
189
|
+
def test_raises_key_error_if_debtor_bic_missing
|
190
|
+
@debtor.delete(:bic)
|
191
|
+
assert_raises(KeyError) { Sepa::Payment.new(@debtor, @params) }
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_raises_key_error_if_transactions_missing
|
195
|
+
@params.delete(:transactions)
|
196
|
+
assert_raises(KeyError) { Sepa::Payment.new(@debtor, @params) }
|
197
|
+
end
|
198
|
+
end
|
data/test/sepa/sepa_test.rb
CHANGED
@@ -0,0 +1,362 @@
|
|
1
|
+
require File.expand_path('../../test_helper.rb', __FILE__)
|
2
|
+
|
3
|
+
class TestTransaction < MiniTest::Test
|
4
|
+
def setup
|
5
|
+
@invoice_bundle = []
|
6
|
+
|
7
|
+
invoice_1 = {
|
8
|
+
type: 'CINV',
|
9
|
+
amount: '700',
|
10
|
+
currency: 'EUR',
|
11
|
+
invoice_number: '123456'
|
12
|
+
}
|
13
|
+
|
14
|
+
invoice_2 = {
|
15
|
+
type: 'CINV',
|
16
|
+
amount: '300',
|
17
|
+
currency: 'EUR',
|
18
|
+
reference: '123456789',
|
19
|
+
}
|
20
|
+
|
21
|
+
invoice_3 = {
|
22
|
+
type: 'CREN',
|
23
|
+
amount: '-100',
|
24
|
+
currency: 'EUR',
|
25
|
+
invoice_number: '654321'
|
26
|
+
}
|
27
|
+
|
28
|
+
invoice_4 = {
|
29
|
+
type: 'CREN',
|
30
|
+
amount: '-500',
|
31
|
+
currency: 'EUR',
|
32
|
+
reference: '987654321'
|
33
|
+
}
|
34
|
+
|
35
|
+
@invoice_bundle.push(invoice_1)
|
36
|
+
@invoice_bundle.push(invoice_2)
|
37
|
+
@invoice_bundle.push(invoice_3)
|
38
|
+
@invoice_bundle.push(invoice_4)
|
39
|
+
|
40
|
+
@params = {
|
41
|
+
instruction_id: '70CEF29BEBA8396A1F806005EDA51DEE4CE',
|
42
|
+
end_to_end_id: '629CADFDAD5246AD915BA24A3C8E9FC3313',
|
43
|
+
amount: '30.75',
|
44
|
+
currency: 'EUR',
|
45
|
+
bic: 'NDEAFIHH',
|
46
|
+
name: 'Testi Saaja Oy',
|
47
|
+
address: 'Kokeilukatu 66',
|
48
|
+
country: 'FI',
|
49
|
+
postcode: '00200',
|
50
|
+
town: 'Helsinki',
|
51
|
+
iban: 'FI7429501800000014',
|
52
|
+
reference: '00000000000000001245',
|
53
|
+
message: 'Maksu',
|
54
|
+
social_security_number: '112233-0005'
|
55
|
+
}
|
56
|
+
|
57
|
+
@transaction = Sepa::Transaction.new(@params)
|
58
|
+
@transaction_node = @transaction.to_node
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_should_initialize_with_proper_params
|
62
|
+
assert Sepa::Transaction.new(@params)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_instruction_id_is_set_correctly
|
66
|
+
assert_equal @params[:instruction_id],
|
67
|
+
@transaction_node.at('/CdtTrfTxInf/PmtId/InstrId').content
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_end_to_end_id_is_set_correctly
|
71
|
+
assert_equal @params[:end_to_end_id],
|
72
|
+
@transaction_node.at('/CdtTrfTxInf/PmtId/EndToEndId').content
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_amount_is_set_correctly
|
76
|
+
assert_equal @params[:amount],
|
77
|
+
@transaction_node.at('/CdtTrfTxInf/Amt/InstdAmt').content
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_currency_is_set_correctly
|
81
|
+
assert_equal @params[:currency],
|
82
|
+
@transaction_node.at('/CdtTrfTxInf/Amt/InstdAmt/@Ccy').content
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_bic_is_set_correctly
|
86
|
+
assert_equal @params[:bic],
|
87
|
+
@transaction_node.at('/CdtTrfTxInf/CdtrAgt/FinInstnId/BIC').content
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_name_is_set_correctly
|
91
|
+
assert_equal @params[:name],
|
92
|
+
@transaction_node.at('/CdtTrfTxInf/Cdtr/Nm').content
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_first_address_line_is_set_correctly
|
96
|
+
assert_equal @params[:address],
|
97
|
+
@transaction_node.at('/CdtTrfTxInf/Cdtr/PstlAdr/AdrLine[1]').content
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_second_address_line_is_set_correctly
|
101
|
+
assert_equal "#{@params[:country]}-#{@params[:postcode]} #{@params[:town]}",
|
102
|
+
@transaction_node.at('/CdtTrfTxInf/Cdtr/PstlAdr/AdrLine[2]').content
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_street_name_is_set_correctly
|
106
|
+
assert_equal @params[:address],
|
107
|
+
@transaction_node.at('/CdtTrfTxInf/Cdtr/PstlAdr/StrtNm').content
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_postcode_is_set_correctly
|
111
|
+
assert_equal "#{@params[:country]}-#{@params[:postcode]}",
|
112
|
+
@transaction_node.at('/CdtTrfTxInf/Cdtr/PstlAdr/PstCd').content
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_town_is_set_correctly
|
116
|
+
assert_equal @params[:town],
|
117
|
+
@transaction_node.at('/CdtTrfTxInf/Cdtr/PstlAdr/TwnNm').content
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_country_is_set_correctly
|
121
|
+
assert_equal @params[:country],
|
122
|
+
@transaction_node.at('/CdtTrfTxInf/Cdtr/PstlAdr/Ctry').content
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_iban_is_set_correctly
|
126
|
+
assert_equal @params[:iban],
|
127
|
+
@transaction_node.at('/CdtTrfTxInf/CdtrAcct/Id/IBAN').content
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_reference_is_set_if_present
|
131
|
+
assert_equal @params[:reference],
|
132
|
+
@transaction_node.at(
|
133
|
+
'/CdtTrfTxInf/RmtInf/Strd/CdtrRefInf/CdtrRef'
|
134
|
+
).content
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_message_is_not_set_when_reference_is_present
|
138
|
+
refute @transaction_node.at('/CdtTrfTxInf/RmtInf/Ustrd')
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_message_is_set_when_reference_not_present
|
142
|
+
@params.delete(:reference)
|
143
|
+
|
144
|
+
transaction = Sepa::Transaction.new(@params)
|
145
|
+
transaction_node = transaction.to_node
|
146
|
+
|
147
|
+
assert_equal @params[:message],
|
148
|
+
transaction_node.at('/CdtTrfTxInf/RmtInf/Ustrd').content
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_social_security_number_is_set_correctly_when_salary
|
152
|
+
@params[:salary] = true
|
153
|
+
transaction = Sepa::Transaction.new(@params)
|
154
|
+
transaction_node = transaction.to_node
|
155
|
+
|
156
|
+
assert_equal @params[:social_security_number],
|
157
|
+
transaction_node.at('/CdtTrfTxInf/Cdtr/Id/PrvtId/SclSctyNb').content
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_purpose_is_set_correctly_when_pension
|
161
|
+
@params[:pension] = true
|
162
|
+
transaction = Sepa::Transaction.new(@params)
|
163
|
+
transaction_node = transaction.to_node
|
164
|
+
|
165
|
+
assert_equal transaction_node.at('/CdtTrfTxInf/Purp/Cd').content,
|
166
|
+
'PENS'
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_invoice_bundle_is_added_correctly
|
170
|
+
@params[:invoice_bundle] = @invoice_bundle
|
171
|
+
transaction = Sepa::Transaction.new(@params)
|
172
|
+
transaction_node = transaction.to_node
|
173
|
+
|
174
|
+
assert_equal @invoice_bundle.count,
|
175
|
+
transaction_node.xpath('/CdtTrfTxInf/RmtInf/Strd').count
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_raises_key_error_if_end_to_end_id_missing
|
179
|
+
@params.delete(:end_to_end_id)
|
180
|
+
assert_raises(KeyError) { transaction = Sepa::Transaction.new(@params) }
|
181
|
+
end
|
182
|
+
|
183
|
+
def test_raises_key_error_if_invoice_amount_missing
|
184
|
+
@invoice_bundle[0].delete(:amount)
|
185
|
+
@params[:invoice_bundle] = @invoice_bundle
|
186
|
+
|
187
|
+
assert_raises(KeyError) { transaction = Sepa::Transaction.new(@params) }
|
188
|
+
end
|
189
|
+
|
190
|
+
def test_raises_key_error_if_invoice_type_missing
|
191
|
+
@invoice_bundle[1].delete(:type)
|
192
|
+
@params[:invoice_bundle] = @invoice_bundle
|
193
|
+
transaction = Sepa::Transaction.new(@params)
|
194
|
+
|
195
|
+
assert_raises(KeyError) { transaction.to_node }
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_raises_key_error_if_amount_missing_when_not_invoice_bundle
|
199
|
+
@params.delete(:amount)
|
200
|
+
assert_raises(KeyError) { transaction = Sepa::Transaction.new(@params) }
|
201
|
+
end
|
202
|
+
|
203
|
+
def test_raises_key_error_if_currency_missing
|
204
|
+
@params.delete(:currency)
|
205
|
+
assert_raises(KeyError) { transaction = Sepa::Transaction.new(@params) }
|
206
|
+
end
|
207
|
+
|
208
|
+
def test_raises_key_error_if_bic_missing
|
209
|
+
@params.delete(:bic)
|
210
|
+
assert_raises(KeyError) { transaction = Sepa::Transaction.new(@params) }
|
211
|
+
end
|
212
|
+
|
213
|
+
def test_raises_key_error_if_name_missing
|
214
|
+
@params.delete(:name)
|
215
|
+
assert_raises(KeyError) { transaction = Sepa::Transaction.new(@params) }
|
216
|
+
end
|
217
|
+
|
218
|
+
def test_raises_key_error_if_address_missing
|
219
|
+
@params.delete(:address)
|
220
|
+
assert_raises(KeyError) { transaction = Sepa::Transaction.new(@params) }
|
221
|
+
end
|
222
|
+
|
223
|
+
def test_raises_key_error_if_country_missing
|
224
|
+
@params.delete(:country)
|
225
|
+
assert_raises(KeyError) { transaction = Sepa::Transaction.new(@params) }
|
226
|
+
end
|
227
|
+
|
228
|
+
def test_raises_key_error_if_postcode_missing
|
229
|
+
@params.delete(:postcode)
|
230
|
+
assert_raises(KeyError) { transaction = Sepa::Transaction.new(@params) }
|
231
|
+
end
|
232
|
+
|
233
|
+
def test_raises_key_error_if_town_missing
|
234
|
+
@params.delete(:town)
|
235
|
+
assert_raises(KeyError) { transaction = Sepa::Transaction.new(@params) }
|
236
|
+
end
|
237
|
+
|
238
|
+
def test_raises_key_error_if_iban_missing
|
239
|
+
@params.delete(:iban)
|
240
|
+
assert_raises(KeyError) { transaction = Sepa::Transaction.new(@params) }
|
241
|
+
end
|
242
|
+
|
243
|
+
def test_amount_is_set_correctly_when_invoice_bundle
|
244
|
+
@params[:invoice_bundle] = @invoice_bundle
|
245
|
+
transaction = Sepa::Transaction.new(@params)
|
246
|
+
transaction_node = transaction.to_node
|
247
|
+
|
248
|
+
amount = 0
|
249
|
+
@invoice_bundle.each { |i| amount += i[:amount].to_f }
|
250
|
+
|
251
|
+
assert_equal amount.to_s,
|
252
|
+
transaction_node.at('/CdtTrfTxInf/Amt/InstdAmt').content
|
253
|
+
end
|
254
|
+
|
255
|
+
def test_invoice_type_is_set_correctly_when_invoice_bundle
|
256
|
+
@params[:invoice_bundle] = @invoice_bundle
|
257
|
+
transaction = Sepa::Transaction.new(@params)
|
258
|
+
transaction_node = transaction.to_node
|
259
|
+
|
260
|
+
type_nodes = transaction_node.xpath('//Strd/RfrdDocInf/RfrdDocTp/Cd')
|
261
|
+
|
262
|
+
types_in_doc = []
|
263
|
+
|
264
|
+
type_nodes.each { |t| types_in_doc.push(t.content) }
|
265
|
+
|
266
|
+
types_in_params = []
|
267
|
+
|
268
|
+
@invoice_bundle.each { |i| types_in_params.push(i[:type]) }
|
269
|
+
|
270
|
+
type_hash = types_in_doc.zip(types_in_params)
|
271
|
+
|
272
|
+
type_hash.each { |key, value| assert_equal key, value }
|
273
|
+
end
|
274
|
+
|
275
|
+
def test_invoice_number_is_set_correctly_when_invoice_bundle
|
276
|
+
@params[:invoice_bundle] = @invoice_bundle
|
277
|
+
transaction = Sepa::Transaction.new(@params)
|
278
|
+
transaction_node = transaction.to_node
|
279
|
+
|
280
|
+
number_nodes = transaction_node.xpath('//Strd/RfrdDocInf/RfrdDocNb')
|
281
|
+
|
282
|
+
numbers_in_doc = []
|
283
|
+
|
284
|
+
number_nodes.each { |t| numbers_in_doc.push(t.content) }
|
285
|
+
|
286
|
+
numbers_in_params = []
|
287
|
+
|
288
|
+
@invoice_bundle.each do |i|
|
289
|
+
numbers_in_params.push(i[:invoice_number]) unless i[:invoice_number].nil?
|
290
|
+
end
|
291
|
+
|
292
|
+
number_hash = numbers_in_doc.zip(numbers_in_params)
|
293
|
+
|
294
|
+
number_hash.each { |key, value| assert_equal key, value }
|
295
|
+
end
|
296
|
+
|
297
|
+
def test_invoice_reference_is_set_correctly_when_invoice_bundle
|
298
|
+
@params[:invoice_bundle] = @invoice_bundle
|
299
|
+
transaction = Sepa::Transaction.new(@params)
|
300
|
+
transaction_node = transaction.to_node
|
301
|
+
|
302
|
+
reference_nodes = transaction_node.xpath('//Strd/CdtrRefInf/CdtrRef')
|
303
|
+
|
304
|
+
references_in_doc = []
|
305
|
+
|
306
|
+
reference_nodes.each { |t| references_in_doc.push(t.content) }
|
307
|
+
|
308
|
+
references_in_params = []
|
309
|
+
|
310
|
+
@invoice_bundle.each do |i|
|
311
|
+
references_in_params.push(i[:reference]) unless i[:reference].nil?
|
312
|
+
end
|
313
|
+
|
314
|
+
reference_hash = references_in_doc.zip(references_in_params)
|
315
|
+
|
316
|
+
reference_hash.each { |key, value| assert_equal key, value }
|
317
|
+
end
|
318
|
+
|
319
|
+
def test_invoice_amount_is_set_correctly_when_invoice_bundle_and_not_credit
|
320
|
+
@params[:invoice_bundle] = @invoice_bundle
|
321
|
+
transaction = Sepa::Transaction.new(@params)
|
322
|
+
transaction_node = transaction.to_node
|
323
|
+
|
324
|
+
amount_nodes = transaction_node.xpath('//Strd/RfrdDocAmt/RmtdAmt')
|
325
|
+
|
326
|
+
amounts_in_doc = []
|
327
|
+
|
328
|
+
amount_nodes.each { |a| amounts_in_doc.push(a.content) }
|
329
|
+
|
330
|
+
amounts_in_params = []
|
331
|
+
|
332
|
+
@invoice_bundle.each do |i|
|
333
|
+
amounts_in_params.push(i[:amount]) unless i[:amount].to_f < 0
|
334
|
+
end
|
335
|
+
|
336
|
+
amount_hash = amounts_in_doc.zip(amounts_in_params)
|
337
|
+
|
338
|
+
amount_hash.each { |key, value| assert_equal key, value }
|
339
|
+
end
|
340
|
+
|
341
|
+
def test_invoice_amount_is_set_correctly_when_invoice_bundle_and_credit
|
342
|
+
@params[:invoice_bundle] = @invoice_bundle
|
343
|
+
transaction = Sepa::Transaction.new(@params)
|
344
|
+
transaction_node = transaction.to_node
|
345
|
+
|
346
|
+
amount_nodes = transaction_node.xpath('//Strd/RfrdDocAmt/CdtNoteAmt')
|
347
|
+
|
348
|
+
amounts_in_doc = []
|
349
|
+
|
350
|
+
amount_nodes.each { |a| amounts_in_doc.push(a.content) }
|
351
|
+
|
352
|
+
amounts_in_params = []
|
353
|
+
|
354
|
+
@invoice_bundle.each do |i|
|
355
|
+
amounts_in_params.push(i[:amount].to_f.abs.to_s) unless i[:amount].to_f > 0
|
356
|
+
end
|
357
|
+
|
358
|
+
amount_hash = amounts_in_doc.zip(amounts_in_params)
|
359
|
+
|
360
|
+
amount_hash.each { |key, value| assert_equal key, value }
|
361
|
+
end
|
362
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
require 'minitest/autorun'
|
2
|
-
require File.expand_path('../../lib/sepa.rb', __FILE__)
|
3
|
-
|
4
1
|
require 'simplecov'
|
5
|
-
|
6
2
|
SimpleCov.start do
|
7
3
|
add_filter "/test/"
|
8
4
|
add_filter "/vendor/"
|
9
5
|
end
|
6
|
+
|
7
|
+
require 'minitest/autorun'
|
8
|
+
require File.expand_path('../../lib/sepafm.rb', __FILE__)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sepafm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joni Kanerva
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-07-
|
13
|
+
date: 2013-07-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: savon
|
@@ -124,10 +124,10 @@ files:
|
|
124
124
|
- README.md
|
125
125
|
- Rakefile
|
126
126
|
- lib/danske_get_bank_certificate_test.rb
|
127
|
-
- lib/sepa.rb
|
128
127
|
- lib/sepa/application_request.rb
|
129
128
|
- lib/sepa/application_response.rb
|
130
129
|
- lib/sepa/client.rb
|
130
|
+
- lib/sepa/custom_exceptions.rb
|
131
131
|
- lib/sepa/danske_testing/keys/danske_encryption.crt
|
132
132
|
- lib/sepa/filedescriptor.rb
|
133
133
|
- lib/sepa/filetypeservice.rb
|
@@ -140,12 +140,15 @@ files:
|
|
140
140
|
- lib/sepa/nordea_testing/response/download_filelist_response.xml
|
141
141
|
- lib/sepa/nordea_testing/response/get_user_info_response.xml
|
142
142
|
- lib/sepa/nordea_testing/response/upload_file_response.xml
|
143
|
+
- lib/sepa/payload.rb
|
144
|
+
- lib/sepa/payment.rb
|
143
145
|
- lib/sepa/response.rb
|
144
146
|
- lib/sepa/sender_verifier.rb
|
145
147
|
- lib/sepa/signature.rb
|
146
148
|
- lib/sepa/soap_builder.rb
|
147
149
|
- lib/sepa/soap_danske.rb
|
148
150
|
- lib/sepa/soap_nordea.rb
|
151
|
+
- lib/sepa/transaction.rb
|
149
152
|
- lib/sepa/userfiletype.rb
|
150
153
|
- lib/sepa/version.rb
|
151
154
|
- lib/sepa/wsdl/wsdl_danske.xml
|
@@ -159,6 +162,7 @@ files:
|
|
159
162
|
- lib/sepa/xml_schemas/danske_pki.xsd
|
160
163
|
- lib/sepa/xml_schemas/oasis-200401-wss-wssecurity-secext-1.0.xsd
|
161
164
|
- lib/sepa/xml_schemas/oasis-200401-wss-wssecurity-utility-1.0.xsd
|
165
|
+
- lib/sepa/xml_schemas/pain.001.001.02.xsd
|
162
166
|
- lib/sepa/xml_schemas/soap.xsd
|
163
167
|
- lib/sepa/xml_schemas/wsdl.xml
|
164
168
|
- lib/sepa/xml_schemas/xml.xsd
|
@@ -180,6 +184,7 @@ files:
|
|
180
184
|
- lib/sepa/xml_templates/soap/upload_file.xml
|
181
185
|
- lib/sepa_client_testing_mika.rb
|
182
186
|
- lib/sepa_client_testing_tiere.rb
|
187
|
+
- lib/sepafm.rb
|
183
188
|
- sepa.gemspec
|
184
189
|
- test/sepa/application_request_test.rb
|
185
190
|
- test/sepa/application_response_test.rb
|
@@ -195,6 +200,8 @@ files:
|
|
195
200
|
- test/sepa/nordea_test_keys/nordea.key
|
196
201
|
- test/sepa/nordea_test_keys/root_cert.cer
|
197
202
|
- test/sepa/nordea_test_keys/testcert.csr
|
203
|
+
- test/sepa/payload_test.rb
|
204
|
+
- test/sepa/payment_test.rb
|
198
205
|
- test/sepa/response_test.rb
|
199
206
|
- test/sepa/sepa_test.rb
|
200
207
|
- test/sepa/test_files/invalid.wsdl
|
@@ -202,6 +209,7 @@ files:
|
|
202
209
|
- test/sepa/test_files/test_responses/dfl.xml
|
203
210
|
- test/sepa/test_files/test_responses/gui.xml
|
204
211
|
- test/sepa/test_files/test_responses/uf.xml
|
212
|
+
- test/sepa/transaction_test.rb
|
205
213
|
- test/sepa/user_file_type_test.rb
|
206
214
|
- test/sepa/xml_parser_test.rb
|
207
215
|
- test/test_helper.rb
|
@@ -244,6 +252,8 @@ test_files:
|
|
244
252
|
- test/sepa/nordea_test_keys/nordea.key
|
245
253
|
- test/sepa/nordea_test_keys/root_cert.cer
|
246
254
|
- test/sepa/nordea_test_keys/testcert.csr
|
255
|
+
- test/sepa/payload_test.rb
|
256
|
+
- test/sepa/payment_test.rb
|
247
257
|
- test/sepa/response_test.rb
|
248
258
|
- test/sepa/sepa_test.rb
|
249
259
|
- test/sepa/test_files/invalid.wsdl
|
@@ -251,6 +261,7 @@ test_files:
|
|
251
261
|
- test/sepa/test_files/test_responses/dfl.xml
|
252
262
|
- test/sepa/test_files/test_responses/gui.xml
|
253
263
|
- test/sepa/test_files/test_responses/uf.xml
|
264
|
+
- test/sepa/transaction_test.rb
|
254
265
|
- test/sepa/user_file_type_test.rb
|
255
266
|
- test/sepa/xml_parser_test.rb
|
256
267
|
- test/test_helper.rb
|