mangopay 3.0.32 → 3.0.37

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 12dc8e2f6ecc5798628cbc487075f3d9bf7100d0d5c17e1ec2bdb6c6ab4d0592
4
- data.tar.gz: 87aff78311a7331e52898938ce4824b5ce72f0b6338898a5b5f163ea012201bf
3
+ metadata.gz: 95f96378128e4073bc8726a16a456a3fabfd34008a30f703cd8d22df86e8506e
4
+ data.tar.gz: e6f80ed1350bd81983a6919ced5bcb7052d3eb5bfe4829e942ff0f4a599ce779
5
5
  SHA512:
6
- metadata.gz: a5c90e91c9dee7eb80e250d0f46d04b4af4995ae5cbe25e743eb5870e09b0dd6fa5f4055e5faa4770659a8b5296ba2421dc1d9883aaf4e31d841792ee3260fc8
7
- data.tar.gz: e93958461b0ee968f492d79ae4b7b2402364d9bf7657c07162dac3558a409ce44f6d1706c29b8bed3b623535680e92452cde44a801f3aad844291532eba5a147
6
+ metadata.gz: 1b8a4718718e30c6b40e75f166998c39cedeb881b5b42bfdd8b6f0778e1f067c1eccea8d4269b1547e32a1e3cf2ecda56492d05a36423eb24247064a27ca7cb3
7
+ data.tar.gz: 7a736e8e088babb16034733569c3d04fd2d653f03eddaac925fd9951f8a7759d397a5da7925e864303073a79777a717abfe044263928a7cf900cf2ae1c00b84f
@@ -1,6 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
3
+ # - 2.0.0
4
+ # - 2.1
5
+ # - 2.2
6
+ # - 2.3
7
+ # - 2.4
8
+ - 2.5
4
9
  script: bundle exec rspec
5
10
  deploy:
6
11
  provider: rubygems
@@ -0,0 +1,45 @@
1
+ ## [3.0.37] - 2020-10-30
2
+ - Card Validation endpoint fully activated
3
+ - added pre authorizations transactions method
4
+ - added new methods for client bank accounts and payouts
5
+ - Send headers for different api calls
6
+
7
+ ## [3.0.36] - 2020-08-28
8
+ - Forces TLS version to 1.2
9
+
10
+ ## [3.0.35] - 2020-08-24
11
+ - Improvement to Net::ReadTimeout handling
12
+ - "User-agent" format in the headers changed, aligned to other assets 👤
13
+
14
+ ## [3.0.34] - 2020-06-25
15
+ ### Added
16
+ - This SDK is now GooglePay-ready ! Feel free to ask our lovely support for more infos about its activation.
17
+ - `UBODeclaration` is now directly available through its ID.
18
+ - If a bankwire is done from a UK bankaccount on one of your `BankingAlias`, you could find its `AccountNumber` on `GET /payins/` response
19
+ - You can now send a `Culture` parameter for Paypal PayIns. Thanks to it, payment page can be displayed in various languages.
20
+
21
+ ### Changed
22
+ - `PAYLINEV2`value for Payin Web has been added on `TemplateURLOptions` object. You now should use it instead of `PAYLINE` for page customization.
23
+
24
+ ### Fixed
25
+ - Missing filters parameters have been added
26
+ - You can now send headers in update requests
27
+ - Loggers have been enhanced
28
+
29
+ ## [3.0.33] - 2019-09-23
30
+ ### Added
31
+ - ApplePay `Payin` functions are now available. More info about activation to come in the following weeks...
32
+ ### Changed
33
+ - GET EMoney method now supports year and month parameters. More info on our [docs](https://docs.mangopay.com/endpoints/v2.01/user-emoney#e895_view-a-users-emoney)
34
+
35
+ ## [v3.0.32] - 2019-06-19
36
+ ### Added
37
+ - New UBO Declaration system (more info [here](https://docs.mangopay.com/endpoints/v2.01/ubo-declarations#e1024_the-ubo-declaration-object))
38
+ ### Changed
39
+ - Paypal buyer account email that has been used is now available for Payin Paypal
40
+ - Your `HeadquartersPhoneNumber` can now be updated for your client account directly from our API
41
+ ### BREAKING
42
+ - `APIKey` is now replacing `passphrase` property for credentials. You must update it by updating to 3.0.32 SDK version and upper ones.
43
+
44
+
45
+
data/README.md CHANGED
@@ -4,7 +4,7 @@ The gem for interacting with the version 2 of the Mangopay API.
4
4
  See the [API documentation](http://docs.mangopay.com/api-references/)
5
5
  for more details on the API.
6
6
 
7
- Tested on the following versions of Ruby: 1.9.2, 1.9.3, 2.0.0
7
+ Tested on the following versions of Ruby: 1.9.2, 1.9.3, 2.0.0 and 2.x up to 2.5
8
8
 
9
9
  ## NEWS
10
10
 
@@ -37,7 +37,7 @@ require 'mangopay'
37
37
  MangoPay.configure do |c|
38
38
  c.preproduction = true
39
39
  c.client_id = 'YOUR_CLIENT_ID'
40
- c.client_passphrase = 'YOUR_CLIENT_PASSWORD'
40
+ c.client_apiKey = 'YOUR_CLIENT_API_KEY'
41
41
  c.log_file = File.join('mypath', 'mangopay.log')
42
42
  c.http_timeout = 10000
43
43
  end
@@ -102,7 +102,7 @@ Along with each request, the rate limiting headers are automatically updated in
102
102
  }
103
103
  ```
104
104
 
105
- Read more about rate limiting on [our documetiation](https://docs.mangopay.com/guide/rate-limiting).
105
+ Read more about rate limiting on [our documentation](https://docs.mangopay.com/guide/rate-limiting).
106
106
 
107
107
  ### Log requests and responses
108
108
  You can easily enable logs by setting the ```log_file``` configuration option (see the section **configuration** above). If you don't want logs, remove the ```log_file``` line.
@@ -49,7 +49,8 @@ module MangoPay
49
49
  class Configuration
50
50
  attr_accessor :preproduction, :root_url,
51
51
  :client_id, :client_apiKey,
52
- :temp_dir, :log_file, :http_timeout
52
+ :temp_dir, :log_file, :http_timeout,
53
+ :logger
53
54
 
54
55
  def preproduction
55
56
  @preproduction || false
@@ -134,13 +135,15 @@ module MangoPay
134
135
  headers['Idempotency-Key'] = headers_or_idempotency_key if headers_or_idempotency_key != nil
135
136
  end
136
137
 
137
- res = Net::HTTP.start(uri.host, uri.port, use_ssl: true, :read_timeout => configuration.http_timeout) do |http|
138
+ res = Net::HTTP.start(uri.host, uri.port, use_ssl: true, :read_timeout => configuration.http_timeout, ssl_version: :TLSv1_2) do |http|
138
139
  req = Net::HTTP::const_get(method.capitalize).new(uri.request_uri, headers)
139
140
  req.body = JSON.dump(params)
140
141
  before_request_proc.call(req) if before_request_proc
141
142
  do_request(http, req, uri)
142
143
  end
143
144
 
145
+ raise MangoPay::ResponseError.new(uri, '408', {'Message' => 'Request Timeout'}) if res.nil?
146
+
144
147
  # decode json data
145
148
  data = res.body.to_s.empty? ? {} : JSON.load(res.body.to_s)
146
149
 
@@ -158,7 +161,7 @@ module MangoPay
158
161
  limit: res['x-ratelimit'].split(", "),
159
162
  remaining: res['x-ratelimit-remaining'].split(", "),
160
163
  reset: res['x-ratelimit-reset'].split(", ")
161
- }
164
+ }
162
165
  end
163
166
 
164
167
  data
@@ -192,7 +195,7 @@ module MangoPay
192
195
  def request_headers
193
196
  auth_token = AuthorizationToken::Manager.get_token
194
197
  headers = {
195
- 'User-Agent' => "MANGOPAY V2 RubyBindings/#{VERSION}",
198
+ 'User-Agent' => "MangoPay V2 SDK Ruby Bindings #{VERSION}",
196
199
  'Authorization' => "#{auth_token['token_type']} #{auth_token['access_token']}",
197
200
  'Content-Type' => 'application/json'
198
201
  }
@@ -204,10 +207,10 @@ module MangoPay
204
207
  end
205
208
 
206
209
  def do_request(http, req, uri)
207
- if configuration.log_file.nil?
208
- do_request_without_log(http, req)
209
- else
210
+ if logs_required?
210
211
  do_request_with_log(http, req, uri)
212
+ else
213
+ do_request_without_log(http, req)
211
214
  end
212
215
  end
213
216
 
@@ -216,12 +219,23 @@ module MangoPay
216
219
  params = FilterParameters.request(req.body)
217
220
  line = "[#{Time.now.iso8601}] #{req.method.upcase} \"#{uri.to_s}\" #{params}"
218
221
  begin
219
- time = Benchmark.realtime { res = do_request_without_log(http, req) }
222
+ time = Benchmark.realtime {
223
+ begin
224
+ res = do_request_without_log(http, req)
225
+ rescue Net::ReadTimeout
226
+ res = nil
227
+ end
228
+ }
220
229
  res
221
230
  ensure
222
- params = FilterParameters.response(res.body)
223
231
  line = "#{log_severity(res)} #{line}"
224
- line += "\n [#{(time * 1000).round(1)}ms] #{res.code} #{params}\n"
232
+ if res.nil?
233
+ params = ''
234
+ line += "\n [#{(time * 1000).round(1)}ms] 408 Request Timeout #{params}\n"
235
+ else
236
+ params = FilterParameters.response(res.body)
237
+ line += "\n [#{(time * 1000).round(1)}ms] #{res.code} #{params}\n"
238
+ end
225
239
  logger.info { line }
226
240
  end
227
241
  end
@@ -236,15 +250,23 @@ module MangoPay
236
250
  end
237
251
 
238
252
  def logger
239
- raise NotImplementedError if configuration.log_file.nil?
240
- if @logger.nil?
253
+ raise NotImplementedError unless logs_required?
254
+ return @logger if @logger
255
+
256
+ if !configuration.logger.nil?
257
+ @logger = configuration.logger
258
+ elsif !configuration.log_file.nil?
241
259
  @logger = Logger.new(configuration.log_file)
242
- @logger.formatter = proc do |severity, datetime, progname, msg|
260
+ @logger.formatter = proc do |_, _, _, msg|
243
261
  "#{msg}\n"
244
262
  end
245
263
  end
264
+
246
265
  @logger
247
266
  end
248
267
 
268
+ def logs_required?
269
+ !configuration.log_file.nil? || !configuration.logger.nil?
270
+ end
249
271
  end
250
272
  end
@@ -69,6 +69,19 @@ module MangoPay
69
69
  MangoPay.request(:get, url() + "/wallets/#{funds_type}/#{currency_iso_code}/transactions", {}, filters)
70
70
  end
71
71
 
72
+ def validate(client_id, card_id)
73
+ url = "#{MangoPay.api_path}/cards/#{card_id}/validate"
74
+ MangoPay.request(:post, url)
75
+ end
76
+
77
+ def create_bank_account(params)
78
+ MangoPay.request(:post, url() + "/bankaccounts/iban", params)
79
+ end
80
+
81
+ def create_payout(params)
82
+ MangoPay.request(:post, url() + "/payouts", params)
83
+ end
84
+
72
85
  end
73
86
  end
74
87
  end
@@ -13,7 +13,12 @@ module MangoPay
13
13
 
14
14
  def self.response(body)
15
15
  return '' if body.to_s.empty?
16
- body = JSON.load(body)
16
+
17
+ begin
18
+ body = JSON.load(body)
19
+ rescue MultiJson::LoadError => e
20
+ return body
21
+ end
17
22
  filter_hash(body, res_confidential_params)
18
23
  JSON.dump(body)
19
24
  end
@@ -21,8 +21,8 @@ module MangoPay
21
21
 
22
22
  module Update
23
23
  module ClassMethods
24
- def update(id = nil, params = {})
25
- MangoPay.request(:put, url(id), params)
24
+ def update(id = nil, params = {}, idempotency_key = nil)
25
+ MangoPay.request(:put, url(id), params, {}, idempotency_key)
26
26
  end
27
27
  end
28
28
 
@@ -35,20 +35,20 @@ module MangoPay
35
35
  module ClassMethods
36
36
 
37
37
  # - Fetching _single_entity_ by +id+:
38
- #
38
+ #
39
39
  # MangoPay::User.fetch("user-id") # => {"FirstName"=>"Mango", "LastName"=>"Pay", ...}
40
- #
40
+ #
41
41
  # - or fetching _multiple_entities_ with _optional_ +filters+ hash,
42
42
  # including _pagination_ and _sorting_ params
43
43
  # +page+, +per_page+, +sort+ (see http://docs.mangopay.com/api-references/pagination/):
44
- #
44
+ #
45
45
  # MangoPay::User.fetch() # => [{...}, ...]: list of user data hashes (10 per page by default)
46
46
  # MangoPay::User.fetch({'page' => 2, 'per_page' => 3}) # => list of 3 hashes from 2nd page
47
47
  # MangoPay::BankAccount.fetch(user_id, {'sort' => 'CreationDate:desc'}) # => bank accounts by user, sorting by date descending (with default pagination)
48
48
  # MangoPay::BankAccount.fetch(user_id, {'sort' => 'CreationDate:desc', 'page' => 2, 'per_page' => 3}) # both sorting and pagination params provided
49
- #
49
+ #
50
50
  # - For paginated queries the +filters+ param will be supplemented by +total_pages+ and +total_items+ info:
51
- #
51
+ #
52
52
  # MangoPay::User.fetch(filter = {'page' => 2, 'per_page' => 3})
53
53
  # filter # => {"page"=>2, "per_page"=>3, "total_pages"=>1969, "total_items"=>5905}
54
54
  #
@@ -106,5 +106,25 @@ module MangoPay
106
106
 
107
107
  end
108
108
 
109
+ module ApplePay
110
+ class Direct < Resource
111
+ include HTTPCalls::Create
112
+
113
+ def self.url(*)
114
+ "#{MangoPay.api_path}/payins/applepay/#{CGI.escape(class_name.downcase)}"
115
+ end
116
+ end
117
+ end
118
+
119
+ module GooglePay
120
+ class Direct < Resource
121
+ include HTTPCalls::Create
122
+
123
+ def self.url(*)
124
+ "#{MangoPay.api_path}/payins/googlepay/#{CGI.escape(class_name.downcase)}"
125
+ end
126
+ end
127
+ end
128
+
109
129
  end
110
130
  end
@@ -9,5 +9,9 @@ module MangoPay
9
9
  MangoPay.request(:post, "#{url}/card/direct", params, {}, idempotency_key)
10
10
  end
11
11
 
12
+ def self.transactions(pre_authorization_id, filters = {})
13
+ MangoPay.request(:get, "#{url}/#{pre_authorization_id}/transactions", {}, filters)
14
+ end
15
+
12
16
  end
13
17
  end
@@ -12,7 +12,7 @@ module MangoPay
12
12
  # Fetches list of wallets belonging to the given +user_id+.
13
13
  # Optional +filters+ is a hash accepting following keys:
14
14
  # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
15
- def wallets(user_id, filters={})
15
+ def wallets(user_id, filters = {})
16
16
  MangoPay.request(:get, url(user_id) + '/wallets', {}, filters)
17
17
  end
18
18
 
@@ -20,14 +20,14 @@ module MangoPay
20
20
  # Optional +filters+ is a hash accepting following keys:
21
21
  # - +page+, +per_page+, +sort+: pagination and sorting params
22
22
  # (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
23
- def bank_accounts(user_id, filters={})
23
+ def bank_accounts(user_id, filters = {})
24
24
  MangoPay.request(:get, url(user_id) + '/bankaccounts', {}, filters)
25
25
  end
26
26
 
27
27
  # Fetches list of cards belonging to the given +user_id+.
28
28
  # Optional +filters+ is a hash accepting following keys:
29
29
  # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
30
- def cards(user_id, filters={})
30
+ def cards(user_id, filters = {})
31
31
  MangoPay.request(:get, url(user_id) + '/cards', {}, filters)
32
32
  end
33
33
 
@@ -35,7 +35,7 @@ module MangoPay
35
35
  # Optional +filters+ is a hash accepting following keys:
36
36
  # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
37
37
  # - other keys specific for transactions filtering (see MangoPay::Transaction#fetch)
38
- def transactions(user_id, filters={})
38
+ def transactions(user_id, filters = {})
39
39
  MangoPay.request(:get, url(user_id) + '/transactions', {}, filters)
40
40
  end
41
41
 
@@ -43,21 +43,25 @@ module MangoPay
43
43
  # Optional +filters+ is a hash accepting following keys:
44
44
  # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
45
45
  # - other keys specific for transactions filtering (see MangoPay::Transaction#fetch)
46
- def emoney(user_id, filters={})
47
- MangoPay.request(:get, url(user_id) + '/emoney', {}, filters)
46
+ def emoney(user_id, year, month = nil, filters = {})
47
+ if month
48
+ MangoPay.request(:get, url(user_id) + "/emoney/#{year}/#{month}", {}, filters)
49
+ else
50
+ MangoPay.request(:get, url(user_id) + "/emoney/#{year}", {}, filters)
51
+ end
48
52
  end
49
53
 
50
54
  # Fetches list of kyc documents belonging to the given +user_id+.
51
55
  # Optional +filters+ is a hash accepting following keys:
52
56
  # - +page+, +per_page+, +sort+, +BeforeDate+, +AfterDate+, +Status+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
53
- def kyc_documents(user_id, filters={})
57
+ def kyc_documents(user_id, filters = {})
54
58
  MangoPay.request(:get, url(user_id) + '/KYC/documents', {}, filters)
55
59
  end
56
60
 
57
61
  # Fetches list of pre-authorizations belonging to the given +user_id+.
58
62
  # Optional +filters+ is a hash accepting the following keys:
59
63
  # - +page+, +per_page+, +sort+, +Status+, +ResultCode+, +PaymentStatus+: pagination and sorting/filtering params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
60
- def pre_authorizations(user_id, filters={})
64
+ def pre_authorizations(user_id, filters = {})
61
65
  MangoPay.request(:get, url(user_id) + '/preauthorizations', {}, filters)
62
66
  end
63
67
  end
@@ -1,3 +1,3 @@
1
1
  module MangoPay
2
- VERSION = '3.0.32'
2
+ VERSION = '3.0.37'
3
3
  end
@@ -1,4 +1,6 @@
1
1
  describe MangoPay::Client do
2
+ include_context 'users'
3
+ include_context 'payins'
2
4
 
3
5
  describe 'FETCH' do
4
6
  it 'fetches the current client details' do
@@ -26,6 +28,7 @@ describe MangoPay::Client do
26
28
  Country: 'FR',
27
29
  PostalCode: '150770'
28
30
  }
31
+ clnt['TechEmails'] = ['support@mangopay.com']
29
32
  phoneNumber = rand(99999999).to_s
30
33
  clnt['HeadquartersPhoneNumber'] = phoneNumber
31
34
 
@@ -39,7 +42,7 @@ describe MangoPay::Client do
39
42
  describe 'UPLOAD LOGO' do
40
43
  it 'accepts Base64 encoded file content' do
41
44
  fnm = __FILE__.sub('.rb', '.png')
42
- bts = File.open(fnm, 'rb') {|f| f.read}
45
+ bts = File.open(fnm, 'rb') { |f| f.read }
43
46
  b64 = Base64.encode64(bts)
44
47
  ret = MangoPay::Client.upload_logo(b64)
45
48
  expect(ret).to be_nil
@@ -53,7 +56,7 @@ describe MangoPay::Client do
53
56
 
54
57
  it 'fails when input string is not base64-encoded' do
55
58
  file = 'any file content...'
56
- expect {MangoPay::Client.upload_logo(file)}.to raise_error {|err|
59
+ expect { MangoPay::Client.upload_logo(file) }.to raise_error { |err|
57
60
  expect(err).to be_a MangoPay::ResponseError
58
61
  expect(err.code).to eq '400'
59
62
  expect(err.type).to eq 'param_error'
@@ -72,14 +75,14 @@ describe MangoPay::Client do
72
75
  wlts = MangoPay::Client.fetch_wallets('fees')
73
76
  expect(wlts).to be_kind_of(Array)
74
77
  expect(wlts).not_to be_empty
75
- expect((wlts.map {|m| m['FundsType']}).uniq).to eq(['FEES'])
78
+ expect((wlts.map { |m| m['FundsType'] }).uniq).to eq(['FEES'])
76
79
  end
77
80
 
78
81
  it 'fetches all client credit wallets' do
79
82
  wlts = MangoPay::Client.fetch_wallets('credit')
80
83
  expect(wlts).to be_kind_of(Array)
81
84
  expect(wlts).not_to be_empty
82
- expect((wlts.map {|m| m['FundsType']}).uniq).to eq(['CREDIT'])
85
+ expect((wlts.map { |m| m['FundsType'] }).uniq).to eq(['CREDIT'])
83
86
  end
84
87
  end
85
88
 
@@ -123,4 +126,68 @@ describe MangoPay::Client do
123
126
  end
124
127
  end
125
128
 
129
+ describe 'validate' do
130
+ it 'validates card' do
131
+ client = MangoPay::Client.fetch
132
+ completed = new_card_registration_completed
133
+ card_id = completed['CardId']
134
+ client_id = client['ClientId']
135
+
136
+ card = MangoPay::Client.validate(client_id, card_id)
137
+ expect(client).not_to be_nil
138
+ expect(card).not_to be_nil
139
+ end
140
+ end
141
+
142
+ describe 'create_bank_account' do
143
+ it 'creates a new bank account' do
144
+ bank_account = MangoPay::Client.create_bank_account(Type: 'IBAN',
145
+ OwnerName: 'John',
146
+ OwnerAddress: {
147
+ AddressLine1: 'Le Palais Royal',
148
+ AddressLine2: '8 Rue de Montpensier',
149
+ City: 'Paris',
150
+ Region: '',
151
+ PostalCode: '75001',
152
+ Country: 'FR'
153
+ },
154
+ IBAN: 'FR7618829754160173622224154',
155
+ BIC: 'CMBRFR2BCME',
156
+ Tag: 'Test bank account')
157
+ expect(bank_account).not_to be_nil
158
+ expect(bank_account['Id']).not_to be_nil
159
+ end
160
+ end
161
+
162
+ describe 'create_payout' do
163
+ it 'creates a new payout' do
164
+ wallets = MangoPay::Client.fetch_wallets('FEES')
165
+ bank_account = MangoPay::Client.create_bank_account(Type: 'IBAN',
166
+ OwnerName: 'John',
167
+ OwnerAddress: {
168
+ AddressLine1: 'Le Palais Royal',
169
+ AddressLine2: '8 Rue de Montpensier',
170
+ City: 'Paris',
171
+ Region: '',
172
+ PostalCode: '75001',
173
+ Country: 'FR'
174
+ },
175
+ IBAN: 'FR7618829754160173622224154',
176
+ BIC: 'CMBRFR2BCME',
177
+ Tag: 'Test bank account')
178
+ pay_out = MangoPay::Client.create_payout(BankAccountId: bank_account['Id'],
179
+
180
+ DebitedFunds: {
181
+ Currency: 'EUR',
182
+ Amount: 12
183
+ },
184
+ DebitedWalletId: wallets[0]['Id'],
185
+ BankWireRef: 'invoice 7282',
186
+ Tag: 'bla')
187
+
188
+ expect(pay_out).not_to be_nil
189
+ expect(pay_out['Id']).not_to be_nil
190
+ end
191
+ end
192
+
126
193
  end
@@ -15,6 +15,58 @@ describe MangoPay::Configuration do
15
15
  expect(users).to be_kind_of(Array)
16
16
  end
17
17
 
18
+ describe 'logger' do
19
+ around(:each) do |example|
20
+ c = MangoPay.configuration
21
+ c.logger = logger
22
+ c.log_file = log_file
23
+ example.run
24
+ c.logger = nil
25
+ c.log_file = nil
26
+ MangoPay.instance_variable_set(:@logger, nil)
27
+ end
28
+
29
+ context 'when the logger is set' do
30
+ let(:logger) { Logger.new(STDOUT) }
31
+
32
+ context 'when the log_file is set' do
33
+ let(:log_file) { File.join(MangoPay.configuration.temp_dir, 'mangopay.log.tmp') }
34
+
35
+ it 'initializes the logger using the logger option' do
36
+ expect(MangoPay.send(:logger).instance_variable_get(:@logdev).dev).to(eq(STDOUT))
37
+ end
38
+ end
39
+
40
+ context 'when the log_file is not set' do
41
+ let(:log_file) { nil }
42
+
43
+ it 'initializes the logger using the logger option' do
44
+ expect(MangoPay.send(:logger).instance_variable_get(:@logdev).dev).to(eq(STDOUT))
45
+ end
46
+ end
47
+ end
48
+
49
+ context 'when the logger is not set' do
50
+ let(:logger) { nil }
51
+
52
+ context 'when the log_file is set' do
53
+ let(:log_file) { File.join(MangoPay.configuration.temp_dir, 'mangopay.log.tmp') }
54
+
55
+ it 'initializes the logger using the log file' do
56
+ expect(MangoPay.send(:logger).instance_variable_get(:@logdev).dev).to(be_an_instance_of(File))
57
+ end
58
+ end
59
+
60
+ context 'when the log_file is not set' do
61
+ let(:log_file) { nil }
62
+
63
+ it 'raises an error' do
64
+ expect{ MangoPay.send(:logger) }.to raise_error NotImplementedError
65
+ end
66
+ end
67
+ end
68
+ end
69
+
18
70
  context 'with multithreading' do
19
71
  after :all do
20
72
  reset_mangopay_configuration
@@ -0,0 +1,20 @@
1
+ describe MangoPay::PayIn::ApplePay::Direct, type: :feature do
2
+ include_context 'payins'
3
+
4
+ def check_type_and_status(payin)
5
+ expect(payin['Type']).to eq('PAYIN')
6
+ expect(payin['Nature']).to eq('REGULAR')
7
+ expect(payin['PaymentType']).to eq('APPLEPAY')
8
+ expect(payin['ExecutionType']).to eq('DIRECT')
9
+ expect(payin['Status']).to eq('SUCCEEDED')
10
+ end
11
+
12
+ describe 'CREATE' do
13
+ it 'creates a applepay direct payin' do
14
+ created = new_payin_applepay_direct
15
+ expect(created['Id']).not_to be_nil
16
+ check_type_and_status(created)
17
+ end
18
+ end
19
+ end
20
+
@@ -27,6 +27,42 @@ describe MangoPay::PayIn::BankWire::ExternalInstruction, type: :feature do
27
27
  check_type_and_status(payIn)
28
28
  MangoPay.configuration = backupConfig
29
29
  end
30
+
31
+ it 'fetches a bankwire external instruction with iban' do
32
+ backupConfig = MangoPay.configuration.clone
33
+ MangoPay.configure do |c|
34
+ c.preproduction = true
35
+ c.client_id = 'sdk-unit-tests'
36
+ c.root_url = 'https://api.sandbox.mangopay.com'
37
+ c.client_apiKey = 'cqFfFrWfCcb7UadHNxx2C9Lo6Djw8ZduLi7J9USTmu8bhxxpju'
38
+ c.http_timeout = 10000
39
+ end
40
+
41
+ payInId = "74980101"
42
+ payIn = MangoPay::PayIn.fetch(payInId)
43
+ expect(payIn).to_not be(nil)
44
+ expect(payIn['Id']).to eq(payInId)
45
+ check_type_and_status(payIn)
46
+ MangoPay.configuration = backupConfig
47
+ end
48
+
49
+ it 'fetches a bankwire external instruction with account number' do
50
+ backupConfig = MangoPay.configuration.clone
51
+ MangoPay.configure do |c|
52
+ c.preproduction = true
53
+ c.client_id = 'sdk-unit-tests'
54
+ c.root_url = 'https://api.sandbox.mangopay.com'
55
+ c.client_apiKey = 'cqFfFrWfCcb7UadHNxx2C9Lo6Djw8ZduLi7J9USTmu8bhxxpju'
56
+ c.http_timeout = 10000
57
+ end
58
+
59
+ payInId = "74981216"
60
+ payIn = MangoPay::PayIn.fetch(payInId)
61
+ expect(payIn).to_not be(nil)
62
+ expect(payIn['Id']).to eq(payInId)
63
+ check_type_and_status(payIn)
64
+ MangoPay.configuration = backupConfig
65
+ end
30
66
  end
31
67
 
32
68
  ###############################################
@@ -22,6 +22,15 @@ describe MangoPay::PayIn::Card::Web, type: :feature do
22
22
  end
23
23
  end
24
24
 
25
+ describe 'CREATE with PaylineV2' do
26
+ it 'creates a card web payin with payline v2' do
27
+ created = new_payin_card_web_payline
28
+ expect(created['Id']).not_to be_nil
29
+ expect(created['RedirectURL']).to include('https://www.maysite.com/payline_template/')
30
+ check_type_and_status(created)
31
+ end
32
+ end
33
+
25
34
  describe 'EXTENDED' do
26
35
  context 'when resource not exists' do
27
36
  it 'fetches extended information' do
@@ -18,7 +18,9 @@ describe MangoPay::PayIn::PreAuthorized::Direct, type: :feature do
18
18
  describe 'CREATE' do
19
19
  it 'creates a preauthorized direct payin' do
20
20
  created = new_payin_preauthorized_direct
21
+ transactions = MangoPay::PreAuthorization.transactions(created['PreauthorizationId'])
21
22
  expect(created['Id']).not_to be_nil
23
+ expect(transactions[0]['Status']).to eq('SUCCEEDED')
22
24
  check_type_and_status(created)
23
25
  end
24
26
  end
@@ -3,6 +3,7 @@ shared_context 'users' do
3
3
  ###############################################
4
4
 
5
5
  let(:new_natural_user) { create_new_natural_user }
6
+
6
7
  def define_new_natural_user
7
8
  {
8
9
  Tag: 'Test natural user',
@@ -10,13 +11,13 @@ shared_context 'users' do
10
11
  FirstName: 'John',
11
12
  LastName: 'Doe',
12
13
  Address: {
13
- AddressLine1: 'Le Palais Royal',
14
- AddressLine2: '8 Rue de Montpensier',
15
- City: 'Paris',
16
- Region: '',
17
- PostalCode: '75001',
18
- Country: 'FR'
19
- },
14
+ AddressLine1: 'Le Palais Royal',
15
+ AddressLine2: '8 Rue de Montpensier',
16
+ City: 'Paris',
17
+ Region: '',
18
+ PostalCode: '75001',
19
+ Country: 'FR'
20
+ },
20
21
  Birthday: 1_300_186_358,
21
22
  Birthplace: 'Paris',
22
23
  Nationality: 'FR',
@@ -42,21 +43,22 @@ shared_context 'users' do
42
43
  Region: 'FR',
43
44
  PostalCode: '75004',
44
45
  Country: 'FR'
45
- },
46
+ },
46
47
  LegalRepresentativeFirstName: 'John',
47
48
  LegalRepresentativeLastName: 'Doe',
48
49
  LegalRepresentativeAdress: {
49
- AddressLine1: '38 Rue de Montpensier',
50
- AddressLine2: '',
51
- City: 'Paris',
52
- Region: '',
53
- PostalCode: '75001',
54
- Country: 'FR'
55
- },
50
+ AddressLine1: '38 Rue de Montpensier',
51
+ AddressLine2: '',
52
+ City: 'Paris',
53
+ Region: '',
54
+ PostalCode: '75001',
55
+ Country: 'FR'
56
+ },
56
57
  LegalRepresentativeEmail: 'john@doe.com',
57
58
  LegalRepresentativeBirthday: 1_300_186_358,
58
59
  LegalRepresentativeNationality: 'FR',
59
60
  LegalRepresentativeCountryOfResidence: 'FR',
61
+ CompanyNumber: 'LU123456789',
60
62
  Statute: '',
61
63
  ProofOfRegistration: '',
62
64
  ShareholderDeclaration: ''
@@ -71,12 +73,13 @@ shared_context 'wallets' do
71
73
 
72
74
  let(:new_wallet) { create_new_wallet(new_natural_user) }
73
75
  let(:new_wallet_legal) { create_new_wallet(new_legal_user) }
76
+
74
77
  def create_new_wallet(user)
75
78
  MangoPay::Wallet.create(
76
- Owners: [user['Id']],
77
- Description: 'A test wallet',
78
- Currency: 'EUR',
79
- Tag: 'Test wallet'
79
+ Owners: [user['Id']],
80
+ Description: 'A test wallet',
81
+ Currency: 'EUR',
82
+ Tag: 'Test wallet'
80
83
  )
81
84
  end
82
85
 
@@ -144,14 +147,14 @@ shared_context 'mandates' do
144
147
  ###############################################
145
148
  include_context 'bank_accounts'
146
149
 
147
- let(:new_mandate) {create_new_mandate}
150
+ let(:new_mandate) { create_new_mandate }
148
151
 
149
152
  def create_new_mandate
150
153
  MangoPay::Mandate.create(
151
- BankAccountId: new_bank_account['Id'],
152
- Culture: 'FR',
153
- ReturnURL: MangoPay.configuration.root_url,
154
- Tag: 'Test mandate'
154
+ BankAccountId: new_bank_account['Id'],
155
+ Culture: 'FR',
156
+ ReturnURL: MangoPay.configuration.root_url,
157
+ Tag: 'Test mandate'
155
158
  )
156
159
  end
157
160
  end
@@ -162,6 +165,7 @@ shared_context 'kyc_documents' do
162
165
  include_context 'users'
163
166
 
164
167
  let(:new_document) { create_new_document(new_natural_user) }
168
+
165
169
  def create_new_document(user)
166
170
  MangoPay::KycDocument.create(user['Id'],
167
171
  Type: 'IDENTITY_PROOF',
@@ -182,15 +186,15 @@ shared_context 'payins' do
182
186
 
183
187
  let(:new_payin_directdebit_web) do
184
188
  MangoPay::PayIn::DirectDebit::Web.create(
185
- AuthorId: new_natural_user['Id'],
186
- CreditedUserId: new_wallet['Owners'][0],
187
- CreditedWalletId: new_wallet['Id'],
188
- DebitedFunds: { Currency: 'EUR', Amount: 1000 },
189
- Fees: { Currency: 'EUR', Amount: 0 },
190
- DirectDebitType: 'GIROPAY',
191
- ReturnURL: MangoPay.configuration.root_url,
192
- Culture: 'FR',
193
- Tag: 'Test PayIn/DirectDebit/Web'
189
+ AuthorId: new_natural_user['Id'],
190
+ CreditedUserId: new_wallet['Owners'][0],
191
+ CreditedWalletId: new_wallet['Id'],
192
+ DebitedFunds: {Currency: 'EUR', Amount: 1000},
193
+ Fees: {Currency: 'EUR', Amount: 0},
194
+ DirectDebitType: 'GIROPAY',
195
+ ReturnURL: MangoPay.configuration.root_url,
196
+ Culture: 'FR',
197
+ Tag: 'Test PayIn/DirectDebit/Web'
194
198
  )
195
199
  end
196
200
 
@@ -200,30 +204,87 @@ shared_context 'payins' do
200
204
 
201
205
  let(:new_payin_paypal_web) do
202
206
  MangoPay::PayIn::PayPal::Web.create(
203
- AuthorId: new_natural_user['Id'],
204
- CreditedUserId: new_wallet['Owners'][0],
205
- CreditedWalletId: new_wallet['Id'],
206
- DebitedFunds: { Currency: 'EUR', Amount: 1000 },
207
- Fees: { Currency: 'EUR', Amount: 0 },
208
- ReturnURL: MangoPay.configuration.root_url,
209
- Tag: 'Test PayIn/PayPal/Web'
207
+ AuthorId: new_natural_user['Id'],
208
+ CreditedUserId: new_wallet['Owners'][0],
209
+ CreditedWalletId: new_wallet['Id'],
210
+ DebitedFunds: {Currency: 'EUR', Amount: 1000},
211
+ Fees: {Currency: 'EUR', Amount: 0},
212
+ ReturnURL: MangoPay.configuration.root_url,
213
+ Culture: "FR",
214
+ Tag: 'Test PayIn/PayPal/Web'
210
215
  )
211
216
  end
212
217
 
218
+ ###############################################
219
+ # applepay/direct
220
+ ###############################################
221
+
222
+ let(:new_payin_applepay_direct) do
223
+ MangoPay::PayIn::ApplePay::Direct.create(
224
+ AuthorId: new_natural_user['Id'],
225
+ CreditedUserId: new_wallet['Owners'][0],
226
+ CreditedWalletId: new_wallet['Id'],
227
+ DebitedFunds: {Currency: 'EUR', Amount: 199},
228
+ Fees: {Currency: 'EUR', Amount: 1},
229
+ PaymentType: 'APPLEPAY',
230
+ PaymentData: {
231
+ TransactionId: '061EB32181A2D9CA42AD16031B476EEBAA62A9A095AD660E2759FBA52B51A61',
232
+ Network: 'VISA',
233
+ TokenData: "{\"version\":\"EC_v1\",\"data\":\"w4HMBVqNC9ghPP4zncTA\\/0oQAsduERfsx78oxgniynNjZLANTL6+0koEtkQnW\\/K38Zew8qV1GLp+fLHo+qCBpiKCIwlz3eoFBTbZU+8pYcjaeIYBX9SOxcwxXsNGrGLk+kBUqnpiSIPaAG1E+WPT8R1kjOCnGvtdombvricwRTQkGjtovPfzZo8LzD3ZQJnHMsWJ8QYDLyr\\/ZN9gtLAtsBAMvwManwiaG3pOIWpyeOQOb01YcEVO16EZBjaY4x4C\\/oyFLWDuKGvhbJwZqWh1d1o9JT29QVmvy3Oq2JEjq3c3NutYut4rwDEP4owqI40Nb7mP2ebmdNgnYyWfPmkRfDCRHIWtbMC35IPg5313B1dgXZ2BmyZRXD5p+mr67vAk7iFfjEpu3GieFqwZrTl3\\/pI5V8Sxe3SIYKgT5Hr7ow==\",\"signature\":\"MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwEAAKCAMIID5jCCA4ugAwIBAgIIaGD2mdnMpw8wCgYIKoZIzj0EAwIwejEuMCwGA1UEAwwlQXBwbGUgQXBwbGljYXRpb24gSW50ZWdyYXRpb24gQ0EgLSBHMzEmMCQGA1UECwwdQXBwbGUgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxEzARBgNVBAoMCkFwcGxlIEluYy4xCzAJBgNVBAYTAlVTMB4XDTE2MDYwMzE4MTY0MFoXDTIxMDYwMjE4MTY0MFowYjEoMCYGA1UEAwwfZWNjLXNtcC1icm9rZXItc2lnbl9VQzQtU0FOREJPWDEUMBIGA1UECwwLaU9TIFN5c3RlbXMxEzARBgNVBAoMCkFwcGxlIEluYy4xCzAJBgNVBAYTAlVTMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEgjD9q8Oc914gLFDZm0US5jfiqQHdbLPgsc1LUmeY+M9OvegaJajCHkwz3c6OKpbC9q+hkwNFxOh6RCbOlRsSlaOCAhEwggINMEUGCCsGAQUFBwEBBDkwNzA1BggrBgEFBQcwAYYpaHR0cDovL29jc3AuYXBwbGUuY29tL29jc3AwNC1hcHBsZWFpY2EzMDIwHQYDVR0OBBYEFAIkMAua7u1GMZekplopnkJxghxFMAwGA1UdEwEB\\/wQCMAAwHwYDVR0jBBgwFoAUI\\/JJxE+T5O8n5sT2KGw\\/orv9LkswggEdBgNVHSAEggEUMIIBEDCCAQwGCSqGSIb3Y2QFATCB\\/jCBwwYIKwYBBQUHAgIwgbYMgbNSZWxpYW5jZSBvbiB0aGlzIGNlcnRpZmljYXRlIGJ5IGFueSBwYXJ0eSBhc3N1bWVzIGFjY2VwdGFuY2Ugb2YgdGhlIHRoZW4gYXBwbGljYWJsZSBzdGFuZGFyZCB0ZXJtcyBhbmQgY29uZGl0aW9ucyBvZiB1c2UsIGNlcnRpZmljYXRlIHBvbGljeSBhbmQgY2VydGlmaWNhdGlvbiBwcmFjdGljZSBzdGF0ZW1lbnRzLjA2BggrBgEFBQcCARYqaHR0cDovL3d3dy5hcHBsZS5jb20vY2VydGlmaWNhdGVhdXRob3JpdHkvMDQGA1UdHwQtMCswKaAnoCWGI2h0dHA6Ly9jcmwuYXBwbGUuY29tL2FwcGxlYWljYTMuY3JsMA4GA1UdDwEB\\/wQEAwIHgDAPBgkqhkiG92NkBh0EAgUAMAoGCCqGSM49BAMCA0kAMEYCIQDaHGOui+X2T44R6GVpN7m2nEcr6T6sMjOhZ5NuSo1egwIhAL1a+\\/hp88DKJ0sv3eT3FxWcs71xmbLKD\\/QJ3mWagrJNMIIC7jCCAnWgAwIBAgIISW0vvzqY2pcwCgYIKoZIzj0EAwIwZzEbMBkGA1UEAwwSQXBwbGUgUm9vdCBDQSAtIEczMSYwJAYDVQQLDB1BcHBsZSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTETMBEGA1UECgwKQXBwbGUgSW5jLjELMAkGA1UEBhMCVVMwHhcNMTQwNTA2MjM0NjMwWhcNMjkwNTA2MjM0NjMwWjB6MS4wLAYDVQQDDCVBcHBsZSBBcHBsaWNhdGlvbiBJbnRlZ3JhdGlvbiBDQSAtIEczMSYwJAYDVQQLDB1BcHBsZSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTETMBEGA1UECgwKQXBwbGUgSW5jLjELMAkGA1UEBhMCVVMwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATwFxGEGddkhdUaXiWBB3bogKLv3nuuTeCN\\/EuT4TNW1WZbNa4i0Jd2DSJOe7oI\\/XYXzojLdrtmcL7I6CmE\\/1RFo4H3MIH0MEYGCCsGAQUFBwEBBDowODA2BggrBgEFBQcwAYYqaHR0cDovL29jc3AuYXBwbGUuY29tL29jc3AwNC1hcHBsZXJvb3RjYWczMB0GA1UdDgQWBBQj8knET5Pk7yfmxPYobD+iu\\/0uSzAPBgNVHRMBAf8EBTADAQH\\/MB8GA1UdIwQYMBaAFLuw3qFYM4iapIqZ3r6966\\/ayySrMDcGA1UdHwQwMC4wLKAqoCiGJmh0dHA6Ly9jcmwuYXBwbGUuY29tL2FwcGxlcm9vdGNhZzMuY3JsMA4GA1UdDwEB\\/wQEAwIBBjAQBgoqhkiG92NkBgIOBAIFADAKBggqhkjOPQQDAgNnADBkAjA6z3KDURaZsYb7NcNWymK\\/9Bft2Q91TaKOvvGcgV5Ct4n4mPebWZ+Y1UENj53pwv4CMDIt1UQhsKMFd2xd8zg7kGf9F3wsIW2WT8ZyaYISb1T4en0bmcubCYkhYQaZDwmSHQAAMYIBizCCAYcCAQEwgYYwejEuMCwGA1UEAwwlQXBwbGUgQXBwbGljYXRpb24gSW50ZWdyYXRpb24gQ0EgLSBHMzEmMCQGA1UECwwdQXBwbGUgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxEzARBgNVBAoMCkFwcGxlIEluYy4xCzAJBgNVBAYTAlVTAghoYPaZ2cynDzANBglghkgBZQMEAgEFAKCBlTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0xOTA1MjMxMTA1MDdaMCoGCSqGSIb3DQEJNDEdMBswDQYJYIZIAWUDBAIBBQChCgYIKoZIzj0EAwIwLwYJKoZIhvcNAQkEMSIEIIvfGVQYBeOilcB7GNI8m8+FBVZ28QfA6BIXaggBja2PMAoGCCqGSM49BAMCBEYwRAIgU01yYfjlx9bvGeC5CU2RS5KBEG+15HH9tz\\/sg3qmQ14CID4F4ZJwAz+tXAUcAIzoMpYSnM8YBlnGJSTSp+LhspenAAAAAAAA\",\"header\":{\"ephemeralPublicKey\":\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE0rs3wRpirXjPbFDQfPRdfEzRIZDWm0qn7Y0HB0PNzV1DDKfpYrnhRb4GEhBF\\/oEXBOe452PxbCnN1qAlqcSUWw==\",\"publicKeyHash\":\"saPRAqS7TZ4bAYwzBj8ezDDC55ZolyH1FL+Xc8fd93o=\",\"transactionId\":\"b061eb32181a2d9ca42ad16031b476eebaa62a9a095ad660e2759fba52b51a61\"}}"
234
+ },
235
+ StatementDescriptor: "php",
236
+ ReturnURL: MangoPay.configuration.root_url,
237
+ Tag: 'Test PayIn/ApplePay/Direct'
238
+ )
239
+ end
240
+
241
+ ###############################################
242
+ # CANNOT BE TESTED AS WE CAN'T MOCK TOKEN GENERATION
243
+ # googlepay/direct
244
+ ###############################################
245
+ let(:new_payin_googlepay_direct) do
246
+ MangoPay::PayIn::GooglePay::Direct.create(
247
+ AuthorId: new_natural_user['Id'],
248
+ CreditedUserId: new_wallet['Owners'][0],
249
+ CreditedWalletId: new_wallet['Id'],
250
+ DebitedFunds: {Currency: 'EUR', Amount: 199},
251
+ Fees: {Currency: 'EUR', Amount: 1},
252
+ PaymentData: {
253
+ TransactionId: '061EB32181A2D9CA42AD16031B476EEBAA62A9A095AD660E2759FBA52B51A61',
254
+ Network: 'VISA',
255
+ TokenData: "tokenData"
256
+ },
257
+ StatementDescriptor: "ruby",
258
+ ReturnURL: MangoPay.configuration.root_url,
259
+ Tag: 'Test PayIn/GooglePay/Direct',
260
+ Billing: {
261
+ Address: {
262
+ AddressLine1: 'AddressLine1',
263
+ AddressLine2: 'AddressLine2',
264
+ City: 'City',
265
+ Region: 'Region',
266
+ PostalCode: 'PostalCode',
267
+ CountryIso: 'FR'
268
+ }
269
+ }
270
+ )
271
+ end
272
+
273
+
213
274
  ###############################################
214
275
  # directdebit/direct
215
276
  ###############################################
216
277
 
217
278
  let(:new_payin_directdebit_direct) do
218
279
  MangoPay::PayIn::DirectDebit::Direct.create(
219
- AuthorId: new_natural_user['Id'],
220
- CreditedUserId: new_wallet['Owners'][0],
221
- CreditedWalletId: new_wallet['Id'],
222
- DebitedFunds: { Currency: 'EUR', Amount: 1000 },
223
- Fees: { Currency: 'EUR', Amount: 0 },
224
- MandateId: new_mandate['Id'],
225
- ReturnURL: MangoPay.configuration.root_url,
226
- Tag: 'Test PayIn/DirectDebit/Direct'
280
+ AuthorId: new_natural_user['Id'],
281
+ CreditedUserId: new_wallet['Owners'][0],
282
+ CreditedWalletId: new_wallet['Id'],
283
+ DebitedFunds: {Currency: 'EUR', Amount: 1000},
284
+ Fees: {Currency: 'EUR', Amount: 0},
285
+ MandateId: new_mandate['Id'],
286
+ ReturnURL: MangoPay.configuration.root_url,
287
+ Tag: 'Test PayIn/DirectDebit/Direct'
227
288
  )
228
289
  end
229
290
 
@@ -233,15 +294,30 @@ shared_context 'payins' do
233
294
 
234
295
  let(:new_payin_card_web) do
235
296
  MangoPay::PayIn::Card::Web.create(
236
- AuthorId: new_natural_user['Id'],
237
- CreditedUserId: new_wallet['Owners'][0],
238
- CreditedWalletId: new_wallet['Id'],
239
- DebitedFunds: { Currency: 'EUR', Amount: 1000 },
240
- Fees: { Currency: 'EUR', Amount: 0 },
241
- CardType: 'CB_VISA_MASTERCARD',
242
- ReturnURL: MangoPay.configuration.root_url,
243
- Culture: 'FR',
244
- Tag: 'Test PayIn/Card/Web'
297
+ AuthorId: new_natural_user['Id'],
298
+ CreditedUserId: new_wallet['Owners'][0],
299
+ CreditedWalletId: new_wallet['Id'],
300
+ DebitedFunds: {Currency: 'EUR', Amount: 1000},
301
+ Fees: {Currency: 'EUR', Amount: 0},
302
+ CardType: 'CB_VISA_MASTERCARD',
303
+ ReturnURL: MangoPay.configuration.root_url,
304
+ Culture: 'FR',
305
+ Tag: 'Test PayIn/Card/Web'
306
+ )
307
+ end
308
+
309
+ let(:new_payin_card_web_payline) do
310
+ MangoPay::PayIn::Card::Web.create(
311
+ AuthorId: new_natural_user['Id'],
312
+ CreditedUserId: new_wallet['Owners'][0],
313
+ CreditedWalletId: new_wallet['Id'],
314
+ DebitedFunds: {Currency: 'EUR', Amount: 1000},
315
+ Fees: {Currency: 'EUR', Amount: 0},
316
+ CardType: 'CB_VISA_MASTERCARD',
317
+ ReturnURL: MangoPay.configuration.root_url,
318
+ Culture: 'FR',
319
+ Tag: 'Test PayIn/Card/Web',
320
+ TemplateURLOptions: {PAYLINEV2: "https://www.maysite.com/payline_template/"}
245
321
  )
246
322
  end
247
323
 
@@ -251,9 +327,9 @@ shared_context 'payins' do
251
327
 
252
328
  let(:new_card_registration) do
253
329
  MangoPay::CardRegistration.create(
254
- UserId: new_natural_user['Id'],
255
- Currency: 'EUR',
256
- Tag: 'Test Card Registration'
330
+ UserId: new_natural_user['Id'],
331
+ Currency: 'EUR',
332
+ Tag: 'Test Card Registration'
257
333
  )
258
334
  end
259
335
 
@@ -263,11 +339,11 @@ shared_context 'payins' do
263
339
 
264
340
  # 2nd step: tokenize by payline (fills-in RegistrationData)
265
341
  data = {
266
- data: cardreg['PreregistrationData'],
267
- accessKeyRef: cardreg['AccessKey'],
268
- cardNumber: 4970100000000154,
269
- cardExpirationDate: 1226,
270
- cardCvx: 123}
342
+ data: cardreg['PreregistrationData'],
343
+ accessKeyRef: cardreg['AccessKey'],
344
+ cardNumber: 4970100000000154,
345
+ cardExpirationDate: 1226,
346
+ cardCvx: 123}
271
347
 
272
348
  res = Net::HTTP.post_form(URI(cardreg['CardRegistrationURL']), data)
273
349
  raise Exception, [res, res.body] unless res.is_a?(Net::HTTPOK) && res.body.start_with?('data=')
@@ -280,18 +356,19 @@ shared_context 'payins' do
280
356
  end
281
357
 
282
358
  let(:new_payin_card_direct) { create_new_payin_card_direct(new_wallet) }
359
+
283
360
  def create_new_payin_card_direct(to_wallet, amnt = 1000)
284
361
  cardreg = new_card_registration_completed
285
362
  MangoPay::PayIn::Card::Direct.create(
286
- AuthorId: new_natural_user['Id'],
287
- CreditedUserId: to_wallet['Owners'][0],
288
- CreditedWalletId: to_wallet['Id'],
289
- DebitedFunds: { Currency: 'EUR', Amount: amnt },
290
- Fees: { Currency: 'EUR', Amount: 0 },
291
- CardType: 'CB_VISA_MASTERCARD',
292
- CardId: cardreg['CardId'],
293
- SecureModeReturnURL: 'http://test.com',
294
- Tag: 'Test PayIn/Card/Direct'
363
+ AuthorId: new_natural_user['Id'],
364
+ CreditedUserId: to_wallet['Owners'][0],
365
+ CreditedWalletId: to_wallet['Id'],
366
+ DebitedFunds: {Currency: 'EUR', Amount: amnt},
367
+ Fees: {Currency: 'EUR', Amount: 0},
368
+ CardType: 'CB_VISA_MASTERCARD',
369
+ CardId: cardreg['CardId'],
370
+ SecureModeReturnURL: 'http://test.com',
371
+ Tag: 'Test PayIn/Card/Direct'
295
372
  )
296
373
  end
297
374
 
@@ -300,28 +377,30 @@ shared_context 'payins' do
300
377
  ###############################################
301
378
 
302
379
  let(:new_card_preauthorization) { create_new_card_preauthorization(new_card_registration_completed) }
380
+
303
381
  def create_new_card_preauthorization(cardreg, amnt = 1000)
304
382
  MangoPay::PreAuthorization.create(
305
- AuthorId: new_natural_user['Id'],
306
- DebitedFunds: { Currency: 'EUR', Amount: amnt },
307
- CardId: cardreg['CardId'],
308
- SecureMode: 'DEFAULT',
309
- SecureModeReturnURL: 'http://test.com',
310
- Tag: 'Test Card PreAuthorization'
383
+ AuthorId: new_natural_user['Id'],
384
+ DebitedFunds: {Currency: 'EUR', Amount: amnt},
385
+ CardId: cardreg['CardId'],
386
+ SecureMode: 'DEFAULT',
387
+ SecureModeReturnURL: 'http://test.com',
388
+ Tag: 'Test Card PreAuthorization'
311
389
  )
312
390
  end
313
391
 
314
392
  let(:new_payin_preauthorized_direct) { create_new_payin_preauthorized_direct(new_wallet) }
393
+
315
394
  def create_new_payin_preauthorized_direct(to_wallet, amnt = 1000)
316
395
  preauth = new_card_preauthorization
317
396
  MangoPay::PayIn::PreAuthorized::Direct.create(
318
- AuthorId: new_natural_user['Id'],
319
- CreditedUserId: to_wallet['Owners'][0],
320
- CreditedWalletId: to_wallet['Id'],
321
- DebitedFunds: { Currency: 'EUR', Amount: amnt },
322
- Fees: { Currency: 'EUR', Amount: 0 },
323
- PreauthorizationId: preauth['Id'],
324
- Tag: 'Test PayIn/PreAuthorized/Direct'
397
+ AuthorId: new_natural_user['Id'],
398
+ CreditedUserId: to_wallet['Owners'][0],
399
+ CreditedWalletId: to_wallet['Id'],
400
+ DebitedFunds: {Currency: 'EUR', Amount: amnt},
401
+ Fees: {Currency: 'EUR', Amount: 0},
402
+ PreauthorizationId: preauth['Id'],
403
+ Tag: 'Test PayIn/PreAuthorized/Direct'
325
404
  )
326
405
  end
327
406
 
@@ -330,14 +409,15 @@ shared_context 'payins' do
330
409
  ###############################################
331
410
 
332
411
  let(:new_payin_bankwire_direct) { create_new_payin_bankwire_direct(new_wallet) }
412
+
333
413
  def create_new_payin_bankwire_direct(to_wallet, amnt = 1000)
334
414
  MangoPay::PayIn::BankWire::Direct.create(
335
- AuthorId: new_natural_user['Id'],
336
- CreditedUserId: to_wallet['Owners'][0],
337
- CreditedWalletId: to_wallet['Id'],
338
- DeclaredDebitedFunds: { Currency: 'EUR', Amount: amnt },
339
- DeclaredFees: { Currency: 'EUR', Amount: 0 },
340
- Tag: 'Test PayIn/BankWire/Direct'
415
+ AuthorId: new_natural_user['Id'],
416
+ CreditedUserId: to_wallet['Owners'][0],
417
+ CreditedWalletId: to_wallet['Id'],
418
+ DeclaredDebitedFunds: {Currency: 'EUR', Amount: amnt},
419
+ DeclaredFees: {Currency: 'EUR', Amount: 0},
420
+ Tag: 'Test PayIn/BankWire/Direct'
341
421
  )
342
422
  end
343
423
  end
@@ -348,15 +428,16 @@ shared_context 'payouts' do
348
428
  include_context 'bank_accounts'
349
429
 
350
430
  let(:new_payout_bankwire) { create_new_payout_bankwire(new_payin_card_direct) }
431
+
351
432
  def create_new_payout_bankwire(payin, amnt = 500)
352
433
  MangoPay::PayOut::BankWire.create(
353
- AuthorId: payin['CreditedUserId'],
354
- DebitedWalletId: payin['CreditedWalletId'],
355
- DebitedFunds: { Currency: 'EUR', Amount: amnt },
356
- Fees: { Currency: 'EUR', Amount: 0 },
357
- BankAccountId: new_bank_account['Id'],
358
- Communication: 'This is a test',
359
- Tag: 'Test PayOut/Bank/Wire'
434
+ AuthorId: payin['CreditedUserId'],
435
+ DebitedWalletId: payin['CreditedWalletId'],
436
+ DebitedFunds: {Currency: 'EUR', Amount: amnt},
437
+ Fees: {Currency: 'EUR', Amount: 0},
438
+ BankAccountId: new_bank_account['Id'],
439
+ Communication: 'This is a test',
440
+ Tag: 'Test PayOut/Bank/Wire'
360
441
  )
361
442
  end
362
443
  end
@@ -374,6 +455,7 @@ shared_context 'transfers' do
374
455
  create_new_payin_card_direct(wlt1, 1000) # feed wlt1 with money
375
456
  create_new_transfer(wlt1, wlt2, 500) # transfer wlt1 => wlt2
376
457
  end
458
+
377
459
  def create_new_transfer(from_wallet, to_wallet, amnt = 500)
378
460
  MangoPay::Transfer.create(
379
461
  AuthorId: from_wallet['Owners'][0],
@@ -394,9 +476,9 @@ shared_context 'hooks' do
394
476
  hooks = MangoPay::Hook.fetch('page' => 1, 'per_page' => 1)
395
477
  if hooks.empty?
396
478
  MangoPay::Hook.create(
397
- EventType: 'PAYIN_NORMAL_CREATED',
398
- Url: 'http://test.com',
399
- Tag: 'Test hook'
479
+ EventType: 'PAYIN_NORMAL_CREATED',
480
+ Url: 'http://test.com',
481
+ Tag: 'Test hook'
400
482
  )
401
483
  else
402
484
  hooks[0]
@@ -8,9 +8,10 @@ describe MangoPay::UboDeclaration do
8
8
 
9
9
  ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'])
10
10
 
11
- ubo_declaration = MangoPay::UboDeclaration.fetch(legal_user['Id'], ubo_declaration['Id'])
11
+ ubo_declaration_byId = MangoPay::UboDeclaration.fetch(legal_user['Id'], ubo_declaration['Id'])
12
12
 
13
13
  expect(ubo_declaration).not_to be_nil
14
+ expect(ubo_declaration_byId).not_to be_nil
14
15
  end
15
16
 
16
17
  describe 'UPDATE' do
@@ -13,6 +13,10 @@ describe MangoPay::User do
13
13
  it 'creates a new legal user' do
14
14
  expect(new_legal_user["LegalRepresentativeFirstName"]).to eq('John')
15
15
  end
16
+
17
+ it 'creates a new legal user' do
18
+ expect(new_legal_user["CompanyNumber"]).to eq('LU123456789')
19
+ end
16
20
  end
17
21
 
18
22
  describe 'UPDATE' do
@@ -147,8 +151,17 @@ describe MangoPay::User do
147
151
  end
148
152
 
149
153
  describe 'FETCH EMONEY' do
150
- it 'fetches emoney for the user' do
151
- emoney = MangoPay::User.emoney(new_natural_user['Id'])
154
+ it 'fetches emoney for the user for year 2019' do
155
+ emoney = MangoPay::User.emoney(new_natural_user['Id'], 2019)
156
+ expect(emoney['UserId']).to eq new_natural_user['Id']
157
+ expect(emoney['CreditedEMoney']['Amount']).to eq 0
158
+ expect(emoney['CreditedEMoney']['Currency']).to eq 'EUR'
159
+ expect(emoney['DebitedEMoney']['Amount']).to eq 0
160
+ expect(emoney['DebitedEMoney']['Currency']).to eq 'EUR'
161
+ end
162
+
163
+ it 'fetches emoney for the user for date 08/2019' do
164
+ emoney = MangoPay::User.emoney(new_natural_user['Id'], 2019, 8)
152
165
  expect(emoney['UserId']).to eq new_natural_user['Id']
153
166
  expect(emoney['CreditedEMoney']['Amount']).to eq 0
154
167
  expect(emoney['CreditedEMoney']['Currency']).to eq 'EUR'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mangopay
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.32
4
+ version: 3.0.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geoffroy Lorieux
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-06-19 00:00:00.000000000 Z
12
+ date: 2020-10-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -66,6 +66,7 @@ files:
66
66
  - ".gitignore"
67
67
  - ".rspec"
68
68
  - ".travis.yml"
69
+ - CHANGELOG.md
69
70
  - Gemfile
70
71
  - LICENSE
71
72
  - README.md
@@ -122,6 +123,7 @@ files:
122
123
  - spec/mangopay/kyc_document_spec.rb
123
124
  - spec/mangopay/log_requests_filter_spec.rb
124
125
  - spec/mangopay/mandate_spec.rb
126
+ - spec/mangopay/payin_applepay_direct_spec.rb
125
127
  - spec/mangopay/payin_bankwire_direct_spec.rb
126
128
  - spec/mangopay/payin_bankwire_external_instruction_spec.rb
127
129
  - spec/mangopay/payin_card_direct_spec.rb
@@ -163,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
165
  - !ruby/object:Gem::Version
164
166
  version: '0'
165
167
  requirements: []
166
- rubygems_version: 3.0.4
168
+ rubygems_version: 3.0.8
167
169
  signing_key:
168
170
  specification_version: 4
169
171
  summary: Ruby bindings for the version 2 of the MANGOPAY API
@@ -185,6 +187,7 @@ test_files:
185
187
  - spec/mangopay/kyc_document_spec.rb
186
188
  - spec/mangopay/log_requests_filter_spec.rb
187
189
  - spec/mangopay/mandate_spec.rb
190
+ - spec/mangopay/payin_applepay_direct_spec.rb
188
191
  - spec/mangopay/payin_bankwire_direct_spec.rb
189
192
  - spec/mangopay/payin_bankwire_external_instruction_spec.rb
190
193
  - spec/mangopay/payin_card_direct_spec.rb