fintecture 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -3
- data/Gemfile +4 -2
- data/Gemfile.lock +1 -1
- data/README.md +328 -162
- data/Rakefile +5 -3
- data/bin/console +4 -3
- data/exemples/ais.rb +53 -0
- data/exemples/config_ais.json +8 -0
- data/exemples/config_pis.json +6 -0
- data/exemples/pis.rb +148 -0
- data/exemples/ressources.rb +23 -0
- data/fintecture.gemspec +16 -15
- data/lib/fintecture/ais_client.rb +94 -0
- data/lib/fintecture/api/ais/account_holders.rb +61 -0
- data/lib/fintecture/api/ais/accounts.rb +63 -0
- data/lib/fintecture/api/ais/authorize.rb +72 -0
- data/lib/fintecture/api/ais/authorize_decoupled.rb +68 -0
- data/lib/fintecture/api/ais/connect.rb +65 -0
- data/lib/fintecture/api/ais/delete_customer.rb +53 -0
- data/lib/fintecture/api/ais/transactions.rb +64 -0
- data/lib/fintecture/{authentication.rb → api/auth/authentication.rb} +25 -23
- data/lib/fintecture/api/pis/connect.rb +77 -0
- data/lib/fintecture/api/pis/initiate.rb +52 -0
- data/lib/fintecture/api/pis/payments.rb +48 -0
- data/lib/fintecture/api/pis/refund.rb +67 -0
- data/lib/fintecture/api/pis/request_to_pay.rb +63 -0
- data/lib/fintecture/api/pis/settlements.rb +48 -0
- data/lib/fintecture/api/ressources/applications.rb +57 -0
- data/lib/fintecture/api/ressources/providers.rb +61 -0
- data/lib/fintecture/api/ressources/test_accounts.rb +60 -0
- data/lib/fintecture/base_url.rb +26 -0
- data/lib/fintecture/endpoints/ais.rb +17 -0
- data/lib/fintecture/{api/endpoints → endpoints}/authentication.rb +3 -3
- data/lib/fintecture/endpoints/pis.rb +16 -0
- data/lib/fintecture/endpoints/ressources.rb +13 -0
- data/lib/fintecture/exceptions.rb +52 -13
- data/lib/fintecture/faraday/authentication/connection.rb +60 -40
- data/lib/fintecture/pis_client.rb +100 -0
- data/lib/fintecture/utils/constants.rb +5 -8
- data/lib/fintecture/utils/crypto.rb +15 -18
- data/lib/fintecture/utils/date.rb +4 -4
- data/lib/fintecture/utils/validation.rb +12 -6
- data/lib/fintecture/version.rb +3 -1
- data/lib/fintecture.rb +21 -38
- metadata +31 -8
- data/lib/fintecture/api/base_url.rb +0 -29
- data/lib/fintecture/api/endpoints/pis.rb +0 -14
- data/lib/fintecture/connect.rb +0 -38
- data/lib/fintecture/pis.rb +0 -262
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d789620eea2a69deea71bdf6c3be05b0fb68116bd33f001291c688566713f03
|
4
|
+
data.tar.gz: af4fffca73d93fa28ff50769072cc60efa8bb5aae49129f889c0aaf798476f43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0b3c39d0e5591d0f27caea8a32a0fcee0e707dc3c5efe8b30f3ff2880f30f4f46af9db85c719a1cc2e4d379241322790761bc4dd49e63ebe00b66245da9ace3
|
7
|
+
data.tar.gz: ef26d562d3a5efa9fe86eb94e2fb2b1045a2ba4d407882cefcf51389ed729bc12eaae00efd93b9d62f83d5218282bc8aa870d9fd8cd2358bcdaf5a1b49e54873
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -23,202 +23,368 @@ Or install it yourself as:
|
|
23
23
|
|
24
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
25
|
|
26
|
-
|
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
|
27
42
|
|
28
43
|
```ruby
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
+
})
|
32
50
|
```
|
33
|
-
|
34
|
-
|
35
|
-
#### Environments
|
36
51
|
|
37
|
-
|
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
|
38
94
|
|
39
95
|
```ruby
|
40
|
-
|
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"
|
41
146
|
```
|
42
147
|
|
43
|
-
|
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)
|
154
|
+
# settlement_id: string
|
155
|
+
|
156
|
+
response = pis_client.settlements
|
157
|
+
OR
|
158
|
+
response = pis_client.settlements "127335fdeb073e0eb2313ba0bd71ad44"
|
159
|
+
```
|
44
160
|
|
45
|
-
|
46
|
-
|
161
|
+
## AIS
|
162
|
+
AIS client properties
|
163
|
+
```ruby
|
164
|
+
ais_client.app_id
|
165
|
+
ais_client.app_secret
|
166
|
+
ais_client.private_key
|
167
|
+
ais_client.environment
|
168
|
+
ais_client.token
|
169
|
+
ais_client.refresh_token
|
170
|
+
ais_client.token_expires_in
|
171
|
+
```
|
172
|
+
#### GET /connect
|
173
|
+
Documentation => https://docs.fintecture.com/v2/#get-get-get-connect
|
174
|
+
- An exemple of response in the right column in "Request Body" section
|
47
175
|
|
48
|
-
|
49
|
-
|
176
|
+
```ruby
|
177
|
+
# connect (state, redirect_uri, scope = nil)
|
178
|
+
# state: string
|
179
|
+
# redirect_uri: string
|
180
|
+
# scope: string
|
181
|
+
|
182
|
+
response = ais_client.connect "my-state", "https://www.my-redirect-uri.fr"
|
183
|
+
```
|
184
|
+
When you follow the returned url, you'll be redirect with "customer_id" & "code" parameters
|
185
|
+
```ruby
|
186
|
+
customer_id = "fa51058b5f8306f1e048f1adda5488a9"
|
187
|
+
code = "f66ec660b0bbd2797bf6847fb4b98454"
|
188
|
+
```
|
50
189
|
|
51
190
|
#### Access token
|
191
|
+
Documentation => https://docs.fintecture.com/v2/#post-post-post-oauth-accesstoken
|
52
192
|
|
193
|
+
This method return the token and store it in the client for future requests
|
53
194
|
```ruby
|
54
|
-
|
55
|
-
```
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
* end_to_end_id: **[optional]** A unique ID given by the creator of the payment and send to the bank. By default de session_id is used.
|
129
|
-
* scheme: **[optional]** The payment scheme to use. Default: AUTO (automatic selection), SEPA, INSTANT_SEPA
|
130
|
-
* customer_full_name: **[mandatory]** The full name of the payer
|
131
|
-
* customer_email: **[mandatory]** The email of the payer
|
132
|
-
* customer_phone: **[optional]** The phone of the payer
|
133
|
-
* customer_phone_prefix: **[optional]**
|
134
|
-
* customer_ip: **[mandatory]** The ip address of the payer
|
135
|
-
* customer_address: **[optional]** The address of the payer. It has the following structure:
|
136
|
-
* street: **[optional]** The address street name
|
137
|
-
* number: **[optional]** The address number
|
138
|
-
* complement: **[optional]** Complement information to the address
|
139
|
-
* city: **[optional]** The address city*
|
140
|
-
* zip: **[optional]** The address zip code
|
141
|
-
* country: **[optional]** The country code (2 letters)
|
142
|
-
* redirect_uri: **[mandatory]** The callback URL to which the customer is redirected after authentication with his bank
|
143
|
-
* origin_uri: **[optional]** A URL to which the customer will be redirected if he wants to exit Fintecture Connect
|
144
|
-
* state: **[optional]** A state parameter which is sent back on callback
|
145
|
-
|
146
|
-
#### Get Request-to-pay
|
147
|
-
|
148
|
-
```ruby
|
149
|
-
payment_attrs = {
|
150
|
-
x_language: 'fr',
|
151
|
-
amount: 123,
|
152
|
-
currency: 'EUR',
|
153
|
-
communication: 'Thanks Mom!',
|
154
|
-
customer_full_name: 'John Doe',
|
155
|
-
customer_email: 'john.doe@email.com',
|
156
|
-
customer_phone: '666777888',
|
157
|
-
customer_phone_prefix: '+33',
|
158
|
-
customer_address: {
|
159
|
-
street: 'Main St.',
|
160
|
-
number: '123',
|
161
|
-
city: 'Paris',
|
162
|
-
zip: '75000',
|
163
|
-
country: 'fr'
|
164
|
-
},
|
165
|
-
expirary: 86400,
|
166
|
-
cc: 'exemple@gmail.com',
|
167
|
-
bcc: 'exemple@gmail.com',
|
168
|
-
redirect_uri: 'http://www.google.fr'
|
195
|
+
ais_client.generate_token code
|
196
|
+
```
|
197
|
+
|
198
|
+
#### Refresh token
|
199
|
+
Documentation => https://docs.fintecture.com/v2/#post-post-post-oauth-refreshtoken
|
200
|
+
|
201
|
+
This method return the token and store it in the client for future requests
|
202
|
+
If you do not pass the refreshtoken as a parameter, the client refreshtoken will be used
|
203
|
+
```ruby
|
204
|
+
# generate_refresh_token (refresh_token = nil)
|
205
|
+
# refresh_token: string
|
206
|
+
|
207
|
+
ais_client.generate_refresh_token
|
208
|
+
```
|
209
|
+
|
210
|
+
#### GET /authorize
|
211
|
+
Documentation => https://docs.fintecture.com/v2/#get-get-get-authorize
|
212
|
+
- An exemple of response in the right column in "Request Body" section
|
213
|
+
- The definition of "x_psu_id" and "x_psu_ip_address" fields in the "Header Parameters" section
|
214
|
+
|
215
|
+
```ruby
|
216
|
+
# authorize (app_id_auth: false, provider_id:, redirect_uri:, state: nil, x_psu_id: nil, x_psu_ip_address: nil)
|
217
|
+
# app_id_auth: boolean
|
218
|
+
# provider_id: string
|
219
|
+
# redirect_uri: string
|
220
|
+
# state: string
|
221
|
+
# x_psu_id: string
|
222
|
+
# x_psu_ip_address: string
|
223
|
+
|
224
|
+
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"
|
225
|
+
```
|
226
|
+
|
227
|
+
#### GET /authorize/decoupled
|
228
|
+
Documentation => https://docs.fintecture.com/v2/#get-get-get-authorize-decoupled
|
229
|
+
- An exemple of response in the right column in "Request Body" section
|
230
|
+
|
231
|
+
```ruby
|
232
|
+
# authorize_decoupled (app_id_auth: false, provider_id:, polling_id:)
|
233
|
+
# app_id_auth: boolean
|
234
|
+
# provider_id: string
|
235
|
+
# polling_id: string
|
236
|
+
|
237
|
+
response = ais_client.authorize_decoupled app_id_auth: false, provider_id: "agfbfr", polling_id: "1234"
|
238
|
+
```
|
239
|
+
|
240
|
+
#### GET /accounts
|
241
|
+
Documentation => https://docs.fintecture.com/v2/#get-get-get-accounts
|
242
|
+
- An exemple of response in the right column in "Request Body" section
|
243
|
+
|
244
|
+
```ruby
|
245
|
+
# accounts (customer_id:, account_id: nil, remove_nulls: nil, withBalances: nil)
|
246
|
+
# customer_id: string
|
247
|
+
# account_id: string
|
248
|
+
# remove_nulls: boolean
|
249
|
+
# withBalances: boolean
|
250
|
+
|
251
|
+
response = ais_client.accounts customer_id: customer_id, account_id: nil, remove_nulls: nil, withBalances: nil
|
252
|
+
```
|
253
|
+
|
254
|
+
#### GET /transactions
|
255
|
+
Documentation => https://docs.fintecture.com/v2/#get-get-get-transactions
|
256
|
+
- An exemple of response in the right column in "Request Body" section
|
257
|
+
|
258
|
+
```ruby
|
259
|
+
# transactions (customer_id:, account_id:, remove_nulls: nil, convert_dates: nil, filters: nil)
|
260
|
+
# customer_id: string
|
261
|
+
# account_id: string
|
262
|
+
# remove_nulls: boolean
|
263
|
+
# convert_dates: boolean
|
264
|
+
# filters: {}
|
265
|
+
|
266
|
+
transactions_filters = {
|
267
|
+
"filter[date_to]": "2020-01-01",
|
268
|
+
'filter[date_from]': "max" # Date or 'max'
|
169
269
|
}
|
170
|
-
|
270
|
+
response = ais_client.transactions customer_id: customer_id, account_id: "b71722204d1a3f5ecd895", remove_nulls: true, convert_dates: true, filters: transactions_filters
|
271
|
+
```
|
272
|
+
|
273
|
+
#### GET /accountholders
|
274
|
+
Documentation => https://docs.fintecture.com/v2/#get-get-get-accountholders
|
275
|
+
- An exemple of response in the right column in "Request Body" section
|
276
|
+
|
277
|
+
```ruby
|
278
|
+
# account_holders (customer_id:, remove_nulls: nil)
|
279
|
+
# customer_id: string
|
280
|
+
# remove_nulls: boolean
|
171
281
|
|
172
|
-
|
173
|
-
request_to_pay_response_body = JSON.parse request_to_pay_response.body
|
174
|
-
meta = request_to_pay_response_body['meta']
|
282
|
+
response = ais_client.account_holders customer_id: customer_id, remove_nulls: true
|
175
283
|
```
|
176
|
-
Explanation of each field:
|
177
284
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
* communication: **[optional]** A message sent to the beneficiary of the payment and visible on his bank statement. In the context of ecommerce payment collection, the order reference is inputted here (with an optional prefer ex: REF#23444)
|
182
|
-
* customer_full_name: **[mandatory]** The full name of the payer
|
183
|
-
* customer_email: **[mandatory]** The email of the payer
|
184
|
-
* customer_phone: **[mandatory]** The phone of the payer
|
185
|
-
* customer_phone_prefix: **[mandatory]**
|
186
|
-
* customer_address: **[optional]** The address of the payer. It has the following structure:
|
187
|
-
* street: **[optional]** The address street name
|
188
|
-
* number: **[optional]** The address number
|
189
|
-
* city: **[optional]** The address city*
|
190
|
-
* zip: **[optional]** The address zip code
|
191
|
-
* country: **[optional]** The country code (2 letters)
|
192
|
-
* expirary: **[optional]** The number of seconds of the validity of the request to pay, by default 86400
|
193
|
-
* cc: **[optional]** The CC email to receive a copy (If multiple emails, the emails must be concatenated with a comma.)
|
194
|
-
* bcc: **[optional]** The BCC email to receive a copy (If multiple emails, the emails must be concatenated with a comma.)
|
195
|
-
* redirect_uri: **[optional]** The callback URL to which the customer is redirected after authentication with his bank
|
285
|
+
#### DELETE /customer
|
286
|
+
Documentation => https://docs.fintecture.com/v2/#delete-delete-delete-customer
|
287
|
+
- An exemple of response in the right column in "Request Body" section
|
196
288
|
|
289
|
+
```ruby
|
290
|
+
# account_holders (customer_id:)
|
291
|
+
# customer_id: string
|
292
|
+
|
293
|
+
response = ais_client.delete_customer customer_id: customer_id
|
294
|
+
```
|
295
|
+
## RESSOURCES
|
296
|
+
Use the PIS client to get ressources. The "generate_token" step is not needed for this calls
|
197
297
|
|
298
|
+
#### GET /providers
|
299
|
+
Documentation => https://docs.fintecture.com/v2/#get-get-get-providers
|
300
|
+
- An exemple of response in the right column in "Request Body" section
|
198
301
|
|
302
|
+
```ruby
|
303
|
+
# providers (provider_id: nil, paramsProviders: nil)
|
304
|
+
# provider_id: string
|
305
|
+
# paramsProviders: string
|
306
|
+
|
307
|
+
paramsProviders = {
|
308
|
+
'filter[country]': 'FR',
|
309
|
+
'filter[pis]': 'SEPA',
|
310
|
+
'filter[ais]': 'Accounts',
|
311
|
+
'filter[psu_type]': 'retail',
|
312
|
+
'filter[auth_model]': 'redirect',
|
313
|
+
'sort[name]': 'DESC',
|
314
|
+
'sort[full_name]': 'DESC',
|
315
|
+
'sort[country]': 'DESC',
|
316
|
+
'sort[provider_id]': 'DESC'
|
317
|
+
}
|
318
|
+
response = pis_client.providers provider_id: 'agfbfr', paramsProviders: paramsProviders
|
319
|
+
```
|
199
320
|
|
200
|
-
####
|
321
|
+
#### GET /applications
|
322
|
+
Documentation => https://docs.fintecture.com/v2/#get-get-get-applications
|
323
|
+
- An exemple of response in the right column in "Request Body" section
|
201
324
|
|
202
325
|
```ruby
|
203
|
-
|
204
|
-
payment_response_body = JSON.parse payment_response.body
|
326
|
+
# applications ()
|
205
327
|
|
206
|
-
|
328
|
+
response = pis_client.applications
|
207
329
|
```
|
208
330
|
|
209
|
-
|
331
|
+
#### GET /testaccounts
|
332
|
+
Documentation => https://docs.fintecture.com/v2/#get-get-get-testaccounts
|
333
|
+
- An exemple of response in the right column in "Request Body" section
|
210
334
|
|
211
|
-
|
335
|
+
```ruby
|
336
|
+
# test_accounts (provider_id = nil)
|
337
|
+
# provider_id: string
|
338
|
+
|
339
|
+
response = pis_client.test_accounts 'agfbfr'
|
340
|
+
```
|
212
341
|
|
342
|
+
## API Errors handling
|
343
|
+
Hash version
|
213
344
|
```ruby
|
214
|
-
|
215
|
-
|
216
|
-
|
345
|
+
begin
|
346
|
+
pis_client.refund "7f47d3675f5d4964bc416b43af63b06e", 1
|
347
|
+
rescue => e
|
348
|
+
error = JSON.parse e.to_s
|
349
|
+
puts error
|
350
|
+
end
|
217
351
|
```
|
218
352
|
|
219
|
-
|
353
|
+
```ruby
|
354
|
+
{
|
355
|
+
"type"=>"Fintecture api",
|
356
|
+
"status"=>401,
|
357
|
+
"errors"=>[
|
358
|
+
{
|
359
|
+
"code"=>"invalid_token",
|
360
|
+
"title"=>"Invalid Token",
|
361
|
+
"message"=>"The token is either invalid or expired."
|
362
|
+
}
|
363
|
+
],
|
364
|
+
"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"
|
365
|
+
}
|
366
|
+
```
|
367
|
+
Text version
|
368
|
+
```ruby
|
369
|
+
begin
|
370
|
+
pis_client.refund "7f47d3675f5d4964bc416b43af63b06e", 1
|
371
|
+
rescue => e
|
372
|
+
error = JSON.parse e.to_s
|
373
|
+
puts error['error_string']
|
374
|
+
end
|
375
|
+
```
|
220
376
|
|
377
|
+
```ruby
|
378
|
+
Fintecture server errors :
|
379
|
+
status: 401
|
380
|
+
code: unauthorized
|
381
|
+
id : 2adb9e35-ff0d-4477-959e-b1b1a7d7c812
|
221
382
|
|
383
|
+
code: invalid_token
|
384
|
+
title: Invalid Token
|
385
|
+
message: The token is either invalid or expired.
|
386
|
+
|
387
|
+
```
|
222
388
|
## Development
|
223
389
|
|
224
390
|
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.
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'fintecture'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "fintecture"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start(__FILE__)
|
data/exemples/ais.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require './lib/fintecture'
|
4
|
+
|
5
|
+
config = JSON.parse(File.read('./exemples/config_ais.json'))
|
6
|
+
|
7
|
+
ais_client = Fintecture::AisClient.new({
|
8
|
+
environment: config['environment'],
|
9
|
+
app_id: config['app_id'],
|
10
|
+
app_secret: config['app_secret'],
|
11
|
+
private_key: config['private_key']
|
12
|
+
})
|
13
|
+
|
14
|
+
# ######################## AIS ########################
|
15
|
+
|
16
|
+
# ------------ Connect ------------
|
17
|
+
connect_response = ais_client.connect 'ok', 'https://www.google.fr'
|
18
|
+
connect_id = connect_response['meta']['connect_id']
|
19
|
+
url = connect_response['meta']['url']
|
20
|
+
|
21
|
+
puts "Connect url => #{url}"
|
22
|
+
|
23
|
+
# Put the return of connect url here
|
24
|
+
customer_id = 'c84e6a2c66862f6ce169a11262b28f4c'
|
25
|
+
code = '173535d0acc16271e7942cc6e1772a5b'
|
26
|
+
|
27
|
+
# ------------ Get access token ------------
|
28
|
+
ais_client.generate_token code
|
29
|
+
ais_client.generate_refresh_token
|
30
|
+
# ------------ Authorize ------------
|
31
|
+
puts ais_client.authorize app_id_auth: true, provider_id: 'agfbfr', redirect_uri: 'https://www.google.fr', state: 'ok',
|
32
|
+
x_psu_id: nil, x_psu_ip_address: nil
|
33
|
+
# ------------ Authorize decoupled ------------
|
34
|
+
puts ais_client.authorize_decoupled app_id_auth: false, provider_id: 'agfbfr', polling_id: '1234'
|
35
|
+
# ------------ Get accounts ------------
|
36
|
+
accounts_response = ais_client.accounts customer_id: customer_id, account_id: nil, remove_nulls: nil, withBalances: nil
|
37
|
+
account = accounts_response['data'].first
|
38
|
+
account_id = account['id']
|
39
|
+
# ------------ Get transactions ------------
|
40
|
+
transactions_filters = {
|
41
|
+
"filter[date_to]": '2020-01-01',
|
42
|
+
'filter[date_from]': 'max'
|
43
|
+
}
|
44
|
+
transactions_response = ais_client.transactions customer_id: customer_id, account_id: account_id, remove_nulls: true,
|
45
|
+
convert_dates: true, filters: transactions_filters
|
46
|
+
transaction = transactions_response['data'].first
|
47
|
+
puts transaction
|
48
|
+
# ------------ Get account holders ------------
|
49
|
+
# Caution the hasAccountholders field in db must have a value = 1.
|
50
|
+
puts ais_client.account_holders customer_id: customer_id, remove_nulls: nil
|
51
|
+
# ------------ Delete customer ------------
|
52
|
+
# Customer not found if customer you don't use the api before
|
53
|
+
puts ais_client.delete_customer customer_id: customer_id
|