fintecture 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +17 -17
- data/.rspec +3 -3
- data/.travis.yml +7 -7
- data/CODE_OF_CONDUCT.md +74 -74
- data/Gemfile +8 -8
- data/Gemfile.lock +59 -59
- data/LICENSE.txt +674 -674
- data/README.md +407 -407
- data/Rakefile +8 -8
- data/bin/console +15 -15
- data/bin/setup +8 -8
- data/exemples/ais.rb +53 -53
- data/exemples/config_ais.json +7 -7
- data/exemples/config_pis.json +5 -5
- data/exemples/pis.rb +148 -148
- data/exemples/ressources.rb +23 -23
- data/fintecture.gemspec +44 -44
- data/lib/fintecture/ais_client.rb +94 -94
- data/lib/fintecture/api/ais/account_holders.rb +61 -61
- data/lib/fintecture/api/ais/accounts.rb +63 -63
- data/lib/fintecture/api/ais/authorize.rb +72 -72
- data/lib/fintecture/api/ais/authorize_decoupled.rb +68 -68
- data/lib/fintecture/api/ais/connect.rb +65 -65
- data/lib/fintecture/api/ais/delete_customer.rb +53 -53
- data/lib/fintecture/api/ais/transactions.rb +64 -64
- data/lib/fintecture/api/auth/authentication.rb +78 -78
- data/lib/fintecture/api/pis/connect.rb +77 -77
- data/lib/fintecture/api/pis/initiate.rb +52 -52
- data/lib/fintecture/api/pis/payments.rb +48 -48
- data/lib/fintecture/api/pis/refund.rb +67 -67
- data/lib/fintecture/api/pis/request_to_pay.rb +63 -63
- data/lib/fintecture/api/pis/settlements.rb +50 -50
- data/lib/fintecture/api/ressources/applications.rb +57 -57
- data/lib/fintecture/api/ressources/providers.rb +61 -61
- data/lib/fintecture/api/ressources/test_accounts.rb +60 -60
- data/lib/fintecture/base_url.rb +26 -26
- data/lib/fintecture/endpoints/ais.rb +17 -17
- data/lib/fintecture/endpoints/authentication.rb +13 -13
- data/lib/fintecture/endpoints/pis.rb +16 -16
- data/lib/fintecture/endpoints/ressources.rb +13 -13
- data/lib/fintecture/exceptions.rb +75 -72
- data/lib/fintecture/faraday/authentication/connection.rb +140 -140
- data/lib/fintecture/pis_client.rb +100 -100
- data/lib/fintecture/utils/constants.rb +11 -11
- data/lib/fintecture/utils/crypto.rb +75 -75
- data/lib/fintecture/utils/date.rb +15 -15
- data/lib/fintecture/utils/validation.rb +32 -32
- data/lib/fintecture/version.rb +5 -5
- data/lib/fintecture.rb +65 -65
- metadata +8 -8
data/README.md
CHANGED
@@ -1,407 +1,407 @@
|
|
1
|
-
# Fintecture
|
2
|
-
|
3
|
-
Fintecture is connected with most European banks and enables a user to initiate a payment directly from their bank account. This results to a bank transfer sent from the user's bank account directly to your bank account, skipping all intermediaries. Within the SEPA region, transfers take between 10 seconds to 1 business day to arrive on your bank account. No hidden fees. Check out [our website](https://fintecture.com/).
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
```ruby
|
10
|
-
gem 'fintecture'
|
11
|
-
```
|
12
|
-
|
13
|
-
|
14
|
-
And then execute:
|
15
|
-
|
16
|
-
$ bundle
|
17
|
-
|
18
|
-
Or install it yourself as:
|
19
|
-
|
20
|
-
$ gem install fintecture
|
21
|
-
|
22
|
-
## Usage
|
23
|
-
|
24
|
-
Get started by subscribing to a free developer account. Join today to get access to our sandbox by registering on the [developer console](https://console.fintecture.com) by creating your first sets of API Keys. When creating an account, specify you are an ECOMMERCE. When you’re ready to deploy to production, just go through the Activation Form in your console. Once the Fintecture Team activates your account, you’ll be ready to start receiving real bank transfers directly on the bank account specified during activation.
|
25
|
-
|
26
|
-
By default `sandbox` is the initial environment, but you can change to sandbox by doing
|
27
|
-
|
28
|
-
Initialize your PIS client
|
29
|
-
|
30
|
-
```ruby
|
31
|
-
pis_client = Fintecture::PisClient.new({
|
32
|
-
environment: 'sandbox', # => ["sandbox", "test", "production"]
|
33
|
-
app_id: 'your_app_id',
|
34
|
-
app_secret: 'your_app_secret',
|
35
|
-
private_key: %q(your_private_key)
|
36
|
-
})
|
37
|
-
```
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
Initialize your AIS client
|
42
|
-
|
43
|
-
```ruby
|
44
|
-
ais_client = Fintecture::AisClient.new({
|
45
|
-
environment: 'sandbox', # => ["sandbox", "test", "production"]
|
46
|
-
app_id: 'your_app_id',
|
47
|
-
app_secret: 'your_app_secret',
|
48
|
-
private_key: %q(your_private_key)
|
49
|
-
})
|
50
|
-
```
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
## PIS
|
55
|
-
PIS client properties
|
56
|
-
```ruby
|
57
|
-
pis_client.app_id
|
58
|
-
pis_client.app_secret
|
59
|
-
pis_client.private_key
|
60
|
-
pis_client.environment
|
61
|
-
pis_client.token
|
62
|
-
pis_client.token_expires_in
|
63
|
-
```
|
64
|
-
|
65
|
-
#### Access token
|
66
|
-
This method return the token and store it in the client for future requests
|
67
|
-
```ruby
|
68
|
-
pis_client.generate_token
|
69
|
-
```
|
70
|
-
|
71
|
-
|
72
|
-
#### POST /connect
|
73
|
-
Documentation => https://docs.fintecture.com/v2/#post-post-post-connect
|
74
|
-
- An example of the JSON payload in the right column in "Request Body" section
|
75
|
-
- An exemple of response in the right column in "Request Body" section
|
76
|
-
- The definitions of each field in the "Body Parameters" section
|
77
|
-
|
78
|
-
```ruby
|
79
|
-
# connect (payload, state, redirect_uri = nil, origin_uri = nil)
|
80
|
-
# payload: {}
|
81
|
-
# state: string
|
82
|
-
# redirect_uri: string
|
83
|
-
# origin_uri: string
|
84
|
-
|
85
|
-
response = pis_client.connect payload, "my-state", "https://www.my-redirect-uri.fr", "https://www.my-origine-uri.fr"
|
86
|
-
```
|
87
|
-
|
88
|
-
|
89
|
-
#### POST /initiate
|
90
|
-
Documentation => https://docs.fintecture.com/v2/#post-post-post-initiate
|
91
|
-
- An example of the JSON payload in the right column in "Request Body" section
|
92
|
-
- An exemple of response in the right column in "Request Body" section
|
93
|
-
- The definitions of each field in the "Body Parameters" section
|
94
|
-
|
95
|
-
```ruby
|
96
|
-
# initiate (payload, provider_id, redirect_uri, state = nil)
|
97
|
-
# payload: {}
|
98
|
-
# provider_id: string
|
99
|
-
# redirect_uri: string
|
100
|
-
# state: string
|
101
|
-
|
102
|
-
response = pis_client.initiate payload, "cmcifrpp", "https://www.my-redirect-uri.fr", "my-state"
|
103
|
-
```
|
104
|
-
|
105
|
-
#### GET /payments
|
106
|
-
Documentation => https://docs.fintecture.com/v2/#get-get-get-payments
|
107
|
-
- An exemple of response in the right column in "Request Body" section
|
108
|
-
|
109
|
-
```ruby
|
110
|
-
# payments (session_id = nil)
|
111
|
-
# session_id: string
|
112
|
-
|
113
|
-
response = pis_client.payments "7f47d3675f5d4964bc416b43af63b06e"
|
114
|
-
OR
|
115
|
-
response = pis_client.payments
|
116
|
-
```
|
117
|
-
This endpoint returns the details of all transfers or of a specific transfer
|
118
|
-
|
119
|
-
#### POST /refund
|
120
|
-
Documentation => https://docs.fintecture.com/v2/#post-post-post-refund
|
121
|
-
- An exemple of response in the right column in "Request Body" section
|
122
|
-
|
123
|
-
```ruby
|
124
|
-
# refund (session_id, amount = nil)
|
125
|
-
# session_id: string
|
126
|
-
# amount: number
|
127
|
-
|
128
|
-
response = pis_client.refund "7f47d3675f5d4964bc416b43af63b06e", 5.75
|
129
|
-
```
|
130
|
-
If the amount is not specified, refund the total
|
131
|
-
|
132
|
-
#### POST /request-to-pay
|
133
|
-
Documentation => https://docs.fintecture.com/v2/#post-post-post-request-to-pay
|
134
|
-
- An example of the JSON payload in the right column in "Request Body" section
|
135
|
-
- An exemple of response in the right column in "Request Body" section
|
136
|
-
- The definitions of each field in the "Body Parameters" section
|
137
|
-
- The definition of x_language field in the "Header Parameters" section
|
138
|
-
|
139
|
-
```ruby
|
140
|
-
# refund (payload, x_language, redirect_uri = nil)
|
141
|
-
# payload: {}
|
142
|
-
# x_language: string
|
143
|
-
# redirect_uri: string
|
144
|
-
|
145
|
-
response = pis_client.request_to_pay payload, 'fr', "https://www.my-redirect-uri.fr"
|
146
|
-
```
|
147
|
-
|
148
|
-
#### GET /settlements
|
149
|
-
Documentation => https://docs.fintecture.com/v2/#get-get-get-settlements
|
150
|
-
- An exemple of response in the right column in "Request Body" section
|
151
|
-
|
152
|
-
```ruby
|
153
|
-
# settlements (settlement_id = nil, include_payments = false)
|
154
|
-
# settlement_id: string
|
155
|
-
# include_payments: boolean
|
156
|
-
|
157
|
-
response = pis_client.settlements
|
158
|
-
OR
|
159
|
-
response = pis_client.settlements "127335fdeb073e0eb2313ba0bd71ad44"
|
160
|
-
OR
|
161
|
-
response = pis_client.settlements "127335fdeb073e0eb2313ba0bd71ad44", true
|
162
|
-
```
|
163
|
-
|
164
|
-
## AIS
|
165
|
-
AIS client properties
|
166
|
-
```ruby
|
167
|
-
ais_client.app_id
|
168
|
-
ais_client.app_secret
|
169
|
-
ais_client.private_key
|
170
|
-
ais_client.environment
|
171
|
-
ais_client.token
|
172
|
-
ais_client.refresh_token
|
173
|
-
ais_client.token_expires_in
|
174
|
-
```
|
175
|
-
#### GET /connect
|
176
|
-
Documentation => https://docs.fintecture.com/v2/#get-get-get-connect
|
177
|
-
- An exemple of response in the right column in "Request Body" section
|
178
|
-
|
179
|
-
```ruby
|
180
|
-
# connect (state, redirect_uri, scope = nil)
|
181
|
-
# state: string
|
182
|
-
# redirect_uri: string
|
183
|
-
# scope: string
|
184
|
-
|
185
|
-
response = ais_client.connect "my-state", "https://www.my-redirect-uri.fr"
|
186
|
-
```
|
187
|
-
When you follow the returned url, you'll be redirect with "customer_id" & "code" parameters
|
188
|
-
```ruby
|
189
|
-
customer_id = "fa51058b5f8306f1e048f1adda5488a9"
|
190
|
-
code = "f66ec660b0bbd2797bf6847fb4b98454"
|
191
|
-
```
|
192
|
-
|
193
|
-
#### Access token
|
194
|
-
Documentation => https://docs.fintecture.com/v2/#post-post-post-oauth-accesstoken
|
195
|
-
|
196
|
-
This method return the token and store it in the client for future requests
|
197
|
-
```ruby
|
198
|
-
ais_client.generate_token code
|
199
|
-
```
|
200
|
-
|
201
|
-
#### Refresh token
|
202
|
-
Documentation => https://docs.fintecture.com/v2/#post-post-post-oauth-refreshtoken
|
203
|
-
|
204
|
-
This method return the token and store it in the client for future requests
|
205
|
-
If you do not pass the refreshtoken as a parameter, the client refreshtoken will be used
|
206
|
-
```ruby
|
207
|
-
# generate_refresh_token (refresh_token = nil)
|
208
|
-
# refresh_token: string
|
209
|
-
|
210
|
-
ais_client.generate_refresh_token
|
211
|
-
```
|
212
|
-
|
213
|
-
#### GET /authorize
|
214
|
-
Documentation => https://docs.fintecture.com/v2/#get-get-get-authorize
|
215
|
-
- An exemple of response in the right column in "Request Body" section
|
216
|
-
- The definition of "x_psu_id" and "x_psu_ip_address" fields in the "Header Parameters" section
|
217
|
-
|
218
|
-
```ruby
|
219
|
-
# authorize (app_id_auth: false, provider_id:, redirect_uri:, state: nil, x_psu_id: nil, x_psu_ip_address: nil)
|
220
|
-
# app_id_auth: boolean
|
221
|
-
# provider_id: string
|
222
|
-
# redirect_uri: string
|
223
|
-
# state: string
|
224
|
-
# x_psu_id: string
|
225
|
-
# x_psu_ip_address: string
|
226
|
-
|
227
|
-
response = ais_client.authorize app_id_auth: false, provider_id: "agfbfr", redirect_uri: "https://www.google.fr", state: "ok", x_psu_id: "123456", x_psu_ip_address: "192.168.1.1"
|
228
|
-
```
|
229
|
-
|
230
|
-
#### GET /authorize/decoupled
|
231
|
-
Documentation => https://docs.fintecture.com/v2/#get-get-get-authorize-decoupled
|
232
|
-
- An exemple of response in the right column in "Request Body" section
|
233
|
-
|
234
|
-
```ruby
|
235
|
-
# authorize_decoupled (app_id_auth: false, provider_id:, polling_id:)
|
236
|
-
# app_id_auth: boolean
|
237
|
-
# provider_id: string
|
238
|
-
# polling_id: string
|
239
|
-
|
240
|
-
response = ais_client.authorize_decoupled app_id_auth: false, provider_id: "agfbfr", polling_id: "1234"
|
241
|
-
```
|
242
|
-
|
243
|
-
#### GET /accounts
|
244
|
-
Documentation => https://docs.fintecture.com/v2/#get-get-get-accounts
|
245
|
-
- An exemple of response in the right column in "Request Body" section
|
246
|
-
|
247
|
-
```ruby
|
248
|
-
# accounts (customer_id:, account_id: nil, remove_nulls: nil, withBalances: nil)
|
249
|
-
# customer_id: string
|
250
|
-
# account_id: string
|
251
|
-
# remove_nulls: boolean
|
252
|
-
# withBalances: boolean
|
253
|
-
|
254
|
-
response = ais_client.accounts customer_id: customer_id, account_id: nil, remove_nulls: nil, withBalances: nil
|
255
|
-
```
|
256
|
-
|
257
|
-
#### GET /transactions
|
258
|
-
Documentation => https://docs.fintecture.com/v2/#get-get-get-transactions
|
259
|
-
- An exemple of response in the right column in "Request Body" section
|
260
|
-
|
261
|
-
```ruby
|
262
|
-
# transactions (customer_id:, account_id:, remove_nulls: nil, convert_dates: nil, filters: nil)
|
263
|
-
# customer_id: string
|
264
|
-
# account_id: string
|
265
|
-
# remove_nulls: boolean
|
266
|
-
# convert_dates: boolean
|
267
|
-
# filters: {}
|
268
|
-
|
269
|
-
transactions_filters = {
|
270
|
-
"filter[date_to]": "2020-01-01",
|
271
|
-
'filter[date_from]': "max" # Date or 'max'
|
272
|
-
}
|
273
|
-
response = ais_client.transactions customer_id: customer_id, account_id: "b71722204d1a3f5ecd895", remove_nulls: true, convert_dates: true, filters: transactions_filters
|
274
|
-
```
|
275
|
-
|
276
|
-
#### GET /accountholders
|
277
|
-
Documentation => https://docs.fintecture.com/v2/#get-get-get-accountholders
|
278
|
-
- An exemple of response in the right column in "Request Body" section
|
279
|
-
|
280
|
-
```ruby
|
281
|
-
# account_holders (customer_id:, remove_nulls: nil)
|
282
|
-
# customer_id: string
|
283
|
-
# remove_nulls: boolean
|
284
|
-
|
285
|
-
response = ais_client.account_holders customer_id: customer_id, remove_nulls: true
|
286
|
-
```
|
287
|
-
|
288
|
-
#### DELETE /customer
|
289
|
-
Documentation => https://docs.fintecture.com/v2/#delete-delete-delete-customer
|
290
|
-
- An exemple of response in the right column in "Request Body" section
|
291
|
-
|
292
|
-
```ruby
|
293
|
-
# account_holders (customer_id:)
|
294
|
-
# customer_id: string
|
295
|
-
|
296
|
-
response = ais_client.delete_customer customer_id: customer_id
|
297
|
-
```
|
298
|
-
## RESSOURCES
|
299
|
-
Use the PIS client to get ressources. The "generate_token" step is not needed for this calls
|
300
|
-
|
301
|
-
#### GET /providers
|
302
|
-
Documentation => https://docs.fintecture.com/v2/#get-get-get-providers
|
303
|
-
- An exemple of response in the right column in "Request Body" section
|
304
|
-
|
305
|
-
```ruby
|
306
|
-
# providers (provider_id: nil, paramsProviders: nil)
|
307
|
-
# provider_id: string
|
308
|
-
# paramsProviders: string
|
309
|
-
|
310
|
-
paramsProviders = {
|
311
|
-
'filter[country]': 'FR',
|
312
|
-
'filter[pis]': 'SEPA',
|
313
|
-
'filter[ais]': 'Accounts',
|
314
|
-
'filter[psu_type]': 'retail',
|
315
|
-
'filter[auth_model]': 'redirect',
|
316
|
-
'sort[name]': 'DESC',
|
317
|
-
'sort[full_name]': 'DESC',
|
318
|
-
'sort[country]': 'DESC',
|
319
|
-
'sort[provider_id]': 'DESC'
|
320
|
-
}
|
321
|
-
response = pis_client.providers provider_id: 'agfbfr', paramsProviders: paramsProviders
|
322
|
-
```
|
323
|
-
|
324
|
-
#### GET /applications
|
325
|
-
Documentation => https://docs.fintecture.com/v2/#get-get-get-applications
|
326
|
-
- An exemple of response in the right column in "Request Body" section
|
327
|
-
|
328
|
-
```ruby
|
329
|
-
# applications ()
|
330
|
-
|
331
|
-
response = pis_client.applications
|
332
|
-
```
|
333
|
-
|
334
|
-
#### GET /testaccounts
|
335
|
-
Documentation => https://docs.fintecture.com/v2/#get-get-get-testaccounts
|
336
|
-
- An exemple of response in the right column in "Request Body" section
|
337
|
-
|
338
|
-
```ruby
|
339
|
-
# test_accounts (provider_id = nil)
|
340
|
-
# provider_id: string
|
341
|
-
|
342
|
-
response = pis_client.test_accounts 'agfbfr'
|
343
|
-
```
|
344
|
-
|
345
|
-
## API Errors handling
|
346
|
-
Hash version
|
347
|
-
```ruby
|
348
|
-
begin
|
349
|
-
pis_client.refund "7f47d3675f5d4964bc416b43af63b06e", 1
|
350
|
-
rescue => e
|
351
|
-
error = JSON.parse e.to_s
|
352
|
-
puts error
|
353
|
-
end
|
354
|
-
```
|
355
|
-
|
356
|
-
```ruby
|
357
|
-
{
|
358
|
-
"type"=>"Fintecture api",
|
359
|
-
"status"=>401,
|
360
|
-
"errors"=>[
|
361
|
-
{
|
362
|
-
"code"=>"invalid_token",
|
363
|
-
"title"=>"Invalid Token",
|
364
|
-
"message"=>"The token is either invalid or expired."
|
365
|
-
}
|
366
|
-
],
|
367
|
-
"error_string"=>"\nFintecture server errors : \n status: 401 \n code: unauthorized\n id : 3006ddbf-2f97-44d8-9f63-35711b78e8a6\n\n code: invalid_token\n title: Invalid Token\n message: The token is either invalid or expired.\n\n"
|
368
|
-
}
|
369
|
-
```
|
370
|
-
Text version
|
371
|
-
```ruby
|
372
|
-
begin
|
373
|
-
pis_client.refund "7f47d3675f5d4964bc416b43af63b06e", 1
|
374
|
-
rescue => e
|
375
|
-
error = JSON.parse e.to_s
|
376
|
-
puts error['error_string']
|
377
|
-
end
|
378
|
-
```
|
379
|
-
|
380
|
-
```ruby
|
381
|
-
Fintecture server errors :
|
382
|
-
status: 401
|
383
|
-
code: unauthorized
|
384
|
-
id : 2adb9e35-ff0d-4477-959e-b1b1a7d7c812
|
385
|
-
|
386
|
-
code: invalid_token
|
387
|
-
title: Invalid Token
|
388
|
-
message: The token is either invalid or expired.
|
389
|
-
|
390
|
-
```
|
391
|
-
## Development
|
392
|
-
|
393
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
394
|
-
|
395
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
396
|
-
|
397
|
-
## Contributing
|
398
|
-
|
399
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/Fintecture/fintecture-sdk-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
400
|
-
|
401
|
-
## License
|
402
|
-
|
403
|
-
The gem is available as open source under the terms of the [GPL-3.0 License](http://www.gnu.org/licenses/gpl-3.0.txt).
|
404
|
-
|
405
|
-
## Code of Conduct
|
406
|
-
|
407
|
-
Everyone interacting in the Fintecture project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Fintecture/fintecture-sdk-ruby/blob/master/CODE_OF_CONDUCT.md).
|
1
|
+
# Fintecture
|
2
|
+
|
3
|
+
Fintecture is connected with most European banks and enables a user to initiate a payment directly from their bank account. This results to a bank transfer sent from the user's bank account directly to your bank account, skipping all intermediaries. Within the SEPA region, transfers take between 10 seconds to 1 business day to arrive on your bank account. No hidden fees. Check out [our website](https://fintecture.com/).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'fintecture'
|
11
|
+
```
|
12
|
+
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install fintecture
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
Get started by subscribing to a free developer account. Join today to get access to our sandbox by registering on the [developer console](https://console.fintecture.com) by creating your first sets of API Keys. When creating an account, specify you are an ECOMMERCE. When you’re ready to deploy to production, just go through the Activation Form in your console. Once the Fintecture Team activates your account, you’ll be ready to start receiving real bank transfers directly on the bank account specified during activation.
|
25
|
+
|
26
|
+
By default `sandbox` is the initial environment, but you can change to sandbox by doing
|
27
|
+
|
28
|
+
Initialize your PIS client
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
pis_client = Fintecture::PisClient.new({
|
32
|
+
environment: 'sandbox', # => ["sandbox", "test", "production"]
|
33
|
+
app_id: 'your_app_id',
|
34
|
+
app_secret: 'your_app_secret',
|
35
|
+
private_key: %q(your_private_key)
|
36
|
+
})
|
37
|
+
```
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
Initialize your AIS client
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
ais_client = Fintecture::AisClient.new({
|
45
|
+
environment: 'sandbox', # => ["sandbox", "test", "production"]
|
46
|
+
app_id: 'your_app_id',
|
47
|
+
app_secret: 'your_app_secret',
|
48
|
+
private_key: %q(your_private_key)
|
49
|
+
})
|
50
|
+
```
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
## PIS
|
55
|
+
PIS client properties
|
56
|
+
```ruby
|
57
|
+
pis_client.app_id
|
58
|
+
pis_client.app_secret
|
59
|
+
pis_client.private_key
|
60
|
+
pis_client.environment
|
61
|
+
pis_client.token
|
62
|
+
pis_client.token_expires_in
|
63
|
+
```
|
64
|
+
|
65
|
+
#### Access token
|
66
|
+
This method return the token and store it in the client for future requests
|
67
|
+
```ruby
|
68
|
+
pis_client.generate_token
|
69
|
+
```
|
70
|
+
|
71
|
+
|
72
|
+
#### POST /connect
|
73
|
+
Documentation => https://docs.fintecture.com/v2/#post-post-post-connect
|
74
|
+
- An example of the JSON payload in the right column in "Request Body" section
|
75
|
+
- An exemple of response in the right column in "Request Body" section
|
76
|
+
- The definitions of each field in the "Body Parameters" section
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
# connect (payload, state, redirect_uri = nil, origin_uri = nil)
|
80
|
+
# payload: {}
|
81
|
+
# state: string
|
82
|
+
# redirect_uri: string
|
83
|
+
# origin_uri: string
|
84
|
+
|
85
|
+
response = pis_client.connect payload, "my-state", "https://www.my-redirect-uri.fr", "https://www.my-origine-uri.fr"
|
86
|
+
```
|
87
|
+
|
88
|
+
|
89
|
+
#### POST /initiate
|
90
|
+
Documentation => https://docs.fintecture.com/v2/#post-post-post-initiate
|
91
|
+
- An example of the JSON payload in the right column in "Request Body" section
|
92
|
+
- An exemple of response in the right column in "Request Body" section
|
93
|
+
- The definitions of each field in the "Body Parameters" section
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
# initiate (payload, provider_id, redirect_uri, state = nil)
|
97
|
+
# payload: {}
|
98
|
+
# provider_id: string
|
99
|
+
# redirect_uri: string
|
100
|
+
# state: string
|
101
|
+
|
102
|
+
response = pis_client.initiate payload, "cmcifrpp", "https://www.my-redirect-uri.fr", "my-state"
|
103
|
+
```
|
104
|
+
|
105
|
+
#### GET /payments
|
106
|
+
Documentation => https://docs.fintecture.com/v2/#get-get-get-payments
|
107
|
+
- An exemple of response in the right column in "Request Body" section
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
# payments (session_id = nil)
|
111
|
+
# session_id: string
|
112
|
+
|
113
|
+
response = pis_client.payments "7f47d3675f5d4964bc416b43af63b06e"
|
114
|
+
OR
|
115
|
+
response = pis_client.payments
|
116
|
+
```
|
117
|
+
This endpoint returns the details of all transfers or of a specific transfer
|
118
|
+
|
119
|
+
#### POST /refund
|
120
|
+
Documentation => https://docs.fintecture.com/v2/#post-post-post-refund
|
121
|
+
- An exemple of response in the right column in "Request Body" section
|
122
|
+
|
123
|
+
```ruby
|
124
|
+
# refund (session_id, amount = nil)
|
125
|
+
# session_id: string
|
126
|
+
# amount: number
|
127
|
+
|
128
|
+
response = pis_client.refund "7f47d3675f5d4964bc416b43af63b06e", 5.75
|
129
|
+
```
|
130
|
+
If the amount is not specified, refund the total
|
131
|
+
|
132
|
+
#### POST /request-to-pay
|
133
|
+
Documentation => https://docs.fintecture.com/v2/#post-post-post-request-to-pay
|
134
|
+
- An example of the JSON payload in the right column in "Request Body" section
|
135
|
+
- An exemple of response in the right column in "Request Body" section
|
136
|
+
- The definitions of each field in the "Body Parameters" section
|
137
|
+
- The definition of x_language field in the "Header Parameters" section
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
# refund (payload, x_language, redirect_uri = nil)
|
141
|
+
# payload: {}
|
142
|
+
# x_language: string
|
143
|
+
# redirect_uri: string
|
144
|
+
|
145
|
+
response = pis_client.request_to_pay payload, 'fr', "https://www.my-redirect-uri.fr"
|
146
|
+
```
|
147
|
+
|
148
|
+
#### GET /settlements
|
149
|
+
Documentation => https://docs.fintecture.com/v2/#get-get-get-settlements
|
150
|
+
- An exemple of response in the right column in "Request Body" section
|
151
|
+
|
152
|
+
```ruby
|
153
|
+
# settlements (settlement_id = nil, include_payments = false)
|
154
|
+
# settlement_id: string
|
155
|
+
# include_payments: boolean
|
156
|
+
|
157
|
+
response = pis_client.settlements
|
158
|
+
OR
|
159
|
+
response = pis_client.settlements "127335fdeb073e0eb2313ba0bd71ad44"
|
160
|
+
OR
|
161
|
+
response = pis_client.settlements "127335fdeb073e0eb2313ba0bd71ad44", true
|
162
|
+
```
|
163
|
+
|
164
|
+
## AIS
|
165
|
+
AIS client properties
|
166
|
+
```ruby
|
167
|
+
ais_client.app_id
|
168
|
+
ais_client.app_secret
|
169
|
+
ais_client.private_key
|
170
|
+
ais_client.environment
|
171
|
+
ais_client.token
|
172
|
+
ais_client.refresh_token
|
173
|
+
ais_client.token_expires_in
|
174
|
+
```
|
175
|
+
#### GET /connect
|
176
|
+
Documentation => https://docs.fintecture.com/v2/#get-get-get-connect
|
177
|
+
- An exemple of response in the right column in "Request Body" section
|
178
|
+
|
179
|
+
```ruby
|
180
|
+
# connect (state, redirect_uri, scope = nil)
|
181
|
+
# state: string
|
182
|
+
# redirect_uri: string
|
183
|
+
# scope: string
|
184
|
+
|
185
|
+
response = ais_client.connect "my-state", "https://www.my-redirect-uri.fr"
|
186
|
+
```
|
187
|
+
When you follow the returned url, you'll be redirect with "customer_id" & "code" parameters
|
188
|
+
```ruby
|
189
|
+
customer_id = "fa51058b5f8306f1e048f1adda5488a9"
|
190
|
+
code = "f66ec660b0bbd2797bf6847fb4b98454"
|
191
|
+
```
|
192
|
+
|
193
|
+
#### Access token
|
194
|
+
Documentation => https://docs.fintecture.com/v2/#post-post-post-oauth-accesstoken
|
195
|
+
|
196
|
+
This method return the token and store it in the client for future requests
|
197
|
+
```ruby
|
198
|
+
ais_client.generate_token code
|
199
|
+
```
|
200
|
+
|
201
|
+
#### Refresh token
|
202
|
+
Documentation => https://docs.fintecture.com/v2/#post-post-post-oauth-refreshtoken
|
203
|
+
|
204
|
+
This method return the token and store it in the client for future requests
|
205
|
+
If you do not pass the refreshtoken as a parameter, the client refreshtoken will be used
|
206
|
+
```ruby
|
207
|
+
# generate_refresh_token (refresh_token = nil)
|
208
|
+
# refresh_token: string
|
209
|
+
|
210
|
+
ais_client.generate_refresh_token
|
211
|
+
```
|
212
|
+
|
213
|
+
#### GET /authorize
|
214
|
+
Documentation => https://docs.fintecture.com/v2/#get-get-get-authorize
|
215
|
+
- An exemple of response in the right column in "Request Body" section
|
216
|
+
- The definition of "x_psu_id" and "x_psu_ip_address" fields in the "Header Parameters" section
|
217
|
+
|
218
|
+
```ruby
|
219
|
+
# authorize (app_id_auth: false, provider_id:, redirect_uri:, state: nil, x_psu_id: nil, x_psu_ip_address: nil)
|
220
|
+
# app_id_auth: boolean
|
221
|
+
# provider_id: string
|
222
|
+
# redirect_uri: string
|
223
|
+
# state: string
|
224
|
+
# x_psu_id: string
|
225
|
+
# x_psu_ip_address: string
|
226
|
+
|
227
|
+
response = ais_client.authorize app_id_auth: false, provider_id: "agfbfr", redirect_uri: "https://www.google.fr", state: "ok", x_psu_id: "123456", x_psu_ip_address: "192.168.1.1"
|
228
|
+
```
|
229
|
+
|
230
|
+
#### GET /authorize/decoupled
|
231
|
+
Documentation => https://docs.fintecture.com/v2/#get-get-get-authorize-decoupled
|
232
|
+
- An exemple of response in the right column in "Request Body" section
|
233
|
+
|
234
|
+
```ruby
|
235
|
+
# authorize_decoupled (app_id_auth: false, provider_id:, polling_id:)
|
236
|
+
# app_id_auth: boolean
|
237
|
+
# provider_id: string
|
238
|
+
# polling_id: string
|
239
|
+
|
240
|
+
response = ais_client.authorize_decoupled app_id_auth: false, provider_id: "agfbfr", polling_id: "1234"
|
241
|
+
```
|
242
|
+
|
243
|
+
#### GET /accounts
|
244
|
+
Documentation => https://docs.fintecture.com/v2/#get-get-get-accounts
|
245
|
+
- An exemple of response in the right column in "Request Body" section
|
246
|
+
|
247
|
+
```ruby
|
248
|
+
# accounts (customer_id:, account_id: nil, remove_nulls: nil, withBalances: nil)
|
249
|
+
# customer_id: string
|
250
|
+
# account_id: string
|
251
|
+
# remove_nulls: boolean
|
252
|
+
# withBalances: boolean
|
253
|
+
|
254
|
+
response = ais_client.accounts customer_id: customer_id, account_id: nil, remove_nulls: nil, withBalances: nil
|
255
|
+
```
|
256
|
+
|
257
|
+
#### GET /transactions
|
258
|
+
Documentation => https://docs.fintecture.com/v2/#get-get-get-transactions
|
259
|
+
- An exemple of response in the right column in "Request Body" section
|
260
|
+
|
261
|
+
```ruby
|
262
|
+
# transactions (customer_id:, account_id:, remove_nulls: nil, convert_dates: nil, filters: nil)
|
263
|
+
# customer_id: string
|
264
|
+
# account_id: string
|
265
|
+
# remove_nulls: boolean
|
266
|
+
# convert_dates: boolean
|
267
|
+
# filters: {}
|
268
|
+
|
269
|
+
transactions_filters = {
|
270
|
+
"filter[date_to]": "2020-01-01",
|
271
|
+
'filter[date_from]': "max" # Date or 'max'
|
272
|
+
}
|
273
|
+
response = ais_client.transactions customer_id: customer_id, account_id: "b71722204d1a3f5ecd895", remove_nulls: true, convert_dates: true, filters: transactions_filters
|
274
|
+
```
|
275
|
+
|
276
|
+
#### GET /accountholders
|
277
|
+
Documentation => https://docs.fintecture.com/v2/#get-get-get-accountholders
|
278
|
+
- An exemple of response in the right column in "Request Body" section
|
279
|
+
|
280
|
+
```ruby
|
281
|
+
# account_holders (customer_id:, remove_nulls: nil)
|
282
|
+
# customer_id: string
|
283
|
+
# remove_nulls: boolean
|
284
|
+
|
285
|
+
response = ais_client.account_holders customer_id: customer_id, remove_nulls: true
|
286
|
+
```
|
287
|
+
|
288
|
+
#### DELETE /customer
|
289
|
+
Documentation => https://docs.fintecture.com/v2/#delete-delete-delete-customer
|
290
|
+
- An exemple of response in the right column in "Request Body" section
|
291
|
+
|
292
|
+
```ruby
|
293
|
+
# account_holders (customer_id:)
|
294
|
+
# customer_id: string
|
295
|
+
|
296
|
+
response = ais_client.delete_customer customer_id: customer_id
|
297
|
+
```
|
298
|
+
## RESSOURCES
|
299
|
+
Use the PIS client to get ressources. The "generate_token" step is not needed for this calls
|
300
|
+
|
301
|
+
#### GET /providers
|
302
|
+
Documentation => https://docs.fintecture.com/v2/#get-get-get-providers
|
303
|
+
- An exemple of response in the right column in "Request Body" section
|
304
|
+
|
305
|
+
```ruby
|
306
|
+
# providers (provider_id: nil, paramsProviders: nil)
|
307
|
+
# provider_id: string
|
308
|
+
# paramsProviders: string
|
309
|
+
|
310
|
+
paramsProviders = {
|
311
|
+
'filter[country]': 'FR',
|
312
|
+
'filter[pis]': 'SEPA',
|
313
|
+
'filter[ais]': 'Accounts',
|
314
|
+
'filter[psu_type]': 'retail',
|
315
|
+
'filter[auth_model]': 'redirect',
|
316
|
+
'sort[name]': 'DESC',
|
317
|
+
'sort[full_name]': 'DESC',
|
318
|
+
'sort[country]': 'DESC',
|
319
|
+
'sort[provider_id]': 'DESC'
|
320
|
+
}
|
321
|
+
response = pis_client.providers provider_id: 'agfbfr', paramsProviders: paramsProviders
|
322
|
+
```
|
323
|
+
|
324
|
+
#### GET /applications
|
325
|
+
Documentation => https://docs.fintecture.com/v2/#get-get-get-applications
|
326
|
+
- An exemple of response in the right column in "Request Body" section
|
327
|
+
|
328
|
+
```ruby
|
329
|
+
# applications ()
|
330
|
+
|
331
|
+
response = pis_client.applications
|
332
|
+
```
|
333
|
+
|
334
|
+
#### GET /testaccounts
|
335
|
+
Documentation => https://docs.fintecture.com/v2/#get-get-get-testaccounts
|
336
|
+
- An exemple of response in the right column in "Request Body" section
|
337
|
+
|
338
|
+
```ruby
|
339
|
+
# test_accounts (provider_id = nil)
|
340
|
+
# provider_id: string
|
341
|
+
|
342
|
+
response = pis_client.test_accounts 'agfbfr'
|
343
|
+
```
|
344
|
+
|
345
|
+
## API Errors handling
|
346
|
+
Hash version
|
347
|
+
```ruby
|
348
|
+
begin
|
349
|
+
pis_client.refund "7f47d3675f5d4964bc416b43af63b06e", 1
|
350
|
+
rescue => e
|
351
|
+
error = JSON.parse e.to_s
|
352
|
+
puts error
|
353
|
+
end
|
354
|
+
```
|
355
|
+
|
356
|
+
```ruby
|
357
|
+
{
|
358
|
+
"type"=>"Fintecture api",
|
359
|
+
"status"=>401,
|
360
|
+
"errors"=>[
|
361
|
+
{
|
362
|
+
"code"=>"invalid_token",
|
363
|
+
"title"=>"Invalid Token",
|
364
|
+
"message"=>"The token is either invalid or expired."
|
365
|
+
}
|
366
|
+
],
|
367
|
+
"error_string"=>"\nFintecture server errors : \n status: 401 \n code: unauthorized\n id : 3006ddbf-2f97-44d8-9f63-35711b78e8a6\n\n code: invalid_token\n title: Invalid Token\n message: The token is either invalid or expired.\n\n"
|
368
|
+
}
|
369
|
+
```
|
370
|
+
Text version
|
371
|
+
```ruby
|
372
|
+
begin
|
373
|
+
pis_client.refund "7f47d3675f5d4964bc416b43af63b06e", 1
|
374
|
+
rescue => e
|
375
|
+
error = JSON.parse e.to_s
|
376
|
+
puts error['error_string']
|
377
|
+
end
|
378
|
+
```
|
379
|
+
|
380
|
+
```ruby
|
381
|
+
Fintecture server errors :
|
382
|
+
status: 401
|
383
|
+
code: unauthorized
|
384
|
+
id : 2adb9e35-ff0d-4477-959e-b1b1a7d7c812
|
385
|
+
|
386
|
+
code: invalid_token
|
387
|
+
title: Invalid Token
|
388
|
+
message: The token is either invalid or expired.
|
389
|
+
|
390
|
+
```
|
391
|
+
## Development
|
392
|
+
|
393
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
394
|
+
|
395
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
396
|
+
|
397
|
+
## Contributing
|
398
|
+
|
399
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Fintecture/fintecture-sdk-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
400
|
+
|
401
|
+
## License
|
402
|
+
|
403
|
+
The gem is available as open source under the terms of the [GPL-3.0 License](http://www.gnu.org/licenses/gpl-3.0.txt).
|
404
|
+
|
405
|
+
## Code of Conduct
|
406
|
+
|
407
|
+
Everyone interacting in the Fintecture project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Fintecture/fintecture-sdk-ruby/blob/master/CODE_OF_CONDUCT.md).
|