mangopay 3.0.25.pre.alpha.pre.20 → 3.0.25
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/.gitignore +28 -28
- data/.rspec +2 -2
- data/.travis.yml +4 -13
- data/Gemfile +2 -2
- data/LICENSE +20 -20
- data/README.md +126 -126
- data/bin/mangopay +9 -9
- data/lib/generators/mangopay/install_generator.rb +60 -60
- data/lib/generators/templates/mangopay.rb.erb +5 -5
- data/lib/mangopay.rb +225 -225
- data/lib/mangopay/authorization_token.rb +88 -88
- data/lib/mangopay/bank_account.rb +38 -38
- data/lib/mangopay/card.rb +8 -8
- data/lib/mangopay/card_registration.rb +9 -9
- data/lib/mangopay/client.rb +74 -74
- data/lib/mangopay/dispute.rb +130 -130
- data/lib/mangopay/errors.rb +61 -61
- data/lib/mangopay/event.rb +18 -18
- data/lib/mangopay/filter_parameters.rb +46 -46
- data/lib/mangopay/hook.rb +9 -9
- data/lib/mangopay/http_calls.rb +85 -85
- data/lib/mangopay/json.rb +14 -14
- data/lib/mangopay/kyc_document.rb +70 -70
- data/lib/mangopay/legal_user.rb +15 -15
- data/lib/mangopay/mandate.rb +32 -32
- data/lib/mangopay/natural_user.rb +14 -14
- data/lib/mangopay/pay_in.rb +85 -85
- data/lib/mangopay/pay_out.rb +14 -14
- data/lib/mangopay/pre_authorization.rb +13 -13
- data/lib/mangopay/refund.rb +7 -7
- data/lib/mangopay/report.rb +17 -17
- data/lib/mangopay/resource.rb +21 -21
- data/lib/mangopay/temp.rb +74 -74
- data/lib/mangopay/transaction.rb +24 -24
- data/lib/mangopay/transfer.rb +9 -9
- data/lib/mangopay/user.rb +43 -43
- data/lib/mangopay/version.rb +3 -3
- data/lib/mangopay/wallet.rb +17 -17
- data/mangopay.gemspec +30 -31
- data/spec/mangopay/authorization_token_spec.rb +70 -70
- data/spec/mangopay/bank_account_spec.rb +97 -97
- data/spec/mangopay/card_registration_spec.rb +73 -73
- data/spec/mangopay/client_spec.rb +110 -110
- data/spec/mangopay/configuration_spec.rb +95 -95
- data/spec/mangopay/dispute_spec.rb +262 -262
- data/spec/mangopay/event_spec.rb +31 -31
- data/spec/mangopay/fetch_filters_spec.rb +63 -63
- data/spec/mangopay/hook_spec.rb +37 -37
- data/spec/mangopay/idempotency_spec.rb +41 -41
- data/spec/mangopay/kyc_document_spec.rb +103 -103
- data/spec/mangopay/log_requests_filter_spec.rb +25 -25
- data/spec/mangopay/mandate_spec.rb +92 -92
- data/spec/mangopay/payin_bankwire_direct_spec.rb +74 -74
- data/spec/mangopay/payin_card_direct_spec.rb +68 -68
- data/spec/mangopay/payin_card_web_spec.rb +38 -38
- data/spec/mangopay/payin_directdebit_direct_spec.rb +37 -37
- data/spec/mangopay/payin_directdebit_web_spec.rb +38 -38
- data/spec/mangopay/payin_paypal_web_spec.rb +38 -38
- data/spec/mangopay/payin_preauthorized_direct_spec.rb +68 -68
- data/spec/mangopay/payout_bankwire_spec.rb +54 -54
- data/spec/mangopay/preauthorization_spec.rb +42 -42
- data/spec/mangopay/refund_spec.rb +21 -21
- data/spec/mangopay/report_spec.rb +39 -39
- data/spec/mangopay/shared_resources.rb +381 -381
- data/spec/mangopay/temp_paymentcard_spec.rb +31 -31
- data/spec/mangopay/transaction_spec.rb +54 -54
- data/spec/mangopay/transfer_spec.rb +69 -69
- data/spec/mangopay/user_spec.rb +137 -137
- data/spec/mangopay/wallet_spec.rb +80 -80
- data/spec/spec_helper.rb +31 -31
- metadata +5 -5
@@ -1,38 +1,38 @@
|
|
1
|
-
describe MangoPay::PayIn::Card::Web, 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('CARD')
|
8
|
-
expect(payin['ExecutionType']).to eq('WEB')
|
9
|
-
|
10
|
-
# not SUCCEEDED yet: waiting for processing
|
11
|
-
expect(payin['Status']).to eq('CREATED')
|
12
|
-
expect(payin['ResultCode']).to be_nil
|
13
|
-
expect(payin['ResultMessage']).to be_nil
|
14
|
-
expect(payin['ExecutionDate']).to be_nil
|
15
|
-
end
|
16
|
-
|
17
|
-
describe 'CREATE' do
|
18
|
-
it 'creates a card web payin' do
|
19
|
-
created = new_payin_card_web
|
20
|
-
expect(created['Id']).not_to be_nil
|
21
|
-
check_type_and_status(created)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe 'FETCH' do
|
26
|
-
it 'fetches a payin' do
|
27
|
-
created = new_payin_card_web
|
28
|
-
fetched = MangoPay::PayIn.fetch(created['Id'])
|
29
|
-
expect(fetched['Id']).to eq(created['Id'])
|
30
|
-
expect(fetched['CreationDate']).to eq(created['CreationDate'])
|
31
|
-
expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
|
32
|
-
expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
|
33
|
-
check_type_and_status(created)
|
34
|
-
check_type_and_status(fetched)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
1
|
+
describe MangoPay::PayIn::Card::Web, 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('CARD')
|
8
|
+
expect(payin['ExecutionType']).to eq('WEB')
|
9
|
+
|
10
|
+
# not SUCCEEDED yet: waiting for processing
|
11
|
+
expect(payin['Status']).to eq('CREATED')
|
12
|
+
expect(payin['ResultCode']).to be_nil
|
13
|
+
expect(payin['ResultMessage']).to be_nil
|
14
|
+
expect(payin['ExecutionDate']).to be_nil
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'CREATE' do
|
18
|
+
it 'creates a card web payin' do
|
19
|
+
created = new_payin_card_web
|
20
|
+
expect(created['Id']).not_to be_nil
|
21
|
+
check_type_and_status(created)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'FETCH' do
|
26
|
+
it 'fetches a payin' do
|
27
|
+
created = new_payin_card_web
|
28
|
+
fetched = MangoPay::PayIn.fetch(created['Id'])
|
29
|
+
expect(fetched['Id']).to eq(created['Id'])
|
30
|
+
expect(fetched['CreationDate']).to eq(created['CreationDate'])
|
31
|
+
expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
|
32
|
+
expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
|
33
|
+
check_type_and_status(created)
|
34
|
+
check_type_and_status(fetched)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -1,37 +1,37 @@
|
|
1
|
-
describe MangoPay::PayIn::DirectDebit::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('DIRECT_DEBIT')
|
8
|
-
expect(payin['ExecutionType']).to eq('DIRECT')
|
9
|
-
|
10
|
-
# FAILED: the related Mandate is not confirmed yet
|
11
|
-
expect(payin['Status']).to eq('FAILED')
|
12
|
-
expect(payin['ResultMessage']).to eq('The Status of this Mandate does not allow for payments')
|
13
|
-
expect(payin['ExecutionDate']).to be_nil
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'CREATE' do
|
17
|
-
it 'creates a directdebit direct payin' do
|
18
|
-
created = new_payin_directdebit_direct
|
19
|
-
expect(created['Id']).not_to be_nil
|
20
|
-
check_type_and_status(created)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe 'FETCH' do
|
25
|
-
it 'fetches a payin' do
|
26
|
-
created = new_payin_directdebit_direct
|
27
|
-
fetched = MangoPay::PayIn.fetch(created['Id'])
|
28
|
-
expect(fetched['Id']).to eq(created['Id'])
|
29
|
-
expect(fetched['CreationDate']).to eq(created['CreationDate'])
|
30
|
-
expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
|
31
|
-
expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
|
32
|
-
check_type_and_status(created)
|
33
|
-
check_type_and_status(fetched)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
1
|
+
describe MangoPay::PayIn::DirectDebit::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('DIRECT_DEBIT')
|
8
|
+
expect(payin['ExecutionType']).to eq('DIRECT')
|
9
|
+
|
10
|
+
# FAILED: the related Mandate is not confirmed yet
|
11
|
+
expect(payin['Status']).to eq('FAILED')
|
12
|
+
expect(payin['ResultMessage']).to eq('The Status of this Mandate does not allow for payments')
|
13
|
+
expect(payin['ExecutionDate']).to be_nil
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'CREATE' do
|
17
|
+
it 'creates a directdebit direct payin' do
|
18
|
+
created = new_payin_directdebit_direct
|
19
|
+
expect(created['Id']).not_to be_nil
|
20
|
+
check_type_and_status(created)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'FETCH' do
|
25
|
+
it 'fetches a payin' do
|
26
|
+
created = new_payin_directdebit_direct
|
27
|
+
fetched = MangoPay::PayIn.fetch(created['Id'])
|
28
|
+
expect(fetched['Id']).to eq(created['Id'])
|
29
|
+
expect(fetched['CreationDate']).to eq(created['CreationDate'])
|
30
|
+
expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
|
31
|
+
expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
|
32
|
+
check_type_and_status(created)
|
33
|
+
check_type_and_status(fetched)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -1,38 +1,38 @@
|
|
1
|
-
describe MangoPay::PayIn::DirectDebit::Web, 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('DIRECT_DEBIT')
|
8
|
-
expect(payin['ExecutionType']).to eq('WEB')
|
9
|
-
|
10
|
-
# not SUCCEEDED yet: waiting for processing
|
11
|
-
expect(payin['Status']).to eq('CREATED')
|
12
|
-
expect(payin['ResultCode']).to be_nil
|
13
|
-
expect(payin['ResultMessage']).to be_nil
|
14
|
-
expect(payin['ExecutionDate']).to be_nil
|
15
|
-
end
|
16
|
-
|
17
|
-
describe 'CREATE' do
|
18
|
-
it 'creates a directdebit web payin' do
|
19
|
-
created = new_payin_directdebit_web
|
20
|
-
expect(created['Id']).not_to be_nil
|
21
|
-
check_type_and_status(created)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe 'FETCH' do
|
26
|
-
it 'fetches a payin' do
|
27
|
-
created = new_payin_directdebit_web
|
28
|
-
fetched = MangoPay::PayIn.fetch(created['Id'])
|
29
|
-
expect(fetched['Id']).to eq(created['Id'])
|
30
|
-
expect(fetched['CreationDate']).to eq(created['CreationDate'])
|
31
|
-
expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
|
32
|
-
expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
|
33
|
-
check_type_and_status(created)
|
34
|
-
check_type_and_status(fetched)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
1
|
+
describe MangoPay::PayIn::DirectDebit::Web, 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('DIRECT_DEBIT')
|
8
|
+
expect(payin['ExecutionType']).to eq('WEB')
|
9
|
+
|
10
|
+
# not SUCCEEDED yet: waiting for processing
|
11
|
+
expect(payin['Status']).to eq('CREATED')
|
12
|
+
expect(payin['ResultCode']).to be_nil
|
13
|
+
expect(payin['ResultMessage']).to be_nil
|
14
|
+
expect(payin['ExecutionDate']).to be_nil
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'CREATE' do
|
18
|
+
it 'creates a directdebit web payin' do
|
19
|
+
created = new_payin_directdebit_web
|
20
|
+
expect(created['Id']).not_to be_nil
|
21
|
+
check_type_and_status(created)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'FETCH' do
|
26
|
+
it 'fetches a payin' do
|
27
|
+
created = new_payin_directdebit_web
|
28
|
+
fetched = MangoPay::PayIn.fetch(created['Id'])
|
29
|
+
expect(fetched['Id']).to eq(created['Id'])
|
30
|
+
expect(fetched['CreationDate']).to eq(created['CreationDate'])
|
31
|
+
expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
|
32
|
+
expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
|
33
|
+
check_type_and_status(created)
|
34
|
+
check_type_and_status(fetched)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -1,38 +1,38 @@
|
|
1
|
-
describe MangoPay::PayIn::PayPal::Web, 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('PAYPAL')
|
8
|
-
expect(payin['ExecutionType']).to eq('WEB')
|
9
|
-
|
10
|
-
# not SUCCEEDED yet: waiting for processing
|
11
|
-
expect(payin['Status']).to eq('CREATED')
|
12
|
-
expect(payin['ResultCode']).to be_nil
|
13
|
-
expect(payin['ResultMessage']).to be_nil
|
14
|
-
expect(payin['ExecutionDate']).to be_nil
|
15
|
-
end
|
16
|
-
|
17
|
-
describe 'CREATE' do
|
18
|
-
it 'creates a paypal web payin' do
|
19
|
-
created = new_payin_paypal_web
|
20
|
-
expect(created['Id']).not_to be_nil
|
21
|
-
check_type_and_status(created)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe 'FETCH' do
|
26
|
-
it 'fetches a payin' do
|
27
|
-
created = new_payin_paypal_web
|
28
|
-
fetched = MangoPay::PayIn.fetch(created['Id'])
|
29
|
-
expect(fetched['Id']).to eq(created['Id'])
|
30
|
-
expect(fetched['CreationDate']).to eq(created['CreationDate'])
|
31
|
-
expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
|
32
|
-
expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
|
33
|
-
check_type_and_status(created)
|
34
|
-
check_type_and_status(fetched)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
1
|
+
describe MangoPay::PayIn::PayPal::Web, 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('PAYPAL')
|
8
|
+
expect(payin['ExecutionType']).to eq('WEB')
|
9
|
+
|
10
|
+
# not SUCCEEDED yet: waiting for processing
|
11
|
+
expect(payin['Status']).to eq('CREATED')
|
12
|
+
expect(payin['ResultCode']).to be_nil
|
13
|
+
expect(payin['ResultMessage']).to be_nil
|
14
|
+
expect(payin['ExecutionDate']).to be_nil
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'CREATE' do
|
18
|
+
it 'creates a paypal web payin' do
|
19
|
+
created = new_payin_paypal_web
|
20
|
+
expect(created['Id']).not_to be_nil
|
21
|
+
check_type_and_status(created)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'FETCH' do
|
26
|
+
it 'fetches a payin' do
|
27
|
+
created = new_payin_paypal_web
|
28
|
+
fetched = MangoPay::PayIn.fetch(created['Id'])
|
29
|
+
expect(fetched['Id']).to eq(created['Id'])
|
30
|
+
expect(fetched['CreationDate']).to eq(created['CreationDate'])
|
31
|
+
expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
|
32
|
+
expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
|
33
|
+
check_type_and_status(created)
|
34
|
+
check_type_and_status(fetched)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -1,68 +1,68 @@
|
|
1
|
-
describe MangoPay::PayIn::PreAuthorized::Direct, type: :feature do
|
2
|
-
include_context 'wallets'
|
3
|
-
include_context 'payins'
|
4
|
-
|
5
|
-
def check_type_and_status(payin)
|
6
|
-
expect(payin['Type']).to eq('PAYIN')
|
7
|
-
expect(payin['Nature']).to eq('REGULAR')
|
8
|
-
expect(payin['PaymentType']).to eq('PREAUTHORIZED')
|
9
|
-
expect(payin['ExecutionType']).to eq('DIRECT')
|
10
|
-
|
11
|
-
# SUCCEEDED
|
12
|
-
expect(payin['Status']).to eq('SUCCEEDED')
|
13
|
-
expect(payin['ResultCode']).to eq('000000')
|
14
|
-
expect(payin['ResultMessage']).to eq('Success')
|
15
|
-
expect(payin['ExecutionDate']).to be > 0
|
16
|
-
end
|
17
|
-
|
18
|
-
describe 'CREATE' do
|
19
|
-
it 'creates a preauthorized direct payin' do
|
20
|
-
created = new_payin_preauthorized_direct
|
21
|
-
expect(created['Id']).not_to be_nil
|
22
|
-
check_type_and_status(created)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe 'FETCH' do
|
27
|
-
it 'fetches a payin' do
|
28
|
-
created = new_payin_preauthorized_direct
|
29
|
-
fetched = MangoPay::PayIn.fetch(created['Id'])
|
30
|
-
expect(fetched['Id']).to eq(created['Id'])
|
31
|
-
expect(fetched['CreationDate']).to eq(created['CreationDate'])
|
32
|
-
expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
|
33
|
-
expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
|
34
|
-
check_type_and_status(created)
|
35
|
-
check_type_and_status(fetched)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe 'REFUND' do
|
40
|
-
it 'refunds a payin' do
|
41
|
-
payin = new_payin_preauthorized_direct
|
42
|
-
refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
|
43
|
-
expect(refund['Id']).not_to be_nil
|
44
|
-
expect(refund['Status']).to eq('SUCCEEDED')
|
45
|
-
expect(refund['Type']).to eq('PAYOUT')
|
46
|
-
expect(refund['Nature']).to eq('REFUND')
|
47
|
-
expect(refund['InitialTransactionType']).to eq('PAYIN')
|
48
|
-
expect(refund['InitialTransactionId']).to eq(payin['Id'])
|
49
|
-
expect(refund['DebitedWalletId']).to eq(payin['CreditedWalletId'])
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe 'CASH FLOW' do
|
54
|
-
it 'changes balances correctly' do
|
55
|
-
wlt = new_wallet
|
56
|
-
wallets_check_amounts(wlt, 0)
|
57
|
-
|
58
|
-
# payin: feed wlt1 with money
|
59
|
-
payin = create_new_payin_preauthorized_direct(wlt, 1000)
|
60
|
-
wallets_reload_and_check_amounts(wlt, 1000)
|
61
|
-
|
62
|
-
# refund the payin
|
63
|
-
refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
|
64
|
-
wallets_reload_and_check_amounts(wlt, 0)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
1
|
+
describe MangoPay::PayIn::PreAuthorized::Direct, type: :feature do
|
2
|
+
include_context 'wallets'
|
3
|
+
include_context 'payins'
|
4
|
+
|
5
|
+
def check_type_and_status(payin)
|
6
|
+
expect(payin['Type']).to eq('PAYIN')
|
7
|
+
expect(payin['Nature']).to eq('REGULAR')
|
8
|
+
expect(payin['PaymentType']).to eq('PREAUTHORIZED')
|
9
|
+
expect(payin['ExecutionType']).to eq('DIRECT')
|
10
|
+
|
11
|
+
# SUCCEEDED
|
12
|
+
expect(payin['Status']).to eq('SUCCEEDED')
|
13
|
+
expect(payin['ResultCode']).to eq('000000')
|
14
|
+
expect(payin['ResultMessage']).to eq('Success')
|
15
|
+
expect(payin['ExecutionDate']).to be > 0
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'CREATE' do
|
19
|
+
it 'creates a preauthorized direct payin' do
|
20
|
+
created = new_payin_preauthorized_direct
|
21
|
+
expect(created['Id']).not_to be_nil
|
22
|
+
check_type_and_status(created)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'FETCH' do
|
27
|
+
it 'fetches a payin' do
|
28
|
+
created = new_payin_preauthorized_direct
|
29
|
+
fetched = MangoPay::PayIn.fetch(created['Id'])
|
30
|
+
expect(fetched['Id']).to eq(created['Id'])
|
31
|
+
expect(fetched['CreationDate']).to eq(created['CreationDate'])
|
32
|
+
expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
|
33
|
+
expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
|
34
|
+
check_type_and_status(created)
|
35
|
+
check_type_and_status(fetched)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'REFUND' do
|
40
|
+
it 'refunds a payin' do
|
41
|
+
payin = new_payin_preauthorized_direct
|
42
|
+
refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
|
43
|
+
expect(refund['Id']).not_to be_nil
|
44
|
+
expect(refund['Status']).to eq('SUCCEEDED')
|
45
|
+
expect(refund['Type']).to eq('PAYOUT')
|
46
|
+
expect(refund['Nature']).to eq('REFUND')
|
47
|
+
expect(refund['InitialTransactionType']).to eq('PAYIN')
|
48
|
+
expect(refund['InitialTransactionId']).to eq(payin['Id'])
|
49
|
+
expect(refund['DebitedWalletId']).to eq(payin['CreditedWalletId'])
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'CASH FLOW' do
|
54
|
+
it 'changes balances correctly' do
|
55
|
+
wlt = new_wallet
|
56
|
+
wallets_check_amounts(wlt, 0)
|
57
|
+
|
58
|
+
# payin: feed wlt1 with money
|
59
|
+
payin = create_new_payin_preauthorized_direct(wlt, 1000)
|
60
|
+
wallets_reload_and_check_amounts(wlt, 1000)
|
61
|
+
|
62
|
+
# refund the payin
|
63
|
+
refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
|
64
|
+
wallets_reload_and_check_amounts(wlt, 0)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -1,54 +1,54 @@
|
|
1
|
-
describe MangoPay::PayOut::BankWire, type: :feature do
|
2
|
-
include_context 'bank_accounts'
|
3
|
-
include_context 'payins'
|
4
|
-
include_context 'payouts'
|
5
|
-
|
6
|
-
def check_type_and_status(payout, check_status = true)
|
7
|
-
expect(payout['Type']).to eq('PAYOUT')
|
8
|
-
expect(payout['Nature']).to eq('REGULAR')
|
9
|
-
expect(payout['PaymentType']).to eq('BANK_WIRE')
|
10
|
-
|
11
|
-
# linked to correct bank account
|
12
|
-
expect(payout['BankAccountId']).to eq(new_bank_account['Id'])
|
13
|
-
|
14
|
-
if (check_status)
|
15
|
-
# not SUCCEEDED yet: waiting for processing
|
16
|
-
expect(payout['ExecutionDate']).to be_nil
|
17
|
-
expect(payout['Status']).to eq('CREATED')
|
18
|
-
expect(payout['ResultCode']).to be_nil
|
19
|
-
expect(payout['ResultMessage']).to be_nil
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe 'CREATE' do
|
24
|
-
|
25
|
-
it 'creates a bank wire payout' do
|
26
|
-
payin = new_payin_card_direct # this payin is successfull so payout may happen
|
27
|
-
payout = create_new_payout_bankwire(payin)
|
28
|
-
expect(payout['Id']).not_to be_nil
|
29
|
-
check_type_and_status(payout)
|
30
|
-
expect(payout['DebitedWalletId']).to eq(payin['CreditedWalletId'])
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'fails if not enough money' do
|
34
|
-
payin = new_payin_card_web # this payin is NOT processed yet so payout may NOT happen
|
35
|
-
payout = create_new_payout_bankwire(payin)
|
36
|
-
check_type_and_status(payout, false)
|
37
|
-
expect(payout['Status']).to eq('FAILED')
|
38
|
-
expect(payout['ResultCode']).to eq('001001')
|
39
|
-
expect(payout['ResultMessage']).to eq('Unsufficient wallet balance')
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe 'FETCH' do
|
44
|
-
it 'fetches a payout' do
|
45
|
-
created = new_payout_bankwire
|
46
|
-
fetched = MangoPay::PayOut.fetch(created['Id'])
|
47
|
-
expect(fetched['Id']).to eq(created['Id'])
|
48
|
-
expect(fetched['CreationDate']).to eq(created['CreationDate'])
|
49
|
-
check_type_and_status(created)
|
50
|
-
check_type_and_status(fetched)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
1
|
+
describe MangoPay::PayOut::BankWire, type: :feature do
|
2
|
+
include_context 'bank_accounts'
|
3
|
+
include_context 'payins'
|
4
|
+
include_context 'payouts'
|
5
|
+
|
6
|
+
def check_type_and_status(payout, check_status = true)
|
7
|
+
expect(payout['Type']).to eq('PAYOUT')
|
8
|
+
expect(payout['Nature']).to eq('REGULAR')
|
9
|
+
expect(payout['PaymentType']).to eq('BANK_WIRE')
|
10
|
+
|
11
|
+
# linked to correct bank account
|
12
|
+
expect(payout['BankAccountId']).to eq(new_bank_account['Id'])
|
13
|
+
|
14
|
+
if (check_status)
|
15
|
+
# not SUCCEEDED yet: waiting for processing
|
16
|
+
expect(payout['ExecutionDate']).to be_nil
|
17
|
+
expect(payout['Status']).to eq('CREATED')
|
18
|
+
expect(payout['ResultCode']).to be_nil
|
19
|
+
expect(payout['ResultMessage']).to be_nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'CREATE' do
|
24
|
+
|
25
|
+
it 'creates a bank wire payout' do
|
26
|
+
payin = new_payin_card_direct # this payin is successfull so payout may happen
|
27
|
+
payout = create_new_payout_bankwire(payin)
|
28
|
+
expect(payout['Id']).not_to be_nil
|
29
|
+
check_type_and_status(payout)
|
30
|
+
expect(payout['DebitedWalletId']).to eq(payin['CreditedWalletId'])
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'fails if not enough money' do
|
34
|
+
payin = new_payin_card_web # this payin is NOT processed yet so payout may NOT happen
|
35
|
+
payout = create_new_payout_bankwire(payin)
|
36
|
+
check_type_and_status(payout, false)
|
37
|
+
expect(payout['Status']).to eq('FAILED')
|
38
|
+
expect(payout['ResultCode']).to eq('001001')
|
39
|
+
expect(payout['ResultMessage']).to eq('Unsufficient wallet balance')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'FETCH' do
|
44
|
+
it 'fetches a payout' do
|
45
|
+
created = new_payout_bankwire
|
46
|
+
fetched = MangoPay::PayOut.fetch(created['Id'])
|
47
|
+
expect(fetched['Id']).to eq(created['Id'])
|
48
|
+
expect(fetched['CreationDate']).to eq(created['CreationDate'])
|
49
|
+
check_type_and_status(created)
|
50
|
+
check_type_and_status(fetched)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|