fintecture 0.2.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +17 -19
- data/.rspec +3 -3
- data/.travis.yml +7 -7
- data/CODE_OF_CONDUCT.md +74 -74
- data/Gemfile +8 -6
- data/Gemfile.lock +59 -59
- data/LICENSE.txt +674 -674
- data/README.md +407 -238
- data/Rakefile +8 -6
- data/bin/console +15 -14
- data/bin/setup +8 -8
- 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 +44 -43
- 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} +78 -76
- 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 +50 -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 +13 -13
- data/lib/fintecture/endpoints/pis.rb +16 -0
- data/lib/fintecture/endpoints/ressources.rb +13 -0
- data/lib/fintecture/exceptions.rb +72 -33
- data/lib/fintecture/faraday/authentication/connection.rb +140 -120
- data/lib/fintecture/pis_client.rb +100 -0
- data/lib/fintecture/utils/constants.rb +11 -14
- data/lib/fintecture/utils/crypto.rb +75 -78
- data/lib/fintecture/utils/date.rb +15 -15
- data/lib/fintecture/utils/validation.rb +32 -26
- data/lib/fintecture/version.rb +5 -3
- data/lib/fintecture.rb +65 -82
- metadata +35 -12
- 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
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'base64'
|
4
|
+
require 'json'
|
5
|
+
require 'faraday'
|
6
|
+
require 'fintecture/utils/validation'
|
7
|
+
require 'fintecture/exceptions'
|
8
|
+
require 'fintecture/utils/date'
|
9
|
+
require 'fintecture/utils/constants'
|
10
|
+
|
11
|
+
module Fintecture
|
12
|
+
module Ais
|
13
|
+
class Authorize
|
14
|
+
class << self
|
15
|
+
# ------------ PUBLIC METHOD ------------
|
16
|
+
def get(client, app_id_auth, provider_id, redirect_uri, state, x_psu_id, x_psu_ip_address)
|
17
|
+
@client = client
|
18
|
+
|
19
|
+
# Do the request
|
20
|
+
_request app_id_auth, provider_id, redirect_uri, state, x_psu_id, x_psu_ip_address
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# ------------ REQUEST ------------
|
26
|
+
def _request(app_id_auth, provider_id, redirect_uri, state, x_psu_id, x_psu_ip_address)
|
27
|
+
# Get the url request
|
28
|
+
url = _endpoint provider_id
|
29
|
+
|
30
|
+
# Build uri params
|
31
|
+
query_string = ''
|
32
|
+
|
33
|
+
params = {}
|
34
|
+
params['response_type'] = 'code' if app_id_auth
|
35
|
+
params['redirect_uri'] = redirect_uri if redirect_uri
|
36
|
+
params['state'] = state if state
|
37
|
+
params['model'] = 'redirect'
|
38
|
+
|
39
|
+
query_string = "?#{params.map { |key, value| "#{key}=#{value}" }.join('&')}"
|
40
|
+
|
41
|
+
# Build additional headers
|
42
|
+
additional_headers = {}
|
43
|
+
additional_headers['app_id'] = @client.app_id if app_id_auth
|
44
|
+
additional_headers['x-psu-id'] = x_psu_id if x_psu_id
|
45
|
+
additional_headers['x-psu-ip-address'] = x_psu_ip_address if x_psu_ip_address
|
46
|
+
|
47
|
+
# Do connect request
|
48
|
+
Fintecture::Faraday::Authentication::Connection.get(
|
49
|
+
url: url + query_string,
|
50
|
+
client: @client,
|
51
|
+
custom_content_type: 'application/json',
|
52
|
+
bearer: "Bearer #{@client.token}",
|
53
|
+
secure_headers: true,
|
54
|
+
additional_headers: additional_headers,
|
55
|
+
disableAuthorization: app_id_auth ? true : false
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
# ------------ API ENDPOINT ------------
|
60
|
+
def _endpoint(provider_id)
|
61
|
+
"#{_api_base_url}/#{Fintecture::Api::Endpoints::Ais::AUTHORIZE}/#{provider_id}/authorize"
|
62
|
+
end
|
63
|
+
|
64
|
+
# ------------ BASE URL ------------
|
65
|
+
def _api_base_url
|
66
|
+
Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'base64'
|
4
|
+
require 'json'
|
5
|
+
require 'faraday'
|
6
|
+
require 'fintecture/utils/validation'
|
7
|
+
require 'fintecture/exceptions'
|
8
|
+
require 'fintecture/utils/date'
|
9
|
+
require 'fintecture/utils/constants'
|
10
|
+
|
11
|
+
module Fintecture
|
12
|
+
module Ais
|
13
|
+
class AuthorizeDecoupled
|
14
|
+
class << self
|
15
|
+
# ------------ PUBLIC METHOD ------------
|
16
|
+
def get(client, app_id_auth, provider_id, polling_id)
|
17
|
+
@client = client
|
18
|
+
|
19
|
+
# Do the request
|
20
|
+
_request app_id_auth, provider_id, polling_id
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# ------------ REQUEST ------------
|
26
|
+
def _request(app_id_auth, provider_id, polling_id)
|
27
|
+
# Get the url request
|
28
|
+
url = _endpoint provider_id, polling_id
|
29
|
+
|
30
|
+
# Build uri params
|
31
|
+
query_string = ''
|
32
|
+
|
33
|
+
params = {}
|
34
|
+
params['response_type'] = 'code' if app_id_auth
|
35
|
+
params['model'] = 'decoupled'
|
36
|
+
|
37
|
+
query_string = "?#{params.map { |key, value| "#{key}=#{value}" }.join('&')}"
|
38
|
+
|
39
|
+
# Build additional headers
|
40
|
+
additional_headers = {}
|
41
|
+
additional_headers['app_id'] = @client.app_id if app_id_auth
|
42
|
+
|
43
|
+
# Do connect request
|
44
|
+
Fintecture::Faraday::Authentication::Connection.get(
|
45
|
+
url: url + query_string,
|
46
|
+
client: @client,
|
47
|
+
custom_content_type: 'application/json',
|
48
|
+
bearer: "Bearer #{@client.token}",
|
49
|
+
secure_headers: true,
|
50
|
+
additional_headers: additional_headers,
|
51
|
+
disableAuthorization: app_id_auth ? true : false
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
# ------------ API ENDPOINT ------------
|
56
|
+
def _endpoint(provider_id, polling_id)
|
57
|
+
"#{_api_base_url}/#{Fintecture::Api::Endpoints::Ais::AUTHORIZE}/#{provider_id}/authorize/decoupled/#{polling_id}"
|
58
|
+
end
|
59
|
+
|
60
|
+
# ------------ BASE URL ------------
|
61
|
+
def _api_base_url
|
62
|
+
Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'base64'
|
4
|
+
require 'json'
|
5
|
+
require 'faraday'
|
6
|
+
require 'fintecture/utils/validation'
|
7
|
+
require 'fintecture/exceptions'
|
8
|
+
require 'fintecture/utils/date'
|
9
|
+
require 'fintecture/utils/constants'
|
10
|
+
|
11
|
+
module Fintecture
|
12
|
+
module Ais
|
13
|
+
class Connect
|
14
|
+
class << self
|
15
|
+
# ------------ PUBLIC METHOD ------------
|
16
|
+
def generate(client, state, redirect_uri, scope)
|
17
|
+
@client = client
|
18
|
+
|
19
|
+
# Do the request
|
20
|
+
_request state, redirect_uri, scope
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# ------------ REQUEST ------------
|
26
|
+
def _request(state, redirect_uri, scope)
|
27
|
+
# Get the url request
|
28
|
+
url = _endpoint
|
29
|
+
|
30
|
+
# Build uri params
|
31
|
+
params = {}
|
32
|
+
params['state'] = state
|
33
|
+
params['redirect_uri'] = redirect_uri
|
34
|
+
params['scope'] = scope if scope
|
35
|
+
|
36
|
+
query_string = "?#{params.map { |key, value| "#{key}=#{value}" }.join('&')}"
|
37
|
+
|
38
|
+
# Build additional headers
|
39
|
+
additional_headers = {}
|
40
|
+
additional_headers['app_id'] = @client.app_id
|
41
|
+
|
42
|
+
# Do connect request
|
43
|
+
Fintecture::Faraday::Authentication::Connection.get(
|
44
|
+
url: url + query_string,
|
45
|
+
client: @client,
|
46
|
+
custom_content_type: 'application/json',
|
47
|
+
secure_headers: true,
|
48
|
+
additional_headers: additional_headers
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
# ------------ API ENDPOINT ------------
|
53
|
+
def _endpoint
|
54
|
+
"#{_api_base_url}/#{Fintecture::Api::Endpoints::Ais::CONNECT}"
|
55
|
+
end
|
56
|
+
|
57
|
+
# ------------ BASE URL ------------
|
58
|
+
def _api_base_url
|
59
|
+
Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'base64'
|
4
|
+
require 'json'
|
5
|
+
require 'faraday'
|
6
|
+
require 'fintecture/utils/validation'
|
7
|
+
require 'fintecture/exceptions'
|
8
|
+
require 'fintecture/utils/date'
|
9
|
+
require 'fintecture/utils/constants'
|
10
|
+
|
11
|
+
module Fintecture
|
12
|
+
module Ais
|
13
|
+
class DeleteCustomer
|
14
|
+
class << self
|
15
|
+
# ------------ PUBLIC METHOD ------------
|
16
|
+
def delete(client, customer_id)
|
17
|
+
@client = client
|
18
|
+
|
19
|
+
# Do the request
|
20
|
+
_request customer_id
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# ------------ REQUEST ------------
|
26
|
+
def _request(customer_id)
|
27
|
+
# Get the url request
|
28
|
+
url = _endpoint customer_id
|
29
|
+
|
30
|
+
# Do connect request
|
31
|
+
Fintecture::Faraday::Authentication::Connection.delete(
|
32
|
+
url: url,
|
33
|
+
client: @client,
|
34
|
+
custom_content_type: 'application/json',
|
35
|
+
bearer: "Bearer #{@client.token}",
|
36
|
+
secure_headers: true
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
# ------------ API ENDPOINT ------------
|
41
|
+
def _endpoint(customer_id)
|
42
|
+
"#{_api_base_url}/#{Fintecture::Api::Endpoints::Ais::CUSTOMER}/#{customer_id}"
|
43
|
+
end
|
44
|
+
|
45
|
+
# ------------ BASE URL ------------
|
46
|
+
def _api_base_url
|
47
|
+
Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'base64'
|
4
|
+
require 'json'
|
5
|
+
require 'faraday'
|
6
|
+
require 'fintecture/utils/validation'
|
7
|
+
require 'fintecture/exceptions'
|
8
|
+
require 'fintecture/utils/date'
|
9
|
+
require 'fintecture/utils/constants'
|
10
|
+
|
11
|
+
module Fintecture
|
12
|
+
module Ais
|
13
|
+
class Transactions
|
14
|
+
class << self
|
15
|
+
# ------------ PUBLIC METHOD ------------
|
16
|
+
def get(client, customer_id, account_id, remove_nulls, convert_dates, filters)
|
17
|
+
@client = client
|
18
|
+
|
19
|
+
# Do the request
|
20
|
+
_request customer_id, account_id, remove_nulls, convert_dates, filters
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# ------------ REQUEST ------------
|
26
|
+
def _request(customer_id, account_id, remove_nulls, convert_dates, filters)
|
27
|
+
# Get the url request
|
28
|
+
url = _endpoint customer_id, account_id
|
29
|
+
|
30
|
+
# Build uri params
|
31
|
+
query_string = ''
|
32
|
+
if remove_nulls || convert_dates || filters
|
33
|
+
params = {}
|
34
|
+
params['remove_nulls'] = remove_nulls if remove_nulls
|
35
|
+
params['convert_dates'] = convert_dates if convert_dates
|
36
|
+
filters.each { |key, value| params[key] = value } if filters
|
37
|
+
|
38
|
+
query_string = "?#{params.map { |key, value| "#{key}=#{value}" }.join('&')}"
|
39
|
+
end
|
40
|
+
|
41
|
+
# Do connect request
|
42
|
+
Fintecture::Faraday::Authentication::Connection.get(
|
43
|
+
url: url + query_string,
|
44
|
+
client: @client,
|
45
|
+
custom_content_type: 'application/json',
|
46
|
+
bearer: "Bearer #{@client.token}",
|
47
|
+
secure_headers: true
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
# ------------ API ENDPOINT ------------
|
52
|
+
def _endpoint(customer_id, account_id)
|
53
|
+
"#{_api_base_url}/#{Fintecture::Api::Endpoints::Ais::TRANSACTIONS}/#{customer_id}/accounts/#{account_id}/transactions"
|
54
|
+
end
|
55
|
+
|
56
|
+
# ------------ BASE URL ------------
|
57
|
+
def _api_base_url
|
58
|
+
Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -1,76 +1,78 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'faraday'
|
5
|
+
|
6
|
+
module Fintecture
|
7
|
+
class Authentication
|
8
|
+
class << self
|
9
|
+
def authorize(redirect_uri, state = nil)
|
10
|
+
query_string = "?#{{
|
11
|
+
response_type: 'code',
|
12
|
+
app_id: Fintecture.app_id,
|
13
|
+
redirect_uri: redirect_uri,
|
14
|
+
state: state
|
15
|
+
}.map { |key, value| "#{key}=#{value}" }.join('&')}"
|
16
|
+
|
17
|
+
::Faraday.get "#{token_authorize_endpoint}#{query_string}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_access_token(client, auth_code = nil)
|
21
|
+
@client = client
|
22
|
+
body = access_token_data auth_code
|
23
|
+
|
24
|
+
Fintecture::Faraday::Authentication::Connection.post url: access_token_url, req_body: body, client: client
|
25
|
+
end
|
26
|
+
|
27
|
+
def refresh_token(client, refresh_token)
|
28
|
+
@client = client
|
29
|
+
body = refresh_token_data refresh_token
|
30
|
+
|
31
|
+
Fintecture::Faraday::Authentication::Connection.post url: refresh_token_url, req_body: body, client: client
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def base_url
|
37
|
+
Fintecture::Api::BaseUrl::FINTECTURE_OAUTH_URL[@client.environment.to_sym]
|
38
|
+
end
|
39
|
+
|
40
|
+
def token_authorize_endpoint
|
41
|
+
"#{base_url}#{Fintecture::Api::Endpoints::Authentication::OAUTH_TOKEN_AUTHORIZE}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def access_token_url
|
45
|
+
"#{base_url}#{Fintecture::Api::Endpoints::Authentication::OAUTH_ACCESS_TOKEN}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def refresh_token_url
|
49
|
+
"#{base_url}#{Fintecture::Api::Endpoints::Authentication::OAUTH_REFRESH_TOKEN}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def access_token_data(auth_code)
|
53
|
+
data = {
|
54
|
+
scope: 'PIS',
|
55
|
+
app_id: @client.app_id,
|
56
|
+
grant_type: 'client_credentials'
|
57
|
+
}
|
58
|
+
|
59
|
+
if auth_code
|
60
|
+
data = {
|
61
|
+
scope: 'AIS',
|
62
|
+
code: auth_code,
|
63
|
+
grant_type: 'authorization_code'
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
data
|
68
|
+
end
|
69
|
+
|
70
|
+
def refresh_token_data(refresh_token)
|
71
|
+
{
|
72
|
+
grant_type: 'refresh_token',
|
73
|
+
refresh_token: refresh_token
|
74
|
+
}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'base64'
|
4
|
+
require 'json'
|
5
|
+
require 'faraday'
|
6
|
+
require 'fintecture/utils/validation'
|
7
|
+
require 'fintecture/exceptions'
|
8
|
+
require 'fintecture/utils/date'
|
9
|
+
require 'fintecture/utils/constants'
|
10
|
+
|
11
|
+
module Fintecture
|
12
|
+
module Pis
|
13
|
+
class Connect
|
14
|
+
class << self
|
15
|
+
# ------------ PUBLIC METHOD ------------
|
16
|
+
def generate(client, payload, state, redirect_uri, origin_uri)
|
17
|
+
@client = client
|
18
|
+
|
19
|
+
# Build the request payload
|
20
|
+
payload = _build_payload(payload)
|
21
|
+
|
22
|
+
# Do the request
|
23
|
+
_request payload, state, redirect_uri, origin_uri
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
# ------------ REQUEST ------------
|
29
|
+
def _request(payload, state, redirect_uri, origin_uri)
|
30
|
+
# Get the url request
|
31
|
+
url = _endpoint
|
32
|
+
|
33
|
+
# Build uri params
|
34
|
+
params = {}
|
35
|
+
params['redirect_uri'] = redirect_uri if redirect_uri
|
36
|
+
params['origin_uri'] = origin_uri if origin_uri
|
37
|
+
params['state'] = state
|
38
|
+
|
39
|
+
query_string = "?#{params.map { |key, value| "#{key}=#{value}" }.join('&')}"
|
40
|
+
|
41
|
+
# Do connect request
|
42
|
+
Fintecture::Faraday::Authentication::Connection.post(
|
43
|
+
url: url + query_string,
|
44
|
+
req_body: payload.to_json,
|
45
|
+
client: @client,
|
46
|
+
custom_content_type: 'application/json',
|
47
|
+
bearer: "Bearer #{@client.token}",
|
48
|
+
secure_headers: true
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
# ------------ BUILD PAYLOAD ------------
|
53
|
+
def _build_payload(payload)
|
54
|
+
payload[:data][:attributes][:amount] = payload[:data][:attributes][:amount].to_s
|
55
|
+
|
56
|
+
unless payload[:data][:attributes][:end_to_end_id]
|
57
|
+
payload[:data][:attributes][:end_to_end_id] =
|
58
|
+
Fintecture::Utils::Crypto.generate_uuid_only_chars
|
59
|
+
end
|
60
|
+
|
61
|
+
payload
|
62
|
+
end
|
63
|
+
|
64
|
+
# ------------ API ENDPOINT ------------
|
65
|
+
def _endpoint
|
66
|
+
"#{_api_base_url}/#{Fintecture::Api::Endpoints::Pis::CONNECT}"
|
67
|
+
end
|
68
|
+
|
69
|
+
# ------------ BASE URL ------------
|
70
|
+
def _api_base_url
|
71
|
+
Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Fintecture
|
4
|
+
module Pis
|
5
|
+
class Initiate
|
6
|
+
class << self
|
7
|
+
# ------------ PUBLIC METHOD ------------
|
8
|
+
def generate(client, payload, provider_id, redirect_uri, state)
|
9
|
+
@client = client
|
10
|
+
|
11
|
+
# Do the _request request
|
12
|
+
_request payload, provider_id, redirect_uri, state
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
# ------------ REQUEST ------------
|
18
|
+
def _request(payload, provider_id, redirect_uri, state)
|
19
|
+
# Get the url request
|
20
|
+
url = _endpoint provider_id
|
21
|
+
|
22
|
+
# Build uri params
|
23
|
+
params = {}
|
24
|
+
params['state'] = state
|
25
|
+
params['redirect_uri'] = redirect_uri
|
26
|
+
query_string = "?#{params.map { |key, value| "#{key}=#{value}" }.join('&')}"
|
27
|
+
|
28
|
+
# Do connect request
|
29
|
+
Fintecture::Faraday::Authentication::Connection.post(
|
30
|
+
url: url + query_string,
|
31
|
+
req_body: payload.to_json,
|
32
|
+
client: @client,
|
33
|
+
custom_content_type: 'application/json',
|
34
|
+
bearer: "Bearer #{@client.token}",
|
35
|
+
secure_headers: true
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
# ------------ API ENDPOINT ------------
|
40
|
+
def _endpoint(provider_id)
|
41
|
+
"#{_api_base_url}/#{Fintecture::Api::Endpoints::Pis::INITIATE}/#{provider_id}/initiate"
|
42
|
+
end
|
43
|
+
|
44
|
+
# ------------ BASE URL ------------
|
45
|
+
def _api_base_url
|
46
|
+
Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'faraday'
|
5
|
+
require 'fintecture/endpoints/pis'
|
6
|
+
require 'fintecture/base_url'
|
7
|
+
|
8
|
+
module Fintecture
|
9
|
+
module Pis
|
10
|
+
class Payments
|
11
|
+
class << self
|
12
|
+
# ------------ PUBLIC METHOD ------------
|
13
|
+
def get(client, session_id)
|
14
|
+
@client = client
|
15
|
+
|
16
|
+
# Do the get_payments request
|
17
|
+
_request session_id
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# ------------ REQUEST ------------
|
23
|
+
def _request(session_id)
|
24
|
+
url = _endpoint
|
25
|
+
|
26
|
+
Fintecture::Faraday::Authentication::Connection.get(
|
27
|
+
url: "#{url}/#{session_id}",
|
28
|
+
client: @client,
|
29
|
+
custom_content_type: 'application/json',
|
30
|
+
bearer: "Bearer #{@client.token}",
|
31
|
+
secure_headers: true
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
# ------------ API ENDPOINT ------------
|
36
|
+
def _endpoint
|
37
|
+
"#{_api_base_url}/#{Fintecture::Api::Endpoints::Pis::PAYMENTS}"
|
38
|
+
end
|
39
|
+
|
40
|
+
# ------------ BASE URL ------------
|
41
|
+
def _api_base_url
|
42
|
+
Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|