mangopay 3.0.31 → 3.0.36

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module MangoPay
2
- VERSION = '3.0.31'
2
+ VERSION = '3.0.36'
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,26 @@ 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
+ clnt['TechEmails'] = ['support@mangopay.com']
30
+ phoneNumber = rand(99999999).to_s
31
+ clnt['HeadquartersPhoneNumber'] = phoneNumber
22
32
 
23
33
  updated = MangoPay::Client.update(clnt)
24
34
  expect(updated['ClientId']).to eq(MangoPay.configuration.client_id)
25
35
  expect(updated['PrimaryThemeColour']).to eq(after)
36
+ expect(updated['HeadquartersPhoneNumber']).to eq(phoneNumber)
26
37
  end
27
38
  end
28
39
 
29
40
  describe 'UPLOAD LOGO' do
30
41
  it 'accepts Base64 encoded file content' do
31
42
  fnm = __FILE__.sub('.rb', '.png')
32
- bts = File.open(fnm, 'rb') { |f| f.read }
43
+ bts = File.open(fnm, 'rb') {|f| f.read}
33
44
  b64 = Base64.encode64(bts)
34
45
  ret = MangoPay::Client.upload_logo(b64)
35
46
  expect(ret).to be_nil
@@ -43,7 +54,7 @@ describe MangoPay::Client do
43
54
 
44
55
  it 'fails when input string is not base64-encoded' do
45
56
  file = 'any file content...'
46
- expect { MangoPay::Client.upload_logo(file) }.to raise_error { |err|
57
+ expect {MangoPay::Client.upload_logo(file)}.to raise_error {|err|
47
58
  expect(err).to be_a MangoPay::ResponseError
48
59
  expect(err.code).to eq '400'
49
60
  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
@@ -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
@@ -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
@@ -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
+
@@ -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,56 @@ 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
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
26
65
  end
27
66
  end
28
67
 
@@ -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
@@ -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,82 +1,86 @@
1
1
  ###############################################
2
2
  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
- Tag: 'Test natural user',
9
- Email: 'my@email.com',
10
- FirstName: 'John',
11
- LastName: 'Doe',
12
- Address: {
13
- AddressLine1: 'Le Palais Royal',
14
- AddressLine2: '8 Rue de Montpensier',
15
- City: 'Paris',
16
- Region: '',
17
- PostalCode: '75001',
18
- Country: 'FR'
19
- },
20
- Birthday: 1300186358,
21
- Birthplace: 'Paris',
22
- Nationality: 'FR',
23
- CountryOfResidence: 'FR',
24
- Occupation: 'Worker',
25
- IncomeRange: 1
9
+ Tag: 'Test natural user',
10
+ Email: 'my@email.com',
11
+ FirstName: 'John',
12
+ LastName: 'Doe',
13
+ Address: {
14
+ AddressLine1: 'Le Palais Royal',
15
+ AddressLine2: '8 Rue de Montpensier',
16
+ City: 'Paris',
17
+ Region: '',
18
+ PostalCode: '75001',
19
+ Country: 'FR'
20
+ },
21
+ Birthday: 1_300_186_358,
22
+ Birthplace: 'Paris',
23
+ Nationality: 'FR',
24
+ CountryOfResidence: 'FR',
25
+ Occupation: 'Worker',
26
+ IncomeRange: 1
26
27
  }
27
28
  end
29
+
28
30
  def create_new_natural_user
29
31
  MangoPay::NaturalUser.create(define_new_natural_user)
30
32
  end
31
33
 
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'
44
- },
45
- LegalRepresentativeFirstName: 'John',
46
- LegalRepresentativeLastName: 'Doe',
47
- LegalRepresentativeAdress: {
48
- AddressLine1: '38 Rue de Montpensier',
49
- AddressLine2: '',
50
- City: 'Paris',
51
- Region: '',
52
- PostalCode: '75001',
53
- Country: 'FR'
54
- },
55
- LegalRepresentativeEmail: 'john@doe.com',
56
- LegalRepresentativeBirthday: 1300186358,
57
- LegalRepresentativeNationality: 'FR',
58
- LegalRepresentativeCountryOfResidence: 'FR',
59
- Statute: '',
60
- ProofOfRegistration: '',
61
- ShareholderDeclaration: ''
62
- })
63
- }
34
+ let(:new_legal_user) do
35
+ MangoPay::LegalUser.create(
36
+ Name: 'Super',
37
+ Email: 'super@email.com',
38
+ LegalPersonType: 'BUSINESS',
39
+ HeadquartersAddress: {
40
+ AddressLine1: '6 Parvis Notre-Dame',
41
+ AddressLine2: 'Pl. Jean-Paul II',
42
+ City: 'Paris',
43
+ Region: 'FR',
44
+ PostalCode: '75004',
45
+ Country: 'FR'
46
+ },
47
+ LegalRepresentativeFirstName: 'John',
48
+ LegalRepresentativeLastName: 'Doe',
49
+ LegalRepresentativeAdress: {
50
+ AddressLine1: '38 Rue de Montpensier',
51
+ AddressLine2: '',
52
+ City: 'Paris',
53
+ Region: '',
54
+ PostalCode: '75001',
55
+ Country: 'FR'
56
+ },
57
+ LegalRepresentativeEmail: 'john@doe.com',
58
+ LegalRepresentativeBirthday: 1_300_186_358,
59
+ LegalRepresentativeNationality: 'FR',
60
+ LegalRepresentativeCountryOfResidence: 'FR',
61
+ CompanyNumber: 'LU123456789',
62
+ Statute: '',
63
+ ProofOfRegistration: '',
64
+ ShareholderDeclaration: ''
65
+ )
66
+ end
64
67
  end
65
68
 
66
69
  ###############################################
67
70
  shared_context 'wallets' do
68
- ###############################################
71
+ ###############################################
69
72
  include_context 'users'
70
73
 
71
74
  let(:new_wallet) { create_new_wallet(new_natural_user) }
72
75
  let(:new_wallet_legal) { create_new_wallet(new_legal_user) }
76
+
73
77
  def create_new_wallet(user)
74
- MangoPay::Wallet.create({
75
- Owners: [user['Id']],
76
- Description: 'A test wallet',
77
- Currency: 'EUR',
78
- Tag: 'Test wallet'
79
- })
78
+ MangoPay::Wallet.create(
79
+ Owners: [user['Id']],
80
+ Description: 'A test wallet',
81
+ Currency: 'EUR',
82
+ Tag: 'Test wallet'
83
+ )
80
84
  end
81
85
 
82
86
  def wallets_check_amounts(wlt1, amnt1, wlt2 = nil, amnt2 = nil)
@@ -85,69 +89,93 @@ shared_context 'wallets' do
85
89
  end
86
90
 
87
91
  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
92
+ wlt1 = MangoPay::Wallet.fetch(wlt1['Id'])
93
+ wlt2 = MangoPay::Wallet.fetch(wlt2['Id']) if wlt2
90
94
  wallets_check_amounts(wlt1, amnt1, wlt2, amnt2)
91
95
  end
92
96
  end
93
97
 
98
+ shared_context 'ubo' do
99
+ def new_ubo(user, ubo_declaration)
100
+ ubo = {
101
+ FirstName: 'John',
102
+ LastName: 'Doe',
103
+ Address: {
104
+ AddressLine1: '6 Parvis Notre-Dame',
105
+ AddressLine2: 'Pl. Jean-Paul II',
106
+ City: 'Paris',
107
+ Region: '',
108
+ PostalCode: '75004',
109
+ Country: 'FR'
110
+ },
111
+ Nationality: 'FR',
112
+ Birthday: 1_300_186_358,
113
+ Birthplace: {
114
+ City: 'Paris',
115
+ Country: 'FR'
116
+ }
117
+ }
118
+ MangoPay::Ubo.create(user['Id'], ubo_declaration['Id'], ubo)
119
+ end
120
+ end
121
+
94
122
  ###############################################
95
123
  shared_context 'bank_accounts' do
96
- ###############################################
124
+ ###############################################
97
125
  include_context 'users'
98
126
 
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
- }
127
+ let(:new_bank_account) do
128
+ MangoPay::BankAccount.create(new_natural_user['Id'],
129
+ Type: 'IBAN',
130
+ OwnerName: 'John',
131
+ OwnerAddress: {
132
+ AddressLine1: 'Le Palais Royal',
133
+ AddressLine2: '8 Rue de Montpensier',
134
+ City: 'Paris',
135
+ Region: '',
136
+ PostalCode: '75001',
137
+ Country: 'FR'
138
+ },
139
+ IBAN: 'FR7618829754160173622224154',
140
+ BIC: 'CMBRFR2BCME',
141
+ Tag: 'Test bank account')
142
+ end
116
143
  end
117
144
 
118
145
  ###############################################
119
146
  shared_context 'mandates' do
120
- ###############################################
147
+ ###############################################
121
148
  include_context 'bank_accounts'
122
149
 
123
- let(:new_mandate) { create_new_mandate() }
124
- def create_new_mandate()
125
- MangoPay::Mandate.create({
126
- BankAccountId: new_bank_account['Id'],
127
- Culture: 'FR',
128
- ReturnURL: MangoPay.configuration.root_url,
129
- Tag: 'Test mandate'
130
- })
150
+ let(:new_mandate) { create_new_mandate }
151
+
152
+ def create_new_mandate
153
+ MangoPay::Mandate.create(
154
+ BankAccountId: new_bank_account['Id'],
155
+ Culture: 'FR',
156
+ ReturnURL: MangoPay.configuration.root_url,
157
+ Tag: 'Test mandate'
158
+ )
131
159
  end
132
160
  end
133
161
 
134
162
  ###############################################
135
163
  shared_context 'kyc_documents' do
136
- ###############################################
164
+ ###############################################
137
165
  include_context 'users'
138
166
 
139
167
  let(:new_document) { create_new_document(new_natural_user) }
168
+
140
169
  def create_new_document(user)
141
- MangoPay::KycDocument.create(user['Id'], {
142
- Type: 'IDENTITY_PROOF',
143
- Tag: 'Test document'
144
- })
170
+ MangoPay::KycDocument.create(user['Id'],
171
+ Type: 'IDENTITY_PROOF',
172
+ Tag: 'Test document')
145
173
  end
146
174
  end
147
175
 
148
176
  ###############################################
149
177
  shared_context 'payins' do
150
- ###############################################
178
+ ###############################################
151
179
  include_context 'users'
152
180
  include_context 'wallets'
153
181
  include_context 'mandates'
@@ -156,118 +184,192 @@ shared_context 'payins' do
156
184
  # directdebit/web
157
185
  ###############################################
158
186
 
159
- let(:new_payin_directdebit_web) {
160
- MangoPay::PayIn::DirectDebit::Web.create({
161
- AuthorId: new_natural_user['Id'],
162
- CreditedUserId: new_wallet['Owners'][0],
163
- CreditedWalletId: new_wallet['Id'],
164
- DebitedFunds: { Currency: 'EUR', Amount: 1000 },
165
- Fees: { Currency: 'EUR', Amount: 0 },
166
- DirectDebitType: 'GIROPAY',
167
- ReturnURL: MangoPay.configuration.root_url,
168
- Culture: 'FR',
169
- Tag: 'Test PayIn/DirectDebit/Web'
170
- })
171
- }
187
+ let(:new_payin_directdebit_web) do
188
+ MangoPay::PayIn::DirectDebit::Web.create(
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'
198
+ )
199
+ end
172
200
 
173
201
  ###############################################
174
202
  # paypal/web
175
203
  ###############################################
176
204
 
177
- let(:new_payin_paypal_web) {
178
- MangoPay::PayIn::PayPal::Web.create({
179
- AuthorId: new_natural_user['Id'],
180
- CreditedUserId: new_wallet['Owners'][0],
181
- CreditedWalletId: new_wallet['Id'],
182
- DebitedFunds: { Currency: 'EUR', Amount: 1000 },
183
- Fees: { Currency: 'EUR', Amount: 0 },
184
- ReturnURL: MangoPay.configuration.root_url,
185
- Tag: 'Test PayIn/PayPal/Web'
186
- })
187
- }
188
-
189
- ###############################################
205
+ let(:new_payin_paypal_web) do
206
+ MangoPay::PayIn::PayPal::Web.create(
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'
215
+ )
216
+ end
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
+
274
+ ###############################################
190
275
  # directdebit/direct
191
276
  ###############################################
192
277
 
193
- let(:new_payin_directdebit_direct) {
194
- MangoPay::PayIn::DirectDebit::Direct.create({
195
- AuthorId: new_natural_user['Id'],
196
- CreditedUserId: new_wallet['Owners'][0],
197
- CreditedWalletId: new_wallet['Id'],
198
- DebitedFunds: { Currency: 'EUR', Amount: 1000 },
199
- Fees: { Currency: 'EUR', Amount: 0 },
200
- MandateId: new_mandate['Id'],
201
- ReturnURL: MangoPay.configuration.root_url,
202
- Tag: 'Test PayIn/DirectDebit/Direct'
203
- })
204
- }
205
-
278
+ let(:new_payin_directdebit_direct) do
279
+ MangoPay::PayIn::DirectDebit::Direct.create(
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'
288
+ )
289
+ end
290
+
206
291
  ###############################################
207
292
  # card/web
208
293
  ###############################################
209
294
 
210
- let(:new_payin_card_web) {
211
- MangoPay::PayIn::Card::Web.create({
212
- AuthorId: new_natural_user['Id'],
213
- CreditedUserId: new_wallet['Owners'][0],
214
- CreditedWalletId: new_wallet['Id'],
215
- DebitedFunds: { Currency: 'EUR', Amount: 1000 },
216
- Fees: { Currency: 'EUR', Amount: 0 },
217
- CardType: 'CB_VISA_MASTERCARD',
218
- ReturnURL: MangoPay.configuration.root_url,
219
- Culture: 'FR',
220
- Tag: 'Test PayIn/Card/Web'
221
- })
222
- }
295
+ let(:new_payin_card_web) do
296
+ MangoPay::PayIn::Card::Web.create(
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/"}
321
+ )
322
+ end
223
323
 
224
324
  ###############################################
225
325
  # card/direct
226
326
  ###############################################
227
327
 
228
- let(:new_card_registration) {
229
- MangoPay::CardRegistration.create({
230
- UserId: new_natural_user['Id'],
231
- Currency: 'EUR',
232
- Tag: 'Test Card Registration'
233
- })
234
- }
328
+ let(:new_card_registration) do
329
+ MangoPay::CardRegistration.create(
330
+ UserId: new_natural_user['Id'],
331
+ Currency: 'EUR',
332
+ Tag: 'Test Card Registration'
333
+ )
334
+ end
235
335
 
236
- let(:new_card_registration_completed) {
336
+ let(:new_card_registration_completed) do
237
337
  # 1st step: create
238
338
  cardreg = new_card_registration
239
339
 
240
340
  # 2nd step: tokenize by payline (fills-in RegistrationData)
241
341
  data = {
242
- data: cardreg['PreregistrationData'],
243
- accessKeyRef: cardreg['AccessKey'],
244
- cardNumber: 4970100000000154,
245
- cardExpirationDate: 1218,
246
- cardCvx: 123}
342
+ data: cardreg['PreregistrationData'],
343
+ accessKeyRef: cardreg['AccessKey'],
344
+ cardNumber: 4970100000000154,
345
+ cardExpirationDate: 1226,
346
+ cardCvx: 123}
347
+
247
348
  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='))
349
+ raise Exception, [res, res.body] unless res.is_a?(Net::HTTPOK) && res.body.start_with?('data=')
350
+
249
351
  cardreg['RegistrationData'] = res.body
250
352
 
251
353
  # 3rd step: update (fills-in CardId) and return it
252
- MangoPay::CardRegistration.update(cardreg['Id'], {
253
- RegistrationData: cardreg['RegistrationData']
254
- })
255
- }
354
+ MangoPay::CardRegistration.update(cardreg['Id'],
355
+ RegistrationData: cardreg['RegistrationData'])
356
+ end
256
357
 
257
358
  let(:new_payin_card_direct) { create_new_payin_card_direct(new_wallet) }
359
+
258
360
  def create_new_payin_card_direct(to_wallet, amnt = 1000)
259
361
  cardreg = new_card_registration_completed
260
- MangoPay::PayIn::Card::Direct.create({
261
- AuthorId: new_natural_user['Id'],
262
- CreditedUserId: to_wallet['Owners'][0],
263
- CreditedWalletId: to_wallet['Id'],
264
- DebitedFunds: { Currency: 'EUR', Amount: amnt },
265
- Fees: { Currency: 'EUR', Amount: 0 },
266
- CardType: 'CB_VISA_MASTERCARD',
267
- CardId: cardreg['CardId'],
268
- SecureModeReturnURL: 'http://test.com',
269
- Tag: 'Test PayIn/Card/Direct'
270
- })
362
+ MangoPay::PayIn::Card::Direct.create(
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'
372
+ )
271
373
  end
272
374
 
273
375
  ###############################################
@@ -275,29 +377,31 @@ shared_context 'payins' do
275
377
  ###############################################
276
378
 
277
379
  let(:new_card_preauthorization) { create_new_card_preauthorization(new_card_registration_completed) }
380
+
278
381
  def create_new_card_preauthorization(cardreg, amnt = 1000)
279
- MangoPay::PreAuthorization.create({
280
- AuthorId: new_natural_user['Id'],
281
- DebitedFunds: { Currency: 'EUR', Amount: amnt },
282
- CardId: cardreg['CardId'],
283
- SecureMode: 'DEFAULT',
284
- SecureModeReturnURL: 'http://test.com',
285
- Tag: 'Test Card PreAuthorization'
286
- })
382
+ MangoPay::PreAuthorization.create(
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'
389
+ )
287
390
  end
288
391
 
289
392
  let(:new_payin_preauthorized_direct) { create_new_payin_preauthorized_direct(new_wallet) }
393
+
290
394
  def create_new_payin_preauthorized_direct(to_wallet, amnt = 1000)
291
395
  preauth = new_card_preauthorization
292
- MangoPay::PayIn::PreAuthorized::Direct.create({
293
- AuthorId: new_natural_user['Id'],
294
- CreditedUserId: to_wallet['Owners'][0],
295
- CreditedWalletId: to_wallet['Id'],
296
- DebitedFunds: { Currency: 'EUR', Amount: amnt },
297
- Fees: { Currency: 'EUR', Amount: 0 },
298
- PreauthorizationId: preauth['Id'],
299
- Tag: 'Test PayIn/PreAuthorized/Direct'
300
- })
396
+ MangoPay::PayIn::PreAuthorized::Direct.create(
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'
404
+ )
301
405
  end
302
406
 
303
407
  ###############################################
@@ -305,93 +409,95 @@ shared_context 'payins' do
305
409
  ###############################################
306
410
 
307
411
  let(:new_payin_bankwire_direct) { create_new_payin_bankwire_direct(new_wallet) }
412
+
308
413
  def create_new_payin_bankwire_direct(to_wallet, amnt = 1000)
309
- MangoPay::PayIn::BankWire::Direct.create({
310
- AuthorId: new_natural_user['Id'],
311
- CreditedUserId: to_wallet['Owners'][0],
312
- CreditedWalletId: to_wallet['Id'],
313
- DeclaredDebitedFunds: { Currency: 'EUR', Amount: amnt },
314
- DeclaredFees: { Currency: 'EUR', Amount: 0 },
315
- Tag: 'Test PayIn/BankWire/Direct'
316
- })
414
+ MangoPay::PayIn::BankWire::Direct.create(
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'
421
+ )
317
422
  end
318
-
319
423
  end
320
424
 
321
425
  ###############################################
322
426
  shared_context 'payouts' do
323
- ###############################################
427
+ ###############################################
324
428
  include_context 'bank_accounts'
325
429
 
326
430
  let(:new_payout_bankwire) { create_new_payout_bankwire(new_payin_card_direct) }
431
+
327
432
  def create_new_payout_bankwire(payin, amnt = 500)
328
- MangoPay::PayOut::BankWire.create({
329
- AuthorId: payin['CreditedUserId'],
330
- DebitedWalletId: payin['CreditedWalletId'],
331
- DebitedFunds: { Currency: 'EUR', Amount: amnt },
332
- Fees: { Currency: 'EUR', Amount: 0 },
333
- BankAccountId: new_bank_account['Id'],
334
- Communication: 'This is a test',
335
- Tag: 'Test PayOut/Bank/Wire'
336
- })
433
+ MangoPay::PayOut::BankWire.create(
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'
441
+ )
337
442
  end
338
443
  end
339
444
 
340
445
  ###############################################
341
446
  shared_context 'transfers' do
342
- ###############################################
447
+ ###############################################
343
448
  include_context 'users'
344
449
  include_context 'wallets'
345
450
  include_context 'payins'
346
451
 
347
- let(:new_transfer) {
452
+ let(:new_transfer) do
348
453
  wlt1 = new_wallet
349
454
  wlt2 = new_wallet_legal
350
455
  create_new_payin_card_direct(wlt1, 1000) # feed wlt1 with money
351
456
  create_new_transfer(wlt1, wlt2, 500) # transfer wlt1 => wlt2
352
- }
457
+ end
458
+
353
459
  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
- })
460
+ MangoPay::Transfer.create(
461
+ AuthorId: from_wallet['Owners'][0],
462
+ DebitedWalletId: from_wallet['Id'],
463
+ CreditedUserId: to_wallet['Owners'][0],
464
+ CreditedWalletId: to_wallet['Id'],
465
+ DebitedFunds: {Currency: 'EUR', Amount: amnt},
466
+ Fees: {Currency: 'EUR', Amount: 0},
467
+ Tag: 'Test transfer'
468
+ )
363
469
  end
364
470
  end
365
471
 
366
472
  ###############################################
367
473
  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({
373
- EventType: 'PAYIN_NORMAL_CREATED',
374
- Url: 'http://test.com',
375
- Tag: 'Test hook'
376
- })
474
+ ###############################################
475
+ let(:new_hook) do
476
+ hooks = MangoPay::Hook.fetch('page' => 1, 'per_page' => 1)
477
+ if hooks.empty?
478
+ MangoPay::Hook.create(
479
+ EventType: 'PAYIN_NORMAL_CREATED',
480
+ Url: 'http://test.com',
481
+ Tag: 'Test hook'
482
+ )
377
483
  else
378
484
  hooks[0]
379
485
  end
380
- }
486
+ end
381
487
  end
382
488
 
383
489
  ###############################################
384
490
  shared_context 'bankigaliases' do
385
- ###############################################
491
+ ###############################################
386
492
  include_context 'users'
387
493
  include_context 'wallets'
388
494
 
389
- let(:new_banking_alias) {
495
+ let(:new_banking_alias) do
390
496
  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
- }
497
+ CreditedUserId: new_natural_user['Id'],
498
+ WalletId: new_wallet['Id'],
499
+ OwnerName: new_natural_user['FirstName'],
500
+ Country: 'LU'
501
+ }, new_wallet['Id'])
502
+ end
397
503
  end