mangopay 3.0.31 → 3.0.32

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: 73c15899898b7b234b4acf3ce46155a7a206bd629b5ef98d682e6125d3c5cd52
4
- data.tar.gz: f2e564568a12d93c36eb1fc42b70c21b6cf5753c18810b5cef5d28e8f1e1ae93
3
+ metadata.gz: 12dc8e2f6ecc5798628cbc487075f3d9bf7100d0d5c17e1ec2bdb6c6ab4d0592
4
+ data.tar.gz: 87aff78311a7331e52898938ce4824b5ce72f0b6338898a5b5f163ea012201bf
5
5
  SHA512:
6
- metadata.gz: df581e3dd8afa4312a20388604c2b1f907908898e92d26db4cd3bab264e5ac11ea2a2448cccac73b55054fcdb68bbed07b58bff7e5ab99996dd0a378fce3d819
7
- data.tar.gz: 48e91bdd987927f105cd7fea1ef4863211b78e1f2728106cd0ab2618049db67988cd6d445e542ece17915c829a4c29f88995e05d480434e712fb40cb9ceecbea
6
+ metadata.gz: a5c90e91c9dee7eb80e250d0f46d04b4af4995ae5cbe25e743eb5870e09b0dd6fa5f4055e5faa4770659a8b5296ba2421dc1d9883aaf4e31d841792ee3260fc8
7
+ data.tar.gz: e93958461b0ee968f492d79ae4b7b2402364d9bf7657c07162dac3558a409ce44f6d1706c29b8bed3b623535680e92452cde44a801f3aad844291532eba5a147
data/README.md CHANGED
@@ -96,8 +96,8 @@ Along with each request, the rate limiting headers are automatically updated in
96
96
  MangoPay.ratelimit
97
97
 
98
98
  {
99
- :limit=>["74", "74", "75", "908"],
100
- :remaining=>["2226", "4426", "8725", "104692"],
99
+ :limit=>["74", "74", "75", "908"],
100
+ :remaining=>["2226", "4426", "8725", "104692"],
101
101
  :reset=>["1495615620", "1495616520", "1495618320", "1495701060"]
102
102
  }
103
103
  ```
@@ -17,7 +17,7 @@ module Mangopay
17
17
  client = client_id_valid?
18
18
  remove_file 'config/initializers/mangopay.rb'
19
19
  @client_id = client_id
20
- @client_passphrase = client['Passphrase']
20
+ @client_apiKey = client['APIKey']
21
21
  template 'mangopay.rb.erb', 'config/initializers/mangopay.rb'
22
22
  rescue => e
23
23
  puts e.message
@@ -1,5 +1,5 @@
1
1
  MangoPay.configure do |c|
2
2
  c.preproduction = <%= options[:preproduction] %>
3
3
  c.client_id = '<%= @client_id %>'
4
- c.client_passphrase = '<%= @client_passphrase %>'
4
+ c.client_apiKey = '<%= @client_apiKey %>'
5
5
  end
@@ -41,13 +41,14 @@ module MangoPay
41
41
  autoload :BankingAliases, 'mangopay/bankingaliases'
42
42
  autoload :BankingAliasesIBAN, 'mangopay/bankingaliases_iban'
43
43
  autoload :UboDeclaration, 'mangopay/ubo_declaration'
44
+ autoload :Ubo, 'mangopay/ubo'
44
45
 
45
46
  # temporary
46
47
  autoload :Temp, 'mangopay/temp'
47
48
 
48
49
  class Configuration
49
50
  attr_accessor :preproduction, :root_url,
50
- :client_id, :client_passphrase,
51
+ :client_id, :client_apiKey,
51
52
  :temp_dir, :log_file, :http_timeout
52
53
 
53
54
  def preproduction
@@ -19,7 +19,7 @@ module MangoPay
19
19
  if token.nil? || token['timestamp'].nil? || token['timestamp'] <= Time.now || token['environment_key'] != env_key
20
20
  token = MangoPay.request(:post, "/#{MangoPay.version_code}/oauth/token", {}, {}, {}, Proc.new do |req|
21
21
  cfg = MangoPay.configuration
22
- req.basic_auth cfg.client_id, cfg.client_passphrase
22
+ req.basic_auth cfg.client_id, cfg.client_apiKey
23
23
  req.body = 'grant_type=client_credentials'
24
24
  req.add_field('Content-Type', 'application/x-www-form-urlencoded')
25
25
  end)
@@ -32,7 +32,7 @@ module MangoPay
32
32
 
33
33
  def get_environment_key_for_token
34
34
  cfg = MangoPay.configuration
35
- key = "#{cfg.root_url}|#{cfg.client_id}|#{cfg.client_passphrase}"
35
+ key = "#{cfg.root_url}|#{cfg.client_id}|#{cfg.client_apiKey}"
36
36
  key = Digest::MD5.hexdigest(key)
37
37
  key
38
38
  end
@@ -13,14 +13,6 @@ module MangoPay
13
13
  end
14
14
 
15
15
  class << self
16
-
17
- # Create a UBO declaration.
18
- # @param +user_id+ ID of the legal user owning the declaration
19
- # @param +ubo_declaration+ Object containing UBO declaration data
20
- # @return Newly-created UBO declaration entity data
21
- def create_ubo_declaration(user_id, ubo_declaration)
22
- MangoPay.request(:post, "#{url(user_id)}/ubodeclarations", ubo_declaration)
23
- end
24
16
  end
25
17
  end
26
18
  end
@@ -0,0 +1,26 @@
1
+ module MangoPay
2
+ # Provides API methods for the UBO entity.
3
+ class Ubo < Resource
4
+ class << self
5
+ def url(user_id, ubo_declaration_id, id = nil)
6
+ if id
7
+ "#{MangoPay.api_path}/users/#{user_id}/kyc/ubodeclarations/#{ubo_declaration_id}/ubos/#{id}"
8
+ else
9
+ "#{MangoPay.api_path}/users/#{user_id}/kyc/ubodeclarations/#{ubo_declaration_id}/ubos"
10
+ end
11
+ end
12
+
13
+ def create(user_id, ubo_declaration_id, params)
14
+ MangoPay.request(:post, url(user_id, ubo_declaration_id), params)
15
+ end
16
+
17
+ def fetch(user_id, ubo_declaration_id, ubo_id)
18
+ MangoPay.request(:get, url(user_id, ubo_declaration_id, ubo_id))
19
+ end
20
+
21
+ def update(user_id, ubo_declaration_id, ubo_id, params)
22
+ MangoPay.request(:put, url(user_id, ubo_declaration_id, ubo_id), params)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,19 +1,30 @@
1
1
  module MangoPay
2
-
3
2
  # Provides API methods for the UBO declaration entity.
4
3
  class UboDeclaration < Resource
5
- include HTTPCalls::Fetch
6
-
7
4
  class << self
8
-
9
- def update(id = nil, params = {})
10
- declared_ubo_ids = []
11
- params['DeclaredUBOs'].each do |ubo|
12
- declared_ubo_ids << (ubo.key?('UserId') ? ubo['UserId'] : ubo)
5
+ def url(user_id, id = nil)
6
+ if id
7
+ "#{MangoPay.api_path}/users/#{user_id}/kyc/ubodeclarations/#{id}"
8
+ else
9
+ "#{MangoPay.api_path}/users/#{user_id}/kyc/ubodeclarations"
13
10
  end
14
- params['DeclaredUBOs'] = declared_ubo_ids
15
- MangoPay.request(:put, url(id), params)
11
+ end
12
+
13
+ def create(user_id)
14
+ MangoPay.request(:post, url(user_id))
15
+ end
16
+
17
+ def fetch(user_id, id)
18
+ MangoPay.request(:get, url(user_id, id))
19
+ end
20
+
21
+ def update(user_id, id, params = {})
22
+ request_params = {
23
+ Status: params['Status'],
24
+ Ubos: params['Ubos']
25
+ }
26
+ MangoPay.request(:put, url(user_id, id), request_params)
16
27
  end
17
28
  end
18
29
  end
19
- end
30
+ end
@@ -1,3 +1,3 @@
1
1
  module MangoPay
2
- VERSION = '3.0.31'
2
+ VERSION = '3.0.32'
3
3
  end
@@ -7,6 +7,13 @@ describe MangoPay::Client do
7
7
  end
8
8
  end
9
9
 
10
+ describe 'FETCH' do
11
+ it "fetches the client headquarter's phone number" do
12
+ client = MangoPay::Client.fetch
13
+ expect(client['HeadquartersPhoneNumber']).to_not be_nil
14
+ end
15
+ end
16
+
10
17
  describe 'UPDATE' do
11
18
  it 'updates the current client details' do
12
19
  clnt = MangoPay::Client.fetch
@@ -14,22 +21,25 @@ describe MangoPay::Client do
14
21
  after = before == '#aaaaaa' ? '#bbbbbb' : '#aaaaaa' # change the color
15
22
  clnt['PrimaryThemeColour'] = after
16
23
  clnt['HeadquartersAddress'] = {
17
- AddressLine1: 'Rue Dandelion, n. 17',
18
- City: 'Lyon',
19
- Country: 'FR',
20
- PostalCode: '150770'
24
+ AddressLine1: 'Rue Dandelion, n. 17',
25
+ City: 'Lyon',
26
+ Country: 'FR',
27
+ PostalCode: '150770'
21
28
  }
29
+ phoneNumber = rand(99999999).to_s
30
+ clnt['HeadquartersPhoneNumber'] = phoneNumber
22
31
 
23
32
  updated = MangoPay::Client.update(clnt)
24
33
  expect(updated['ClientId']).to eq(MangoPay.configuration.client_id)
25
34
  expect(updated['PrimaryThemeColour']).to eq(after)
35
+ expect(updated['HeadquartersPhoneNumber']).to eq(phoneNumber)
26
36
  end
27
37
  end
28
38
 
29
39
  describe 'UPLOAD LOGO' do
30
40
  it 'accepts Base64 encoded file content' do
31
41
  fnm = __FILE__.sub('.rb', '.png')
32
- bts = File.open(fnm, 'rb') { |f| f.read }
42
+ bts = File.open(fnm, 'rb') {|f| f.read}
33
43
  b64 = Base64.encode64(bts)
34
44
  ret = MangoPay::Client.upload_logo(b64)
35
45
  expect(ret).to be_nil
@@ -43,7 +53,7 @@ describe MangoPay::Client do
43
53
 
44
54
  it 'fails when input string is not base64-encoded' do
45
55
  file = 'any file content...'
46
- expect { MangoPay::Client.upload_logo(file) }.to raise_error { |err|
56
+ expect {MangoPay::Client.upload_logo(file)}.to raise_error {|err|
47
57
  expect(err).to be_a MangoPay::ResponseError
48
58
  expect(err.code).to eq '400'
49
59
  expect(err.type).to eq 'param_error'
@@ -4,7 +4,7 @@ describe MangoPay::Configuration do
4
4
  expect {
5
5
  c = MangoPay.configuration
6
6
  c.client_id = 'test_asd'
7
- c.client_passphrase = '00000'
7
+ c.client_apiKey = '00000'
8
8
  MangoPay::User.fetch()
9
9
  }.to raise_error(MangoPay::ResponseError)
10
10
  end
@@ -11,21 +11,23 @@ describe MangoPay::Event do
11
11
  payin = new_payin_card_direct
12
12
  create_new_payout_bankwire(payin)
13
13
 
14
- # get all # TODO: Uncomment this test once Events are fixed on the server
15
- # events = MangoPay::Event.fetch()
16
- # expect(events).to be_kind_of(Array)
17
- # expect(events.count).to be >= 2
14
+ # get all #
15
+ events = MangoPay::Event.fetch
16
+ expect(events).to be_kind_of(Array)
17
+ expect(events.count).to be >= 2
18
18
 
19
- # only one per page # TODO: Uncomment this test once Events are fixed on the server
20
- # events = MangoPay::Event.fetch({'per_page' => 1})
21
- # expect(events).to be_kind_of(Array)
22
- # expect(events.count).to eq 1
19
+ # only one per page #
20
+ events = MangoPay::Event.fetch({'per_page' => 1})
21
+ expect(events).to be_kind_of(Array)
22
+ expect(events.count).to eq 1
23
23
 
24
24
  # filter by date
25
- events = MangoPay::Event.fetch({'AfterDate' => payin['CreationDate'], 'BeforeDate' => payin['CreationDate']})
25
+ eventDate = events[0]["Date"]
26
+ resourceId=events[0]["ResourceId"]
27
+ events = MangoPay::Event.fetch({'AfterDate' => eventDate - 1, 'BeforeDate' => eventDate + 1})
26
28
  expect(events).to be_kind_of(Array)
27
29
  expect(events.count).to be >= 1
28
- expect(events.count { |e| e['ResourceId'] == payin['Id'] }).to be >= 1
30
+ expect(events.count {|e| e['ResourceId'] == resourceId}).to be >= 1
29
31
  end
30
32
  end
31
33
  end
@@ -1,7 +1,8 @@
1
1
  describe MangoPay::PayIn::BankWire::ExternalInstruction, type: :feature do
2
2
  include_context 'wallets'
3
3
  include_context 'payins'
4
-
4
+
5
+
5
6
  def check_type_and_status(payin)
6
7
  expect(payin['Type']).to eq('PAYIN')
7
8
  expect(payin['Nature']).to eq('REGULAR')
@@ -11,18 +12,20 @@ describe MangoPay::PayIn::BankWire::ExternalInstruction, type: :feature do
11
12
 
12
13
  describe 'FETCH' do
13
14
  it 'fetches a payin' do
15
+ backupConfig = MangoPay.configuration.clone
14
16
  MangoPay.configure do |c|
15
17
  c.preproduction = true
16
18
  c.client_id = 'sdk-unit-tests'
17
- c.root_url = 'https://api-test.mangopay.com'
18
- c.client_passphrase = '9RMGpwVUwFLK0SurxObJ2yaadDcO0zeKFKxWmthjB93SQjFzy0'
19
+ c.root_url = 'https://api.sandbox.mangopay.com'
20
+ c.client_apiKey = 'cqFfFrWfCcb7UadHNxx2C9Lo6Djw8ZduLi7J9USTmu8bhxxpju'
19
21
  c.http_timeout = 10000
20
22
  end
21
23
 
22
- id = "2826947"
24
+ id = "66142029"
23
25
  payIn = MangoPay::PayIn.fetch(id)
24
26
  expect(payIn['Id']).to eq(id)
25
27
  check_type_and_status(payIn)
28
+ MangoPay.configuration = backupConfig
26
29
  end
27
30
  end
28
31
 
@@ -13,7 +13,7 @@ describe MangoPay::PayIn::PayPal::Web, type: :feature do
13
13
  expect(payin['ResultMessage']).to be_nil
14
14
  expect(payin['ExecutionDate']).to be_nil
15
15
  end
16
-
16
+
17
17
  describe 'CREATE' do
18
18
  it 'creates a paypal web payin' do
19
19
  created = new_payin_paypal_web
@@ -22,6 +22,18 @@ describe MangoPay::PayIn::PayPal::Web, type: :feature do
22
22
  end
23
23
  end
24
24
 
25
+ describe "FETCH" do
26
+ it 'FETCHES a payIn with PayPal account email' do
27
+ payin_id = "54088959"
28
+ buyer_account_email = "paypal-buyer-user@mangopay.com"
29
+ payin = MangoPay::PayIn.fetch(id = payin_id)
30
+
31
+ expect(payin).not_to be_nil
32
+ expect(payin["PaypalBuyerAccountEmail"]).not_to be_nil
33
+ expect(payin["PaypalBuyerAccountEmail"]).to eq(buyer_account_email)
34
+ end
35
+ end
36
+
25
37
  describe 'FETCH' do
26
38
  it 'fetches a payin' do
27
39
  created = new_payin_paypal_web
@@ -19,16 +19,16 @@ describe MangoPay::Refund do
19
19
  end
20
20
  end
21
21
 
22
- describe 'FETCH for Repudiation' do
23
- it "fetches a repudiation's refunds" do
24
- disputes = MangoPay::Dispute.fetch
25
- dispute = disputes.find do |dispute|
26
- dispute['DisputeType'] == 'NOT_CONTESTABLE'\
27
- && !dispute['InitialTransactionId'].nil?
28
- end
29
- repudiation_id = MangoPay::Dispute.transactions(dispute['Id'])[0]['Id']
30
- refunds = MangoPay::Refund.of_repudiation(repudiation_id)
31
- expect(refunds).to be_an(Array)
32
- end
33
- end
22
+ #describe 'FETCH for Repudiation' do
23
+ # it "fetches a repudiation's refunds" do
24
+ # disputes = MangoPay::Dispute.fetch
25
+ # dispute = disputes.find do |dispute|
26
+ # dispute['DisputeType'] == 'NOT_CONTESTABLE'\
27
+ # && !dispute['InitialTransactionId'].nil?
28
+ # end
29
+ # repudiation_id = MangoPay::Dispute.transactions(dispute['Id'])[0]['Id']
30
+ # refunds = MangoPay::Refund.of_repudiation(repudiation_id)
31
+ # expect(refunds).to be_an(Array)
32
+ # end
33
+ # end
34
34
  end
@@ -1,15 +1,15 @@
1
1
  ###############################################
2
2
  shared_context 'users' do
3
- ###############################################
3
+ ###############################################
4
4
 
5
5
  let(:new_natural_user) { create_new_natural_user }
6
6
  def define_new_natural_user
7
7
  {
8
- Tag: 'Test natural user',
9
- Email: 'my@email.com',
10
- FirstName: 'John',
11
- LastName: 'Doe',
12
- Address: {
8
+ Tag: 'Test natural user',
9
+ Email: 'my@email.com',
10
+ FirstName: 'John',
11
+ LastName: 'Doe',
12
+ Address: {
13
13
  AddressLine1: 'Le Palais Royal',
14
14
  AddressLine2: '8 Rue de Montpensier',
15
15
  City: 'Paris',
@@ -17,34 +17,35 @@ shared_context 'users' do
17
17
  PostalCode: '75001',
18
18
  Country: 'FR'
19
19
  },
20
- Birthday: 1300186358,
21
- Birthplace: 'Paris',
22
- Nationality: 'FR',
23
- CountryOfResidence: 'FR',
24
- Occupation: 'Worker',
25
- IncomeRange: 1
20
+ Birthday: 1_300_186_358,
21
+ Birthplace: 'Paris',
22
+ Nationality: 'FR',
23
+ CountryOfResidence: 'FR',
24
+ Occupation: 'Worker',
25
+ IncomeRange: 1
26
26
  }
27
27
  end
28
+
28
29
  def create_new_natural_user
29
30
  MangoPay::NaturalUser.create(define_new_natural_user)
30
31
  end
31
32
 
32
- let(:new_legal_user) {
33
- MangoPay::LegalUser.create({
34
- Name: 'Super',
35
- Email: 'super@email.com',
36
- LegalPersonType: 'BUSINESS',
37
- HeadquartersAddress: {
38
- AddressLine1: '6 Parvis Notre-Dame',
39
- AddressLine2: 'Pl. Jean-Paul II',
40
- City: 'Paris',
41
- Region: '',
42
- PostalCode: '75004',
43
- Country: 'FR'
33
+ let(:new_legal_user) do
34
+ MangoPay::LegalUser.create(
35
+ Name: 'Super',
36
+ Email: 'super@email.com',
37
+ LegalPersonType: 'BUSINESS',
38
+ HeadquartersAddress: {
39
+ AddressLine1: '6 Parvis Notre-Dame',
40
+ AddressLine2: 'Pl. Jean-Paul II',
41
+ City: 'Paris',
42
+ Region: 'FR',
43
+ PostalCode: '75004',
44
+ Country: 'FR'
44
45
  },
45
- LegalRepresentativeFirstName: 'John',
46
- LegalRepresentativeLastName: 'Doe',
47
- LegalRepresentativeAdress: {
46
+ LegalRepresentativeFirstName: 'John',
47
+ LegalRepresentativeLastName: 'Doe',
48
+ LegalRepresentativeAdress: {
48
49
  AddressLine1: '38 Rue de Montpensier',
49
50
  AddressLine2: '',
50
51
  City: 'Paris',
@@ -52,31 +53,31 @@ shared_context 'users' do
52
53
  PostalCode: '75001',
53
54
  Country: 'FR'
54
55
  },
55
- LegalRepresentativeEmail: 'john@doe.com',
56
- LegalRepresentativeBirthday: 1300186358,
57
- LegalRepresentativeNationality: 'FR',
58
- LegalRepresentativeCountryOfResidence: 'FR',
59
- Statute: '',
60
- ProofOfRegistration: '',
61
- ShareholderDeclaration: ''
62
- })
63
- }
56
+ LegalRepresentativeEmail: 'john@doe.com',
57
+ LegalRepresentativeBirthday: 1_300_186_358,
58
+ LegalRepresentativeNationality: 'FR',
59
+ LegalRepresentativeCountryOfResidence: 'FR',
60
+ Statute: '',
61
+ ProofOfRegistration: '',
62
+ ShareholderDeclaration: ''
63
+ )
64
+ end
64
65
  end
65
66
 
66
67
  ###############################################
67
68
  shared_context 'wallets' do
68
- ###############################################
69
+ ###############################################
69
70
  include_context 'users'
70
71
 
71
72
  let(:new_wallet) { create_new_wallet(new_natural_user) }
72
73
  let(:new_wallet_legal) { create_new_wallet(new_legal_user) }
73
74
  def create_new_wallet(user)
74
- MangoPay::Wallet.create({
75
+ MangoPay::Wallet.create(
75
76
  Owners: [user['Id']],
76
77
  Description: 'A test wallet',
77
78
  Currency: 'EUR',
78
79
  Tag: 'Test wallet'
79
- })
80
+ )
80
81
  end
81
82
 
82
83
  def wallets_check_amounts(wlt1, amnt1, wlt2 = nil, amnt2 = nil)
@@ -85,69 +86,92 @@ shared_context 'wallets' do
85
86
  end
86
87
 
87
88
  def wallets_reload_and_check_amounts(wlt1, amnt1, wlt2 = nil, amnt2 = nil)
88
- wlt1 = MangoPay::Wallet::fetch(wlt1['Id'])
89
- wlt2 = MangoPay::Wallet::fetch(wlt2['Id']) if wlt2
89
+ wlt1 = MangoPay::Wallet.fetch(wlt1['Id'])
90
+ wlt2 = MangoPay::Wallet.fetch(wlt2['Id']) if wlt2
90
91
  wallets_check_amounts(wlt1, amnt1, wlt2, amnt2)
91
92
  end
92
93
  end
93
94
 
95
+ shared_context 'ubo' do
96
+ def new_ubo(user, ubo_declaration)
97
+ ubo = {
98
+ FirstName: 'John',
99
+ LastName: 'Doe',
100
+ Address: {
101
+ AddressLine1: '6 Parvis Notre-Dame',
102
+ AddressLine2: 'Pl. Jean-Paul II',
103
+ City: 'Paris',
104
+ Region: '',
105
+ PostalCode: '75004',
106
+ Country: 'FR'
107
+ },
108
+ Nationality: 'FR',
109
+ Birthday: 1_300_186_358,
110
+ Birthplace: {
111
+ City: 'Paris',
112
+ Country: 'FR'
113
+ }
114
+ }
115
+ MangoPay::Ubo.create(user['Id'], ubo_declaration['Id'], ubo)
116
+ end
117
+ end
118
+
94
119
  ###############################################
95
120
  shared_context 'bank_accounts' do
96
- ###############################################
121
+ ###############################################
97
122
  include_context 'users'
98
123
 
99
- let(:new_bank_account) {
100
- MangoPay::BankAccount.create(new_natural_user['Id'], {
101
- Type: 'IBAN',
102
- OwnerName: 'John',
103
- OwnerAddress: {
104
- AddressLine1: 'Le Palais Royal',
105
- AddressLine2: '8 Rue de Montpensier',
106
- City: 'Paris',
107
- Region: '',
108
- PostalCode: '75001',
109
- Country: 'FR'
110
- },
111
- IBAN: 'FR7618829754160173622224154',
112
- BIC: 'CMBRFR2BCME',
113
- Tag: 'Test bank account'
114
- })
115
- }
124
+ let(:new_bank_account) do
125
+ MangoPay::BankAccount.create(new_natural_user['Id'],
126
+ Type: 'IBAN',
127
+ OwnerName: 'John',
128
+ OwnerAddress: {
129
+ AddressLine1: 'Le Palais Royal',
130
+ AddressLine2: '8 Rue de Montpensier',
131
+ City: 'Paris',
132
+ Region: '',
133
+ PostalCode: '75001',
134
+ Country: 'FR'
135
+ },
136
+ IBAN: 'FR7618829754160173622224154',
137
+ BIC: 'CMBRFR2BCME',
138
+ Tag: 'Test bank account')
139
+ end
116
140
  end
117
141
 
118
142
  ###############################################
119
143
  shared_context 'mandates' do
120
- ###############################################
144
+ ###############################################
121
145
  include_context 'bank_accounts'
122
146
 
123
- let(:new_mandate) { create_new_mandate() }
124
- def create_new_mandate()
125
- MangoPay::Mandate.create({
147
+ let(:new_mandate) {create_new_mandate}
148
+
149
+ def create_new_mandate
150
+ MangoPay::Mandate.create(
126
151
  BankAccountId: new_bank_account['Id'],
127
152
  Culture: 'FR',
128
153
  ReturnURL: MangoPay.configuration.root_url,
129
154
  Tag: 'Test mandate'
130
- })
155
+ )
131
156
  end
132
157
  end
133
158
 
134
159
  ###############################################
135
160
  shared_context 'kyc_documents' do
136
- ###############################################
161
+ ###############################################
137
162
  include_context 'users'
138
163
 
139
164
  let(:new_document) { create_new_document(new_natural_user) }
140
165
  def create_new_document(user)
141
- MangoPay::KycDocument.create(user['Id'], {
142
- Type: 'IDENTITY_PROOF',
143
- Tag: 'Test document'
144
- })
166
+ MangoPay::KycDocument.create(user['Id'],
167
+ Type: 'IDENTITY_PROOF',
168
+ Tag: 'Test document')
145
169
  end
146
170
  end
147
171
 
148
172
  ###############################################
149
173
  shared_context 'payins' do
150
- ###############################################
174
+ ###############################################
151
175
  include_context 'users'
152
176
  include_context 'wallets'
153
177
  include_context 'mandates'
@@ -156,8 +180,8 @@ shared_context 'payins' do
156
180
  # directdebit/web
157
181
  ###############################################
158
182
 
159
- let(:new_payin_directdebit_web) {
160
- MangoPay::PayIn::DirectDebit::Web.create({
183
+ let(:new_payin_directdebit_web) do
184
+ MangoPay::PayIn::DirectDebit::Web.create(
161
185
  AuthorId: new_natural_user['Id'],
162
186
  CreditedUserId: new_wallet['Owners'][0],
163
187
  CreditedWalletId: new_wallet['Id'],
@@ -167,15 +191,15 @@ shared_context 'payins' do
167
191
  ReturnURL: MangoPay.configuration.root_url,
168
192
  Culture: 'FR',
169
193
  Tag: 'Test PayIn/DirectDebit/Web'
170
- })
171
- }
194
+ )
195
+ end
172
196
 
173
197
  ###############################################
174
198
  # paypal/web
175
199
  ###############################################
176
200
 
177
- let(:new_payin_paypal_web) {
178
- MangoPay::PayIn::PayPal::Web.create({
201
+ let(:new_payin_paypal_web) do
202
+ MangoPay::PayIn::PayPal::Web.create(
179
203
  AuthorId: new_natural_user['Id'],
180
204
  CreditedUserId: new_wallet['Owners'][0],
181
205
  CreditedWalletId: new_wallet['Id'],
@@ -183,15 +207,15 @@ shared_context 'payins' do
183
207
  Fees: { Currency: 'EUR', Amount: 0 },
184
208
  ReturnURL: MangoPay.configuration.root_url,
185
209
  Tag: 'Test PayIn/PayPal/Web'
186
- })
187
- }
188
-
189
- ###############################################
210
+ )
211
+ end
212
+
213
+ ###############################################
190
214
  # directdebit/direct
191
215
  ###############################################
192
216
 
193
- let(:new_payin_directdebit_direct) {
194
- MangoPay::PayIn::DirectDebit::Direct.create({
217
+ let(:new_payin_directdebit_direct) do
218
+ MangoPay::PayIn::DirectDebit::Direct.create(
195
219
  AuthorId: new_natural_user['Id'],
196
220
  CreditedUserId: new_wallet['Owners'][0],
197
221
  CreditedWalletId: new_wallet['Id'],
@@ -200,15 +224,15 @@ shared_context 'payins' do
200
224
  MandateId: new_mandate['Id'],
201
225
  ReturnURL: MangoPay.configuration.root_url,
202
226
  Tag: 'Test PayIn/DirectDebit/Direct'
203
- })
204
- }
205
-
227
+ )
228
+ end
229
+
206
230
  ###############################################
207
231
  # card/web
208
232
  ###############################################
209
233
 
210
- let(:new_payin_card_web) {
211
- MangoPay::PayIn::Card::Web.create({
234
+ let(:new_payin_card_web) do
235
+ MangoPay::PayIn::Card::Web.create(
212
236
  AuthorId: new_natural_user['Id'],
213
237
  CreditedUserId: new_wallet['Owners'][0],
214
238
  CreditedWalletId: new_wallet['Id'],
@@ -218,22 +242,22 @@ shared_context 'payins' do
218
242
  ReturnURL: MangoPay.configuration.root_url,
219
243
  Culture: 'FR',
220
244
  Tag: 'Test PayIn/Card/Web'
221
- })
222
- }
245
+ )
246
+ end
223
247
 
224
248
  ###############################################
225
249
  # card/direct
226
250
  ###############################################
227
251
 
228
- let(:new_card_registration) {
229
- MangoPay::CardRegistration.create({
252
+ let(:new_card_registration) do
253
+ MangoPay::CardRegistration.create(
230
254
  UserId: new_natural_user['Id'],
231
255
  Currency: 'EUR',
232
256
  Tag: 'Test Card Registration'
233
- })
234
- }
257
+ )
258
+ end
235
259
 
236
- let(:new_card_registration_completed) {
260
+ let(:new_card_registration_completed) do
237
261
  # 1st step: create
238
262
  cardreg = new_card_registration
239
263
 
@@ -242,22 +266,23 @@ shared_context 'payins' do
242
266
  data: cardreg['PreregistrationData'],
243
267
  accessKeyRef: cardreg['AccessKey'],
244
268
  cardNumber: 4970100000000154,
245
- cardExpirationDate: 1218,
269
+ cardExpirationDate: 1226,
246
270
  cardCvx: 123}
271
+
247
272
  res = Net::HTTP.post_form(URI(cardreg['CardRegistrationURL']), data)
248
- raise Exception, [res, res.body] unless (res.is_a?(Net::HTTPOK) && res.body.start_with?('data='))
273
+ raise Exception, [res, res.body] unless res.is_a?(Net::HTTPOK) && res.body.start_with?('data=')
274
+
249
275
  cardreg['RegistrationData'] = res.body
250
276
 
251
277
  # 3rd step: update (fills-in CardId) and return it
252
- MangoPay::CardRegistration.update(cardreg['Id'], {
253
- RegistrationData: cardreg['RegistrationData']
254
- })
255
- }
278
+ MangoPay::CardRegistration.update(cardreg['Id'],
279
+ RegistrationData: cardreg['RegistrationData'])
280
+ end
256
281
 
257
282
  let(:new_payin_card_direct) { create_new_payin_card_direct(new_wallet) }
258
283
  def create_new_payin_card_direct(to_wallet, amnt = 1000)
259
284
  cardreg = new_card_registration_completed
260
- MangoPay::PayIn::Card::Direct.create({
285
+ MangoPay::PayIn::Card::Direct.create(
261
286
  AuthorId: new_natural_user['Id'],
262
287
  CreditedUserId: to_wallet['Owners'][0],
263
288
  CreditedWalletId: to_wallet['Id'],
@@ -267,7 +292,7 @@ shared_context 'payins' do
267
292
  CardId: cardreg['CardId'],
268
293
  SecureModeReturnURL: 'http://test.com',
269
294
  Tag: 'Test PayIn/Card/Direct'
270
- })
295
+ )
271
296
  end
272
297
 
273
298
  ###############################################
@@ -276,20 +301,20 @@ shared_context 'payins' do
276
301
 
277
302
  let(:new_card_preauthorization) { create_new_card_preauthorization(new_card_registration_completed) }
278
303
  def create_new_card_preauthorization(cardreg, amnt = 1000)
279
- MangoPay::PreAuthorization.create({
304
+ MangoPay::PreAuthorization.create(
280
305
  AuthorId: new_natural_user['Id'],
281
306
  DebitedFunds: { Currency: 'EUR', Amount: amnt },
282
307
  CardId: cardreg['CardId'],
283
308
  SecureMode: 'DEFAULT',
284
309
  SecureModeReturnURL: 'http://test.com',
285
310
  Tag: 'Test Card PreAuthorization'
286
- })
311
+ )
287
312
  end
288
313
 
289
314
  let(:new_payin_preauthorized_direct) { create_new_payin_preauthorized_direct(new_wallet) }
290
315
  def create_new_payin_preauthorized_direct(to_wallet, amnt = 1000)
291
316
  preauth = new_card_preauthorization
292
- MangoPay::PayIn::PreAuthorized::Direct.create({
317
+ MangoPay::PayIn::PreAuthorized::Direct.create(
293
318
  AuthorId: new_natural_user['Id'],
294
319
  CreditedUserId: to_wallet['Owners'][0],
295
320
  CreditedWalletId: to_wallet['Id'],
@@ -297,7 +322,7 @@ shared_context 'payins' do
297
322
  Fees: { Currency: 'EUR', Amount: 0 },
298
323
  PreauthorizationId: preauth['Id'],
299
324
  Tag: 'Test PayIn/PreAuthorized/Direct'
300
- })
325
+ )
301
326
  end
302
327
 
303
328
  ###############################################
@@ -306,26 +331,25 @@ shared_context 'payins' do
306
331
 
307
332
  let(:new_payin_bankwire_direct) { create_new_payin_bankwire_direct(new_wallet) }
308
333
  def create_new_payin_bankwire_direct(to_wallet, amnt = 1000)
309
- MangoPay::PayIn::BankWire::Direct.create({
334
+ MangoPay::PayIn::BankWire::Direct.create(
310
335
  AuthorId: new_natural_user['Id'],
311
336
  CreditedUserId: to_wallet['Owners'][0],
312
337
  CreditedWalletId: to_wallet['Id'],
313
338
  DeclaredDebitedFunds: { Currency: 'EUR', Amount: amnt },
314
339
  DeclaredFees: { Currency: 'EUR', Amount: 0 },
315
340
  Tag: 'Test PayIn/BankWire/Direct'
316
- })
341
+ )
317
342
  end
318
-
319
343
  end
320
344
 
321
345
  ###############################################
322
346
  shared_context 'payouts' do
323
- ###############################################
347
+ ###############################################
324
348
  include_context 'bank_accounts'
325
349
 
326
350
  let(:new_payout_bankwire) { create_new_payout_bankwire(new_payin_card_direct) }
327
351
  def create_new_payout_bankwire(payin, amnt = 500)
328
- MangoPay::PayOut::BankWire.create({
352
+ MangoPay::PayOut::BankWire.create(
329
353
  AuthorId: payin['CreditedUserId'],
330
354
  DebitedWalletId: payin['CreditedWalletId'],
331
355
  DebitedFunds: { Currency: 'EUR', Amount: amnt },
@@ -333,65 +357,65 @@ shared_context 'payouts' do
333
357
  BankAccountId: new_bank_account['Id'],
334
358
  Communication: 'This is a test',
335
359
  Tag: 'Test PayOut/Bank/Wire'
336
- })
360
+ )
337
361
  end
338
362
  end
339
363
 
340
364
  ###############################################
341
365
  shared_context 'transfers' do
342
- ###############################################
366
+ ###############################################
343
367
  include_context 'users'
344
368
  include_context 'wallets'
345
369
  include_context 'payins'
346
370
 
347
- let(:new_transfer) {
371
+ let(:new_transfer) do
348
372
  wlt1 = new_wallet
349
373
  wlt2 = new_wallet_legal
350
374
  create_new_payin_card_direct(wlt1, 1000) # feed wlt1 with money
351
375
  create_new_transfer(wlt1, wlt2, 500) # transfer wlt1 => wlt2
352
- }
376
+ end
353
377
  def create_new_transfer(from_wallet, to_wallet, amnt = 500)
354
- MangoPay::Transfer.create({
355
- AuthorId: from_wallet['Owners'][0],
356
- DebitedWalletId: from_wallet['Id'],
357
- CreditedUserId: to_wallet['Owners'][0],
358
- CreditedWalletId: to_wallet['Id'],
359
- DebitedFunds: { Currency: 'EUR', Amount: amnt},
360
- Fees: { Currency: 'EUR', Amount: 0},
361
- Tag: 'Test transfer'
362
- })
378
+ MangoPay::Transfer.create(
379
+ AuthorId: from_wallet['Owners'][0],
380
+ DebitedWalletId: from_wallet['Id'],
381
+ CreditedUserId: to_wallet['Owners'][0],
382
+ CreditedWalletId: to_wallet['Id'],
383
+ DebitedFunds: {Currency: 'EUR', Amount: amnt},
384
+ Fees: {Currency: 'EUR', Amount: 0},
385
+ Tag: 'Test transfer'
386
+ )
363
387
  end
364
388
  end
365
389
 
366
390
  ###############################################
367
391
  shared_context 'hooks' do
368
- ###############################################
369
- let(:new_hook) {
370
- hooks = MangoPay::Hook.fetch({'page' => 1, 'per_page' => 1})
371
- if hooks.length == 0
372
- MangoPay::Hook.create({
392
+ ###############################################
393
+ let(:new_hook) do
394
+ hooks = MangoPay::Hook.fetch('page' => 1, 'per_page' => 1)
395
+ if hooks.empty?
396
+ MangoPay::Hook.create(
373
397
  EventType: 'PAYIN_NORMAL_CREATED',
374
398
  Url: 'http://test.com',
375
399
  Tag: 'Test hook'
376
- })
400
+ )
377
401
  else
378
402
  hooks[0]
379
403
  end
380
- }
404
+ end
381
405
  end
382
406
 
383
407
  ###############################################
384
408
  shared_context 'bankigaliases' do
385
- ###############################################
409
+ ###############################################
386
410
  include_context 'users'
387
411
  include_context 'wallets'
388
412
 
389
- let(:new_banking_alias) {
413
+ let(:new_banking_alias) do
390
414
  MangoPay::BankingAliasesIBAN.create({
391
- CreditedUserId: new_natural_user['Id'],
392
- WalletId: new_wallet['Id'],
393
- OwnerName: new_natural_user['FirstName'],
394
- Country: 'LU'
395
- }, new_wallet['Id'])
396
- }
415
+ CreditedUserId: new_natural_user['Id'],
416
+ WalletId: new_wallet['Id'],
417
+ OwnerName: new_natural_user['FirstName'],
418
+ Country: 'LU'
419
+ }, new_wallet['Id'])
420
+ end
397
421
  end
@@ -1,17 +1,14 @@
1
1
  describe MangoPay::UboDeclaration do
2
2
  include_context 'users'
3
+ include_context 'ubo'
3
4
 
4
5
  describe 'FETCH' do
5
6
  it 'can fetch a UBO declaration' do
6
7
  legal_user = new_legal_user
7
- natural_user = define_new_natural_user
8
- natural_user['Capacity'] = 'DECLARATIVE'
9
- natural_user = MangoPay::NaturalUser.create(natural_user)
10
- ubo_declaration = {
11
- DeclaredUBOs: [natural_user['Id']]
12
- }
13
- ubo_declaration = MangoPay::LegalUser.create_ubo_declaration(legal_user['Id'], ubo_declaration)
14
- ubo_declaration = MangoPay::UboDeclaration.fetch(ubo_declaration['Id'])
8
+
9
+ ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'])
10
+
11
+ ubo_declaration = MangoPay::UboDeclaration.fetch(legal_user['Id'], ubo_declaration['Id'])
15
12
 
16
13
  expect(ubo_declaration).not_to be_nil
17
14
  end
@@ -19,19 +16,17 @@ describe MangoPay::UboDeclaration do
19
16
  describe 'UPDATE' do
20
17
  it 'can update a UBO declaration' do
21
18
  legal_user = new_legal_user
22
- natural_user = define_new_natural_user
23
- natural_user['Capacity'] = 'DECLARATIVE'
24
- natural_user = MangoPay::NaturalUser.create(natural_user)
25
- ubo_declaration = {
26
- DeclaredUBOs: [natural_user['Id']]
27
- }
28
- ubo_declaration = MangoPay::LegalUser.create_ubo_declaration(legal_user['Id'], ubo_declaration)
19
+ ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'])
29
20
  ubo_declaration['Status'] = 'VALIDATION_ASKED'
30
- ubo_declaration = MangoPay::UboDeclaration.update(ubo_declaration['Id'], ubo_declaration)
21
+
22
+ ubo = new_ubo(legal_user, ubo_declaration)
23
+
24
+ ubo_declaration['Ubos'] = [ubo]
25
+ ubo_declaration = MangoPay::UboDeclaration.update(legal_user['Id'], ubo_declaration['Id'], ubo_declaration)
31
26
 
32
27
  expect(ubo_declaration).not_to be_nil
33
28
  expect(ubo_declaration['Status']).to eq 'VALIDATION_ASKED'
34
29
  end
35
30
  end
36
31
  end
37
- end
32
+ end
@@ -0,0 +1,39 @@
1
+ describe MangoPay::Ubo do
2
+ include_context 'users'
3
+ include_context 'ubo'
4
+
5
+ describe 'FETCH' do
6
+ it 'can fetch a Ubo' do
7
+ legal_user = new_legal_user
8
+ ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'])
9
+ ubo = new_ubo(legal_user, ubo_declaration)
10
+ result = MangoPay::Ubo.fetch(legal_user['Id'], ubo_declaration['Id'], ubo['Id'])
11
+ expect(result).not_to be_nil
12
+ expect(result['Id']).equal? ubo['Id']
13
+ end
14
+ end
15
+
16
+ describe 'CREATE' do
17
+ it 'can create a new Ubo' do
18
+ legal_user = new_legal_user
19
+ ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'])
20
+ result = new_ubo(legal_user, ubo_declaration)
21
+ expect(result).not_to be_nil
22
+ end
23
+ end
24
+
25
+ describe 'UPDATE' do
26
+ it 'can update a Ubo' do
27
+ legal_user = new_legal_user
28
+ ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'])
29
+ ubo = new_ubo(legal_user, ubo_declaration)
30
+ ubo['FirstName'] = 'Santa'
31
+ ubo['LastName'] = 'Clause'
32
+
33
+ result = MangoPay::Ubo.update(legal_user['Id'], ubo_declaration['Id'], ubo['Id'], ubo)
34
+ expect(result).not_to be_nil
35
+ expect(result['FirstName']).equal? ubo['FirstName']
36
+ expect(result['LastName']).equal? ubo['LastName']
37
+ end
38
+ end
39
+ end
@@ -173,23 +173,20 @@ describe MangoPay::User do
173
173
  end
174
174
  end
175
175
 
176
- describe 'CREATE UBO DECLARATION' do
177
- it 'creates a UBO declaration' do
178
- legal_user = new_legal_user
179
- natural_user = define_new_natural_user
180
- natural_user['Capacity'] = 'DECLARATIVE'
181
- natural_user = MangoPay::NaturalUser.create(natural_user)
182
- ubo_declaration = {
183
- DeclaredUBOs: [natural_user['Id']]
184
- }
185
- ubo_declaration = MangoPay::LegalUser.create_ubo_declaration(legal_user['Id'], ubo_declaration)
186
-
187
- expect(ubo_declaration).not_to be_nil
188
- expect(ubo_declaration['Status']).to eq 'CREATED'
189
- expect(ubo_declaration['UserId']).to eq legal_user['Id']
190
- expect(ubo_declaration['DeclaredUBOs'][0]['UserId']).to eq natural_user['Id']
191
- end
192
- end
176
+ #describe 'CREATE UBO DECLARATION' do
177
+ # it 'creates a UBO declaration' do
178
+ # legal_user = new_legal_user
179
+ # natural_user = define_new_natural_user
180
+ # natural_user['Capacity'] = 'DECLARATIVE'
181
+ # natural_user = MangoPay::NaturalUser.create(natural_user)
182
+ # ubo_declaration = MangoPay::LegalUser.create_ubo_declaration(legal_user['Id'])
183
+
184
+ # expect(ubo_declaration).not_to be_nil
185
+ # expect(ubo_declaration['Status']).to eq 'CREATED'
186
+ # expect(ubo_declaration['UserId']).to eq legal_user['Id']
187
+ # expect(ubo_declaration['DeclaredUBOs'][0]['UserId']).to eq natural_user['Id']
188
+ # end
189
+ #end
193
190
 
194
191
  describe 'FETCH Pre-Authorizations' do
195
192
  it "fetches list of user's pre-authorizations belonging" do
@@ -11,7 +11,7 @@ def reset_mangopay_configuration
11
11
 
12
12
  # sandbox environment:
13
13
  c.root_url = 'https://api.sandbox.mangopay.com'
14
- c.client_passphrase = 'cqFfFrWfCcb7UadHNxx2C9Lo6Djw8ZduLi7J9USTmu8bhxxpju'
14
+ c.client_apiKey = 'cqFfFrWfCcb7UadHNxx2C9Lo6Djw8ZduLi7J9USTmu8bhxxpju'
15
15
 
16
16
  c.temp_dir = File.expand_path('../tmp', __FILE__)
17
17
  require 'fileutils'
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.31
4
+ version: 3.0.32
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: 2018-03-23 00:00:00.000000000 Z
12
+ date: 2019-06-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -99,6 +99,7 @@ files:
99
99
  - lib/mangopay/resource.rb
100
100
  - lib/mangopay/transaction.rb
101
101
  - lib/mangopay/transfer.rb
102
+ - lib/mangopay/ubo.rb
102
103
  - lib/mangopay/ubo_declaration.rb
103
104
  - lib/mangopay/user.rb
104
105
  - lib/mangopay/version.rb
@@ -138,6 +139,7 @@ files:
138
139
  - spec/mangopay/transaction_spec.rb
139
140
  - spec/mangopay/transfer_spec.rb
140
141
  - spec/mangopay/ubo_declaration_spec.rb
142
+ - spec/mangopay/ubo_spec.rb
141
143
  - spec/mangopay/user_spec.rb
142
144
  - spec/mangopay/wallet_spec.rb
143
145
  - spec/spec_helper.rb
@@ -161,8 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
163
  - !ruby/object:Gem::Version
162
164
  version: '0'
163
165
  requirements: []
164
- rubyforge_project:
165
- rubygems_version: 2.7.6
166
+ rubygems_version: 3.0.4
166
167
  signing_key:
167
168
  specification_version: 4
168
169
  summary: Ruby bindings for the version 2 of the MANGOPAY API
@@ -201,6 +202,7 @@ test_files:
201
202
  - spec/mangopay/transaction_spec.rb
202
203
  - spec/mangopay/transfer_spec.rb
203
204
  - spec/mangopay/ubo_declaration_spec.rb
205
+ - spec/mangopay/ubo_spec.rb
204
206
  - spec/mangopay/user_spec.rb
205
207
  - spec/mangopay/wallet_spec.rb
206
208
  - spec/spec_helper.rb