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,21 @@
|
|
|
1
|
+
describe MangoPay::PayIn::GooglePay::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('GOOGLE_PAY')
|
|
8
|
+
expect(payin['ExecutionType']).to eq('DIRECT')
|
|
9
|
+
expect(payin['Status']).to eq('CREATED')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe 'CREATE' do
|
|
13
|
+
it 'creates a googlepay direct payin' do
|
|
14
|
+
pending("Cannot be tested due to impossibility to generate payment_data in test")
|
|
15
|
+
created = new_payin_googlepay_direct
|
|
16
|
+
expect(created['Id']).not_to be_nil
|
|
17
|
+
check_type_and_status(created)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
describe MangoPay::PayIn::Ideal::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('IDEAL')
|
|
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 ideal web payin' do
|
|
15
|
+
created = new_payin_ideal_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_ideal_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,151 @@
|
|
|
1
|
+
describe MangoPay::PayIn::PayInIntent, type: :feature do
|
|
2
|
+
include_context 'wallets'
|
|
3
|
+
include_context 'intents'
|
|
4
|
+
|
|
5
|
+
describe 'CREATE' do
|
|
6
|
+
it 'creates a payin intent authorization' do
|
|
7
|
+
created = new_payin_intent_authorization
|
|
8
|
+
expect(created['Id']).not_to be_nil
|
|
9
|
+
expect(created['Status']).to eq('AUTHORIZED')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'creates a payin intent full capture' do
|
|
13
|
+
intent = new_payin_intent_authorization
|
|
14
|
+
to_create = {
|
|
15
|
+
"ExternalData": {
|
|
16
|
+
"ExternalProcessingDate": "01-10-2029",
|
|
17
|
+
"ExternalProviderReference": SecureRandom.uuid,
|
|
18
|
+
"ExternalMerchantReference": "Order-xyz-35e8490e-2ec9-4c82-978e-c712a3f5ba16",
|
|
19
|
+
"ExternalProviderName": "Stripe",
|
|
20
|
+
"ExternalProviderPaymentMethod": "PAYPAL"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
created = MangoPay::PayIn::PayInIntent::Capture.create(intent['Id'], to_create)
|
|
25
|
+
expect(created['Id']).not_to be_nil
|
|
26
|
+
expect(created['Status']).to eq('CAPTURED')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'creates a payin intent partial capture' do
|
|
30
|
+
intent = new_payin_intent_authorization
|
|
31
|
+
to_create = {
|
|
32
|
+
"Amount": 1000,
|
|
33
|
+
"Currency": "EUR",
|
|
34
|
+
"PlatformFeesAmount": 0,
|
|
35
|
+
"ExternalData": {
|
|
36
|
+
"ExternalProcessingDate": "01-10-2024",
|
|
37
|
+
"ExternalProviderReference": SecureRandom.uuid,
|
|
38
|
+
"ExternalMerchantReference": "Order-xyz-35e8490e-2ec9-4c82-978e-c712a3f5ba16",
|
|
39
|
+
"ExternalProviderName": "Stripe",
|
|
40
|
+
"ExternalProviderPaymentMethod": "PAYPAL"
|
|
41
|
+
},
|
|
42
|
+
"LineItems": [
|
|
43
|
+
{
|
|
44
|
+
"Amount": 1000,
|
|
45
|
+
"Id": intent['LineItems'][0]['Id']
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
created = MangoPay::PayIn::PayInIntent::Capture.create(intent['Id'], to_create)
|
|
51
|
+
expect(created['Id']).not_to be_nil
|
|
52
|
+
expect(created['Status']).to eq('CAPTURED')
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
describe 'GET' do
|
|
57
|
+
it 'fetches an intent' do
|
|
58
|
+
intent = new_payin_intent_authorization
|
|
59
|
+
fetched = MangoPay::PayIn::PayInIntent::Intent.get(intent['Id'])
|
|
60
|
+
expect(intent['Id']).to eq(fetched['Id'])
|
|
61
|
+
expect(intent['Status']).to eq(fetched['Status'])
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
describe 'CANCEL' do
|
|
66
|
+
it 'cancels an intent' do
|
|
67
|
+
intent = new_payin_intent_authorization
|
|
68
|
+
canceled = MangoPay::PayIn::PayInIntent::Intent.cancel(intent['Id'], {
|
|
69
|
+
"ExternalData": {
|
|
70
|
+
"ExternalProcessingDate": 1728133765,
|
|
71
|
+
"ExternalProviderReference": SecureRandom.uuid,
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
expect(canceled['Status']).to eq('CANCELLED')
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
describe 'SPLITS' do
|
|
79
|
+
it 'creates a split' do
|
|
80
|
+
intent = new_payin_intent_authorization
|
|
81
|
+
created = create_new_splits(intent)
|
|
82
|
+
expect(created['Splits']).to be_kind_of(Array)
|
|
83
|
+
expect(created['Splits']).not_to be_empty
|
|
84
|
+
expect(created['Splits'][0]['Status']).to eq('CREATED')
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it 'executes split' do
|
|
88
|
+
intent = new_payin_intent_authorization
|
|
89
|
+
split = create_new_splits(intent)['Splits'][0]
|
|
90
|
+
expect {
|
|
91
|
+
MangoPay::PayIn::PayInIntent::Split.execute(intent['Id'], split['Id'])
|
|
92
|
+
}.to raise_error { |err|
|
|
93
|
+
expect(err).to be_a MangoPay::ResponseError
|
|
94
|
+
expect(err.code).to eq '400'
|
|
95
|
+
expect(err.details['Type']).to eq 'param_error'
|
|
96
|
+
}
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it 'reverses split' do
|
|
100
|
+
intent = new_payin_intent_authorization
|
|
101
|
+
split = create_new_splits(intent)['Splits'][0]
|
|
102
|
+
expect {
|
|
103
|
+
MangoPay::PayIn::PayInIntent::Split.reverse(intent['Id'], split['Id'])
|
|
104
|
+
}.to raise_error { |err|
|
|
105
|
+
expect(err).to be_a MangoPay::ResponseError
|
|
106
|
+
expect(err.code).to eq '400'
|
|
107
|
+
expect(err.details['Type']).to eq 'param_error'
|
|
108
|
+
}
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
it 'fetches split' do
|
|
112
|
+
intent = new_payin_intent_authorization
|
|
113
|
+
split = create_new_splits(intent)['Splits'][0]
|
|
114
|
+
fetched = MangoPay::PayIn::PayInIntent::Split.get(intent['Id'], split['Id'])
|
|
115
|
+
expect(fetched['Status']).to eq('CREATED')
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it 'updates split' do
|
|
119
|
+
intent = new_payin_intent_authorization
|
|
120
|
+
split = create_new_splits(intent)['Splits'][0]
|
|
121
|
+
params = {
|
|
122
|
+
LineItemId: split['LineItemId'],
|
|
123
|
+
Description: 'updated split'
|
|
124
|
+
}
|
|
125
|
+
updated = MangoPay::PayIn::PayInIntent::Split.update(intent['Id'], split['Id'], params)
|
|
126
|
+
expect(updated['Description']).to eq('updated split')
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def create_new_splits(intent)
|
|
131
|
+
full_capture = {
|
|
132
|
+
"ExternalData": {
|
|
133
|
+
"ExternalProcessingDate": "01-10-2029",
|
|
134
|
+
"ExternalProviderReference": SecureRandom.uuid,
|
|
135
|
+
"ExternalMerchantReference": "Order-xyz-35e8490e-2ec9-4c82-978e-c712a3f5ba16",
|
|
136
|
+
"ExternalProviderName": "Stripe",
|
|
137
|
+
"ExternalProviderPaymentMethod": "PAYPAL"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
MangoPay::PayIn::PayInIntent::Capture.create(intent['Id'], full_capture)
|
|
141
|
+
split = {
|
|
142
|
+
"Splits": [
|
|
143
|
+
{
|
|
144
|
+
"LineItemId": intent['LineItems'][0]['Id'],
|
|
145
|
+
"SplitAmount": 10
|
|
146
|
+
}
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
return MangoPay::PayIn::PayInIntent::Split.create(intent['Id'], split)
|
|
150
|
+
end
|
|
151
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
describe MangoPay::PayIn::Klarna::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('KLARNA')
|
|
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 klarna web payin' do
|
|
15
|
+
created = new_payin_klarna_web
|
|
16
|
+
expect(created['Id']).not_to be_nil
|
|
17
|
+
expect(created['ReturnURL']).not_to be_nil
|
|
18
|
+
check_type_and_status(created)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe 'FETCH' do
|
|
23
|
+
it 'fetches a payin' do
|
|
24
|
+
created = new_payin_klarna_web
|
|
25
|
+
fetched = MangoPay::PayIn.fetch(created['Id'])
|
|
26
|
+
expect(fetched['Id']).to eq(created['Id'])
|
|
27
|
+
check_type_and_status(created)
|
|
28
|
+
check_type_and_status(fetched)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
describe MangoPay::PayIn::Mbway::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('MBWAY')
|
|
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 mbway web payin' do
|
|
15
|
+
created = new_payin_mbway_web
|
|
16
|
+
expect(created['Id']).not_to be_nil
|
|
17
|
+
expect(created['Phone']).not_to be_nil
|
|
18
|
+
check_type_and_status(created)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe 'FETCH' do
|
|
23
|
+
it 'fetches a payin' do
|
|
24
|
+
created = new_payin_mbway_web
|
|
25
|
+
fetched = MangoPay::PayIn.fetch(created['Id'])
|
|
26
|
+
expect(fetched['Id']).to eq(created['Id'])
|
|
27
|
+
check_type_and_status(created)
|
|
28
|
+
check_type_and_status(fetched)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
describe MangoPay::PayIn::Multibanco::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('MULTIBANCO')
|
|
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 multibanco web payin' do
|
|
15
|
+
created = new_payin_multibanco_web
|
|
16
|
+
expect(created['Id']).not_to be_nil
|
|
17
|
+
expect(created['ReturnURL']).not_to be_nil
|
|
18
|
+
check_type_and_status(created)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe 'FETCH' do
|
|
23
|
+
it 'fetches a payin' do
|
|
24
|
+
created = new_payin_multibanco_web
|
|
25
|
+
fetched = MangoPay::PayIn.fetch(created['Id'])
|
|
26
|
+
expect(fetched['Id']).to eq(created['Id'])
|
|
27
|
+
check_type_and_status(created)
|
|
28
|
+
check_type_and_status(fetched)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
describe MangoPay::PayIn::PayByBank::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('PAY_BY_BANK')
|
|
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 paybybank web payin' do
|
|
15
|
+
created = new_payin_paybybank_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_paybybank_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
|
+
|
|
31
|
+
describe "FETCH SUPPORTED BANKS" do
|
|
32
|
+
it "fetches supported banks unfiltered" do
|
|
33
|
+
result = MangoPay::PayIn::PayByBank::Web.get_supported_banks
|
|
34
|
+
expect(result['SupportedBanks']['Countries']).to be_kind_of(Array)
|
|
35
|
+
expect(result['SupportedBanks']['Countries']).not_to be_empty
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "fetches supported banks filtered" do
|
|
39
|
+
result = MangoPay::PayIn::PayByBank::Web.get_supported_banks({CountryCodes: "DE"})
|
|
40
|
+
expect(result['SupportedBanks']['Countries']).to be_kind_of(Array)
|
|
41
|
+
expect(result['SupportedBanks']['Countries'][0]['Banks'].count).to be(5)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "fetches supported banks paginated" do
|
|
45
|
+
result = MangoPay::PayIn::PayByBank::Web.get_supported_banks({per_page: 2, page: 1})
|
|
46
|
+
expect(result['SupportedBanks']['Countries']).to be_kind_of(Array)
|
|
47
|
+
expect(result['SupportedBanks']['Countries'][0]['Banks'].count).to be(2)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "fetches supported banks paginated and filtered" do
|
|
51
|
+
result = MangoPay::PayIn::PayByBank::Web.get_supported_banks({per_page: 2, page: 1, CountryCodes: "DE"})
|
|
52
|
+
expect(result['SupportedBanks']['Countries']).to be_kind_of(Array)
|
|
53
|
+
expect(result['SupportedBanks']['Countries'][0]['Banks'].count).to be(2)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
describe MangoPay::PayIn::Payconiq::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('PAYCONIQ')
|
|
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 payconiq web payin' do
|
|
19
|
+
created = new_payin_payconiq_web
|
|
20
|
+
expect(created['Id']).not_to be_nil
|
|
21
|
+
check_type_and_status(created)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'creates a payconiq web payin using the old endpoint' do
|
|
25
|
+
created = new_payin_payconiq_web_legacy
|
|
26
|
+
expect(created['Id']).not_to be_nil
|
|
27
|
+
check_type_and_status(created)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
@@ -0,0 +1,113 @@
|
|
|
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 'CREATE V2' do
|
|
26
|
+
it 'creates a paypal web v2 payin' do
|
|
27
|
+
created = new_payin_paypal_web_v2
|
|
28
|
+
expect(created['Id']).not_to be_nil
|
|
29
|
+
# generic operation error
|
|
30
|
+
# check_type_and_status(created)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe "FETCH" do
|
|
35
|
+
it 'FETCHES a payIn with PayPal account email' do
|
|
36
|
+
pending("Expired PayIn id")
|
|
37
|
+
payin_id = "54088959"
|
|
38
|
+
buyer_account_email = "paypal-buyer-user@mangopay.com"
|
|
39
|
+
payin = MangoPay::PayIn.fetch(id = payin_id)
|
|
40
|
+
|
|
41
|
+
expect(payin).not_to be_nil
|
|
42
|
+
expect(payin["PaypalBuyerAccountEmail"]).not_to be_nil
|
|
43
|
+
expect(payin["PaypalBuyerAccountEmail"]).to eq(buyer_account_email)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe 'FETCH' do
|
|
48
|
+
it 'fetches a payin' do
|
|
49
|
+
created = new_payin_paypal_web
|
|
50
|
+
fetched = MangoPay::PayIn.fetch(created['Id'])
|
|
51
|
+
expect(fetched['Id']).to eq(created['Id'])
|
|
52
|
+
expect(fetched['CreationDate']).to eq(created['CreationDate'])
|
|
53
|
+
expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
|
|
54
|
+
expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
|
|
55
|
+
check_type_and_status(created)
|
|
56
|
+
check_type_and_status(fetched)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# skip because of Generic Operation Error
|
|
61
|
+
describe 'FETCH V2' do
|
|
62
|
+
xit 'fetches a payin' do
|
|
63
|
+
created = new_payin_paypal_web_v2
|
|
64
|
+
fetched = MangoPay::PayIn.fetch(created['Id'])
|
|
65
|
+
expect(fetched['Id']).to eq(created['Id'])
|
|
66
|
+
expect(fetched['CreationDate']).to eq(created['CreationDate'])
|
|
67
|
+
expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
|
|
68
|
+
expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
|
|
69
|
+
check_type_and_status(created)
|
|
70
|
+
check_type_and_status(fetched)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
describe 'Data Collection' do
|
|
75
|
+
it 'creates data collection' do
|
|
76
|
+
created = MangoPay::PayIn::PayPal::Web.create_data_collection(get_data_collection_dto)
|
|
77
|
+
expect(created['dataCollectionId']).not_to be_nil
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it 'fetches data collection' do
|
|
81
|
+
created = MangoPay::PayIn::PayPal::Web.create_data_collection(get_data_collection_dto)
|
|
82
|
+
fetched = MangoPay::PayIn::PayPal::Web.get_data_collection(created['dataCollectionId'])
|
|
83
|
+
expect(fetched['DataCollectionId']).to eq(created['dataCollectionId'])
|
|
84
|
+
expect(fetched['sender_first_name']).to eq('Jane')
|
|
85
|
+
expect(fetched['sender_last_name']).to eq('Doe')
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def get_data_collection_dto
|
|
90
|
+
return {
|
|
91
|
+
"sender_account_id": "A12345N343",
|
|
92
|
+
"sender_first_name": "Jane",
|
|
93
|
+
"sender_last_name": "Doe",
|
|
94
|
+
"sender_email": "jane.doe@sample.com",
|
|
95
|
+
"sender_phone": "(042)11234567",
|
|
96
|
+
"sender_address_zip": "75009",
|
|
97
|
+
"sender_country_code": "FR",
|
|
98
|
+
"sender_create_date": "2012-12-09T19:14:55.277-0:00",
|
|
99
|
+
"sender_signup_ip": "10.220.90.20",
|
|
100
|
+
"sender_popularity_score": "high",
|
|
101
|
+
"receiver_account_id": "A12345N344",
|
|
102
|
+
"receiver_create_date": "2012-12-09T19:14:55.277-0:00",
|
|
103
|
+
"receiver_email": "jane@sample.com",
|
|
104
|
+
"receiver_address_country_code": "FR",
|
|
105
|
+
"business_name": "Jane Ltd",
|
|
106
|
+
"recipient_popularity_score": "high",
|
|
107
|
+
"first_interaction_date": "2012-12-09T19:14:55.277-0:00",
|
|
108
|
+
"txn_count_total": "34",
|
|
109
|
+
"vertical": "Household goods",
|
|
110
|
+
"transaction_is_tangible": "0"
|
|
111
|
+
}
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
describe MangoPay::PayIn::PreAuthorized::Direct, type: :feature do
|
|
2
|
+
include_context 'wallets'
|
|
3
|
+
include_context 'payins'
|
|
4
|
+
include_context 'users'
|
|
5
|
+
|
|
6
|
+
def check_type_and_status(payin)
|
|
7
|
+
expect(payin['Type']).to eq('PAYIN')
|
|
8
|
+
expect(payin['Nature']).to eq('REGULAR')
|
|
9
|
+
expect(payin['PaymentType']).to eq('PREAUTHORIZED')
|
|
10
|
+
expect(payin['ExecutionType']).to eq('DIRECT')
|
|
11
|
+
|
|
12
|
+
# SUCCEEDED
|
|
13
|
+
expect(payin['Status']).to eq('SUCCEEDED')
|
|
14
|
+
expect(payin['ResultCode']).to eq('000000')
|
|
15
|
+
expect(payin['ResultMessage']).to eq('Success')
|
|
16
|
+
expect(payin['ExecutionDate']).to be > 0
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe 'CREATE' do
|
|
20
|
+
it 'creates a preauthorized direct payin' do
|
|
21
|
+
created = new_payin_preauthorized_direct
|
|
22
|
+
# wait for the transactions to be created
|
|
23
|
+
sleep(2)
|
|
24
|
+
transactions = MangoPay::PreAuthorization.transactions(created['PreauthorizationId'])
|
|
25
|
+
expect(created['Id']).not_to be_nil
|
|
26
|
+
expect(transactions[0]['Status']).to eq('SUCCEEDED')
|
|
27
|
+
check_type_and_status(created)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe 'FETCH' do
|
|
32
|
+
it 'fetches a payin' do
|
|
33
|
+
created = new_payin_preauthorized_direct
|
|
34
|
+
fetched = MangoPay::PayIn.fetch(created['Id'])
|
|
35
|
+
expect(fetched['Id']).to eq(created['Id'])
|
|
36
|
+
expect(fetched['CreationDate']).to eq(created['CreationDate'])
|
|
37
|
+
expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
|
|
38
|
+
expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
|
|
39
|
+
check_type_and_status(created)
|
|
40
|
+
check_type_and_status(fetched)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe 'REFUND' do
|
|
45
|
+
it 'refunds a payin' do
|
|
46
|
+
payin = new_payin_preauthorized_direct
|
|
47
|
+
sleep(2)
|
|
48
|
+
refund = MangoPay::PayIn.refund(payin['Id'], { AuthorId: payin['AuthorId'] })
|
|
49
|
+
expect(refund['Id']).not_to be_nil
|
|
50
|
+
expect(refund['Status']).to eq('SUCCEEDED')
|
|
51
|
+
expect(refund['Type']).to eq('PAYOUT')
|
|
52
|
+
expect(refund['Nature']).to eq('REFUND')
|
|
53
|
+
expect(refund['InitialTransactionType']).to eq('PAYIN')
|
|
54
|
+
expect(refund['InitialTransactionId']).to eq(payin['Id'])
|
|
55
|
+
expect(refund['DebitedWalletId']).to eq(payin['CreditedWalletId'])
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe 'CASH FLOW' do
|
|
60
|
+
it 'changes balances correctly' do
|
|
61
|
+
wlt = new_wallet
|
|
62
|
+
wallets_check_amounts(wlt, 0)
|
|
63
|
+
|
|
64
|
+
# payin: feed wlt1 with money
|
|
65
|
+
payin = create_new_payin_preauthorized_direct(wlt, 1000)
|
|
66
|
+
wallets_reload_and_check_amounts(wlt, 1000)
|
|
67
|
+
|
|
68
|
+
# refund the payin
|
|
69
|
+
refund = MangoPay::PayIn.refund(payin['Id'], { AuthorId: payin['AuthorId'] })
|
|
70
|
+
wallets_reload_and_check_amounts(wlt, 0)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
begin
|
|
75
|
+
describe 'CREATE AND VIEW PRE AUTHORIZED DEPOSIT' do
|
|
76
|
+
it 'creates a card direct pre authorized deposit payin' do
|
|
77
|
+
wallet = new_wallet
|
|
78
|
+
author = new_natural_user
|
|
79
|
+
card_registration = new_card_registration_completed
|
|
80
|
+
deposit = create_new_deposit(card_registration['CardId'], author['Id'])
|
|
81
|
+
|
|
82
|
+
created = create_new_payin_pre_authorized_deposit_direct(deposit['Id'], author['Id'], wallet['Id'])
|
|
83
|
+
|
|
84
|
+
expect(created['Id']).not_to be_nil
|
|
85
|
+
check_type_and_status(created)
|
|
86
|
+
expect(created['DepositId']).to eq(deposit['Id'])
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it 'creates a card direct pre authorized deposit payin prior to complement' do
|
|
90
|
+
wallet = new_wallet
|
|
91
|
+
author = new_natural_user
|
|
92
|
+
card_registration = new_card_registration_completed
|
|
93
|
+
deposit = create_new_deposit(card_registration['CardId'], author['Id'])
|
|
94
|
+
|
|
95
|
+
created = create_new_deposit_pre_authorized_pay_in_prior_to_complement(deposit['Id'], author['Id'], wallet['Id'])
|
|
96
|
+
|
|
97
|
+
expect(created['Id']).not_to be_nil
|
|
98
|
+
check_type_and_status(created)
|
|
99
|
+
expect(created['DepositId']).to eq(deposit['Id'])
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# skip because of PSP error
|
|
103
|
+
xit 'creates a card direct pre authorized deposit payin complement' do
|
|
104
|
+
wallet = new_wallet
|
|
105
|
+
author = new_natural_user
|
|
106
|
+
card_registration = new_card_registration_completed
|
|
107
|
+
deposit = create_new_deposit(card_registration['CardId'], author['Id'])
|
|
108
|
+
MangoPay::Deposit.update(deposit['Id'], {PaymentStatus: 'NO_SHOW_REQUESTED'})
|
|
109
|
+
|
|
110
|
+
created = create_new_deposit_pre_authorized_pay_in_complement(deposit['Id'], author['Id'], wallet['Id'])
|
|
111
|
+
|
|
112
|
+
expect(created['Id']).not_to be_nil
|
|
113
|
+
check_type_and_status(created)
|
|
114
|
+
expect(created['DepositId']).to eq(deposit['Id'])
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
describe MangoPay::PayIn::Satispay::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('SATISPAY')
|
|
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 satispay web payin' do
|
|
15
|
+
created = new_payin_satispay_web
|
|
16
|
+
expect(created['Id']).not_to be_nil
|
|
17
|
+
expect(created['Country']).not_to be_nil
|
|
18
|
+
check_type_and_status(created)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe 'FETCH' do
|
|
23
|
+
it 'fetches a payin' do
|
|
24
|
+
created = new_payin_satispay_web
|
|
25
|
+
fetched = MangoPay::PayIn.fetch(created['Id'])
|
|
26
|
+
expect(fetched['Id']).to eq(created['Id'])
|
|
27
|
+
check_type_and_status(created)
|
|
28
|
+
check_type_and_status(fetched)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|