sepafm 0.1.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +6 -0
- data/lib/sepa/application_request.rb +87 -0
- data/lib/sepa/application_response.rb +37 -2
- data/lib/sepa/attribute_checks.rb +30 -0
- data/lib/sepa/banks/danske/danske_response.rb +86 -0
- data/lib/sepa/banks/danske/soap_danske.rb +81 -3
- data/lib/sepa/banks/nordea/nordea_response.rb +18 -0
- data/lib/sepa/banks/nordea/soap_nordea.rb +25 -2
- data/lib/sepa/client.rb +203 -18
- data/lib/sepa/error_messages.rb +54 -13
- data/lib/sepa/response.rb +118 -11
- data/lib/sepa/soap_builder.rb +53 -2
- data/lib/sepa/utilities.rb +167 -6
- data/lib/sepa/version.rb +3 -1
- data/lib/sepafm.rb +57 -4
- data/readme.md +74 -60
- data/test/sepa/sepa_test.rb +1 -1
- metadata +5 -3
data/lib/sepafm.rb
CHANGED
@@ -19,33 +19,86 @@ require 'sepa/banks/danske/soap_danske'
|
|
19
19
|
require 'sepa/banks/nordea/soap_nordea'
|
20
20
|
require 'sepa/version'
|
21
21
|
|
22
|
+
# The root path of where the gem is installed
|
23
|
+
# @todo Put all constants under Sepa namespace
|
22
24
|
ROOT_PATH = File.expand_path('../../', __FILE__)
|
25
|
+
|
26
|
+
|
27
|
+
# @!group Schemas
|
28
|
+
|
29
|
+
# The path where the WSDL-files for different banks are located
|
23
30
|
WSDL_PATH = "#{ROOT_PATH}/lib/sepa/wsdl"
|
31
|
+
|
32
|
+
# The path where the xml schemas are located
|
24
33
|
SCHEMA_PATH = "#{ROOT_PATH}/lib/sepa/xml_schemas"
|
34
|
+
|
35
|
+
# Path to the WSDL schema
|
25
36
|
SCHEMA_FILE = "#{ROOT_PATH}/lib/sepa/xml_schemas/wsdl.xml"
|
37
|
+
|
38
|
+
# @!endgroup
|
39
|
+
|
40
|
+
|
41
|
+
# @!group Templates
|
42
|
+
|
43
|
+
# Path to the application request templates
|
26
44
|
AR_TEMPLATE_PATH = "#{ROOT_PATH}/lib/sepa/xml_templates/application_request"
|
45
|
+
|
46
|
+
# Path to the soap templates
|
27
47
|
SOAP_TEMPLATE_PATH = "#{ROOT_PATH}/lib/sepa/xml_templates/soap"
|
28
48
|
|
29
|
-
#
|
49
|
+
# @!endgroup
|
50
|
+
|
51
|
+
|
52
|
+
# @!group Certificates
|
53
|
+
|
54
|
+
# Path to where the certificates are located
|
30
55
|
CERTIFICATE_PATH = "#{ROOT_PATH}/lib/sepa/certificates/"
|
56
|
+
|
31
57
|
nordea_root_certificate_string = File.read("#{CERTIFICATE_PATH}nordea_root_certificate.cer")
|
58
|
+
|
59
|
+
# Nordea's root certificate as an OpenSSL::X509::Certificate
|
32
60
|
NORDEA_ROOT_CERTIFICATE = OpenSSL::X509::Certificate.new nordea_root_certificate_string
|
33
61
|
danske_root_certificate_string = File.read("#{CERTIFICATE_PATH}danske_root_certificate.cer")
|
62
|
+
|
63
|
+
# Danske Bank's root certificate as an OpenSSL::X509::Certificate
|
34
64
|
DANSKE_ROOT_CERTIFICATE = OpenSSL::X509::Certificate.new danske_root_certificate_string
|
35
65
|
|
36
|
-
#
|
66
|
+
# @!endgroup
|
67
|
+
|
68
|
+
|
69
|
+
# @!group XML Namespaces
|
70
|
+
|
71
|
+
# Namespace used by XML digital signature
|
37
72
|
DSIG = 'http://www.w3.org/2000/09/xmldsig#'
|
73
|
+
|
74
|
+
# Oasis utility namespace used in soap header for security purposes
|
38
75
|
OASIS_UTILITY = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'
|
76
|
+
|
77
|
+
# Oasis secext namespace used in soap header for security purposes
|
39
78
|
OASIS_SECEXT = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'
|
79
|
+
|
80
|
+
# Namespace used in application requests and application responses
|
40
81
|
XML_DATA = 'http://bxd.fi/xmldata/'
|
82
|
+
|
83
|
+
# Namespace of the node that contains application request or application response
|
41
84
|
BXD = 'http://model.bxd.fi'
|
85
|
+
|
86
|
+
# Namespace for XML encryption syntax and processing
|
42
87
|
XMLENC = 'http://www.w3.org/2001/04/xmlenc#'
|
88
|
+
|
89
|
+
# Soap envelope namespace
|
43
90
|
ENVELOPE = 'http://schemas.xmlsoap.org/soap/envelope/'
|
44
91
|
|
45
|
-
# Nordea
|
92
|
+
# Namespace used in Nordea's certificate requests and responses soap
|
46
93
|
NORDEA_PKI = 'http://bxd.fi/CertificateService'
|
94
|
+
|
95
|
+
# Namespace used in Nordea's certificate application requests and responses
|
47
96
|
NORDEA_XML_DATA = 'http://filetransfer.nordea.com/xmldata/'
|
48
97
|
|
49
|
-
# Danske
|
98
|
+
# Namespace used in Danske Bank's certificate services application requests and responses
|
50
99
|
DANSKE_PKI = 'http://danskebank.dk/PKI/PKIFactoryService/elements'
|
100
|
+
|
101
|
+
# Namespace used in Danske Bank's certificate services soap
|
51
102
|
DANSKE_PKIF = 'http://danskebank.dk/PKI/PKIFactoryService'
|
103
|
+
|
104
|
+
# @!endgroup
|
data/readme.md
CHANGED
@@ -7,42 +7,40 @@
|
|
7
7
|
|
8
8
|
This project aims to create an open source implementation of SEPA Financial Messages using Web Services. Project implementation is done in Ruby.
|
9
9
|
|
10
|
-
Currently we have support for SEPA Web Services for
|
10
|
+
Currently we have support for SEPA Web Services for
|
11
11
|
|
12
12
|
* Nordea
|
13
13
|
* Danske Bank
|
14
14
|
|
15
15
|
## Installation
|
16
16
|
|
17
|
-
Add this line to your application's Gemfile
|
17
|
+
Add this line to your application's Gemfile
|
18
18
|
|
19
19
|
```ruby
|
20
20
|
gem 'sepafm'
|
21
21
|
```
|
22
22
|
|
23
|
-
And then execute
|
23
|
+
And then execute
|
24
24
|
|
25
25
|
```bash
|
26
26
|
$ bundle
|
27
27
|
```
|
28
28
|
|
29
|
-
Or install
|
29
|
+
**Or** install gem with
|
30
30
|
|
31
31
|
```bash
|
32
32
|
$ gem install sepafm
|
33
33
|
```
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
### Require the gem
|
35
|
+
And require it in your code
|
38
36
|
|
39
37
|
```ruby
|
40
38
|
require 'sepafm'
|
41
39
|
```
|
42
40
|
|
43
|
-
|
41
|
+
## Using the Gem
|
44
42
|
|
45
|
-
Define parameters hash for client, ie. get Nordea bank statement
|
43
|
+
Define parameters hash for client, ie. get Nordea bank statement
|
46
44
|
|
47
45
|
```ruby
|
48
46
|
params = {
|
@@ -69,8 +67,6 @@ Send request to bank
|
|
69
67
|
response = client.send_request
|
70
68
|
```
|
71
69
|
|
72
|
-
### Interacting with the response
|
73
|
-
|
74
70
|
Make sure response is valid
|
75
71
|
|
76
72
|
```ruby
|
@@ -83,7 +79,38 @@ Get response content
|
|
83
79
|
response.content
|
84
80
|
```
|
85
81
|
|
86
|
-
|
82
|
+
## Getting Started
|
83
|
+
|
84
|
+
First, you need certificates from your bank. For basic requests you'll need
|
85
|
+
|
86
|
+
* Your signing certificate
|
87
|
+
* Private key for your signing certificate
|
88
|
+
* Your encryption certificate (Danske Only)
|
89
|
+
* Private key for your encryption certificate (Danske Only)
|
90
|
+
* Banks encryption certificate (Danske Only)
|
91
|
+
|
92
|
+
You have to get your bank to sign your signing/encryption certificate(s). For this you need to make
|
93
|
+
|
94
|
+
* Your signing certificate signing request
|
95
|
+
* Your encryption certificate signing request (Danske Only)
|
96
|
+
|
97
|
+
You can generate your certificate signing requests with `openssl`
|
98
|
+
|
99
|
+
```bash
|
100
|
+
openssl req -out encryption.csr -new -newkey rsa:2048 -nodes -keyout encryption.key
|
101
|
+
openssl req -out signing.csr -new -newkey rsa:2048 -nodes -keyout signing.key
|
102
|
+
```
|
103
|
+
|
104
|
+
Enter your information and you should have four files
|
105
|
+
|
106
|
+
```
|
107
|
+
encryption.csr
|
108
|
+
encryption.key
|
109
|
+
signing.csr
|
110
|
+
signing.key
|
111
|
+
```
|
112
|
+
|
113
|
+
### Downloading Nordea Certificate
|
87
114
|
|
88
115
|
Define parameters hash for client
|
89
116
|
|
@@ -94,7 +121,7 @@ params = {
|
|
94
121
|
command: :get_certificate,
|
95
122
|
customer_id: '11111111',
|
96
123
|
environment: 'test',
|
97
|
-
signing_csr: "...your signing
|
124
|
+
signing_csr: "...your signing.csr content..."
|
98
125
|
}
|
99
126
|
```
|
100
127
|
|
@@ -116,15 +143,15 @@ Make sure the response is valid
|
|
116
143
|
response.valid?
|
117
144
|
```
|
118
145
|
|
119
|
-
Get the certificate from the response
|
146
|
+
Get the certificate from the response and save it in a safe place
|
120
147
|
|
121
148
|
```ruby
|
122
149
|
response.own_signing_certificate
|
123
150
|
```
|
124
151
|
|
125
|
-
### Downloading Danske
|
152
|
+
### Downloading Danske Bank Certificates
|
126
153
|
|
127
|
-
|
154
|
+
**Bank's certificates**
|
128
155
|
|
129
156
|
Define parameters hash for client
|
130
157
|
|
@@ -156,7 +183,7 @@ Make sure the response is valid
|
|
156
183
|
response.valid?
|
157
184
|
```
|
158
185
|
|
159
|
-
Get the certificates from the response
|
186
|
+
Get the certificates from the response and save them in a safe place
|
160
187
|
|
161
188
|
```ruby
|
162
189
|
# Bank's encryption certificate
|
@@ -169,19 +196,19 @@ response.bank_signing_certificate
|
|
169
196
|
response.bank_root_certificate
|
170
197
|
```
|
171
198
|
|
172
|
-
|
199
|
+
**Own certificates**
|
173
200
|
|
174
201
|
Define parameters hash
|
175
202
|
|
176
203
|
``` ruby
|
177
204
|
params = {
|
178
205
|
bank: :danske,
|
179
|
-
bank_encryption_certificate: '...banks encryption certificate...',
|
206
|
+
bank_encryption_certificate: '...banks encryption certificate content from above...',
|
180
207
|
command: :create_certificate,
|
181
208
|
customer_id: '360817',
|
182
209
|
environment: 'production',
|
183
|
-
encryption_csr: '...encryption
|
184
|
-
signing_csr: '...
|
210
|
+
encryption_csr: '...your encryption.csr content ...',
|
211
|
+
signing_csr: '...your signing.csr content...',
|
185
212
|
pin: '1234'
|
186
213
|
}
|
187
214
|
```
|
@@ -204,7 +231,7 @@ Make sure the response is valid
|
|
204
231
|
response.valid?
|
205
232
|
```
|
206
233
|
|
207
|
-
Get the certificates from the response
|
234
|
+
Get the certificates from the response and save them in a safe place
|
208
235
|
|
209
236
|
```ruby
|
210
237
|
# Own encryption certificate
|
@@ -217,42 +244,31 @@ response.own_signing_certificate
|
|
217
244
|
response.ca_certificate
|
218
245
|
```
|
219
246
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
* TITO = Konekielinen tiliote (saapuva)
|
246
|
-
* NDCORPAYS = Yrityksen maksut XML (lähtevä)
|
247
|
-
* NDCAMT53L = Konekielinen XML-tiliote (saapuva)
|
248
|
-
* NDCAMT54L = Saapuvat XML viitemaksu (saapuva)
|
249
|
-
* **content** - The payload to send.
|
250
|
-
* **file_reference** - File reference for :download_file command
|
251
|
-
* **pin** - Your personal pin-code provided by the bank
|
252
|
-
|
253
|
-
---
|
254
|
-
|
255
|
-
## Upcoming features
|
247
|
+
## Client Parameters
|
248
|
+
|
249
|
+
Not all parameters are needed in every request.
|
250
|
+
|
251
|
+
Parameter | Description
|
252
|
+
--- | ---
|
253
|
+
bank | Bank you want to send the request to. Either `:nordea` or `:danske`
|
254
|
+
customer_id | Customer id from bank.
|
255
|
+
command | Must be one of: `download_file_list`, `upload_file`, `download_file`, `get_user_info`, `get_certificate`, `get_bank_certificate`, `create_certificate`.
|
256
|
+
content | Content to be sent to the bank in `upload_file`.
|
257
|
+
environment | Bank's environment where the request is sent. Has to be `production` or `test`.
|
258
|
+
language | Language of the response. Must be either `FI`, `EN` or `SV`.
|
259
|
+
target_id | Code used to categorize files. Can be retrieved with `get_user_info` -command. Only used by Nordea.
|
260
|
+
file_type | Type of the file(s) your are going to download or send. These differ by bank. With Nordea they can be retrieved with `get_user_info` -command.
|
261
|
+
file_reference | File's unique identification for downloading a file. Retrieved with `download_file_list` -command.
|
262
|
+
status | Status for the file to be retrieved. Has to be `NEW`, `DOWNLOADED` or `ALL`.
|
263
|
+
signing_private_key | Your private key of your signing certificate for signing the request.
|
264
|
+
encryption_private_key | Your private key of your encryption certificate for decrypting the response.
|
265
|
+
own_signing_certificate | Your signing certificate, signed by the bank.
|
266
|
+
bank_encryption_certificate | Encryption certificate of the bank for encrypting the request.
|
267
|
+
pin | One-time code retrieved from bank which can be used to download new certificates.
|
268
|
+
signing_csr | Signing certificate signing request.
|
269
|
+
encryption_csr | Encryption certificate signing request.
|
270
|
+
|
271
|
+
## Upcoming Features
|
256
272
|
|
257
273
|
* Parse responses
|
258
274
|
* Bank-to-Customer Statement
|
@@ -266,8 +282,6 @@ response.ca_certificate
|
|
266
282
|
* ISO standard "CustomerCreditTransferInitiationV03"
|
267
283
|
* XML schema "pain.001.001.03"
|
268
284
|
|
269
|
-
---
|
270
|
-
|
271
285
|
## Contributing
|
272
286
|
|
273
287
|
1. Fork it
|
data/test/sepa/sepa_test.rb
CHANGED
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.
|
4
|
+
version: 1.0.0
|
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: 2014-08-
|
13
|
+
date: 2014-08-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activemodel
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- ".gitignore"
|
149
149
|
- ".ruby-version"
|
150
150
|
- ".travis.yml"
|
151
|
+
- ".yardopts"
|
151
152
|
- Gemfile
|
152
153
|
- LICENSE
|
153
154
|
- Rakefile
|
@@ -267,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
267
268
|
version: '0'
|
268
269
|
requirements: []
|
269
270
|
rubyforge_project:
|
270
|
-
rubygems_version: 2.
|
271
|
+
rubygems_version: 2.4.1
|
271
272
|
signing_key:
|
272
273
|
specification_version: 4
|
273
274
|
summary: SEPA Financial Messages
|
@@ -317,3 +318,4 @@ test_files:
|
|
317
318
|
- test/sepa/sepa_test.rb
|
318
319
|
- test/sepa/test_files/invalid_wsdl.wsdl
|
319
320
|
- test/test_helper.rb
|
321
|
+
has_rdoc:
|