mangopay4-ruby-sdk 3.44.0
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 +7 -0
- data/.github/workflows/ruby_cd.yml +34 -0
- data/.github/workflows/ruby_ci.yml +30 -0
- data/.gitignore +30 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +640 -0
- data/Gemfile +2 -0
- data/LICENSE +20 -0
- data/README.md +162 -0
- data/Rakefile +5 -0
- data/bin/mangopay +9 -0
- data/lib/generators/mangopay/install_generator.rb +60 -0
- data/lib/generators/templates/mangopay.rb.erb +5 -0
- data/lib/mangopay/acquiring.rb +56 -0
- data/lib/mangopay/authorization_token.rb +89 -0
- data/lib/mangopay/bank_account.rb +49 -0
- data/lib/mangopay/bankingaliases.rb +29 -0
- data/lib/mangopay/bankingaliases_iban.rb +16 -0
- data/lib/mangopay/card.rb +54 -0
- data/lib/mangopay/card_registration.rb +9 -0
- data/lib/mangopay/client.rb +94 -0
- data/lib/mangopay/conversion.rb +49 -0
- data/lib/mangopay/deposit.rb +36 -0
- data/lib/mangopay/dispute.rb +152 -0
- data/lib/mangopay/errors.rb +66 -0
- data/lib/mangopay/event.rb +18 -0
- data/lib/mangopay/filter_parameters.rb +56 -0
- data/lib/mangopay/hook.rb +9 -0
- data/lib/mangopay/http_calls.rb +88 -0
- data/lib/mangopay/identity_verification.rb +16 -0
- data/lib/mangopay/json.rb +14 -0
- data/lib/mangopay/kyc_document.rb +83 -0
- data/lib/mangopay/legal_user.rb +21 -0
- data/lib/mangopay/legal_user_sca.rb +25 -0
- data/lib/mangopay/mandate.rb +42 -0
- data/lib/mangopay/natural_user.rb +20 -0
- data/lib/mangopay/natural_user_sca.rb +25 -0
- data/lib/mangopay/pay_in.rb +415 -0
- data/lib/mangopay/pay_out.rb +41 -0
- data/lib/mangopay/payment_method_metadata.rb +13 -0
- data/lib/mangopay/pre_authorization.rb +17 -0
- data/lib/mangopay/recipient.rb +35 -0
- data/lib/mangopay/refund.rb +19 -0
- data/lib/mangopay/regulatory.rb +22 -0
- data/lib/mangopay/report.rb +24 -0
- data/lib/mangopay/report_v2.rb +21 -0
- data/lib/mangopay/resource.rb +21 -0
- data/lib/mangopay/settlement.rb +21 -0
- data/lib/mangopay/transaction.rb +24 -0
- data/lib/mangopay/transfer.rb +20 -0
- data/lib/mangopay/ubo.rb +26 -0
- data/lib/mangopay/ubo_declaration.rb +32 -0
- data/lib/mangopay/user.rb +100 -0
- data/lib/mangopay/version.rb +3 -0
- data/lib/mangopay/virtual_account.rb +44 -0
- data/lib/mangopay/wallet.rb +17 -0
- data/lib/mangopay.rb +456 -0
- data/mangopay.gemspec +30 -0
- data/spec/mangopay/acquiring_spec.rb +176 -0
- data/spec/mangopay/authorization_token_spec.rb +70 -0
- data/spec/mangopay/bank_account_spec.rb +105 -0
- data/spec/mangopay/bankingaliases_spec.rb +29 -0
- data/spec/mangopay/card_registration_spec.rb +123 -0
- data/spec/mangopay/client_spec.png +0 -0
- data/spec/mangopay/client_spec.rb +213 -0
- data/spec/mangopay/configuration_spec.rb +249 -0
- data/spec/mangopay/conversion_spec.rb +96 -0
- data/spec/mangopay/deposit_spec.rb +107 -0
- data/spec/mangopay/dispute_spec.png +0 -0
- data/spec/mangopay/dispute_spec.rb +294 -0
- data/spec/mangopay/event_spec.rb +33 -0
- data/spec/mangopay/fetch_filters_spec.rb +63 -0
- data/spec/mangopay/hook_spec.rb +37 -0
- data/spec/mangopay/idempotency_spec.rb +41 -0
- data/spec/mangopay/identity_verification_spec.rb +47 -0
- data/spec/mangopay/kyc_document_spec.png +0 -0
- data/spec/mangopay/kyc_document_spec.rb +118 -0
- data/spec/mangopay/log_requests_filter_spec.rb +26 -0
- data/spec/mangopay/mandate_spec.rb +99 -0
- data/spec/mangopay/payin_applepay_direct_spec.rb +21 -0
- data/spec/mangopay/payin_bancontact_web_spec.rb +30 -0
- data/spec/mangopay/payin_bankwire_direct_spec.rb +74 -0
- data/spec/mangopay/payin_bankwire_external_instruction_spec.rb +104 -0
- data/spec/mangopay/payin_bizum_web_spec.rb +54 -0
- data/spec/mangopay/payin_blik_web_spec.rb +41 -0
- data/spec/mangopay/payin_card_direct_spec.rb +69 -0
- data/spec/mangopay/payin_card_web_spec.rb +64 -0
- data/spec/mangopay/payin_directdebit_direct_spec.rb +37 -0
- data/spec/mangopay/payin_directdebit_web_spec.rb +38 -0
- data/spec/mangopay/payin_giropay_web_spec.rb +30 -0
- data/spec/mangopay/payin_googlepay_direct_spec.rb +21 -0
- data/spec/mangopay/payin_ideal_web_spec.rb +30 -0
- data/spec/mangopay/payin_intent_spec.rb +151 -0
- data/spec/mangopay/payin_klarna_web_spec.rb +32 -0
- data/spec/mangopay/payin_mbway_web_spec.rb +32 -0
- data/spec/mangopay/payin_multibanco_web_spec.rb +31 -0
- data/spec/mangopay/payin_paybybank_web_spec.rb +56 -0
- data/spec/mangopay/payin_payconiq_web_spec.rb +31 -0
- data/spec/mangopay/payin_paypal_web_spec.rb +113 -0
- data/spec/mangopay/payin_preauthorized_direct_spec.rb +118 -0
- data/spec/mangopay/payin_satispay_web_spec.rb +32 -0
- data/spec/mangopay/payin_swish_web_spec.rb +30 -0
- data/spec/mangopay/payin_twint_web_spec.rb +30 -0
- data/spec/mangopay/payment_method_metadata_spec.rb +15 -0
- data/spec/mangopay/payout_bankwire_spec.rb +93 -0
- data/spec/mangopay/preauthorization_spec.rb +51 -0
- data/spec/mangopay/recipient_spec.rb +134 -0
- data/spec/mangopay/recurring_payin_spec.rb +222 -0
- data/spec/mangopay/refund_spec.rb +34 -0
- data/spec/mangopay/regulatory_spec.rb +26 -0
- data/spec/mangopay/report_spec.rb +40 -0
- data/spec/mangopay/report_v2_spec.rb +117 -0
- data/spec/mangopay/report_wallets_spec.rb +40 -0
- data/spec/mangopay/settlement_sample.csv +8 -0
- data/spec/mangopay/settlement_spec.rb +38 -0
- data/spec/mangopay/shared_resources.rb +1380 -0
- data/spec/mangopay/transaction_spec.rb +59 -0
- data/spec/mangopay/transfer_spec.rb +77 -0
- data/spec/mangopay/ubo_declaration_spec.rb +44 -0
- data/spec/mangopay/ubo_spec.rb +39 -0
- data/spec/mangopay/user_spec.rb +444 -0
- data/spec/mangopay/virtual_account_spec.rb +52 -0
- data/spec/mangopay/wallet_spec.rb +100 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/tmp/.keep +0 -0
- metadata +280 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
describe MangoPay::PayIn::Swish::Web, 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('SWISH')
|
|
9
|
+
expect(payin['ExecutionType']).to eq('WEB')
|
|
10
|
+
expect(payin['Status']).to eq('CREATED')
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe 'CREATE' do
|
|
14
|
+
it 'creates a swish web payin' do
|
|
15
|
+
created = new_payin_swish_web
|
|
16
|
+
expect(created['Id']).not_to be_nil
|
|
17
|
+
check_type_and_status(created)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe 'FETCH' do
|
|
22
|
+
it 'fetches a payin' do
|
|
23
|
+
created = new_payin_swish_web
|
|
24
|
+
fetched = MangoPay::PayIn.fetch(created['Id'])
|
|
25
|
+
expect(fetched['Id']).to eq(created['Id'])
|
|
26
|
+
check_type_and_status(created)
|
|
27
|
+
check_type_and_status(fetched)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
describe MangoPay::PayIn::Twint::Web, 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('TWINT')
|
|
9
|
+
expect(payin['ExecutionType']).to eq('WEB')
|
|
10
|
+
expect(payin['Status']).to eq('CREATED')
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe 'CREATE' do
|
|
14
|
+
it 'creates a twint web payin' do
|
|
15
|
+
created = new_payin_twint_web
|
|
16
|
+
expect(created['Id']).not_to be_nil
|
|
17
|
+
check_type_and_status(created)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe 'FETCH' do
|
|
22
|
+
it 'fetches a payin' do
|
|
23
|
+
created = new_payin_twint_web
|
|
24
|
+
fetched = MangoPay::PayIn.fetch(created['Id'])
|
|
25
|
+
expect(fetched['Id']).to eq(created['Id'])
|
|
26
|
+
check_type_and_status(created)
|
|
27
|
+
check_type_and_status(fetched)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
describe MangoPay::PaymentMethodMetadata, type: :feature do
|
|
2
|
+
include_context 'payment_method_metadata'
|
|
3
|
+
|
|
4
|
+
describe 'GET PAYMENT METHOD METADATA' do
|
|
5
|
+
it 'gets a new payment method metadata' do
|
|
6
|
+
metadata = get_payment_method_metadata
|
|
7
|
+
|
|
8
|
+
expect(metadata).not_to be_nil
|
|
9
|
+
expect(metadata['IssuerCountryCode']).not_to be_nil
|
|
10
|
+
expect(metadata['IssuingBank']).not_to be_nil
|
|
11
|
+
expect(metadata['BinData']).not_to be_nil
|
|
12
|
+
expect(metadata['BinData'][0]['CardType']).not_to be_nil
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
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, 100)
|
|
36
|
+
sleep(2)
|
|
37
|
+
fetched = MangoPay::PayOut::BankWire.get_bankwire(payout['Id'])
|
|
38
|
+
check_type_and_status(payout, true)
|
|
39
|
+
expect(fetched['Status']).to eq('FAILED')
|
|
40
|
+
expect(fetched['ResultCode']).to eq('002998')
|
|
41
|
+
# expect(fetched['ResultMessage']).to eq('Unsufficient wallet balance')
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe 'Get Bankwire' do
|
|
46
|
+
it 'gets a bankwire' do
|
|
47
|
+
created = new_payout_bankwire
|
|
48
|
+
fetched = MangoPay::PayOut::BankWire.get_bankwire(created['Id'])
|
|
49
|
+
expect(fetched['Id']).to eq(created['Id'])
|
|
50
|
+
expect(fetched['CreationDate']).to eq(created['CreationDate'])
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe 'Check Eligibility' do
|
|
55
|
+
it 'checks the eligibility of a payout' do
|
|
56
|
+
created = new_payout_bankwire
|
|
57
|
+
|
|
58
|
+
eligibility = MangoPay::PayOut::InstantPayoutEligibility::Reachability.create(
|
|
59
|
+
AuthorId: created['AuthorId'],
|
|
60
|
+
DebitedFunds: {
|
|
61
|
+
Amount: 10,
|
|
62
|
+
Currency: 'EUR'
|
|
63
|
+
},
|
|
64
|
+
PayoutModeRequested: 'INSTANT_PAYMENT',
|
|
65
|
+
BankAccountId: created['BankAccountId'],
|
|
66
|
+
DebitedWalletId: created['DebitedWalletId']
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
expect(created).not_to be_nil
|
|
70
|
+
expect(eligibility).not_to be_nil
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
describe 'FETCH' do
|
|
75
|
+
it 'fetches a payout' do
|
|
76
|
+
created = new_payout_bankwire
|
|
77
|
+
fetched = MangoPay::PayOut.fetch(created['Id'])
|
|
78
|
+
expect(fetched['Id']).to eq(created['Id'])
|
|
79
|
+
expect(fetched['CreationDate']).to eq(created['CreationDate'])
|
|
80
|
+
check_type_and_status(created)
|
|
81
|
+
check_type_and_status(fetched)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
describe 'GET Refunds' do
|
|
86
|
+
it "fetches the pay-out's refunds" do
|
|
87
|
+
payout = new_payout_bankwire
|
|
88
|
+
refunds = MangoPay::PayOut.refunds(payout['Id'])
|
|
89
|
+
expect(refunds).to be_an(Array)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
describe MangoPay::PreAuthorization do
|
|
2
|
+
include_context 'users'
|
|
3
|
+
include_context 'payins'
|
|
4
|
+
|
|
5
|
+
describe 'CREATE' do
|
|
6
|
+
it 'creates a new card pre-authorization' do
|
|
7
|
+
cardreg = new_card_registration_completed
|
|
8
|
+
created = new_card_preauthorization
|
|
9
|
+
expect(created['Id']).not_to be_nil
|
|
10
|
+
expect(created['CardId']).to eq(cardreg['CardId'])
|
|
11
|
+
expect(created['AuthorId']).to eq(new_natural_user["Id"])
|
|
12
|
+
expect(created['PayInId']).to be_nil
|
|
13
|
+
expect(created['Status']).to eq('SUCCEEDED')
|
|
14
|
+
expect(created['PaymentStatus']).to eq('WAITING')
|
|
15
|
+
expect(created['PaymentType']).to eq('CARD')
|
|
16
|
+
expect(created['ExecutionType']).to eq('DIRECT')
|
|
17
|
+
# expect(created['Requested3DSVersion']).to eq('V2_1')
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe 'UPDATE' do
|
|
22
|
+
it 'updates a card pre-authorization' do
|
|
23
|
+
created = new_card_preauthorization
|
|
24
|
+
updated = MangoPay::PreAuthorization.update(created['Id'] ,{
|
|
25
|
+
PaymentStatus: 'CANCELED'
|
|
26
|
+
})
|
|
27
|
+
expect(updated['PaymentStatus']).to eq('CANCELED')
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe 'FETCH' do
|
|
32
|
+
it 'fetches a card pre-authorization' do
|
|
33
|
+
created = new_card_preauthorization
|
|
34
|
+
fetched = MangoPay::PreAuthorization.fetch(created['Id'])
|
|
35
|
+
expect(fetched['Id']).to eq(created['Id'])
|
|
36
|
+
expect(fetched['CardId']).to eq(created['CardId'])
|
|
37
|
+
expect(fetched['AuthorId']).to eq(created['AuthorId'])
|
|
38
|
+
expect(fetched['Tag']).to eq(created['Tag'])
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe 'FETCH FOR CARD' do
|
|
43
|
+
it "fetches a card's pre-authorizations" do
|
|
44
|
+
created = new_card_preauthorization
|
|
45
|
+
fetched = MangoPay::Card.get_pre_authorizations(created['CardId'])
|
|
46
|
+
|
|
47
|
+
expect(fetched).to be_an(Array)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
describe MangoPay::Recipient do
|
|
2
|
+
include_context 'recipient'
|
|
3
|
+
|
|
4
|
+
describe 'CREATE' do
|
|
5
|
+
it 'creates a new recipient' do
|
|
6
|
+
recipient = new_recipient
|
|
7
|
+
assert_recipient(recipient)
|
|
8
|
+
expect(recipient['Status']).to eq('PENDING')
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe 'GET' do
|
|
13
|
+
it 'fetches a recipient' do
|
|
14
|
+
recipient = new_recipient
|
|
15
|
+
fetched = MangoPay::Recipient.get(recipient['Id'])
|
|
16
|
+
assert_recipient(fetched)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe 'GET User Recipients' do
|
|
21
|
+
it 'fetches recipients without query param' do
|
|
22
|
+
john = create_new_natural_user_sca_owner
|
|
23
|
+
create_new_recipient(john['Id'])
|
|
24
|
+
fetched = MangoPay::Recipient.get_user_recipients(john['Id'])
|
|
25
|
+
expect(fetched).not_to be_nil
|
|
26
|
+
expect(fetched).to be_kind_of(Array)
|
|
27
|
+
expect(fetched).not_to be_empty
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'fetches recipients with scope PAYOUT' do
|
|
31
|
+
john = create_new_natural_user_sca_owner
|
|
32
|
+
create_new_recipient(john['Id'])
|
|
33
|
+
fetched = MangoPay::Recipient.get_user_recipients(john['Id'], {RecipientScope: "PAYOUT"})
|
|
34
|
+
expect(fetched).not_to be_nil
|
|
35
|
+
expect(fetched).to be_kind_of(Array)
|
|
36
|
+
expect(fetched).not_to be_empty
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'fetches recipients with scope PAYIN' do
|
|
40
|
+
john = create_new_natural_user_sca_owner
|
|
41
|
+
create_new_recipient(john['Id'])
|
|
42
|
+
fetched = MangoPay::Recipient.get_user_recipients(john['Id'], {RecipientScope: "PAYIN"})
|
|
43
|
+
expect(fetched).not_to be_nil
|
|
44
|
+
expect(fetched).to be_kind_of(Array)
|
|
45
|
+
expect(fetched).to be_empty
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe 'GET Schema' do
|
|
50
|
+
it 'fetches schema for LocalBankTransfer, Individual' do
|
|
51
|
+
schema = MangoPay::Recipient.get_schema('LocalBankTransfer', 'Individual', 'GBP', 'GB')
|
|
52
|
+
expect(schema).not_to be_nil
|
|
53
|
+
expect(schema['DisplayName']).not_to be_nil
|
|
54
|
+
expect(schema['Currency']).not_to be_nil
|
|
55
|
+
expect(schema['RecipientType']).not_to be_nil
|
|
56
|
+
expect(schema['PayoutMethodType']).not_to be_nil
|
|
57
|
+
expect(schema['RecipientScope']).not_to be_nil
|
|
58
|
+
expect(schema['Tag']).not_to be_nil
|
|
59
|
+
expect(schema['IndividualRecipient']).not_to be_nil
|
|
60
|
+
expect(schema['LocalBankTransfer']).not_to be_nil
|
|
61
|
+
expect(schema['BusinessRecipient']).to be_nil
|
|
62
|
+
expect(schema['InternationalBankTransfer']).to be_nil
|
|
63
|
+
expect(schema['Country']).not_to be_nil
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it 'fetches schema for InternationalBankTransfer, Business' do
|
|
67
|
+
schema = MangoPay::Recipient.get_schema('InternationalBankTransfer', 'Business', 'GBP', 'GB')
|
|
68
|
+
expect(schema).not_to be_nil
|
|
69
|
+
expect(schema['DisplayName']).not_to be_nil
|
|
70
|
+
expect(schema['Currency']).not_to be_nil
|
|
71
|
+
expect(schema['RecipientType']).not_to be_nil
|
|
72
|
+
expect(schema['PayoutMethodType']).not_to be_nil
|
|
73
|
+
expect(schema['RecipientScope']).not_to be_nil
|
|
74
|
+
expect(schema['Tag']).not_to be_nil
|
|
75
|
+
expect(schema['BusinessRecipient']).not_to be_nil
|
|
76
|
+
expect(schema['InternationalBankTransfer']).not_to be_nil
|
|
77
|
+
expect(schema['IndividualRecipient']).to be_nil
|
|
78
|
+
expect(schema['LocalBankTransfer']).to be_nil
|
|
79
|
+
expect(schema['Country']).not_to be_nil
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
describe 'GET Payout Methods' do
|
|
84
|
+
it 'fetches payout methods' do
|
|
85
|
+
payout_methods = MangoPay::Recipient.get_payout_methods('DE', 'EUR')
|
|
86
|
+
expect(payout_methods).not_to be_nil
|
|
87
|
+
expect(payout_methods['AvailablePayoutMethods']).to be_kind_of(Array)
|
|
88
|
+
expect(payout_methods['AvailablePayoutMethods']).not_to be_empty
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
describe 'VALIDATE' do
|
|
93
|
+
it 'validates a recipient' do
|
|
94
|
+
recipient = define_new_recipient
|
|
95
|
+
john = create_new_natural_user_sca_owner
|
|
96
|
+
# it should pass
|
|
97
|
+
MangoPay::Recipient.validate(recipient, john['Id'])
|
|
98
|
+
|
|
99
|
+
# it should throw error
|
|
100
|
+
recipient['Currency'] = nil
|
|
101
|
+
expect { MangoPay::Recipient.validate(recipient, john['Id']) }.to raise_error { |err|
|
|
102
|
+
expect(err).to be_a MangoPay::ResponseError
|
|
103
|
+
expect(err.code).to eq '400'
|
|
104
|
+
expect(err.type).to eq 'param_error'
|
|
105
|
+
}
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
describe 'DEACTIVATE' do
|
|
110
|
+
it 'deactivates a recipient' do
|
|
111
|
+
pending("a recipient needs to be manually activated before running the test")
|
|
112
|
+
john = create_new_natural_user_sca_owner
|
|
113
|
+
recipient = create_new_recipient(john['Id'])
|
|
114
|
+
deactivated = MangoPay::Recipient.deactivate(recipient['Id'])
|
|
115
|
+
fetched = MangoPay::Recipient.get(recipient['Id'])
|
|
116
|
+
expect(deactivated['Status']).to eq('DEACTIVATED')
|
|
117
|
+
expect(fetched['Status']).to eq('DEACTIVATED')
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def assert_recipient(recipient)
|
|
124
|
+
expect(recipient).not_to be_nil
|
|
125
|
+
expect(recipient['Status']).not_to be_nil
|
|
126
|
+
expect(recipient['DisplayName']).not_to be_nil
|
|
127
|
+
expect(recipient['PayoutMethodType']).not_to be_nil
|
|
128
|
+
expect(recipient['RecipientType']).not_to be_nil
|
|
129
|
+
expect(recipient['IndividualRecipient']).not_to be_nil
|
|
130
|
+
expect(recipient['LocalBankTransfer']).not_to be_nil
|
|
131
|
+
expect(recipient['RecipientScope']).not_to be_nil
|
|
132
|
+
expect(recipient['UserId']).not_to be_nil
|
|
133
|
+
expect(recipient['Country']).not_to be_nil
|
|
134
|
+
end
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
describe MangoPay::PayIn::RecurringPayments, type: :feature do
|
|
2
|
+
include_context 'wallets'
|
|
3
|
+
include_context 'users'
|
|
4
|
+
include_context 'payins'
|
|
5
|
+
|
|
6
|
+
describe 'CREATE' do
|
|
7
|
+
it 'creates a recurring payment' do
|
|
8
|
+
cardreg = new_card_registration_completed
|
|
9
|
+
wallet = new_wallet
|
|
10
|
+
recurring = MangoPay::PayIn::RecurringPayments::Recurring.create(
|
|
11
|
+
AuthorId: new_natural_user['Id'],
|
|
12
|
+
CardId: cardreg['CardId'],
|
|
13
|
+
CreditedUserId: wallet['Owners'][0],
|
|
14
|
+
CreditedWalletId: wallet['Id'],
|
|
15
|
+
FirstTransactionDebitedFunds: {Currency: 'EUR', Amount: 10},
|
|
16
|
+
FirstTransactionFees: {Currency: 'EUR', Amount: 1},
|
|
17
|
+
Billing: {
|
|
18
|
+
Address: {
|
|
19
|
+
AddressLine1: 'AddressLine1',
|
|
20
|
+
AddressLine2: 'AddressLine2',
|
|
21
|
+
City: 'City',
|
|
22
|
+
Region: 'Region',
|
|
23
|
+
PostalCode: 'PostalCode',
|
|
24
|
+
Country: 'FR'
|
|
25
|
+
},
|
|
26
|
+
FirstName: 'Joe',
|
|
27
|
+
LastName: 'Blogs'
|
|
28
|
+
},
|
|
29
|
+
Shipping: {
|
|
30
|
+
Address: {
|
|
31
|
+
AddressLine1: 'AddressLine1',
|
|
32
|
+
AddressLine2: 'AddressLine2',
|
|
33
|
+
City: 'City',
|
|
34
|
+
Region: 'Region',
|
|
35
|
+
PostalCode: 'PostalCode',
|
|
36
|
+
Country: 'FR'
|
|
37
|
+
},
|
|
38
|
+
FirstName: 'Joe',
|
|
39
|
+
LastName: 'Blogs'
|
|
40
|
+
},
|
|
41
|
+
FreeCycles: 0
|
|
42
|
+
)
|
|
43
|
+
expect(recurring).not_to be_nil
|
|
44
|
+
expect(recurring['Status']).not_to be_nil
|
|
45
|
+
expect(recurring['Id']).not_to be_nil
|
|
46
|
+
expect(recurring['FreeCycles']).not_to be_nil
|
|
47
|
+
|
|
48
|
+
id = recurring['Id']
|
|
49
|
+
|
|
50
|
+
get = MangoPay::PayIn::RecurringPayments::Recurring.fetch(id)
|
|
51
|
+
expect(get).not_to be_nil
|
|
52
|
+
expect(get['FreeCycles']).not_to be_nil
|
|
53
|
+
|
|
54
|
+
cit = MangoPay::PayIn::RecurringPayments::CIT.create(
|
|
55
|
+
RecurringPayinRegistrationId: recurring['Id'],
|
|
56
|
+
IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C",
|
|
57
|
+
SecureModeReturnURL: "http://www.my-site.com/returnurl",
|
|
58
|
+
StatementDescriptor: "lorem",
|
|
59
|
+
Tag: "custom meta",
|
|
60
|
+
BrowserInfo: {
|
|
61
|
+
AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
|
|
62
|
+
JavaEnabled: true,
|
|
63
|
+
Language: "FR-FR",
|
|
64
|
+
ColorDepth: 4,
|
|
65
|
+
ScreenHeight: 1800,
|
|
66
|
+
ScreenWidth: 400,
|
|
67
|
+
JavascriptEnabled: true,
|
|
68
|
+
TimeZoneOffset: "+60",
|
|
69
|
+
UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
expect(cit).not_to be_nil
|
|
74
|
+
|
|
75
|
+
update = MangoPay::PayIn::RecurringPayments::Recurring.update(id, {
|
|
76
|
+
Status: 'ENDED'
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
expect(update).not_to be_nil
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it 'creates a recurring paypal payment CIT' do
|
|
83
|
+
wallet = new_wallet
|
|
84
|
+
recurring = MangoPay::PayIn::RecurringPayments::Recurring.create(
|
|
85
|
+
AuthorId: new_natural_user['Id'],
|
|
86
|
+
CreditedUserId: wallet['Owners'][0],
|
|
87
|
+
CreditedWalletId: wallet['Id'],
|
|
88
|
+
FirstTransactionDebitedFunds: {Currency: 'EUR', Amount: 1000},
|
|
89
|
+
FirstTransactionFees: {Currency: 'EUR', Amount: 0},
|
|
90
|
+
Billing: {
|
|
91
|
+
Address: {
|
|
92
|
+
AddressLine1: 'AddressLine1',
|
|
93
|
+
AddressLine2: 'AddressLine2',
|
|
94
|
+
City: 'City',
|
|
95
|
+
Region: 'Region',
|
|
96
|
+
PostalCode: 'PostalCode',
|
|
97
|
+
Country: 'FR'
|
|
98
|
+
},
|
|
99
|
+
FirstName: 'Joe',
|
|
100
|
+
LastName: 'Blogs'
|
|
101
|
+
},
|
|
102
|
+
Shipping: {
|
|
103
|
+
Address: {
|
|
104
|
+
AddressLine1: 'AddressLine1',
|
|
105
|
+
AddressLine2: 'AddressLine2',
|
|
106
|
+
City: 'City',
|
|
107
|
+
Region: 'Region',
|
|
108
|
+
PostalCode: 'PostalCode',
|
|
109
|
+
Country: 'FR'
|
|
110
|
+
},
|
|
111
|
+
FirstName: 'Joe',
|
|
112
|
+
LastName: 'Blogs'
|
|
113
|
+
},
|
|
114
|
+
PaymentType: 'PAYPAL'
|
|
115
|
+
)
|
|
116
|
+
expect(recurring).not_to be_nil
|
|
117
|
+
expect(recurring['Status']).not_to be_nil
|
|
118
|
+
expect(recurring['Id']).not_to be_nil
|
|
119
|
+
|
|
120
|
+
cit = MangoPay::PayIn::RecurringPayments::PayPalCIT.create(
|
|
121
|
+
{
|
|
122
|
+
"ReturnURL": "http://example.com",
|
|
123
|
+
"CancelURL": "http://example.net",
|
|
124
|
+
"LineItems": [
|
|
125
|
+
{
|
|
126
|
+
"Name": "Running shoes",
|
|
127
|
+
"Quantity": 1,
|
|
128
|
+
"UnitAmount": 1000,
|
|
129
|
+
"TaxAmount": 0,
|
|
130
|
+
"Description": "ID of Seller 1",
|
|
131
|
+
"Category": "PHYSICAL_GOODS"
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
"Tag": "Created using the Mangopay API Postman collection",
|
|
135
|
+
"RecurringPayinRegistrationId": recurring['Id'],
|
|
136
|
+
"ShippingPreference": "SET_PROVIDED_ADDRESS",
|
|
137
|
+
"Reference": "abcd-efgh-ijkl",
|
|
138
|
+
"StatementDescriptor": "Example123"
|
|
139
|
+
}
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
expect(cit).not_to be_nil
|
|
143
|
+
# expect(cit['Status']).to eq('CREATED')
|
|
144
|
+
expect(cit['PaymentType']).to eq('PAYPAL')
|
|
145
|
+
expect(cit['ExecutionType']).to eq('WEB')
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
it 'creates a recurring paypal payment MIT' do
|
|
149
|
+
wallet = new_wallet
|
|
150
|
+
recurring = MangoPay::PayIn::RecurringPayments::Recurring.create(
|
|
151
|
+
AuthorId: new_natural_user['Id'],
|
|
152
|
+
CreditedUserId: wallet['Owners'][0],
|
|
153
|
+
CreditedWalletId: wallet['Id'],
|
|
154
|
+
FirstTransactionDebitedFunds: {Currency: 'EUR', Amount: 1000},
|
|
155
|
+
FirstTransactionFees: {Currency: 'EUR', Amount: 0},
|
|
156
|
+
Billing: {
|
|
157
|
+
Address: {
|
|
158
|
+
AddressLine1: 'AddressLine1',
|
|
159
|
+
AddressLine2: 'AddressLine2',
|
|
160
|
+
City: 'City',
|
|
161
|
+
Region: 'Region',
|
|
162
|
+
PostalCode: 'PostalCode',
|
|
163
|
+
Country: 'FR'
|
|
164
|
+
},
|
|
165
|
+
FirstName: 'Joe',
|
|
166
|
+
LastName: 'Blogs'
|
|
167
|
+
},
|
|
168
|
+
Shipping: {
|
|
169
|
+
Address: {
|
|
170
|
+
AddressLine1: 'AddressLine1',
|
|
171
|
+
AddressLine2: 'AddressLine2',
|
|
172
|
+
City: 'City',
|
|
173
|
+
Region: 'Region',
|
|
174
|
+
PostalCode: 'PostalCode',
|
|
175
|
+
Country: 'FR'
|
|
176
|
+
},
|
|
177
|
+
FirstName: 'Joe',
|
|
178
|
+
LastName: 'Blogs'
|
|
179
|
+
},
|
|
180
|
+
PaymentType: 'PAYPAL'
|
|
181
|
+
)
|
|
182
|
+
expect(recurring).not_to be_nil
|
|
183
|
+
expect(recurring['Status']).not_to be_nil
|
|
184
|
+
expect(recurring['Id']).not_to be_nil
|
|
185
|
+
|
|
186
|
+
cit = MangoPay::PayIn::RecurringPayments::PayPalMIT.create(
|
|
187
|
+
{
|
|
188
|
+
"ReturnURL": "http://example.com",
|
|
189
|
+
"CancelURL": "http://example.net",
|
|
190
|
+
"LineItems": [
|
|
191
|
+
{
|
|
192
|
+
"Name": "Running shoes",
|
|
193
|
+
"Quantity": 1,
|
|
194
|
+
"UnitAmount": 1000,
|
|
195
|
+
"TaxAmount": 0,
|
|
196
|
+
"Description": "ID of Seller 1",
|
|
197
|
+
"Category": "PHYSICAL_GOODS"
|
|
198
|
+
}
|
|
199
|
+
],
|
|
200
|
+
"Tag": "Created using the Mangopay API Postman collection",
|
|
201
|
+
"RecurringPayinRegistrationId": recurring['Id'],
|
|
202
|
+
"ShippingPreference": "SET_PROVIDED_ADDRESS",
|
|
203
|
+
"Reference": "abcd-efgh-ijkl",
|
|
204
|
+
"StatementDescriptor": "Example123",
|
|
205
|
+
"DebitedFunds": {
|
|
206
|
+
"Currency": "EUR",
|
|
207
|
+
"Amount": 1000
|
|
208
|
+
},
|
|
209
|
+
"Fees": {
|
|
210
|
+
"Currency": "EUR",
|
|
211
|
+
"Amount": 0
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
expect(cit).not_to be_nil
|
|
217
|
+
# expect(cit['Status']).to eq('CREATED')
|
|
218
|
+
expect(cit['PaymentType']).to eq('PAYPAL')
|
|
219
|
+
expect(cit['ExecutionType']).to eq('WEB')
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
describe MangoPay::Refund do
|
|
2
|
+
include_context 'transfers'
|
|
3
|
+
|
|
4
|
+
describe 'FETCH' do
|
|
5
|
+
it 'fetches a refund' do
|
|
6
|
+
transfer = new_transfer
|
|
7
|
+
resource = MangoPay::Transfer.refund(transfer['Id'], { AuthorId: transfer['AuthorId'] })
|
|
8
|
+
|
|
9
|
+
refund = MangoPay::Refund.fetch(resource['Id'])
|
|
10
|
+
|
|
11
|
+
expect(refund['Id']).not_to be_nil
|
|
12
|
+
expect(refund['Status']).to eq('SUCCEEDED')
|
|
13
|
+
expect(refund['Type']).to eq('TRANSFER')
|
|
14
|
+
expect(refund['Nature']).to eq('REFUND')
|
|
15
|
+
expect(refund['InitialTransactionType']).to eq('TRANSFER')
|
|
16
|
+
expect(refund['InitialTransactionId']).to eq(transfer['Id'])
|
|
17
|
+
expect(refund['DebitedWalletId']).to eq(transfer['CreditedWalletId'])
|
|
18
|
+
expect(refund['CreditedWalletId']).to eq(transfer['DebitedWalletId'])
|
|
19
|
+
end
|
|
20
|
+
end
|
|
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
|
|
34
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
describe MangoPay::Regulatory do
|
|
2
|
+
|
|
3
|
+
describe 'GET Country Authorizations' do
|
|
4
|
+
it 'can get country authorizations' do
|
|
5
|
+
country_authorizations = MangoPay::Regulatory.get_country_authorizations('FR')
|
|
6
|
+
|
|
7
|
+
expect(country_authorizations).not_to be_nil
|
|
8
|
+
expect(country_authorizations['CountryCode']).not_to be_nil
|
|
9
|
+
expect(country_authorizations['CountryName']).not_to be_nil
|
|
10
|
+
expect(country_authorizations['Authorization']).not_to be_nil
|
|
11
|
+
expect(country_authorizations['LastUpdate']).not_to be_nil
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe 'GET All Countries Authorizations' do
|
|
16
|
+
it 'can get all countries authorizations' do
|
|
17
|
+
country_authorizations = MangoPay::Regulatory.get_all_countries_authorizations
|
|
18
|
+
|
|
19
|
+
expect(country_authorizations).not_to be_nil
|
|
20
|
+
expect(country_authorizations[0]['CountryCode']).not_to be_nil
|
|
21
|
+
expect(country_authorizations[0]['CountryName']).not_to be_nil
|
|
22
|
+
expect(country_authorizations[0]['Authorization']).not_to be_nil
|
|
23
|
+
expect(country_authorizations[0]['LastUpdate']).not_to be_nil
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
describe MangoPay::Report do
|
|
2
|
+
|
|
3
|
+
def create
|
|
4
|
+
params = {
|
|
5
|
+
Tag: 'custom meta',
|
|
6
|
+
CallbackURL: 'http://www.my-site.com/callbackURL/',
|
|
7
|
+
DownloadFormat: 'CSV',
|
|
8
|
+
Sort: 'CreationDate:DESC',
|
|
9
|
+
Preview: false,
|
|
10
|
+
Filters: {},
|
|
11
|
+
Columns: [ 'Id', 'CreationDate' ],
|
|
12
|
+
ReportType: 'transactions'
|
|
13
|
+
}
|
|
14
|
+
MangoPay::Report.create(params)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe 'CREATE' do
|
|
18
|
+
it 'creates a report' do
|
|
19
|
+
created = create
|
|
20
|
+
expect(created['Id']).to_not be_nil
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe 'FETCH' do
|
|
25
|
+
|
|
26
|
+
it 'fetches a report' do
|
|
27
|
+
created = create
|
|
28
|
+
fetched = MangoPay::Report.fetch(created['Id'])
|
|
29
|
+
expect(fetched['Id']).to eq(created['Id'])
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'fetches all the reports' do
|
|
33
|
+
reports = MangoPay::Report.fetch()
|
|
34
|
+
expect(reports).to be_kind_of(Array)
|
|
35
|
+
expect(reports).not_to be_empty
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|