mangopay 3.0.7 → 3.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mangopay.rb +1 -0
- data/lib/mangopay/payin.rb +24 -0
- data/lib/mangopay/preauthorization.rb +11 -0
- data/lib/mangopay/user.rb +22 -0
- data/lib/mangopay/version.rb +1 -1
- data/lib/mangopay/wallet.rb +8 -0
- data/spec/lib/mangopay/payin_bankwire_direct_spec.rb +76 -0
- data/spec/lib/mangopay/payin_preauthorized_direct_spec.rb +70 -0
- data/spec/lib/mangopay/preauthorization_spec.rb +44 -0
- data/spec/lib/mangopay/shared_resources.rb +46 -0
- data/spec/lib/mangopay/user_spec.rb +65 -0
- data/spec/lib/mangopay/wallet_spec.rb +58 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92c94eb1efc37815f64d2e8ebeca3ebfa4b7f044
|
4
|
+
data.tar.gz: 099332edf99baa6b8c2ce5422a99514cd2fde164
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 977dd21b45ce1732329e1edfd6fd911338ee63e9d90521c729871bb80165d7dd137c791a23ad3d059a6626be0ba719e3bf25a1e6bd5142498548787413b2badd
|
7
|
+
data.tar.gz: 6e911359d8da8a38ad008f2646058ec20711197d127dacb0c71682ae403113e7677e4d4e3fd0e8ed8dad2dd9602a606d8ca7f5473d8f91d030c4ad26665966a7
|
data/lib/mangopay.rb
CHANGED
@@ -22,6 +22,7 @@ require 'mangopay/transaction'
|
|
22
22
|
require 'mangopay/wallet'
|
23
23
|
require 'mangopay/bank_account'
|
24
24
|
require 'mangopay/card_registration'
|
25
|
+
require 'mangopay/preauthorization'
|
25
26
|
require 'mangopay/card'
|
26
27
|
require 'mangopay/event'
|
27
28
|
require 'mangopay/kyc_document'
|
data/lib/mangopay/payin.rb
CHANGED
@@ -23,5 +23,29 @@ module MangoPay
|
|
23
23
|
|
24
24
|
end
|
25
25
|
|
26
|
+
module PreAuthorized
|
27
|
+
|
28
|
+
class Direct < Resource
|
29
|
+
include MangoPay::HTTPCalls::Create
|
30
|
+
private
|
31
|
+
def self.url(*)
|
32
|
+
"/v2/#{MangoPay.configuration.client_id}/payins/preauthorized/direct"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
module BankWire
|
39
|
+
|
40
|
+
class Direct < Resource
|
41
|
+
include MangoPay::HTTPCalls::Create
|
42
|
+
private
|
43
|
+
def self.url(*)
|
44
|
+
"/v2/#{MangoPay.configuration.client_id}/payins/bankwire/direct"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
26
50
|
end
|
27
51
|
end
|
data/lib/mangopay/user.rb
CHANGED
@@ -3,5 +3,27 @@ module MangoPay
|
|
3
3
|
include MangoPay::HTTPCalls::Create
|
4
4
|
include MangoPay::HTTPCalls::Update
|
5
5
|
include MangoPay::HTTPCalls::Fetch
|
6
|
+
|
7
|
+
# Fetches list of wallets belonging to the given +user_id+.
|
8
|
+
# Optional +filters+ is a hash accepting following keys:
|
9
|
+
# - +page+, +per_page+: pagination params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
|
10
|
+
# - other keys specific for transactions filtering (see MangoPay::Transaction.fetch)
|
11
|
+
def self.wallets(user_id, filters={})
|
12
|
+
MangoPay.request(:get, url(user_id) + '/wallets', {}, filters)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Fetches list of cards belonging to the given +user_id+.
|
16
|
+
# Optional +filters+ is a hash accepting following keys:
|
17
|
+
# - +page+, +per_page+: pagination params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
|
18
|
+
def self.cards(user_id, filters={})
|
19
|
+
MangoPay.request(:get, url(user_id) + '/cards', {}, filters)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Fetches list of transactions belonging to the given +user_id+.
|
23
|
+
# Optional +filters+ is a hash accepting following keys:
|
24
|
+
# - +page+, +per_page+: pagination params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
|
25
|
+
def self.transactions(user_id, filters={})
|
26
|
+
MangoPay.request(:get, url(user_id) + '/transactions', {}, filters)
|
27
|
+
end
|
6
28
|
end
|
7
29
|
end
|
data/lib/mangopay/version.rb
CHANGED
data/lib/mangopay/wallet.rb
CHANGED
@@ -3,5 +3,13 @@ module MangoPay
|
|
3
3
|
include MangoPay::HTTPCalls::Create
|
4
4
|
include MangoPay::HTTPCalls::Update
|
5
5
|
include MangoPay::HTTPCalls::Fetch
|
6
|
+
|
7
|
+
# Fetches list of transactions belonging to the given +wallet_id+.
|
8
|
+
# Optional +filters+ is a hash accepting following keys:
|
9
|
+
# - +page+, +per_page+: pagination params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
|
10
|
+
# - other keys specific for transactions filtering (see MangoPay::Transaction.fetch)
|
11
|
+
def self.transactions(wallet_id, filters={})
|
12
|
+
MangoPay::Transaction.fetch(wallet_id, filters)
|
13
|
+
end
|
6
14
|
end
|
7
15
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe MangoPay::PayIn::BankWire::Direct, type: :feature do
|
4
|
+
include_context 'wallets'
|
5
|
+
include_context 'payins'
|
6
|
+
|
7
|
+
def check_type_and_status(payin)
|
8
|
+
expect(payin['Type']).to eq('PAYIN')
|
9
|
+
expect(payin['Nature']).to eq('REGULAR')
|
10
|
+
expect(payin['PaymentType']).to eq('BANK_WIRE')
|
11
|
+
expect(payin['ExecutionType']).to eq('DIRECT')
|
12
|
+
|
13
|
+
expect(payin['Status']).to eq('CREATED')
|
14
|
+
expect(payin['ResultCode']).to be_nil
|
15
|
+
expect(payin['ResultMessage']).to be_nil
|
16
|
+
expect(payin['ExecutionDate']).to be_nil
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'CREATE' do
|
20
|
+
it 'creates a bankwire direct payin' do
|
21
|
+
created = new_payin_bankwire_direct
|
22
|
+
expect(created['Id']).not_to be_nil
|
23
|
+
check_type_and_status(created)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'FETCH' do
|
28
|
+
it 'fetches a payin' do
|
29
|
+
created = new_payin_bankwire_direct
|
30
|
+
fetched = MangoPay::PayIn.fetch(created['Id'])
|
31
|
+
expect(fetched['Id']).to eq(created['Id'])
|
32
|
+
expect(fetched['CreationDate']).to eq(created['CreationDate'])
|
33
|
+
expect(fetched['DeclaredDebitedFunds']).to eq(created['DeclaredDebitedFunds'])
|
34
|
+
expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
|
35
|
+
check_type_and_status(created)
|
36
|
+
check_type_and_status(fetched)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
###############################################
|
41
|
+
# refund not implemented for this type of payin
|
42
|
+
###############################################
|
43
|
+
# describe 'REFUND' do
|
44
|
+
# it 'refunds a payin' do
|
45
|
+
# payin = new_payin_bankwire_direct
|
46
|
+
# refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
|
47
|
+
# expect(refund['Id']).not_to be_nil
|
48
|
+
# expect(refund['Status']).to eq('SUCCEEDED')
|
49
|
+
# expect(refund['Type']).to eq('PAYOUT')
|
50
|
+
# expect(refund['Nature']).to eq('REFUND')
|
51
|
+
# expect(refund['InitialTransactionType']).to eq('PAYIN')
|
52
|
+
# expect(refund['InitialTransactionId']).to eq(payin['Id'])
|
53
|
+
# expect(refund['DebitedWalletId']).to eq(payin['CreditedWalletId'])
|
54
|
+
# end
|
55
|
+
# end
|
56
|
+
#
|
57
|
+
###############################################
|
58
|
+
# status is CREATED instead of SUCCEEDED
|
59
|
+
# so no cash flow yet
|
60
|
+
###############################################
|
61
|
+
# describe 'CASH FLOW' do
|
62
|
+
# it 'changes balances correctly' do
|
63
|
+
# wlt = new_wallet
|
64
|
+
# wallets_check_amounts(wlt, 0)
|
65
|
+
#
|
66
|
+
# # payin: feed wlt1 with money
|
67
|
+
# payin = create_new_payin_bankwire_direct(wlt, 1000)
|
68
|
+
# wallets_reload_and_check_amounts(wlt, 1000)
|
69
|
+
#
|
70
|
+
# # refund the payin
|
71
|
+
# refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
|
72
|
+
# wallets_reload_and_check_amounts(wlt, 0)
|
73
|
+
# end
|
74
|
+
# end
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe MangoPay::PayIn::PreAuthorized::Direct, type: :feature do
|
4
|
+
include_context 'wallets'
|
5
|
+
include_context 'payins'
|
6
|
+
|
7
|
+
def check_type_and_status(payin)
|
8
|
+
expect(payin['Type']).to eq('PAYIN')
|
9
|
+
expect(payin['Nature']).to eq('REGULAR')
|
10
|
+
expect(payin['PaymentType']).to eq('PREAUTHORIZED')
|
11
|
+
expect(payin['ExecutionType']).to eq('DIRECT')
|
12
|
+
|
13
|
+
# SUCCEEDED
|
14
|
+
expect(payin['Status']).to eq('SUCCEEDED')
|
15
|
+
expect(payin['ResultCode']).to eq('000000')
|
16
|
+
expect(payin['ResultMessage']).to eq('Success')
|
17
|
+
expect(payin['ExecutionDate']).to be > 0
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'CREATE' do
|
21
|
+
it 'creates a preauthorized direct payin' do
|
22
|
+
created = new_payin_preauthorized_direct
|
23
|
+
expect(created['Id']).not_to be_nil
|
24
|
+
check_type_and_status(created)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'FETCH' do
|
29
|
+
it 'fetches a payin' do
|
30
|
+
created = new_payin_preauthorized_direct
|
31
|
+
fetched = MangoPay::PayIn.fetch(created['Id'])
|
32
|
+
expect(fetched['Id']).to eq(created['Id'])
|
33
|
+
expect(fetched['CreationDate']).to eq(created['CreationDate'])
|
34
|
+
expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
|
35
|
+
expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
|
36
|
+
check_type_and_status(created)
|
37
|
+
check_type_and_status(fetched)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'REFUND' do
|
42
|
+
it 'refunds a payin' do
|
43
|
+
payin = new_payin_preauthorized_direct
|
44
|
+
refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
|
45
|
+
expect(refund['Id']).not_to be_nil
|
46
|
+
expect(refund['Status']).to eq('SUCCEEDED')
|
47
|
+
expect(refund['Type']).to eq('PAYOUT')
|
48
|
+
expect(refund['Nature']).to eq('REFUND')
|
49
|
+
expect(refund['InitialTransactionType']).to eq('PAYIN')
|
50
|
+
expect(refund['InitialTransactionId']).to eq(payin['Id'])
|
51
|
+
expect(refund['DebitedWalletId']).to eq(payin['CreditedWalletId'])
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe 'CASH FLOW' do
|
56
|
+
it 'changes balances correctly' do
|
57
|
+
wlt = new_wallet
|
58
|
+
wallets_check_amounts(wlt, 0)
|
59
|
+
|
60
|
+
# payin: feed wlt1 with money
|
61
|
+
payin = create_new_payin_preauthorized_direct(wlt, 1000)
|
62
|
+
wallets_reload_and_check_amounts(wlt, 1000)
|
63
|
+
|
64
|
+
# refund the payin
|
65
|
+
refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
|
66
|
+
wallets_reload_and_check_amounts(wlt, 0)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe MangoPay::PreAuthorization do
|
4
|
+
include_context 'users'
|
5
|
+
include_context 'payins'
|
6
|
+
|
7
|
+
describe 'CREATE' do
|
8
|
+
it 'creates a new card pre-authorization' do
|
9
|
+
cardreg = new_card_registration_completed
|
10
|
+
created = new_card_preauthorization
|
11
|
+
expect(created['Id']).not_to be_nil
|
12
|
+
expect(created['Id'].to_i).to be > 0
|
13
|
+
expect(created['CardId']).to eq(cardreg['CardId'])
|
14
|
+
expect(created['AuthorId']).to eq(new_natural_user["Id"])
|
15
|
+
expect(created['PayInId']).to be_nil
|
16
|
+
expect(created['Status']).to eq('SUCCEEDED')
|
17
|
+
expect(created['PaymentStatus']).to eq('WAITING')
|
18
|
+
expect(created['PaymentType']).to eq('CARD')
|
19
|
+
expect(created['ExecutionType']).to eq('DIRECT')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'UPDATE' do
|
24
|
+
it 'updates a card pre-authorization' do
|
25
|
+
created = new_card_preauthorization
|
26
|
+
updated = MangoPay::PreAuthorization.update(created['Id'] ,{
|
27
|
+
PaymentStatus: 'CANCELED'
|
28
|
+
})
|
29
|
+
expect(updated['PaymentStatus']).to eq('CANCELED')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'FETCH' do
|
34
|
+
it 'fetches a card pre-authorization' do
|
35
|
+
created = new_card_preauthorization
|
36
|
+
fetched = MangoPay::PreAuthorization.fetch(created['Id'])
|
37
|
+
expect(fetched['Id']).to eq(created['Id'])
|
38
|
+
expect(fetched['CardId']).to eq(created['CardId'])
|
39
|
+
expect(fetched['AuthorId']).to eq(created['AuthorId'])
|
40
|
+
expect(fetched['Tag']).to eq(created['Tag'])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -204,6 +204,52 @@ shared_context 'payins' do
|
|
204
204
|
})
|
205
205
|
end
|
206
206
|
|
207
|
+
###############################################
|
208
|
+
# card/direct with pre-authorization
|
209
|
+
###############################################
|
210
|
+
|
211
|
+
let(:new_card_preauthorization) { create_new_card_preauthorization(new_card_registration_completed) }
|
212
|
+
def create_new_card_preauthorization(cardreg, amnt = 1000)
|
213
|
+
MangoPay::PreAuthorization.create({
|
214
|
+
AuthorId: new_natural_user['Id'],
|
215
|
+
DebitedFunds: { Currency: 'EUR', Amount: amnt },
|
216
|
+
CardId: cardreg['CardId'],
|
217
|
+
SecureMode: 'DEFAULT',
|
218
|
+
SecureModeReturnURL: 'http://test.com',
|
219
|
+
Tag: 'Test Card PreAuthorization'
|
220
|
+
})
|
221
|
+
end
|
222
|
+
|
223
|
+
let(:new_payin_preauthorized_direct) { create_new_payin_preauthorized_direct(new_wallet) }
|
224
|
+
def create_new_payin_preauthorized_direct(to_wallet, amnt = 1000)
|
225
|
+
preauth = new_card_preauthorization
|
226
|
+
MangoPay::PayIn::PreAuthorized::Direct.create({
|
227
|
+
AuthorId: new_natural_user['Id'],
|
228
|
+
CreditedUserId: to_wallet['Owners'][0],
|
229
|
+
CreditedWalletId: to_wallet['Id'],
|
230
|
+
DebitedFunds: { Currency: 'EUR', Amount: amnt },
|
231
|
+
Fees: { Currency: 'EUR', Amount: 0 },
|
232
|
+
PreauthorizationId: preauth['Id'],
|
233
|
+
Tag: 'Test PayIn/PreAuthorized/Direct'
|
234
|
+
})
|
235
|
+
end
|
236
|
+
|
237
|
+
###############################################
|
238
|
+
# bankwire/direct
|
239
|
+
###############################################
|
240
|
+
|
241
|
+
let(:new_payin_bankwire_direct) { create_new_payin_bankwire_direct(new_wallet) }
|
242
|
+
def create_new_payin_bankwire_direct(to_wallet, amnt = 1000)
|
243
|
+
MangoPay::PayIn::BankWire::Direct.create({
|
244
|
+
AuthorId: new_natural_user['Id'],
|
245
|
+
CreditedUserId: to_wallet['Owners'][0],
|
246
|
+
CreditedWalletId: to_wallet['Id'],
|
247
|
+
DeclaredDebitedFunds: { Currency: 'EUR', Amount: amnt },
|
248
|
+
DeclaredFees: { Currency: 'EUR', Amount: 0 },
|
249
|
+
Tag: 'Test PayIn/BankWire/Direct'
|
250
|
+
})
|
251
|
+
end
|
252
|
+
|
207
253
|
end
|
208
254
|
|
209
255
|
###############################################
|
@@ -2,6 +2,9 @@ require_relative '../../spec_helper'
|
|
2
2
|
|
3
3
|
describe MangoPay::User do
|
4
4
|
include_context 'users'
|
5
|
+
include_context 'payins'
|
6
|
+
include_context 'payouts'
|
7
|
+
include_context 'wallets'
|
5
8
|
|
6
9
|
describe 'CREATE' do
|
7
10
|
it 'creates a new natural user' do
|
@@ -56,4 +59,66 @@ describe MangoPay::User do
|
|
56
59
|
expect(user['Id']).to eq(new_natural_user['Id'])
|
57
60
|
end
|
58
61
|
end
|
62
|
+
|
63
|
+
describe 'FETCH TRANSACTIONS' do
|
64
|
+
it 'fetches empty list of transactions if no transactions done' do
|
65
|
+
transactions = MangoPay::User.transactions(new_natural_user['Id'])
|
66
|
+
expect(transactions).to be_kind_of(Array)
|
67
|
+
expect(transactions).to be_empty
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'fetches list with single transaction after payin done' do
|
71
|
+
payin = new_payin_card_direct
|
72
|
+
transactions = MangoPay::User.transactions(new_natural_user['Id'])
|
73
|
+
expect(transactions).to be_kind_of(Array)
|
74
|
+
expect(transactions.count).to eq 1
|
75
|
+
expect(transactions.first['Id']).to eq payin['Id']
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'fetches list with two transactions after payin and payout done' do
|
79
|
+
payin = new_payin_card_direct
|
80
|
+
payout = create_new_payout_bankwire(payin)
|
81
|
+
transactions = MangoPay::User.transactions(new_natural_user['Id'])
|
82
|
+
|
83
|
+
expect(transactions).to be_kind_of(Array)
|
84
|
+
expect(transactions.count).to eq 2
|
85
|
+
|
86
|
+
transactions_ids = transactions.map {|t| t['Id']}
|
87
|
+
expect(transactions_ids).to include payin['Id']
|
88
|
+
expect(transactions_ids).to include payout['Id']
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe 'FETCH WALLETS' do
|
93
|
+
it 'fetches empty list of wallets if no wallets created' do
|
94
|
+
wallets = MangoPay::User.wallets(new_natural_user['Id'])
|
95
|
+
expect(wallets).to be_kind_of(Array)
|
96
|
+
expect(wallets).to be_empty
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'fetches list with single wallet after created' do
|
100
|
+
wallet = new_wallet
|
101
|
+
wallets = MangoPay::User.wallets(new_natural_user['Id'])
|
102
|
+
expect(wallets).to be_kind_of(Array)
|
103
|
+
expect(wallets.count).to eq 1
|
104
|
+
expect(wallets.first['Id']).to eq wallet['Id']
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe 'FETCH CARDS' do
|
109
|
+
it 'fetches empty list of cards if no cards created' do
|
110
|
+
cards = MangoPay::User.cards(new_natural_user['Id'])
|
111
|
+
expect(cards).to be_kind_of(Array)
|
112
|
+
expect(cards).to be_empty
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'fetches list with single card after created' do
|
116
|
+
card = new_card_registration_completed
|
117
|
+
cards = MangoPay::User.cards(new_natural_user['Id'])
|
118
|
+
expect(cards).to be_kind_of(Array)
|
119
|
+
expect(cards.count).to eq 1
|
120
|
+
expect(cards.first['Id']).to eq card['CardId']
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
59
124
|
end
|
@@ -2,6 +2,8 @@ require_relative '../../spec_helper'
|
|
2
2
|
|
3
3
|
describe MangoPay::Wallet do
|
4
4
|
include_context 'wallets'
|
5
|
+
include_context 'payins'
|
6
|
+
include_context 'payouts'
|
5
7
|
|
6
8
|
describe 'CREATE' do
|
7
9
|
it 'creates a wallet' do
|
@@ -28,4 +30,60 @@ describe MangoPay::Wallet do
|
|
28
30
|
expect(wallet['Id']).to eq(new_wallet['Id'])
|
29
31
|
end
|
30
32
|
end
|
33
|
+
|
34
|
+
describe 'FETCH TRANSACTIONS' do
|
35
|
+
|
36
|
+
it 'fetches empty list of transactions if no transactions done' do
|
37
|
+
transactions = MangoPay::Wallet.transactions(new_wallet['Id'])
|
38
|
+
expect(transactions).to be_kind_of(Array)
|
39
|
+
expect(transactions).to be_empty
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'fetches list with single transaction after payin done' do
|
43
|
+
payin = new_payin_card_direct
|
44
|
+
transactions = MangoPay::Wallet.transactions(new_wallet['Id'])
|
45
|
+
expect(transactions).to be_kind_of(Array)
|
46
|
+
expect(transactions.count).to eq 1
|
47
|
+
expect(transactions.first['Id']).to eq payin['Id']
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'fetches list with two transactions after payin and payout done' do
|
51
|
+
payin = new_payin_card_direct
|
52
|
+
payout = create_new_payout_bankwire(payin)
|
53
|
+
transactions = MangoPay::Wallet.transactions(new_wallet['Id'])
|
54
|
+
|
55
|
+
expect(transactions).to be_kind_of(Array)
|
56
|
+
expect(transactions.count).to eq 2
|
57
|
+
|
58
|
+
transactions_ids = transactions.map {|t| t['Id']}
|
59
|
+
expect(transactions_ids).to include payin['Id']
|
60
|
+
expect(transactions_ids).to include payout['Id']
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'accepts filtering params' do
|
64
|
+
payin = new_payin_card_direct
|
65
|
+
payout = create_new_payout_bankwire(payin)
|
66
|
+
wallet_id = new_wallet['Id']
|
67
|
+
|
68
|
+
by_nature_reg = MangoPay::Wallet.transactions(wallet_id, {'Nature' => 'REGULAR'})
|
69
|
+
by_nature_ref = MangoPay::Wallet.transactions(wallet_id, {'Nature' => 'REFUND'})
|
70
|
+
expect(by_nature_reg.count).to eq 2
|
71
|
+
expect(by_nature_ref.count).to eq 0
|
72
|
+
|
73
|
+
by_type_pyin = MangoPay::Wallet.transactions(wallet_id, {'Type' => 'PAYIN'})
|
74
|
+
by_type_pyout = MangoPay::Wallet.transactions(wallet_id, {'Type' => 'PAYOUT'})
|
75
|
+
expect(by_type_pyin.count).to eq 1
|
76
|
+
expect(by_type_pyout.count).to eq 1
|
77
|
+
expect(by_type_pyin.first['Id']).to eq payin['Id']
|
78
|
+
expect(by_type_pyout.first['Id']).to eq payout['Id']
|
79
|
+
|
80
|
+
by_dir_cred = MangoPay::Wallet.transactions(wallet_id, {'Direction' => 'CREDIT'})
|
81
|
+
by_dir_debt = MangoPay::Wallet.transactions(wallet_id, {'Direction' => 'DEBIT'})
|
82
|
+
expect(by_dir_cred.count).to eq 1
|
83
|
+
expect(by_dir_debt.count).to eq 1
|
84
|
+
expect(by_dir_cred.first['Id']).to eq payin['Id']
|
85
|
+
expect(by_dir_debt.first['Id']).to eq payout['Id']
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
31
89
|
end
|
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.
|
4
|
+
version: 3.0.8
|
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:
|
12
|
+
date: 2014-01-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- lib/mangopay/natural_user.rb
|
129
129
|
- lib/mangopay/payin.rb
|
130
130
|
- lib/mangopay/payout.rb
|
131
|
+
- lib/mangopay/preauthorization.rb
|
131
132
|
- lib/mangopay/resource.rb
|
132
133
|
- lib/mangopay/transaction.rb
|
133
134
|
- lib/mangopay/transfer.rb
|
@@ -143,9 +144,12 @@ files:
|
|
143
144
|
- spec/lib/mangopay/event_spec.rb
|
144
145
|
- spec/lib/mangopay/fetch_filters_spec.rb
|
145
146
|
- spec/lib/mangopay/kyc_document_spec.rb
|
147
|
+
- spec/lib/mangopay/payin_bankwire_direct_spec.rb
|
146
148
|
- spec/lib/mangopay/payin_card_direct_spec.rb
|
147
149
|
- spec/lib/mangopay/payin_card_web_spec.rb
|
150
|
+
- spec/lib/mangopay/payin_preauthorized_direct_spec.rb
|
148
151
|
- spec/lib/mangopay/payout_bankwire_spec.rb
|
152
|
+
- spec/lib/mangopay/preauthorization_spec.rb
|
149
153
|
- spec/lib/mangopay/shared_resources.rb
|
150
154
|
- spec/lib/mangopay/transaction_spec.rb
|
151
155
|
- spec/lib/mangopay/transfer_spec.rb
|
@@ -186,9 +190,12 @@ test_files:
|
|
186
190
|
- spec/lib/mangopay/event_spec.rb
|
187
191
|
- spec/lib/mangopay/fetch_filters_spec.rb
|
188
192
|
- spec/lib/mangopay/kyc_document_spec.rb
|
193
|
+
- spec/lib/mangopay/payin_bankwire_direct_spec.rb
|
189
194
|
- spec/lib/mangopay/payin_card_direct_spec.rb
|
190
195
|
- spec/lib/mangopay/payin_card_web_spec.rb
|
196
|
+
- spec/lib/mangopay/payin_preauthorized_direct_spec.rb
|
191
197
|
- spec/lib/mangopay/payout_bankwire_spec.rb
|
198
|
+
- spec/lib/mangopay/preauthorization_spec.rb
|
192
199
|
- spec/lib/mangopay/shared_resources.rb
|
193
200
|
- spec/lib/mangopay/transaction_spec.rb
|
194
201
|
- spec/lib/mangopay/transfer_spec.rb
|