mangopay-v4 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +30 -0
- data/.rspec +4 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +13 -0
- data/Gemfile +2 -0
- data/LICENSE +20 -0
- data/README.md +380 -0
- data/bin/mangopay +9 -0
- data/lib/mangopay.rb +133 -0
- data/lib/mangopay/api/api.rb +9 -0
- data/lib/mangopay/api/api_methods.rb +137 -0
- data/lib/mangopay/api/auth_token_manager.rb +173 -0
- data/lib/mangopay/api/http_client.rb +325 -0
- data/lib/mangopay/api/service/bank_accounts.rb +146 -0
- data/lib/mangopay/api/service/cards.rb +152 -0
- data/lib/mangopay/api/service/client_wallets.rb +89 -0
- data/lib/mangopay/api/service/clients.rb +68 -0
- data/lib/mangopay/api/service/dispute_documents.rb +158 -0
- data/lib/mangopay/api/service/disputes.rb +187 -0
- data/lib/mangopay/api/service/e_money.rb +42 -0
- data/lib/mangopay/api/service/events.rb +47 -0
- data/lib/mangopay/api/service/hooks.rb +93 -0
- data/lib/mangopay/api/service/kyc_documents.rb +153 -0
- data/lib/mangopay/api/service/mandates.rb +142 -0
- data/lib/mangopay/api/service/oauth_tokens.rb +25 -0
- data/lib/mangopay/api/service/pay_ins.rb +260 -0
- data/lib/mangopay/api/service/pay_outs.rb +54 -0
- data/lib/mangopay/api/service/pre_authorizations.rb +69 -0
- data/lib/mangopay/api/service/refunds.rb +62 -0
- data/lib/mangopay/api/service/reports.rb +151 -0
- data/lib/mangopay/api/service/repudiations.rb +32 -0
- data/lib/mangopay/api/service/responses.rb +102 -0
- data/lib/mangopay/api/service/settlement_transfers.rb +55 -0
- data/lib/mangopay/api/service/transactions.rb +183 -0
- data/lib/mangopay/api/service/transfers.rb +54 -0
- data/lib/mangopay/api/service/ubo_declarations.rb +70 -0
- data/lib/mangopay/api/service/users.rb +163 -0
- data/lib/mangopay/api/service/wallets.rb +99 -0
- data/lib/mangopay/api/uri_provider.rb +35 -0
- data/lib/mangopay/common/json_tag_converter.rb +68 -0
- data/lib/mangopay/common/jsonifier.rb +249 -0
- data/lib/mangopay/common/log_provider.rb +34 -0
- data/lib/mangopay/common/rate_limit_interval.rb +17 -0
- data/lib/mangopay/common/read_only_fields.rb +27 -0
- data/lib/mangopay/common/response_error.rb +61 -0
- data/lib/mangopay/common/sort_direction.rb +15 -0
- data/lib/mangopay/common/sort_field.rb +13 -0
- data/lib/mangopay/common/template_url_options.rb +9 -0
- data/lib/mangopay/configuration.rb +39 -0
- data/lib/mangopay/environment.rb +66 -0
- data/lib/mangopay/model/address.rb +27 -0
- data/lib/mangopay/model/declared_ubo.rb +21 -0
- data/lib/mangopay/model/dispute_reason.rb +15 -0
- data/lib/mangopay/model/document_page_consult.rb +15 -0
- data/lib/mangopay/model/e_money.rb +18 -0
- data/lib/mangopay/model/entity/account/bank_account.rb +26 -0
- data/lib/mangopay/model/entity/account/ca_bank_account.rb +27 -0
- data/lib/mangopay/model/entity/account/gb_bank_account.rb +21 -0
- data/lib/mangopay/model/entity/account/iban_bank_account.rb +21 -0
- data/lib/mangopay/model/entity/account/other_bank_account.rb +24 -0
- data/lib/mangopay/model/entity/account/us_bank_account.rb +24 -0
- data/lib/mangopay/model/entity/card.rb +45 -0
- data/lib/mangopay/model/entity/card_registration.rb +43 -0
- data/lib/mangopay/model/entity/client.rb +63 -0
- data/lib/mangopay/model/entity/client_wallet.rb +23 -0
- data/lib/mangopay/model/entity/dispute.rb +50 -0
- data/lib/mangopay/model/entity/dispute_document.rb +29 -0
- data/lib/mangopay/model/entity/entity_base.rb +18 -0
- data/lib/mangopay/model/entity/hook.rb +26 -0
- data/lib/mangopay/model/entity/kyc_document.rb +28 -0
- data/lib/mangopay/model/entity/mandate.rb +51 -0
- data/lib/mangopay/model/entity/pay_in/bank_wire_direct_pay_in.rb +22 -0
- data/lib/mangopay/model/entity/pay_in/card_direct_pay_in.rb +33 -0
- data/lib/mangopay/model/entity/pay_in/card_pre_authorized_pay_in.rb +13 -0
- data/lib/mangopay/model/entity/pay_in/card_web_pay_in.rb +40 -0
- data/lib/mangopay/model/entity/pay_in/direct_debit_direct_pay_in.rb +23 -0
- data/lib/mangopay/model/entity/pay_in/direct_debit_web_pay_in.rb +38 -0
- data/lib/mangopay/model/entity/pay_in/pay_in.rb +16 -0
- data/lib/mangopay/model/entity/pay_out.rb +22 -0
- data/lib/mangopay/model/entity/pre_authorization.rb +68 -0
- data/lib/mangopay/model/entity/refund.rb +18 -0
- data/lib/mangopay/model/entity/report.rb +51 -0
- data/lib/mangopay/model/entity/repudiation.rb +18 -0
- data/lib/mangopay/model/entity/settlement_transfer.rb +17 -0
- data/lib/mangopay/model/entity/transaction.rb +52 -0
- data/lib/mangopay/model/entity/transfer.rb +13 -0
- data/lib/mangopay/model/entity/ubo_declaration.rb +32 -0
- data/lib/mangopay/model/entity/user/legal_user.rb +53 -0
- data/lib/mangopay/model/entity/user/natural_user.rb +50 -0
- data/lib/mangopay/model/entity/user/user.rb +18 -0
- data/lib/mangopay/model/entity/wallet.rb +28 -0
- data/lib/mangopay/model/enum/account_type.rb +24 -0
- data/lib/mangopay/model/enum/card_status.rb +15 -0
- data/lib/mangopay/model/enum/card_type.rb +33 -0
- data/lib/mangopay/model/enum/card_validity.rb +19 -0
- data/lib/mangopay/model/enum/country_iso.rb +759 -0
- data/lib/mangopay/model/enum/culture_code.rb +44 -0
- data/lib/mangopay/model/enum/currency_iso.rb +552 -0
- data/lib/mangopay/model/enum/declared_ubo_refused_reason_type.rb +16 -0
- data/lib/mangopay/model/enum/declared_ubo_status.rb +18 -0
- data/lib/mangopay/model/enum/deposit_type.rb +15 -0
- data/lib/mangopay/model/enum/direct_debit_type.rb +13 -0
- data/lib/mangopay/model/enum/dispute_doc_refused_reason_type.rb +25 -0
- data/lib/mangopay/model/enum/dispute_document_type.rb +23 -0
- data/lib/mangopay/model/enum/dispute_reason_type.rb +33 -0
- data/lib/mangopay/model/enum/dispute_status.rb +21 -0
- data/lib/mangopay/model/enum/dispute_type.rb +15 -0
- data/lib/mangopay/model/enum/document_status.rb +21 -0
- data/lib/mangopay/model/enum/download_format.rb +11 -0
- data/lib/mangopay/model/enum/event_type.rb +74 -0
- data/lib/mangopay/model/enum/funds_type.rb +15 -0
- data/lib/mangopay/model/enum/hook_status.rb +13 -0
- data/lib/mangopay/model/enum/hook_validity.rb +15 -0
- data/lib/mangopay/model/enum/income_range.rb +21 -0
- data/lib/mangopay/model/enum/kyc_doc_refused_reason_type.rb +37 -0
- data/lib/mangopay/model/enum/kyc_document_type.rb +19 -0
- data/lib/mangopay/model/enum/kyc_level.rb +13 -0
- data/lib/mangopay/model/enum/legal_person_type.rb +15 -0
- data/lib/mangopay/model/enum/mandate_culture_code.rb +23 -0
- data/lib/mangopay/model/enum/mandate_execution_type.rb +11 -0
- data/lib/mangopay/model/enum/mandate_scheme.rb +13 -0
- data/lib/mangopay/model/enum/mandate_status.rb +24 -0
- data/lib/mangopay/model/enum/mandate_type.rb +11 -0
- data/lib/mangopay/model/enum/natural_user_capacity.rb +15 -0
- data/lib/mangopay/model/enum/pay_in_execution_type.rb +18 -0
- data/lib/mangopay/model/enum/pay_in_payment_type.rb +21 -0
- data/lib/mangopay/model/enum/pay_out_payment_type.rb +11 -0
- data/lib/mangopay/model/enum/payment_status.rb +21 -0
- data/lib/mangopay/model/enum/person_type.rb +15 -0
- data/lib/mangopay/model/enum/platform_type.rb +23 -0
- data/lib/mangopay/model/enum/pre_authorization_execution_type.rb +11 -0
- data/lib/mangopay/model/enum/pre_authorization_status.rb +18 -0
- data/lib/mangopay/model/enum/refund_reason_type.rb +21 -0
- data/lib/mangopay/model/enum/report_status.rb +17 -0
- data/lib/mangopay/model/enum/report_type.rb +13 -0
- data/lib/mangopay/model/enum/secure_mode.rb +16 -0
- data/lib/mangopay/model/enum/transaction_nature.rb +17 -0
- data/lib/mangopay/model/enum/transaction_status.rb +15 -0
- data/lib/mangopay/model/enum/transaction_type.rb +15 -0
- data/lib/mangopay/model/enum/ubo_declaration_refused_reason_type.rb +19 -0
- data/lib/mangopay/model/enum/ubo_declaration_status.rb +21 -0
- data/lib/mangopay/model/event.rb +18 -0
- data/lib/mangopay/model/model.rb +194 -0
- data/lib/mangopay/model/money.rb +17 -0
- data/lib/mangopay/model/pay_in_web_extended_view.rb +31 -0
- data/lib/mangopay/model/refund_reason.rb +15 -0
- data/lib/mangopay/model/report_filter.rb +83 -0
- data/lib/mangopay/model/request/cancel_request.rb +16 -0
- data/lib/mangopay/model/request/complete_registration_request.rb +13 -0
- data/lib/mangopay/model/request/currency_request.rb +13 -0
- data/lib/mangopay/model/request/deactivation_request.rb +10 -0
- data/lib/mangopay/model/request/filter_request.rb +38 -0
- data/lib/mangopay/model/request/submit_document_request.rb +14 -0
- data/lib/mangopay/model/request/submit_ubo_declaration_request.rb +14 -0
- data/lib/mangopay/model/request/upload_file_request.rb +9 -0
- data/lib/mangopay/model/response_replica.rb +27 -0
- data/lib/mangopay/util/custom_formatter.rb +12 -0
- data/lib/mangopay/util/custom_logger.rb +34 -0
- data/lib/mangopay/util/enum.rb +52 -0
- data/lib/mangopay/util/file_encoder.rb +16 -0
- data/lib/mangopay/util/non_instantiable.rb +6 -0
- data/lib/mangopay/util/storage_strategy.rb +10 -0
- data/lib/mangopay/util/void_logger.rb +6 -0
- data/mangopay.gemspec +32 -0
- data/spec/context/address_context.rb +25 -0
- data/spec/context/bank_account_context.rb +138 -0
- data/spec/context/card_context.rb +46 -0
- data/spec/context/client_context.rb +45 -0
- data/spec/context/dispute_context.rb +37 -0
- data/spec/context/dispute_document_context.rb +20 -0
- data/spec/context/hook_context.rb +16 -0
- data/spec/context/kyc_document_context.rb +23 -0
- data/spec/context/mandate_context.rb +27 -0
- data/spec/context/pay_in_context.rb +225 -0
- data/spec/context/pay_out_context.rb +39 -0
- data/spec/context/pre_authorization_context.rb +41 -0
- data/spec/context/refund_context.rb +33 -0
- data/spec/context/report_context.rb +22 -0
- data/spec/context/repudiation_context.rb +19 -0
- data/spec/context/settlement_transfer_context.rb +28 -0
- data/spec/context/transfer_context.rb +51 -0
- data/spec/context/ubo_declaration_context.rb +25 -0
- data/spec/context/user_context.rb +83 -0
- data/spec/context/wallet_context.rb +53 -0
- data/spec/mangopay/bank_accounts_spec.rb +229 -0
- data/spec/mangopay/cards_spec.rb +135 -0
- data/spec/mangopay/client_wallets_spec.rb +148 -0
- data/spec/mangopay/clients_spec.rb +55 -0
- data/spec/mangopay/configuration_spec.rb +126 -0
- data/spec/mangopay/dispute_documents_spec.rb +174 -0
- data/spec/mangopay/disputes_spec.rb +265 -0
- data/spec/mangopay/e_money_spec.rb +38 -0
- data/spec/mangopay/events_spec.rb +50 -0
- data/spec/mangopay/hooks_spec.rb +71 -0
- data/spec/mangopay/kyc_documents_spec.rb +180 -0
- data/spec/mangopay/mandates_spec.rb +219 -0
- data/spec/mangopay/oauth_tokens_spec.rb +41 -0
- data/spec/mangopay/pay_ins_spec.rb +181 -0
- data/spec/mangopay/pay_outs_spec.rb +39 -0
- data/spec/mangopay/pre_authorizations_spec.rb +58 -0
- data/spec/mangopay/refunds_spec.rb +40 -0
- data/spec/mangopay/reports_spec.rb +121 -0
- data/spec/mangopay/responses_spec.rb +295 -0
- data/spec/mangopay/settlement_transfers_spec.rb +37 -0
- data/spec/mangopay/transactions_spec.rb +233 -0
- data/spec/mangopay/transfers_spec.rb +38 -0
- data/spec/mangopay/ubo_declarations_spec.rb +65 -0
- data/spec/mangopay/users_spec.rb +146 -0
- data/spec/mangopay/wallets_spec.rb +104 -0
- data/spec/resources/logo.png +0 -0
- data/spec/resources/test_pdf.pdf +0 -0
- data/spec/spec_helper.rb +72 -0
- metadata +349 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative '../../lib/mangopay/api/service/oauth_tokens'
|
2
|
+
require_relative '../../lib/mangopay/api/http_client'
|
3
|
+
require_relative '../../lib/mangopay/common/response_error'
|
4
|
+
require_relative '../context/user_context'
|
5
|
+
|
6
|
+
describe MangoApi::OAuthTokens do
|
7
|
+
include_context 'user_context'
|
8
|
+
|
9
|
+
describe '.create' do
|
10
|
+
|
11
|
+
context 'having a valid configuration' do
|
12
|
+
config = MangoPay.configuration
|
13
|
+
|
14
|
+
it 'creates a valid authorization token' do
|
15
|
+
token = MangoApi::OAuthTokens.create(config)
|
16
|
+
# noinspection RubyStringKeysInHashInspection
|
17
|
+
headers = {
|
18
|
+
'Authorization' => "#{token['token_type']} #{token['access_token']}",
|
19
|
+
'User-Agent' => "MANGOPAY V2 RubyBindings/#{MangoPay::VERSION}",
|
20
|
+
'Content-Type' => 'application/json'
|
21
|
+
}
|
22
|
+
url = 'https://api.sandbox.mangopay.com/v2.01/sdk-unit-tests/users/natural'
|
23
|
+
# noinspection RubyResolve
|
24
|
+
user = NATURAL_USER_DATA
|
25
|
+
begin
|
26
|
+
# launch a request to the MangoPay server using
|
27
|
+
# the newly-created token as Authorization header
|
28
|
+
MangoApi::HttpClient.post_raw(URI(url)) do |request|
|
29
|
+
request.body = user.jsonify!
|
30
|
+
headers.each do |k, v|
|
31
|
+
request.add_field(k, v)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
rescue MangoApi::ResponseError => e
|
35
|
+
raise "unsuccessful request using created token\n"\
|
36
|
+
"#{e.code} #{e.details}\n#{e.message}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,181 @@
|
|
1
|
+
require_relative '../../spec/context/pay_in_context'
|
2
|
+
require_relative '../../lib/mangopay/api/service/pay_ins'
|
3
|
+
|
4
|
+
describe MangoApi::PayIns do
|
5
|
+
include_context 'pay_in_context'
|
6
|
+
|
7
|
+
describe '.create' do
|
8
|
+
|
9
|
+
describe '#CARD WEB' do
|
10
|
+
context 'given a valid object' do
|
11
|
+
pay_in = CARD_WEB_PAY_IN_DATA
|
12
|
+
|
13
|
+
it 'creates the card web pay-in entity' do
|
14
|
+
created = MangoApi::PayIns.create_card_web pay_in
|
15
|
+
|
16
|
+
expect(created).to be_kind_of MangoModel::CardWebPayIn
|
17
|
+
expect(created.id).not_to be_nil
|
18
|
+
expect(created.status).to be MangoModel::TransactionStatus::CREATED
|
19
|
+
expect(created.payment_type).to be MangoModel::PayInPaymentType::CARD
|
20
|
+
expect(created.execution_type).to be MangoModel::PayInExecutionType::WEB
|
21
|
+
expect(its_the_same_card_web(pay_in, created)).to be_truthy
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#CARD DIRECT' do
|
27
|
+
context 'given a valid object' do
|
28
|
+
pay_in = CARD_DIRECT_PAY_IN_DATA
|
29
|
+
|
30
|
+
it 'creates the card direct pay-in entity' do
|
31
|
+
created = MangoApi::PayIns.create_card_direct pay_in
|
32
|
+
|
33
|
+
expect(created).to be_kind_of MangoModel::CardDirectPayIn
|
34
|
+
expect(created.id).not_to be_nil
|
35
|
+
expect(created.status).to be MangoModel::TransactionStatus::SUCCEEDED
|
36
|
+
expect(created.payment_type).to be MangoModel::PayInPaymentType::CARD
|
37
|
+
expect(created.execution_type).to be MangoModel::PayInExecutionType::DIRECT
|
38
|
+
expect(its_the_same_card_direct(pay_in, created)).to be_truthy
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#CARD PREAUTHORIZED' do
|
44
|
+
context 'given a valid object' do
|
45
|
+
pay_in = CARD_PRE_AUTH_PAY_IN_DATA
|
46
|
+
|
47
|
+
it 'creates the card pre-authorized pay-in entity' do
|
48
|
+
created = CARD_PRE_AUTH_PAY_IN_PERSISTED
|
49
|
+
|
50
|
+
expect(created).to be_kind_of MangoModel::CardPreAuthorizedPayIn
|
51
|
+
expect(created.id).not_to be_nil
|
52
|
+
expect(created.status).to be MangoModel::TransactionStatus::SUCCEEDED
|
53
|
+
expect(created.payment_type).to be MangoModel::PayInPaymentType::PREAUTHORIZED
|
54
|
+
expect(created.execution_type).to be MangoModel::PayInExecutionType::DIRECT
|
55
|
+
expect(its_the_same_card_pre_auth(pay_in, created)).to be_truthy
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#BANK_WIRE DIRECT' do
|
61
|
+
|
62
|
+
context 'to a wallet' do
|
63
|
+
context 'given a valid object' do
|
64
|
+
pay_in = BANK_WIRE_DIRECT_PAY_IN_DATA
|
65
|
+
|
66
|
+
it 'creates the bank wire direct pay-in entity' do
|
67
|
+
created = MangoApi::PayIns.create_bank_wire_direct pay_in
|
68
|
+
|
69
|
+
expect(created).to be_kind_of MangoModel::BankWireDirectPayIn
|
70
|
+
expect(created.id).not_to be_nil
|
71
|
+
expect(created.status).to be MangoModel::TransactionStatus::CREATED
|
72
|
+
expect(created.payment_type).to be MangoModel::PayInPaymentType::BANK_WIRE
|
73
|
+
expect(created.execution_type).to be MangoModel::PayInExecutionType::DIRECT
|
74
|
+
expect(created.bank_account).to be_kind_of MangoModel::BankAccount
|
75
|
+
expect(its_the_same_bank_wire_direct(pay_in, created)).to be_truthy
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'to a client wallet' do
|
81
|
+
pay_in = MangoModel::BankWireDirectPayIn.new
|
82
|
+
pay_in.credited_wallet_id = 'CREDIT_EUR'
|
83
|
+
pay_in.declared_debited_funds = MangoModel::Money.new
|
84
|
+
pay_in.declared_debited_funds.currency = MangoModel::CurrencyIso::EUR
|
85
|
+
pay_in.declared_debited_funds.amount = 120
|
86
|
+
pay_in.declared_fees = MangoModel::Money.new
|
87
|
+
pay_in.declared_fees.currency = MangoModel::CurrencyIso::EUR
|
88
|
+
pay_in.declared_fees.amount = 30
|
89
|
+
|
90
|
+
it 'creates the bank wire direct entity' do
|
91
|
+
created = MangoApi::PayIns.create_client_bank_wire_direct pay_in
|
92
|
+
expect(created).to be_kind_of MangoModel::BankWireDirectPayIn
|
93
|
+
expect(created.id).not_to be_nil
|
94
|
+
expect(created.status).to be MangoModel::TransactionStatus::CREATED
|
95
|
+
expect(created.payment_type).to be MangoModel::PayInPaymentType::BANK_WIRE
|
96
|
+
expect(created.execution_type).to be MangoModel::PayInExecutionType::DIRECT
|
97
|
+
expect(created.bank_account).to be_kind_of MangoModel::BankAccount
|
98
|
+
expect(created.credited_wallet_id).to eq pay_in.credited_wallet_id
|
99
|
+
expect(its_the_same_money(pay_in.declared_debited_funds, created.declared_debited_funds)).to be_truthy
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe '#DIRECT_DEBIT WEB' do
|
105
|
+
context 'given a valid object' do
|
106
|
+
pay_in = DIRECT_DEBIT_WEB_PAY_IN_DATA
|
107
|
+
|
108
|
+
it 'creates the direct-debit web pay-in entity' do
|
109
|
+
created = MangoApi::PayIns.create_direct_debit_web pay_in
|
110
|
+
|
111
|
+
expect(created).to be_kind_of MangoModel::DirectDebitWebPayIn
|
112
|
+
expect(created.id).not_to be_nil
|
113
|
+
expect(created.status).to be MangoModel::TransactionStatus::CREATED
|
114
|
+
expect(created.payment_type).to be MangoModel::PayInPaymentType::DIRECT_DEBIT
|
115
|
+
expect(created.execution_type).to be MangoModel::PayInExecutionType::WEB
|
116
|
+
expect(its_the_same_direct_debit_web(pay_in, created)).to be_truthy
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
# describe '#DIRECT_DEBIT DIRECT' do
|
122
|
+
# context 'given a valid object' do
|
123
|
+
# mandate = MANDATE_PERSISTED
|
124
|
+
#
|
125
|
+
# # Attention
|
126
|
+
# #
|
127
|
+
# # To make this test pass, you must pause execution with a breakpoint on
|
128
|
+
# # the following line, and use your browser to open the page received
|
129
|
+
# # in the +mandate.redirect_url+ property and click the Confirm button
|
130
|
+
# # before continuing
|
131
|
+
# expect(mandate.status).to be MangoModel::MandateStatus::SUBMITTED # Place breakpoint here
|
132
|
+
# pay_in = DIRECT_DEBIT_DIRECT_PAY_IN_DATA
|
133
|
+
#
|
134
|
+
# it 'creates the direct-debit direct pay-in entity' do
|
135
|
+
# created = MangoApi::PayIns.create_direct_debit_direct pay_in
|
136
|
+
#
|
137
|
+
# expect(created).to be_kind_of MangoModel::DirectDebitDirectPayIn
|
138
|
+
# expect(created.id).not_to be_nil
|
139
|
+
# expect(created.status).to be MangoModel::TransactionStatus::CREATED
|
140
|
+
# expect(created.payment_type).to be MangoModel::PayInPaymentType::DIRECT_DEBIT
|
141
|
+
# expect(created.execution_type).to be MangoModel::PayInExecutionType::DIRECT
|
142
|
+
# expect(its_the_same_direct_debit_direct(pay_in, created)).to be_truthy
|
143
|
+
# end
|
144
|
+
# end
|
145
|
+
# end
|
146
|
+
end
|
147
|
+
|
148
|
+
# Fails with message 'Cannot found the ressource PayIn with the id=XXXXXXXX ',
|
149
|
+
# even though a newly-created Pay-In's ID is used. API problem?
|
150
|
+
#
|
151
|
+
# describe '.get_extended_card_view' do
|
152
|
+
#
|
153
|
+
# context "given an existing Card Web Pay-In entity's ID" do
|
154
|
+
# created = CARD_WEB_PAY_IN_PERSISTED
|
155
|
+
# id = created.id
|
156
|
+
#
|
157
|
+
# it 'retrieves an extended detail view of the card used' do
|
158
|
+
# extended_card = MangoApi::PayIns.extended_card_view id
|
159
|
+
#
|
160
|
+
# expect(extended_card).to be_kind_of MangoModel::PayInWebExtendedView
|
161
|
+
# expect(extended_card.id).to eq id
|
162
|
+
# end
|
163
|
+
# end
|
164
|
+
# end
|
165
|
+
|
166
|
+
describe '.get' do
|
167
|
+
|
168
|
+
context "given an existing entity's ID" do
|
169
|
+
created = CARD_WEB_PAY_IN_PERSISTED
|
170
|
+
id = created.id
|
171
|
+
|
172
|
+
it 'retrieves the corresponding entity' do
|
173
|
+
retrieved = MangoApi::PayIns.get id
|
174
|
+
|
175
|
+
expect(retrieved).to be_kind_of MangoModel::CardWebPayIn
|
176
|
+
expect(retrieved.id).to eq id
|
177
|
+
expect(its_the_same_card_web(created, retrieved)).to be_truthy
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative '../../lib/mangopay/api/service/pay_outs'
|
2
|
+
require_relative '../context/pay_out_context'
|
3
|
+
|
4
|
+
describe MangoApi::PayOuts do
|
5
|
+
include_context 'pay_out_context'
|
6
|
+
|
7
|
+
describe '.create' do
|
8
|
+
|
9
|
+
context 'given a valid object' do
|
10
|
+
pay_out = PAY_OUT_DATA
|
11
|
+
|
12
|
+
it 'creates the pay-out entity' do
|
13
|
+
created = MangoApi::PayOuts.create pay_out
|
14
|
+
|
15
|
+
expect(created).to be_kind_of MangoModel::PayOut
|
16
|
+
expect(created.id).not_to be_nil
|
17
|
+
expect(created.payment_type).to be MangoModel::PayOutPaymentType::BANK_WIRE
|
18
|
+
expect(created.status).to be MangoModel::TransactionStatus::CREATED
|
19
|
+
expect(its_the_same_pay_out(pay_out, created)).to be_truthy
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.get' do
|
25
|
+
|
26
|
+
context "given an existing entity's ID" do
|
27
|
+
created = PAY_OUT_PERSISTED
|
28
|
+
id = created.id
|
29
|
+
|
30
|
+
it 'retrieves the corresponding entity' do
|
31
|
+
retrieved = MangoApi::PayOuts.get id
|
32
|
+
|
33
|
+
expect(retrieved).to be_kind_of MangoModel::PayOut
|
34
|
+
expect(retrieved.id).to eq id
|
35
|
+
expect(its_the_same_pay_out(created, retrieved)).to be_truthy
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require_relative '../context/pre_authorization_context'
|
2
|
+
require_relative '../context/pre_authorization_context'
|
3
|
+
require_relative '../../lib/mangopay/api/service/pre_authorizations'
|
4
|
+
require_relative '../../lib/mangopay/model/enum/payment_status'
|
5
|
+
|
6
|
+
describe MangoApi::PreAuthorizations do
|
7
|
+
include_context 'pre_authorization_context'
|
8
|
+
|
9
|
+
describe '.create' do
|
10
|
+
|
11
|
+
context 'given a valid object' do
|
12
|
+
pre_auth = PRE_AUTHORIZATION_DATA
|
13
|
+
|
14
|
+
it 'creates the pre-authorization entity' do
|
15
|
+
created = MangoApi::PreAuthorizations.create pre_auth
|
16
|
+
|
17
|
+
expect(created).to be_kind_of MangoModel::PreAuthorization
|
18
|
+
expect(created.id).not_to be_nil
|
19
|
+
expect(created.payment_status).to be MangoModel::PaymentStatus::WAITING
|
20
|
+
expect(its_the_same_pre_auth(pre_auth, created)).to be_truthy
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '.get' do
|
26
|
+
|
27
|
+
context "given an existing entity's ID" do
|
28
|
+
pre_auth = PRE_AUTHORIZATION_PERSISTED
|
29
|
+
id = pre_auth.id
|
30
|
+
|
31
|
+
it 'retrieves the corresponding entity' do
|
32
|
+
retrieved = MangoApi::PreAuthorizations.get id
|
33
|
+
|
34
|
+
expect(retrieved).to be_kind_of MangoModel::PreAuthorization
|
35
|
+
expect(retrieved.id).to eq id
|
36
|
+
expect(its_the_same_pre_auth(pre_auth, retrieved)).to be_truthy
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '.cancel' do
|
42
|
+
|
43
|
+
context "given an existing entity's ID" do
|
44
|
+
it 'cancels the corresponding entity' do
|
45
|
+
# noinspection RubyResolve
|
46
|
+
pre_auth = new_pre_authorization_persisted
|
47
|
+
id = pre_auth.id
|
48
|
+
canceled = MangoApi::PreAuthorizations.cancel id
|
49
|
+
|
50
|
+
expect(canceled).to be_kind_of MangoModel::PreAuthorization
|
51
|
+
expect(canceled.id).to eq id
|
52
|
+
expect(canceled.status).to be MangoModel::PreAuthorizationStatus::SUCCEEDED
|
53
|
+
expect(canceled.payment_status).to be MangoModel::PaymentStatus::CANCELED
|
54
|
+
expect(its_the_same_pre_auth(pre_auth, canceled)).to be_truthy
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative '../../lib/mangopay/api/service/refunds'
|
2
|
+
require_relative '../context/refund_context'
|
3
|
+
require_relative '../context/transfer_context'
|
4
|
+
|
5
|
+
describe MangoApi::Refunds do
|
6
|
+
include_context 'refund_context'
|
7
|
+
include_context 'transfer_context'
|
8
|
+
|
9
|
+
describe '.create_for_pay_in' do
|
10
|
+
|
11
|
+
context "given an existing pay-in entity's ID and a valid object" do
|
12
|
+
id = CARD_DIRECT_PAY_IN_PERSISTED.id
|
13
|
+
refund = build_pay_in_refund
|
14
|
+
|
15
|
+
it 'creates the refund entity' do
|
16
|
+
created = MangoApi::Refunds.create_for_pay_in(id, refund)
|
17
|
+
|
18
|
+
expect(created).to be_kind_of MangoModel::Refund
|
19
|
+
expect(created.id).not_to be_nil
|
20
|
+
expect(created.status).to be MangoModel::TransactionStatus::SUCCEEDED
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '.create_for_transfer' do
|
26
|
+
|
27
|
+
context "given an existing transfer entity's ID and a valid object" do
|
28
|
+
id = TRANSFER_PERSISTED.id
|
29
|
+
refund = TRANSFER_REFUND_DATA
|
30
|
+
|
31
|
+
it 'creates the refund entity' do
|
32
|
+
created = MangoApi::Refunds.create_for_transfer(id, refund)
|
33
|
+
|
34
|
+
expect(created).to be_kind_of MangoModel::Refund
|
35
|
+
expect(created.id).not_to be_nil
|
36
|
+
expect(created.status).to be MangoModel::TransactionStatus::SUCCEEDED
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require_relative '../../lib/mangopay/api/service/reports'
|
2
|
+
require_relative '../../spec/context/report_context'
|
3
|
+
require_relative '../../lib/mangopay/common/sort_field'
|
4
|
+
require_relative '../../lib/mangopay/common/sort_direction'
|
5
|
+
|
6
|
+
describe MangoApi::Reports do
|
7
|
+
include_context 'report_context'
|
8
|
+
|
9
|
+
describe '.create_for_transactions' do
|
10
|
+
|
11
|
+
context 'given a valid object' do
|
12
|
+
report = REPORT_DATA
|
13
|
+
|
14
|
+
it 'creates the transaction report entity' do
|
15
|
+
created = MangoApi::Reports.create_for_transactions report do |filter|
|
16
|
+
filter.before_date = 1_463_440_221
|
17
|
+
filter.after_date = 1_449_817_821
|
18
|
+
filter.type = [MangoModel::TransactionType::PAYIN]
|
19
|
+
filter.status = [MangoModel::TransactionStatus::SUCCEEDED]
|
20
|
+
filter.nature = [MangoModel::TransactionNature::REGULAR]
|
21
|
+
filter.min_debited_funds_amount = 430
|
22
|
+
filter.min_debited_funds_currency = MangoModel::CurrencyIso::EUR
|
23
|
+
filter.max_debited_funds_amount = 8790
|
24
|
+
filter.max_debited_funds_currency = MangoModel::CurrencyIso::EUR
|
25
|
+
filter.min_fees_amount = 120
|
26
|
+
filter.min_fees_currency = MangoModel::CurrencyIso::EUR
|
27
|
+
filter.max_fees_amount = 450
|
28
|
+
filter.max_fees_currency = MangoModel::CurrencyIso::EUR
|
29
|
+
end
|
30
|
+
|
31
|
+
expect(created).to be_kind_of MangoModel::Report
|
32
|
+
expect(created.id).not_to be_nil
|
33
|
+
expect(created.report_type).to be MangoModel::ReportType::TRANSACTIONS
|
34
|
+
expect(created.status).to be MangoModel::ReportStatus::PENDING
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '.create_for_wallets' do
|
40
|
+
|
41
|
+
context 'given a valid object' do
|
42
|
+
report = REPORT_DATA
|
43
|
+
|
44
|
+
it 'creates the transaction report entity' do
|
45
|
+
created = MangoApi::Reports.create_for_wallets report do |filter|
|
46
|
+
filter.before_date = 1_463_440_221
|
47
|
+
filter.after_date = 1_449_817_821
|
48
|
+
filter.currency = MangoModel::CurrencyIso::EUR
|
49
|
+
filter.min_balance_amount = 123
|
50
|
+
filter.min_balance_currency = MangoModel::CurrencyIso::EUR
|
51
|
+
filter.max_balance_amount = 1230
|
52
|
+
filter.max_balance_currency = MangoModel::CurrencyIso::EUR
|
53
|
+
end
|
54
|
+
|
55
|
+
expect(created).to be_kind_of MangoModel::Report
|
56
|
+
expect(created.id).not_to be_nil
|
57
|
+
expect(created.report_type).to be MangoModel::ReportType::WALLETS
|
58
|
+
expect(created.status).to be MangoModel::ReportStatus::PENDING
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '.get' do
|
64
|
+
|
65
|
+
context "given an existing entity's ID" do
|
66
|
+
created = REPORT_PERSISTED
|
67
|
+
id = created.id
|
68
|
+
|
69
|
+
it 'retrieves the corresponding entity' do
|
70
|
+
retrieved = MangoApi::Reports.get id
|
71
|
+
|
72
|
+
expect(retrieved).to be_kind_of MangoModel::Report
|
73
|
+
expect(retrieved.id).to eq id
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '.all' do
|
79
|
+
|
80
|
+
context 'from a correctly-configured environment' do
|
81
|
+
context 'not having specified filters' do
|
82
|
+
default_per_page = 10
|
83
|
+
|
84
|
+
it 'retrieves list with default parameters' do
|
85
|
+
results = MangoApi::Reports.all
|
86
|
+
|
87
|
+
expect(results).to be_kind_of Array
|
88
|
+
expect(results.length).to eq default_per_page
|
89
|
+
results.each do |result|
|
90
|
+
expect(result).to be_kind_of MangoModel::Report
|
91
|
+
expect(result.id).not_to be_nil
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'having specified filters' do
|
97
|
+
per_page = 11
|
98
|
+
|
99
|
+
it 'retrieves list with specified parameters' do
|
100
|
+
results = MangoApi::Reports.all do |filter|
|
101
|
+
filter.page = 1
|
102
|
+
filter.per_page = per_page
|
103
|
+
filter.sort_field = MangoPay::SortField::CREATION_DATE
|
104
|
+
filter.sort_direction = MangoPay::SortDirection::DESC
|
105
|
+
end
|
106
|
+
|
107
|
+
expect(results).to be_kind_of Array
|
108
|
+
expect(results.length).to eq per_page
|
109
|
+
results.each.with_index do |result, index|
|
110
|
+
expect(result).to be_kind_of MangoModel::Report
|
111
|
+
expect(result.id).not_to be_nil
|
112
|
+
next if index == results.length - 1
|
113
|
+
first_date = result.creation_date
|
114
|
+
second_date = results[index + 1].creation_date
|
115
|
+
expect(first_date >= second_date).to be_truthy
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|