sepafm 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +14 -30
- data/.ruby-version +1 -1
- data/.travis.yml +15 -0
- data/Gemfile +1 -1
- data/LICENSE +16 -4
- data/README.md +180 -319
- data/Rakefile +7 -2
- data/lib/sepa/application_request.rb +100 -131
- data/lib/sepa/application_response.rb +28 -84
- data/lib/sepa/attribute_checks.rb +169 -0
- data/lib/sepa/banks/danske/danske_response.rb +19 -0
- data/lib/sepa/banks/danske/soap_danske.rb +132 -0
- data/lib/sepa/banks/nordea/nordea_response.rb +20 -0
- data/lib/sepa/banks/nordea/soap_nordea.rb +51 -0
- data/lib/sepa/client.rb +72 -60
- data/lib/sepa/error_messages.rb +15 -0
- data/lib/sepa/response.rb +88 -85
- data/lib/sepa/soap_builder.rb +51 -341
- data/lib/sepa/utilities.rb +132 -0
- data/lib/sepa/version.rb +1 -1
- data/lib/sepa/xml_schemas/PKIFactory.xsd +334 -0
- data/lib/sepa/xml_schemas/xml_id.xsd +9 -0
- data/lib/sepa/xml_templates/application_request/create_certificate.xml +15 -10
- data/lib/sepa/xml_templates/application_request/danske_get_bank_certificate.xml +13 -9
- data/lib/sepa/xml_templates/application_request/download_file.xml +32 -30
- data/lib/sepa/xml_templates/application_request/download_file_list.xml +29 -27
- data/lib/sepa/xml_templates/application_request/encrypted_request.xml +22 -0
- data/lib/sepa/xml_templates/application_request/get_certificate.xml +9 -8
- data/lib/sepa/xml_templates/application_request/get_user_info.xml +26 -24
- data/lib/sepa/xml_templates/application_request/upload_file.xml +29 -27
- data/lib/sepa/xml_templates/soap/create_certificate.xml +17 -15
- data/lib/sepa/xml_templates/soap/danske_get_bank_certificate.xml +15 -13
- data/lib/sepa/xml_templates/soap/download_file.xml +19 -15
- data/lib/sepa/xml_templates/soap/download_file_list.xml +19 -15
- data/lib/sepa/xml_templates/soap/get_certificate.xml +2 -1
- data/lib/sepa/xml_templates/soap/get_user_info.xml +19 -15
- data/lib/sepa/xml_templates/soap/header.xml +48 -37
- data/lib/sepa/xml_templates/soap/upload_file.xml +19 -15
- data/lib/sepafm.rb +20 -18
- data/{sepa.gemspec → sepafm.gemspec} +10 -9
- data/test/sepa/banks/danske/danske_cert_response_test.rb +52 -0
- data/test/sepa/banks/danske/danske_cert_soap_builder_test.rb +100 -0
- data/test/sepa/banks/danske/danske_generic_soap_builder_test.rb +278 -0
- data/test/sepa/banks/danske/danske_get_bank_cert_test.rb +111 -0
- data/{lib/sepa/danske_testing/keys/danske_encryption.crt → test/sepa/banks/danske/keys/bank_encryption_cert.pem} +0 -0
- data/test/sepa/{danske_test_keys/danskeroot.pem → banks/danske/keys/bank_root_cert.pem} +1 -1
- data/test/sepa/banks/danske/keys/bank_signing_cert.pem +24 -0
- data/test/sepa/banks/danske/keys/danske_encryption.crt +24 -0
- data/test/sepa/banks/danske/keys/enc_private_key.pem +27 -0
- data/test/sepa/{danske_test_keys → banks/danske/keys}/encryption_pkcs.csr +0 -0
- data/test/sepa/banks/danske/keys/own_enc_cert.pem +21 -0
- data/test/sepa/banks/danske/keys/own_signing_cert.pem +22 -0
- data/test/sepa/{danske_test_keys → banks/danske/keys}/signing_key.pem +0 -0
- data/test/sepa/{danske_test_keys → banks/danske/keys}/signing_pkcs.csr +0 -0
- data/test/sepa/banks/danske/keys/signing_private_key.pem +27 -0
- data/test/sepa/banks/danske/responses/create_cert.xml +38 -0
- data/test/sepa/banks/danske/responses/get_bank_cert.xml +37 -0
- data/{lib/sepa/nordea_testing → test/sepa/banks/nordea}/keys/nordea.crt +0 -4
- data/test/sepa/{nordea_test_keys → banks/nordea/keys}/nordea.key +0 -3
- data/test/sepa/{nordea_test_keys → banks/nordea/keys}/root_cert.cer +0 -0
- data/test/sepa/{nordea_test_keys → banks/nordea/keys}/testcert.csr +0 -0
- data/test/sepa/banks/nordea/nordea_application_request_test.rb +252 -0
- data/test/sepa/{application_response_test.rb → banks/nordea/nordea_application_response_test.rb} +40 -46
- data/test/sepa/banks/nordea/nordea_cert_application_request_test.rb +72 -0
- data/test/sepa/banks/nordea/nordea_cert_request_soap_builder_test.rb +65 -0
- data/test/sepa/banks/nordea/nordea_generic_soap_builder_test.rb +280 -0
- data/test/sepa/banks/nordea/nordea_response_test.rb +116 -0
- data/test/sepa/banks/nordea/responses/df_ktl.xml +45 -0
- data/test/sepa/{test_files/test_responses/df.xml → banks/nordea/responses/df_tito.xml} +1 -1
- data/test/sepa/{test_files/test_responses → banks/nordea/responses}/dfl.xml +0 -0
- data/test/sepa/banks/nordea/responses/gbc.xml +15 -0
- data/test/sepa/banks/nordea/responses/gc.xml +49 -0
- data/test/sepa/{test_files/test_responses → banks/nordea/responses}/gui.xml +0 -0
- data/test/sepa/{test_files/test_responses → banks/nordea/responses}/uf.xml +0 -0
- data/test/sepa/client_test.rb +156 -302
- data/test/sepa/fixtures.rb +214 -0
- data/test/sepa/sepa_test.rb +3 -13
- data/test/sepa/test_files/{invalid.wsdl → invalid_wsdl.wsdl} +0 -0
- data/test/test_helper.rb +29 -3
- metadata +140 -116
- data/lib/danske_get_bank_certificate_test.rb +0 -15
- data/lib/sepa/custom_exceptions.rb +0 -2
- data/lib/sepa/filedescriptor.rb +0 -7
- data/lib/sepa/filetypeservice.rb +0 -6
- data/lib/sepa/nordea_testing/keys/CSR.csr +0 -0
- data/lib/sepa/nordea_testing/keys/nordea.key +0 -19
- data/lib/sepa/nordea_testing/response/content_053.xml +0 -998
- data/lib/sepa/nordea_testing/response/content_054.xml +0 -1
- data/lib/sepa/nordea_testing/response/download_file_response.xml +0 -14
- data/lib/sepa/nordea_testing/response/download_filelist_response.xml +0 -14
- data/lib/sepa/nordea_testing/response/get_user_info_response.xml +0 -14
- data/lib/sepa/nordea_testing/response/upload_file_response.xml +0 -14
- data/lib/sepa/payload.rb +0 -109
- data/lib/sepa/payment.rb +0 -97
- data/lib/sepa/sender_verifier.rb +0 -15
- data/lib/sepa/signature.rb +0 -7
- data/lib/sepa/soap_danske.rb +0 -47
- data/lib/sepa/soap_nordea.rb +0 -68
- data/lib/sepa/transaction.rb +0 -178
- data/lib/sepa/userfiletype.rb +0 -16
- data/lib/sepa/xml_parser.rb +0 -291
- data/lib/sepa_client_testing_mika.rb +0 -32
- data/lib/sepa_client_testing_tiere.rb +0 -257
- data/test/sepa/application_request_test.rb +0 -423
- data/test/sepa/cert_application_request_test.rb +0 -99
- data/test/sepa/nordea_cert_request_soap_builder_test.rb +0 -112
- data/test/sepa/nordea_generic_soap_builder_test.rb +0 -427
- data/test/sepa/nordea_test_keys/nordea.crt +0 -27
- data/test/sepa/payload_test.rb +0 -297
- data/test/sepa/payment_test.rb +0 -198
- data/test/sepa/response_test.rb +0 -269
- data/test/sepa/transaction_test.rb +0 -362
- data/test/sepa/user_file_type_test.rb +0 -21
- data/test/sepa/xml_parser_test.rb +0 -73
data/lib/sepa/xml_parser.rb
DELETED
@@ -1,291 +0,0 @@
|
|
1
|
-
module Sepa
|
2
|
-
# This class is able to handle GetUserInfo, DownloadFileList, DownloadFile responses and pass content
|
3
|
-
class XmlParser
|
4
|
-
attr_accessor :timestamp, :responseCode, :encrypted, :compressed, :customerId, :responseText, :fileDescriptors, :userFiletypes, :content
|
5
|
-
def initialize
|
6
|
-
@content = ""
|
7
|
-
@fileDescriptors = []
|
8
|
-
end
|
9
|
-
# Reads values from content field (xml file), returns a hash
|
10
|
-
# Bank to customer statement
|
11
|
-
def get_account_statement_content(file)
|
12
|
-
|
13
|
-
if file == ""
|
14
|
-
fail ArgumentError, "You didn't provide a file"
|
15
|
-
|
16
|
-
elsif file != nil
|
17
|
-
content = Nokogiri::XML(File.open(file))
|
18
|
-
content.remove_namespaces!
|
19
|
-
|
20
|
-
unless content == ""
|
21
|
-
|
22
|
-
# To contain all needed values
|
23
|
-
statement_content = {}
|
24
|
-
|
25
|
-
# Selected fields
|
26
|
-
|
27
|
-
##CASE Devlab selected fields
|
28
|
-
# Booking date
|
29
|
-
statement_content[:bookingdatefrom] = content.at_css("Document/BkToCstmrStmt/Stmt/FrToDt/FrDtTm").content unless content.at_css("Document/BkToCstmrStmt/Stmt/FrToDt/FrDtTm") == nil
|
30
|
-
statement_content[:bookingdateto] = content.at_css("Document/BkToCstmrStmt/Stmt/FrToDt/ToDtTm").content unless content.at_css("Document/BkToCstmrStmt/Stmt/FrToDt/ToDtTm") == nil
|
31
|
-
|
32
|
-
# Account
|
33
|
-
statement_content[:owneracctiban] = content.at_css("Document/BkToCstmrStmt/Stmt/Acct/Id/IBAN").content unless content.at_css("Document/BkToCstmrStmt/Stmt/Acct/Id/IBAN") == nil
|
34
|
-
statement_content[:owneracctccy] = content.at_css("Document/BkToCstmrStmt/Stmt/Acct/Ccy").content unless content.at_css("Document/BkToCstmrStmt/Stmt/Acct/Ccy") == nil
|
35
|
-
statement_content[:owneraccttype] = content.at_css("Document/BkToCstmrStmt/Stmt/Acct/Nm").content unless content.at_css("Document/BkToCstmrStmt/Stmt/Acct/Nm") == nil
|
36
|
-
|
37
|
-
# Owner
|
38
|
-
statement_content[:acctownername] = content.at_css("Document/BkToCstmrStmt/Stmt/Acct/Ownr/Nm").content unless content.at_css("Document/BkToCstmrStmt/Stmt/Acct/Ownr/Nm") == nil
|
39
|
-
|
40
|
-
# BIC
|
41
|
-
statement_content[:owneracctbic] = content.at_css("Document/BkToCstmrStmt/Stmt/Acct/Svcr/FinInstnId/BIC").content unless content.at_css("Document/BkToCstmrStmt/Stmt/Acct/Svcr/FinInstnId/BIC").content == nil
|
42
|
-
|
43
|
-
# To contain each transaction listed in the content
|
44
|
-
transactions = []
|
45
|
-
|
46
|
-
content.xpath("//Document/BkToCstmrStmt/Stmt/Ntry").each do |node|
|
47
|
-
|
48
|
-
# To contain the values of a single transaction
|
49
|
-
transaction_content = {}
|
50
|
-
|
51
|
-
##CASE Devlab selected fields
|
52
|
-
##Arkistointitunnus
|
53
|
-
transaction_content[:acctsvcrref] = node.at_css("NtryDtls/TxDtls/Refs/AcctSvcrRef").content unless node.at_css("NtryDtls/TxDtls/Refs/AcctSvcrRef") == nil
|
54
|
-
##Saajan tilinumero
|
55
|
-
transaction_content[:crdtiban] = node.at_css("NtryDtls/TxDtls/RltdPties/CdtrAcct/Id/IBAN").content unless node.at_css("NtryDtls/TxDtls/RltdPties/CdtrAcct/Id/IBAN") == nil
|
56
|
-
##Maksupaiva
|
57
|
-
transaction_content[:bookingdate] = node.at_css("BookgDt/Dt").content unless node.at_css("BookgDt/Dt") == nil
|
58
|
-
##Arvopaiva
|
59
|
-
transaction_content[:valuedate] = node.at_css("ValDt/Dt").content unless node.at_css("ValDt/Dt") == nil
|
60
|
-
##Saaja/Maksaja
|
61
|
-
transaction_content[:crdtname] = node.at_css("NtryDtls/TxDtls/RltdPties/Cdtr/Nm").content unless node.at_css("NtryDtls/TxDtls/RltdPties/Cdtr/Nm") == nil
|
62
|
-
##Viesti
|
63
|
-
transaction_content[:message] = node.at_css("NtryDtls/TxDtls/RmtInf/Ustrd").content unless node.at_css("NtryDtls/TxDtls/RmtInf/Ustrd") == nil
|
64
|
-
##Maara sisaantuleva(arvo)
|
65
|
-
transaction_content[:incamt] = node.at_css("NtryDtls/TxDtls/AmtDtls/InstdAmt/Amt").content unless node.at_css("NtryDtls/TxDtls/AmtDtls/InstdAmt/Amt") == nil
|
66
|
-
##Valuutta sisaantuleva
|
67
|
-
transaction_content[:incccy] = node.at_css("NtryDtls/TxDtls/AmtDtls/InstdAmt/Amt")["Ccy"] unless node.at_css("NtryDtls/TxDtls/AmtDtls/InstdAmt/Amt") == nil
|
68
|
-
##Maara kirjanpidollinen(arvo)
|
69
|
-
transaction_content[:bkdamt] = node.at_css("NtryDtls/TxDtls/AmtDtls/TxAmt/Amt").content unless node.at_css("NtryDtls/TxDtls/AmtDtls/TxAmt/Amt") == nil
|
70
|
-
##Valuutta kirjanpidollinen
|
71
|
-
transaction_content[:bkdccy] = node.at_css("NtryDtls/TxDtls/AmtDtls/TxAmt/Amt")["Ccy"] unless node.at_css("NtryDtls/TxDtls/AmtDtls/TxAmt/Amt") == nil
|
72
|
-
##Tapahtumalaji (702, 705)
|
73
|
-
transaction_content[:trnscttype] = node.at_css("BkTxCd/Prtry/Cd").content unless node.at_css("BkTxCd/Prtry/Cd") == nil
|
74
|
-
##Tapahtumien maara
|
75
|
-
transaction_content[:trnsctcnt] = node.at_css("NtryDtls/Btch/NbOfTxs").content unless node.at_css("NtryDtls/Btch/NbOfTxs") == nil
|
76
|
-
##Oma sisainen viite
|
77
|
-
transaction_content[:internalid] = node.at_css("NtryDtls/Btch/PmtInfId").content unless node.at_css("NtryDtls/Btch/PmtInfId") == nil
|
78
|
-
##Maksajan viite
|
79
|
-
transaction_content[:instrid] = node.at_css("NtryDtls/TxDtls/Refs/InstrId").content unless node.at_css("NtryDtls/TxDtls/Refs/InstrId") == nil
|
80
|
-
##BIC koodi (saaja)
|
81
|
-
transaction_content[:crdtbin] = node.at_css("NtryDtls/TxDtls/RltdAgts/DbtrAgt/FinInstId").content unless node.at_css("NtryDtls/TxDtls/RltdAgts/DbtrAgt/FinInstId") == nil
|
82
|
-
##Maksajan tunniste
|
83
|
-
transaction_content[:crdtid] = node.at_css("NtryDtls/TxDtls/RltdPties/CdtrAcct/Id/Othr/Id").content unless node.at_css("NtryDtls/TxDtls/RltdPties/CdtrAcct/Id/Othr/Id") == nil
|
84
|
-
##SEPA arkistointitunnus
|
85
|
-
transaction_content[:sepabookingid] = node.at_css("AcctSvcrRef").content unless node.at_css("AcctSvcrRef") == nil
|
86
|
-
|
87
|
-
# Push to array
|
88
|
-
transactions<<transaction_content
|
89
|
-
end
|
90
|
-
|
91
|
-
statement_content[:transactions] = transactions
|
92
|
-
|
93
|
-
# Returns hash
|
94
|
-
statement_content
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
|
100
|
-
# Reads values from content field (xml file), returns a hash
|
101
|
-
def get_debit_credit_notification_content(file)
|
102
|
-
|
103
|
-
if file == ""
|
104
|
-
fail ArgumentError, "You didn't provide a file"
|
105
|
-
|
106
|
-
elsif file != nil
|
107
|
-
content = Nokogiri::XML(File.open(file))
|
108
|
-
content.remove_namespaces!
|
109
|
-
|
110
|
-
unless content == ""
|
111
|
-
|
112
|
-
notification_content = {}
|
113
|
-
|
114
|
-
##CASE Devlab suggested/selected fields
|
115
|
-
|
116
|
-
# account iban
|
117
|
-
notification_content[:account_iban] = content.at_css("Document/BkToCstmrDbtCdtNtfctn/Ntfctn/Acct/Id/IBAN").content unless content.at_css("Document/BkToCstmrDbtCdtNtfctn/Ntfctn/Acct/Id/IBAN") == nil
|
118
|
-
|
119
|
-
# payer name
|
120
|
-
notification_content[:account_owner] = content.at_css("Document/BkToCstmrDbtCdtNtfctn/Ntfctn/Acct/Ownr/Nm").content unless content.at_css("Document/BkToCstmrDbtCdtNtfctn/Ntfctn/Acct/Ownr/Nm") == nil
|
121
|
-
|
122
|
-
# bic
|
123
|
-
notification_content[:account_bic] = content.at_css("Document/BkToCstmrDbtCdtNtfctn/Ntfctn/Acct/Svcr/FinInstnId/BIC").content unless content.at_css("Document/BkToCstmrDbtCdtNtfctn/Ntfctn/Acct/Svcr/FinInstnId/BIC") == nil
|
124
|
-
|
125
|
-
#Viitesiirtokentat
|
126
|
-
# Notification entries
|
127
|
-
notification_entries = []
|
128
|
-
|
129
|
-
#txdtls_content = {}
|
130
|
-
|
131
|
-
content.xpath("//Document/BkToCstmrDbtCdtNtfctn/Ntfctn/Ntry").each do |node|
|
132
|
-
|
133
|
-
entry_content = {}
|
134
|
-
|
135
|
-
# reference
|
136
|
-
entry_content[:entry_reference] = node.at_css("NtryRef").content unless node.at_css("NtryRef") == nil
|
137
|
-
# sum
|
138
|
-
entry_content[:entry_sum] = node.at_css("Amt").content unless node.at_css("Amt") == nil
|
139
|
-
# currency code
|
140
|
-
entry_content[:entry_currency] = node.at_css("Amt")["Ccy"] unless node.at_css("Amt") == nil
|
141
|
-
# entry date
|
142
|
-
entry_content[:entry_booking_date] = node.at_css("BookgDt/Dt").content unless node.at_css("BookgDt/Dt") == nil
|
143
|
-
# payment date
|
144
|
-
entry_content[:entry_value_date] = node.at_css("ValDt/Dt").content unless node.at_css("ValDt/Dt") == nil
|
145
|
-
|
146
|
-
# LOOP all txdtls
|
147
|
-
txdtls_all = Array.new
|
148
|
-
node.xpath("//NtryDtls/TxDtls").each do |nodejr|
|
149
|
-
txdtls_content = Hash.new
|
150
|
-
|
151
|
-
# TODO add check to transaction number
|
152
|
-
# value before exchange
|
153
|
-
txdtls_content[:gross_outgoing_value] = nodejr.at_css("AmtDtls/InstdAmt/Amt").content unless nodejr.at_css("AmtDtls/InstdAmt/Amt") == nil
|
154
|
-
# currency before exchange
|
155
|
-
txdtls_content[:gross_outgoing_currency] = nodejr.at_css("AmtDtls/InstdAmt/Amt")["Ccy"] unless nodejr.at_css("AmtDtls/InstdAmt/Amt") == nil
|
156
|
-
|
157
|
-
# exchange rate
|
158
|
-
txdtls_content[:currency_exchange_rate] = nodejr.at_css("AmtDtls/InstdAmt/CcyXchg/XchgRate").content unless nodejr.at_css("AmtDtls/InstdAmt/CcyXchg/XchgRate") == nil
|
159
|
-
|
160
|
-
# value after exchange
|
161
|
-
txdtls_content[:value_post_exchange] = nodejr.at_css("AmtDtls/TxAmt/Amt").content unless nodejr.at_css("AmtDtls/TxAmt/Amt") == nil
|
162
|
-
# currency after exchange
|
163
|
-
txdtls_content[:currency_post_exchange] = nodejr.at_css("AmtDtls/TxAmt/Amt")["Ccy"] unless nodejr.at_css("AmtDtls/TxAmt/Amt") == nil
|
164
|
-
|
165
|
-
txdtls_all<<txdtls_content unless txdtls_content[:gross_outgoing_currency] == txdtls_content[:currency_post_exchange]
|
166
|
-
end
|
167
|
-
entry_content[:txdtls] = txdtls_all
|
168
|
-
# Add single notification entry to array
|
169
|
-
notification_entries<<entry_content
|
170
|
-
end
|
171
|
-
# Add array to hash
|
172
|
-
notification_content[:notification_entries] = notification_entries
|
173
|
-
|
174
|
-
# Returns hash
|
175
|
-
notification_content
|
176
|
-
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
end
|
181
|
-
|
182
|
-
# Add incoming descriptor to array
|
183
|
-
def add_descriptor(fdesc)
|
184
|
-
fileDescriptors<<fdesc
|
185
|
-
end
|
186
|
-
|
187
|
-
# Add incoming userfiletype to the array
|
188
|
-
def add_userfiletype(ufiletype)
|
189
|
-
userFiletypes<<ufiletype
|
190
|
-
end
|
191
|
-
|
192
|
-
# Returns an array of file descriptors
|
193
|
-
def list_new_descriptors
|
194
|
-
# Lists NEW (not already downloaded) files only (as filedescriptor objects)
|
195
|
-
kek = Array.new
|
196
|
-
kek<<@fileDescriptors.select { |fd| fd.status == "NEW" }
|
197
|
-
kek
|
198
|
-
end
|
199
|
-
|
200
|
-
def list_all_descriptors
|
201
|
-
@fileDescriptors
|
202
|
-
end
|
203
|
-
|
204
|
-
# Returns the full array list of userfiletypes in the response
|
205
|
-
def list_userfiletypes
|
206
|
-
userFiletypes
|
207
|
-
end
|
208
|
-
|
209
|
-
# Returns a specific descriptor matching the file reference
|
210
|
-
def select_descriptor(fileRef)
|
211
|
-
fileDescriptors.select { |fd| fd.fileReference == fileRef }
|
212
|
-
end
|
213
|
-
|
214
|
-
# Reads response xml from bank and fills attribute values
|
215
|
-
def animate_response(file)
|
216
|
-
# Open the xml file
|
217
|
-
xml = Nokogiri::XML(File.open(file))
|
218
|
-
|
219
|
-
# To help navigating the response xml
|
220
|
-
xml.remove_namespaces!
|
221
|
-
|
222
|
-
customerId = xml.at_css("CustomerId").content unless xml.at_css("CustomerId") == nil
|
223
|
-
timestamp = xml.at_css("Timestamp").content unless xml.at_css("Timestamp") == nil
|
224
|
-
responseCode = xml.at_css("ResponseCode").content unless xml.at_css("ResponseCode") == nil
|
225
|
-
responseText = xml.at_css("ResponseText").content unless xml.at_css("ResponseText") == nil
|
226
|
-
encrypted = xml.at_css("Encrypted").content unless xml.at_css("Encrypted").content == nil
|
227
|
-
compressed = xml.at_css("Compressed").content unless xml.at_css("Compressed") == nil
|
228
|
-
|
229
|
-
# Decode the content portion automatically so that it can be read
|
230
|
-
@content = Base64.decode64(xml.at_css("Content").content) unless xml.at_css("Content") == nil
|
231
|
-
#puts content unless content == ""
|
232
|
-
|
233
|
-
# FILEDESCRIPTORS
|
234
|
-
# Initialize array
|
235
|
-
self.fileDescriptors = Array.new
|
236
|
-
|
237
|
-
# Iterate all descriptors
|
238
|
-
xml.xpath("//FileDescriptors/FileDescriptor").each do |desc|
|
239
|
-
# Initialize
|
240
|
-
fdesc = Sepa::Filedescriptor.new
|
241
|
-
|
242
|
-
# Assigning class attributes
|
243
|
-
fdesc.fileReference = desc.at_css("FileReference").content
|
244
|
-
fdesc.targetId = desc.at_css("TargetId").content
|
245
|
-
fdesc.serviceId = desc.at_css("ServiceId").content
|
246
|
-
fdesc.serviceIdOwnerName = desc.at_css("ServiceIdOwnerName").content
|
247
|
-
fdesc.fileType = desc.at_css("FileType").content
|
248
|
-
fdesc.fileTimestamp = desc.at_css("FileTimestamp").content
|
249
|
-
fdesc.status = desc.at_css("Status").content
|
250
|
-
|
251
|
-
# Add to array
|
252
|
-
self.add_descriptor(fdesc)
|
253
|
-
|
254
|
-
end
|
255
|
-
|
256
|
-
# FILETYPESERVICES
|
257
|
-
# Initialize array
|
258
|
-
self.userFiletypes = Array.new
|
259
|
-
|
260
|
-
# Iterate all userfiletypes
|
261
|
-
xml.xpath("//UserFileTypes/UserFileType").each do |ftype|
|
262
|
-
uftype = Sepa::Userfiletype.new
|
263
|
-
|
264
|
-
# Assign class attributes
|
265
|
-
uftype.targetId = ftype.at_css("TargetId").content
|
266
|
-
uftype.fileType = ftype.at_css("FileType").content
|
267
|
-
uftype.fileTypeName = ftype.at_css("FileTypeName").content
|
268
|
-
uftype.country = ftype.at_css("Country").content
|
269
|
-
uftype.direction = ftype.at_css("Direction").content
|
270
|
-
|
271
|
-
uftype.filetypeServices = Array.new
|
272
|
-
|
273
|
-
# Iterate all filetypeservice
|
274
|
-
ftype.xpath("./FileTypeServices/FileTypeService").each do |ftypes|
|
275
|
-
|
276
|
-
newservice = Sepa::Filetypeservice.new
|
277
|
-
newservice.serviceId = ftypes.at_css("ServiceId").content unless ftypes.at_css("ServiceId") == nil
|
278
|
-
newservice.serviceIdOwnerName = ftypes.at_css("ServiceIdOwnerName").content unless ftypes.at_css("ServiceIdOwnerName") == nil
|
279
|
-
newservice.serviceIdType = ftypes.at_css("ServiceType").content unless ftypes.at_css("ServiceType") == nil
|
280
|
-
newservice.serviceIdText = ftypes.at_css("ServiceIdText").content unless ftypes.at_css("ServiceIdText") == nil
|
281
|
-
|
282
|
-
# Add new service to container
|
283
|
-
uftype.add_filetypeservice(newservice)
|
284
|
-
|
285
|
-
end
|
286
|
-
# Add userfiletype to container
|
287
|
-
self.add_userfiletype(uftype)
|
288
|
-
end
|
289
|
-
end
|
290
|
-
end
|
291
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# First the sepa gem is loaded by requiring it
|
2
|
-
require 'sepafm'
|
3
|
-
|
4
|
-
# The params hash is populated with the data that is needed for gem to function
|
5
|
-
params = {
|
6
|
-
# Test pin for nordea
|
7
|
-
pin: '1234567890',
|
8
|
-
|
9
|
-
# Selected bank
|
10
|
-
bank: :nordea,
|
11
|
-
|
12
|
-
# Command for CertificateService :get_certificate
|
13
|
-
command: :get_certificate,
|
14
|
-
|
15
|
-
# Unique customer ID
|
16
|
-
customer_id: '11111111',
|
17
|
-
|
18
|
-
# Set the environment to be either PRODUCTION or TEST
|
19
|
-
environment: 'TEST',
|
20
|
-
|
21
|
-
csr_path: 'sepa/nordea_testing/keys/CSR.csr',
|
22
|
-
|
23
|
-
# Selected service (For testing: service, For real: ISSUER)
|
24
|
-
service: 'service'
|
25
|
-
|
26
|
-
}
|
27
|
-
|
28
|
-
# You just create the client with the parameters described above.
|
29
|
-
sepa_client = Sepa::Client.new(params)
|
30
|
-
|
31
|
-
sepa_client.send
|
32
|
-
|
@@ -1,257 +0,0 @@
|
|
1
|
-
# First the sepa gem is loaded by requiring it
|
2
|
-
require 'sepafm'
|
3
|
-
|
4
|
-
@invoice_bundle = []
|
5
|
-
|
6
|
-
invoice_1 = {
|
7
|
-
type: 'CINV',
|
8
|
-
amount: '700',
|
9
|
-
currency: 'EUR',
|
10
|
-
invoice_number: '123456'
|
11
|
-
}
|
12
|
-
|
13
|
-
invoice_2 = {
|
14
|
-
type: 'CINV',
|
15
|
-
amount: '300',
|
16
|
-
currency: 'EUR',
|
17
|
-
reference: '123456789',
|
18
|
-
}
|
19
|
-
|
20
|
-
invoice_3 = {
|
21
|
-
type: 'CREN',
|
22
|
-
amount: '-100',
|
23
|
-
currency: 'EUR',
|
24
|
-
invoice_number: '654321'
|
25
|
-
}
|
26
|
-
|
27
|
-
invoice_4 = {
|
28
|
-
type: 'CREN',
|
29
|
-
amount: '-500',
|
30
|
-
currency: 'EUR',
|
31
|
-
reference: '987654321'
|
32
|
-
}
|
33
|
-
|
34
|
-
@invoice_bundle.push(invoice_1)
|
35
|
-
@invoice_bundle.push(invoice_2)
|
36
|
-
@invoice_bundle.push(invoice_3)
|
37
|
-
@invoice_bundle.push(invoice_4)
|
38
|
-
|
39
|
-
trans_1_params = {
|
40
|
-
instruction_id: SecureRandom.hex,
|
41
|
-
end_to_end_id: SecureRandom.hex,
|
42
|
-
amount: '30.75',
|
43
|
-
currency: 'EUR',
|
44
|
-
bic: 'NDEAFIHH',
|
45
|
-
name: 'Testi Saaja Oy',
|
46
|
-
address: 'Kokeilukatu 66',
|
47
|
-
country: 'FI',
|
48
|
-
postcode: '00200',
|
49
|
-
town: 'Helsinki',
|
50
|
-
iban: 'FI7429501800000014',
|
51
|
-
reference: '00000000000000001245',
|
52
|
-
message: 'Maksu'
|
53
|
-
}
|
54
|
-
|
55
|
-
trans_2_params = {
|
56
|
-
instruction_id: SecureRandom.hex,
|
57
|
-
end_to_end_id: SecureRandom.hex,
|
58
|
-
amount: '1075.20',
|
59
|
-
currency: 'EUR',
|
60
|
-
bic: 'NDEAFIHH',
|
61
|
-
name: 'Testing Company',
|
62
|
-
address: 'Tynnyrikatu 56',
|
63
|
-
country: 'FI',
|
64
|
-
postcode: '00600',
|
65
|
-
town: 'Helsinki',
|
66
|
-
iban: 'FI7429501800000014',
|
67
|
-
reference: '000000000000000034795',
|
68
|
-
message: 'Siirto',
|
69
|
-
invoice_bundle: @invoice_bundle
|
70
|
-
}
|
71
|
-
|
72
|
-
trans_3_params = {
|
73
|
-
instruction_id: SecureRandom.hex,
|
74
|
-
end_to_end_id: SecureRandom.hex,
|
75
|
-
amount: '10000',
|
76
|
-
currency: 'EUR',
|
77
|
-
bic: 'NDEAFIHH',
|
78
|
-
name: 'Best Company Ever',
|
79
|
-
address: 'Banaanikuja 66',
|
80
|
-
country: 'FI',
|
81
|
-
postcode: '00900',
|
82
|
-
town: 'Helsinki',
|
83
|
-
iban: 'FI7429501800000014',
|
84
|
-
reference: '000000000000000013247',
|
85
|
-
message: 'Valuutan siirto toiselle tilille'
|
86
|
-
}
|
87
|
-
|
88
|
-
trans_4_params = {
|
89
|
-
instruction_id: SecureRandom.hex,
|
90
|
-
end_to_end_id: SecureRandom.hex,
|
91
|
-
amount: '12',
|
92
|
-
currency: 'EUR',
|
93
|
-
bic: 'NDEAFIHH',
|
94
|
-
name: 'Testi Saaja Oy',
|
95
|
-
address: 'Kokeilukatu 66',
|
96
|
-
country: 'FI',
|
97
|
-
postcode: '00200',
|
98
|
-
town: 'Helsinki',
|
99
|
-
iban: 'FI7429501800000014',
|
100
|
-
reference: '00000000000000001245',
|
101
|
-
message: 'Palkka heinakuulta',
|
102
|
-
salary: true,
|
103
|
-
social_security_number: '112233-0010'
|
104
|
-
}
|
105
|
-
|
106
|
-
trans_5_params = {
|
107
|
-
instruction_id: SecureRandom.hex,
|
108
|
-
end_to_end_id: SecureRandom.hex,
|
109
|
-
amount: '99.20',
|
110
|
-
currency: 'EUR',
|
111
|
-
bic: 'NDEAFIHH',
|
112
|
-
name: 'Testing Company',
|
113
|
-
address: 'Tynnyrikatu 56',
|
114
|
-
country: 'FI',
|
115
|
-
postcode: '00600',
|
116
|
-
town: 'Helsinki',
|
117
|
-
iban: 'FI7429501800000014',
|
118
|
-
reference: '000000000000000034795',
|
119
|
-
message: 'Elake',
|
120
|
-
pension: true
|
121
|
-
}
|
122
|
-
|
123
|
-
trans_6_params = {
|
124
|
-
instruction_id: SecureRandom.hex,
|
125
|
-
end_to_end_id: SecureRandom.hex,
|
126
|
-
amount: '15000',
|
127
|
-
currency: 'EUR',
|
128
|
-
bic: 'NDEAFIHH',
|
129
|
-
name: 'Best Company Ever',
|
130
|
-
address: 'Banaanikuja 66',
|
131
|
-
country: 'FI',
|
132
|
-
postcode: '00900',
|
133
|
-
town: 'Helsinki',
|
134
|
-
iban: 'FI7429501800000014',
|
135
|
-
reference: '000000000000000013247',
|
136
|
-
message: 'Palkka ajalta 15.6.2013 - 30.6.2013',
|
137
|
-
salary: true,
|
138
|
-
social_security_number: '112233-0096'
|
139
|
-
}
|
140
|
-
|
141
|
-
debtor = {
|
142
|
-
name: 'Testi Maksaja Oy',
|
143
|
-
address: 'Testing Street 12',
|
144
|
-
country: 'FI',
|
145
|
-
postcode: '00100',
|
146
|
-
town: 'Helsinki',
|
147
|
-
customer_id: '111111111',
|
148
|
-
iban: 'FI4819503000000010',
|
149
|
-
bic: 'NDEAFIHH'
|
150
|
-
}
|
151
|
-
|
152
|
-
payment_1_transactions = []
|
153
|
-
payment_2_transactions = []
|
154
|
-
|
155
|
-
payment_1_transactions.push(Sepa::Transaction.new(trans_1_params))
|
156
|
-
payment_1_transactions.push(Sepa::Transaction.new(trans_2_params))
|
157
|
-
payment_1_transactions.push(Sepa::Transaction.new(trans_3_params))
|
158
|
-
|
159
|
-
payment_2_transactions.push(Sepa::Transaction.new(trans_4_params))
|
160
|
-
payment_2_transactions.push(Sepa::Transaction.new(trans_5_params))
|
161
|
-
payment_2_transactions.push(Sepa::Transaction.new(trans_6_params))
|
162
|
-
|
163
|
-
payment_1_params = {
|
164
|
-
payment_info_id: SecureRandom.hex,
|
165
|
-
execution_date: '2013-08-10',
|
166
|
-
transactions: payment_1_transactions
|
167
|
-
}
|
168
|
-
|
169
|
-
payment_2_params = {
|
170
|
-
payment_info_id: SecureRandom.hex,
|
171
|
-
execution_date: '2013-08-15',
|
172
|
-
salary_or_pension: true,
|
173
|
-
transactions: payment_2_transactions
|
174
|
-
}
|
175
|
-
|
176
|
-
payments = []
|
177
|
-
|
178
|
-
payments.push(Sepa::Payment.new(debtor, payment_1_params))
|
179
|
-
payments.push(Sepa::Payment.new(debtor, payment_2_params))
|
180
|
-
|
181
|
-
payload = Sepa::Payload.new(debtor, payments)
|
182
|
-
payload = payload.to_xml
|
183
|
-
|
184
|
-
# The params hash is populated with the data that is needed for gem to function.
|
185
|
-
params = {
|
186
|
-
|
187
|
-
bank: :nordea,
|
188
|
-
|
189
|
-
cert_path: "sepa/nordea_testing/keys/nordea.crt",
|
190
|
-
|
191
|
-
private_key_path: "sepa/nordea_testing/keys/nordea.key",
|
192
|
-
|
193
|
-
# Command :download_file_list, :upload_file, :download_file or :get_user_info.
|
194
|
-
command: :upload_file,
|
195
|
-
|
196
|
-
# Unique customer ID.
|
197
|
-
customer_id: '11111111',
|
198
|
-
|
199
|
-
# Set the environment to be either PRODUCTION or TEST.
|
200
|
-
environment: 'PRODUCTION',
|
201
|
-
|
202
|
-
# For filtering stuff. Must be either NEW, DOWNLOADED or ALL.
|
203
|
-
status: 'NEW',
|
204
|
-
|
205
|
-
# Some specification of the folder which to access in the bank. I have no
|
206
|
-
# idea how this works however.
|
207
|
-
target_id: '11111111A1',
|
208
|
-
|
209
|
-
# Language must be either FI, EN or SV.
|
210
|
-
language: 'FI',
|
211
|
-
|
212
|
-
# File types to upload or download:
|
213
|
-
# - LMP300 = Laskujen maksupalvelu (lähtevä)
|
214
|
-
# - LUM2 = Valuuttamaksut (lähtevä)
|
215
|
-
# - KTL = Saapuvat viitemaksut (saapuva)
|
216
|
-
# - TITO = Konekielinen tiliote (saapuva)
|
217
|
-
# - NDCORPAYS = Yrityksen maksut XML (lähtevä)
|
218
|
-
# - NDCAMT53L = Konekielinen XML-tiliote (saapuva)
|
219
|
-
# - NDCAMT54L = Saapuvat XML viitemaksu (saapuva)
|
220
|
-
file_type: 'NDCORPAYS',
|
221
|
-
|
222
|
-
# The WSDL file used by nordea. Is identical between banks except for the
|
223
|
-
# address.
|
224
|
-
wsdl: 'sepa/wsdl/wsdl_nordea.xml',
|
225
|
-
|
226
|
-
# The actual payload to send.
|
227
|
-
content: payload,
|
228
|
-
|
229
|
-
# File reference for :download_file command.
|
230
|
-
file_reference: "11111111A12006030329501800000014"
|
231
|
-
}
|
232
|
-
|
233
|
-
# You just create the client with the parameters described above.
|
234
|
-
sepa_client = Sepa::Client.new(params)
|
235
|
-
|
236
|
-
response = sepa_client.send
|
237
|
-
response = Nokogiri::XML(response.to_xml)
|
238
|
-
response = Sepa::Response.new(response)
|
239
|
-
|
240
|
-
ar = Sepa::ApplicationResponse.new(response.application_response)
|
241
|
-
|
242
|
-
puts "\n\nHashes match in the response: #{response.hashes_match?}"
|
243
|
-
puts "Signature is valid in the response: #{response.signature_is_valid?}"
|
244
|
-
|
245
|
-
puts "\nHashes match in the application response: #{ar.hashes_match?}"
|
246
|
-
puts "Signature is valid in the application response: #{ar.signature_is_valid?}"
|
247
|
-
|
248
|
-
puts "\nSome info about response's certificate:\n" \
|
249
|
-
|
250
|
-
"Issuer: #{response.certificate.issuer}\n" \
|
251
|
-
"First day to use this certificate: #{response.certificate.not_before}\n" \
|
252
|
-
"Expires: #{response.certificate.not_after}"
|
253
|
-
|
254
|
-
puts "\nSome info about application response's certificate:\n" \
|
255
|
-
"Issuer: #{ar.certificate.issuer}\n" \
|
256
|
-
"First day to use this certificate: #{ar.certificate.not_before}\n" \
|
257
|
-
"Expires: #{ar.certificate.not_after}"
|