fintecture 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc9643b34054d33aaaa2b769e3de4912a08b0e374b4b5af249f9b35161737ab5
4
- data.tar.gz: 8fb3bf8e3eeaa845c6487d68d094da0bcbc7359140546dc304c475aa7e099ef6
3
+ metadata.gz: 14560f3b1fead85e89c9aa9503c6e86697ce2acb5eaa8852245863bffbec25cc
4
+ data.tar.gz: 12089429aad012effb216c04c972ffd01fa9df5172c0716d33f076bbf1926407
5
5
  SHA512:
6
- metadata.gz: b6617e344b2e77edfa6957a99498570cb60a515a08a1e38cbc0412600354c32ba1326db8ed606c76a3f19492fe2c47812e70dc4bb4dfeae9a1c3e622380ee398
7
- data.tar.gz: 3041e94a9f644133415dee5144d6531fa0cb3dc4ad4b04456d55ff7c4fc05da374434fd07ed142045ee276ac970a5f20253c0b30f94b78ac6d4fb551918ba583
6
+ metadata.gz: c6f2558e1492658b14135c7d9e449744697517602a7c54c952718e60e0c042f1e36dca47fb27d564df550c18d4d727d7f75efb3e3f7dce0f100b26e5ccd0a733
7
+ data.tar.gz: dd5a65d0104a6a2fdce72bb92493f841a0664cc6aac78be219b151cea66b775acda59c351f6e6196ebfc01ec3d6e1a80ab8b83d700ee10a347bb1b90103fd21a
data/README.md CHANGED
@@ -65,11 +65,21 @@ payment_attrs = {
65
65
  customer_full_name: 'John Doe',
66
66
  customer_email: 'john.doe@email.com',
67
67
  customer_ip: '127.0.0.1',
68
+ customer_phone: '666777888',
69
+ customer_address: {
70
+ street: 'Main St.',
71
+ number: '123',
72
+ complement: '2nd floor',
73
+ zip: '75000',
74
+ city: 'Paris',
75
+ country: 'fr',
76
+ },
68
77
  redirect_uri: 'http://example.com/callback',
69
78
  origin_uri: 'http://example.com/checkout?session=123',
70
79
  state: 'somestate',
71
80
  psu_type: 'retail',
72
- country: 'fr'
81
+ country: 'fr',
82
+
73
83
  }
74
84
  tokens = Fintecture::Pis.get_access_token
75
85
  connect_response = Fintecture::Connect.get_pis_connect tokens['access_token'], payment_attrs
@@ -84,11 +94,32 @@ Explanation of each field:
84
94
  * customer_full_name: **[mandatory]** The full name of the payer
85
95
  * customer_email: **[mandatory]** The email of the payer
86
96
  * customer_ip: **[mandatory]** The ip address of the payer
97
+ * customer_phone: **[optional]** The phone of the payer
98
+ * customer_address: **[optional]** The address of the payer. It has the following structure:
99
+ * street: **[optional]** The address street name
100
+ * number: **[optional]** The address number
101
+ * complement: **[optional]** Complement information to the address
102
+ * zip: **[optional]** The address zip code
103
+ * city: **[optional]** The address city
104
+ * country: **[optional]** The country code (2 letters)
87
105
  * redirect_uri: **[mandatory]** The callback URL to which the customer is redirected after authentication with his bank
88
106
  * origin_uri: **[optional]** A URL to which the customer will be redirected if he wants to exit Fintecture Connect
107
+ * execution_date: **[optional]** A future date to execute the payment. If the execution_date field is omitted, the payment is to be sent immediately.
89
108
  * state: **[optional]** A state parameter which is sent back on callback
90
- * retail: **[optional]** Possible values are **retail** and **corporate** (retail by default)
109
+ * psu_type: **[optional]** Possible values are **retail**, **corporate** and **all** (retail by default)
91
110
  * country: **[optional]** Loads a specific collection of providers filter by country
111
+ * provider: **[optional]** Limits the webview to the provided provider
112
+ * beneficiary: **[optional]** The beneficiary of the payment. It has the following structure:
113
+ * name: **[optional]** The beneficiary name
114
+ * street: **[optional]** The beneficiary address street name
115
+ * number: **[optional]** The beneficiary address number
116
+ * complement: **[optional]** Complement information to the beneficiary address
117
+ * zip: **[optional]** The beneficiary address zip code
118
+ * city: **[optional]** The beneficiary address city
119
+ * country: **[optional]** The beneficiary country code (2 letters)
120
+ * iban: **[optional]** The beneficiary iban
121
+ * swift_bic: **[optional]** The beneficiary swift or bic code
122
+ * bank: **[optional]** The beneficiary bank name
92
123
 
93
124
  #### Verify payment
94
125
 
@@ -66,16 +66,39 @@ module Fintecture
66
66
  raise Fintecture::ValidationException.new("#{@payment_attrs['psu_type']} PSU type not allowed") unless Fintecture::Utils::Constants::PSU_TYPES.include? @payment_attrs['psu_type']
67
67
 
68
68
  raise Fintecture::ValidationException.new('end_to_end_id must be an alphanumeric string') if(@payment_attrs['end_to_end_id'] && !@payment_attrs['end_to_end_id'].match(/^[0-9a-zA-Z]*$/))
69
+ Fintecture::Utils::Validation.raise_if_invalid_date_format(@payment_attrs['execution_date']) if(@payment_attrs['execution_date'])
69
70
 
70
71
  %w[amount currency customer_full_name customer_email customer_ip redirect_uri].each do |param|
71
72
  raise Fintecture::ValidationException.new("#{param} is a mandatory field") if @payment_attrs[param].nil?
72
73
  end
73
74
 
74
75
  # Check if string
75
- %w[communication redirect_uri].each do |param|
76
+ %w[communication redirect_uri provider customer_phone].each do |param|
76
77
  Fintecture::Utils::Validation.raise_if_klass_mismatch(@payment_attrs[param], String, param) if(@payment_attrs[param])
77
78
  end
78
79
 
80
+ # Check customer_address structure
81
+ Fintecture::Utils::Validation.raise_if_klass_mismatch(@payment_attrs['customer_address'], Hash) if(@payment_attrs['customer_address'])
82
+
83
+ raise Fintecture::ValidationException.new('customer_address country must be a 2 letters string') if(@payment_attrs['customer_address'] && @payment_attrs['customer_address']['country'] && !@payment_attrs['customer_address']['country'].match(/^[a-zA-Z]{2}$/))
84
+
85
+ %w[street number complement zip city country].each do |param|
86
+ Fintecture::Utils::Validation.raise_if_klass_mismatch(@payment_attrs['customer_address'][param], String, param) if(@payment_attrs['customer_address'] && @payment_attrs['customer_address'][param])
87
+ end
88
+
89
+ # Check beneficiary structure
90
+
91
+ Fintecture::Utils::Validation.raise_if_klass_mismatch(@payment_attrs['beneficiary'], Hash) if(@payment_attrs['beneficiary'])
92
+
93
+ %w[name street city iban swift_bic].each do |param|
94
+ raise Fintecture::ValidationException.new("beneficiary #{param} is a mandatory field") if @payment_attrs['beneficiary'] && @payment_attrs['beneficiary'][param].nil?
95
+ end
96
+
97
+ raise Fintecture::ValidationException.new('beneficiary country must be a 2 letters string') if(@payment_attrs['beneficiary'] && @payment_attrs['beneficiary']['country'] && !@payment_attrs['beneficiary']['country'].match(/^[a-zA-Z]{2}$/))
98
+
99
+ %w[name street number complement zip city country iban swift_bic bank_name].each do |param|
100
+ Fintecture::Utils::Validation.raise_if_klass_mismatch(@payment_attrs['beneficiary'][param], String, param) if(@payment_attrs['beneficiary'] && @payment_attrs['beneficiary'][param])
101
+ end
79
102
  end
80
103
 
81
104
  def validate_post_payment_integrity
@@ -91,13 +114,32 @@ module Fintecture
91
114
  amount: @payment_attrs['amount'],
92
115
  currency: @payment_attrs['currency'],
93
116
  communication: @payment_attrs['communication'],
94
- end_to_end_id: @payment_attrs['end_to_end_id']
117
+ end_to_end_id: @payment_attrs['end_to_end_id'],
118
+ execution_date: @payment_attrs['execution_date'],
119
+ provider: @payment_attrs['provider']
95
120
  }
96
121
 
122
+ if @payment_attrs['beneficiary']
123
+ attributes['beneficiary'] = {
124
+ name: @payment_attrs['beneficiary']['name'],
125
+ street: @payment_attrs['beneficiary']['street'],
126
+ number: @payment_attrs['beneficiary']['number'],
127
+ complement: @payment_attrs['beneficiary']['complement'],
128
+ zip: @payment_attrs['beneficiary']['zip'],
129
+ city: @payment_attrs['beneficiary']['city'],
130
+ country: @payment_attrs['beneficiary']['country'],
131
+ iban: @payment_attrs['beneficiary']['iban'],
132
+ swift_bic: @payment_attrs['beneficiary']['swift_bic'],
133
+ bank_name: @payment_attrs['beneficiary']['bank_name']
134
+ }
135
+ end
136
+
97
137
  meta = {
98
138
  psu_name: @payment_attrs['customer_full_name'],
99
139
  psu_email: @payment_attrs['customer_email'],
100
- psu_ip: @payment_attrs['customer_ip']
140
+ psu_ip: @payment_attrs['customer_ip'],
141
+ psu_phone: @payment_attrs['customer_phone'],
142
+ psu_address: @payment_attrs['customer_address']
101
143
  }
102
144
 
103
145
  data = {
@@ -110,9 +152,12 @@ module Fintecture
110
152
  meta: meta
111
153
  })
112
154
  prepare_payment_response_body = JSON.parse(prepare_payment_response.body)
155
+ data_attributes = {amount: @payment_attrs['amount'], currency: @payment_attrs['currency']}
156
+ data_attributes[:execution_date] = @payment_attrs['execution_date'] if @payment_attrs['execution_date']
157
+ data_attributes[:beneficiary] = { name: @payment_attrs['beneficiary']['name'] } if @payment_attrs['beneficiary'] && @payment_attrs['beneficiary']['name']
113
158
  {
114
159
  meta: {session_id: prepare_payment_response_body['meta']['session_id']},
115
- data: { attributes: {amount: @payment_attrs['amount'], currency: @payment_attrs['currency']}}
160
+ data: { attributes: data_attributes}
116
161
  }
117
162
  end
118
163
 
@@ -127,7 +172,7 @@ module Fintecture
127
172
  def build_config(payload)
128
173
  header_time = Fintecture::Utils::Date.header_time
129
174
  x_request_id = Fintecture::Utils::Crypto.generate_uuid
130
- {
175
+ config = {
131
176
  app_id: Fintecture.app_id,
132
177
  access_token: @access_token,
133
178
  date: header_time,
@@ -139,6 +184,8 @@ module Fintecture
139
184
  state: @payment_attrs['state'],
140
185
  payload: payload
141
186
  }
187
+ config[:provider] = @payment_attrs['provider'] if @payment_attrs['provider']
188
+ config
142
189
  end
143
190
 
144
191
  def build_local_digest(parameters)
@@ -6,7 +6,7 @@ module Fintecture
6
6
  module Constants
7
7
 
8
8
  SIGNEDHEADERPARAMETERLIST = %w[(request-target) Date Digest X-Request-ID];
9
- PSU_TYPES = %w[retail corporate]
9
+ PSU_TYPES = %w[retail corporate all]
10
10
  SCOPES = %w[pis ais]
11
11
 
12
12
  end
@@ -11,6 +11,15 @@ module Fintecture
11
11
  raise Fintecture::ValidationException.new("invalid #{param_name ? param_name : 'parameter'} format, the parameter should be a #{klass} instead a #{target.class.name}")
12
12
  end
13
13
 
14
+ def raise_if_invalid_date_format(date)
15
+ return unless date
16
+ valid_format = date.match(/\d{4}-\d{2}-\d{2}/)
17
+ valid_date = ::Date.strptime(date, '%Y-%m-%d') rescue false
18
+ return if valid_format && valid_date
19
+
20
+ raise Fintecture::ValidationException.new("invalidss #{date} date, the format should be YYYY-MM-DD")
21
+ end
22
+
14
23
  end
15
24
  end
16
25
  end
@@ -1,3 +1,3 @@
1
1
  module Fintecture
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fintecture
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fintecture
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-24 00:00:00.000000000 Z
11
+ date: 2020-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -120,8 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  - !ruby/object:Gem::Version
121
121
  version: '0'
122
122
  requirements: []
123
- rubyforge_project:
124
- rubygems_version: 2.7.8
123
+ rubygems_version: 3.0.6
125
124
  signing_key:
126
125
  specification_version: 4
127
126
  summary: Short summary