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,45 @@
|
|
1
|
+
require_relative 'address_context'
|
2
|
+
require_relative '../../lib/mangopay/model/entity/client'
|
3
|
+
|
4
|
+
shared_context 'client_context' do
|
5
|
+
|
6
|
+
CLIENT_DATA ||= build_client_data
|
7
|
+
end
|
8
|
+
|
9
|
+
def build_client_data
|
10
|
+
client = MangoModel::Client.new
|
11
|
+
client.primary_theme_colour = '#508c4a'
|
12
|
+
client.primary_button_colour = '#d0ae5f'
|
13
|
+
client.tech_emails = ['tech@mangopay.com']
|
14
|
+
client.admin_emails = ['admin@mangopay.com']
|
15
|
+
client.fraud_emails = ['fraud@mangopay.com']
|
16
|
+
client.billing_emails = ['billing@mangopay.com']
|
17
|
+
client.platform_description = "Test description (time = #{Time.now})"
|
18
|
+
client.platform_type = MangoModel::PlatformType::MARKETPLACE
|
19
|
+
client.platform_url = 'https://www.mangopay.com'
|
20
|
+
client.headquarters_address = build_address
|
21
|
+
client.tax_number = 'FR52BSSS'
|
22
|
+
client
|
23
|
+
end
|
24
|
+
|
25
|
+
def its_the_same_client(client1, client2)
|
26
|
+
client1.primary_theme_colour == client2.primary_theme_colour\
|
27
|
+
&& client1.primary_button_colour == client2.primary_button_colour\
|
28
|
+
&& same_values(client1.tech_emails, client2.tech_emails)\
|
29
|
+
&& same_values(client1.admin_emails, client2.admin_emails)\
|
30
|
+
&& same_values(client1.fraud_emails, client2.fraud_emails)\
|
31
|
+
&& same_values(client1.billing_emails, client2.billing_emails)\
|
32
|
+
&& client1.platform_description == client2.platform_description\
|
33
|
+
&& client1.platform_type.eql?(client2.platform_type)\
|
34
|
+
&& client1.platform_url == client2.platform_url\
|
35
|
+
&& its_the_same_address(client1.headquarters_address, client2.headquarters_address)\
|
36
|
+
&& client1.tax_number == client2.tax_number
|
37
|
+
end
|
38
|
+
|
39
|
+
def same_values(array1, array2)
|
40
|
+
return false unless array1.length == array2.length
|
41
|
+
array1.each do |value|
|
42
|
+
return false unless array2.include? value
|
43
|
+
end
|
44
|
+
true
|
45
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative 'wallet_context'
|
2
|
+
require_relative '../../lib/mangopay/api/service/disputes'
|
3
|
+
|
4
|
+
shared_context 'dispute_context' do
|
5
|
+
include_context 'wallet_context'
|
6
|
+
|
7
|
+
DISPUTE_PERSISTED ||= first_dispute
|
8
|
+
end
|
9
|
+
|
10
|
+
def first_dispute
|
11
|
+
MangoApi::Disputes.all[0]
|
12
|
+
end
|
13
|
+
|
14
|
+
def its_the_same_dispute(dispute1, dispute2)
|
15
|
+
dispute1.contest_deadline_date == dispute2.contest_deadline_date\
|
16
|
+
&& its_the_same_money(dispute1.contested_funds, dispute2.contested_funds)\
|
17
|
+
&& its_the_same_money(dispute1.disputed_funds, dispute2.disputed_funds)\
|
18
|
+
&& its_the_same_reason(dispute1.dispute_reason, dispute2.dispute_reason)\
|
19
|
+
&& dispute1.dispute_type.eql?(dispute2.dispute_type)\
|
20
|
+
&& dispute1.initial_transaction_id == dispute2.initial_transaction_id\
|
21
|
+
&& dispute1.initial_transaction_type.eql?(dispute2.initial_transaction_type)\
|
22
|
+
&& dispute1.repudiation_id == dispute2.repudiation_id\
|
23
|
+
&& dispute1.result_code == dispute2.result_code\
|
24
|
+
&& dispute1.result_message == dispute2.result_message\
|
25
|
+
&& dispute1.status.eql?(dispute2.status)\
|
26
|
+
&& dispute1.status_message == dispute2.status_message
|
27
|
+
end
|
28
|
+
|
29
|
+
def its_the_same_money(money1, money2)
|
30
|
+
money1.currency.eql?(money2.currency)\
|
31
|
+
&& money1.amount == money2.amount
|
32
|
+
end
|
33
|
+
|
34
|
+
def its_the_same_reason(reason1, reason2)
|
35
|
+
reason1.dispute_reason_message == reason2.dispute_reason_message\
|
36
|
+
&& reason1.dispute_reason_type.eql?(reason2.dispute_reason_type)
|
37
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative 'dispute_context'
|
2
|
+
require_relative '../../lib/mangopay/model/entity/dispute_document'
|
3
|
+
require_relative '../../lib/mangopay/model/enum/dispute_document_type'
|
4
|
+
|
5
|
+
shared_context 'dispute_document_context' do
|
6
|
+
include_context 'dispute_context'
|
7
|
+
|
8
|
+
DISPUTE_DOCUMENT_DATA ||= build_dispute_document
|
9
|
+
DISPUTE_DOCUMENT_PERSISTED ||= persisted_dispute_doc
|
10
|
+
end
|
11
|
+
|
12
|
+
def persisted_dispute_doc
|
13
|
+
MangoApi::DisputeDocuments.all[0]
|
14
|
+
end
|
15
|
+
|
16
|
+
def build_dispute_document
|
17
|
+
document = MangoModel::DisputeDocument.new
|
18
|
+
document.type = MangoModel::DisputeDocumentType::REFUND_PROOF
|
19
|
+
document
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative '../../lib/mangopay/api/service/hooks'
|
2
|
+
require_relative '../../lib/mangopay/model/enum/event_type'
|
3
|
+
require_relative '../../lib/mangopay/model/entity/hook'
|
4
|
+
|
5
|
+
shared_context 'hook_context' do
|
6
|
+
|
7
|
+
HOOK_DATA = build_hook
|
8
|
+
HOOK_PERSISTED = MangoApi::Hooks.all[0]
|
9
|
+
end
|
10
|
+
|
11
|
+
def build_hook
|
12
|
+
hook = MangoModel::Hook.new
|
13
|
+
hook.event_type = MangoModel::EventType::PAYIN_REPUDIATION_CREATED
|
14
|
+
hook.url = 'http://www.my-site.com/hooks/'
|
15
|
+
hook
|
16
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative 'user_context'
|
2
|
+
require_relative '../../lib/mangopay/api/service/kyc_documents'
|
3
|
+
|
4
|
+
shared_context 'kyc_document_context' do
|
5
|
+
include_context 'user_context'
|
6
|
+
|
7
|
+
KYC_DOCUMENT_DATA ||= build_kyc_document
|
8
|
+
KYC_DOCUMENT_PERSISTED ||= persist_kyc_doc KYC_DOCUMENT_DATA
|
9
|
+
end
|
10
|
+
|
11
|
+
def persist_kyc_doc(kyc_doc)
|
12
|
+
MangoApi::KycDocuments.create kyc_doc, NATURAL_USER_PERSISTED.id
|
13
|
+
end
|
14
|
+
|
15
|
+
def build_kyc_document
|
16
|
+
kyc_doc = MangoModel::KycDocument.new
|
17
|
+
kyc_doc.type = MangoModel::KycDocumentType::IDENTITY_PROOF
|
18
|
+
kyc_doc
|
19
|
+
end
|
20
|
+
|
21
|
+
def its_the_same_kyc_doc(kyc_doc1, kyc_doc2)
|
22
|
+
kyc_doc1.type.eql?(kyc_doc2.type)
|
23
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative 'bank_account_context'
|
2
|
+
require_relative '../../lib/mangopay/model/enum/mandate_culture_code'
|
3
|
+
require_relative '../../lib/mangopay/api/service/mandates'
|
4
|
+
|
5
|
+
shared_context 'mandate_context' do
|
6
|
+
include_context 'bank_account_context'
|
7
|
+
|
8
|
+
MANDATE_DATA ||= build_mandate
|
9
|
+
MANDATE_PERSISTED ||= persist_mandate MANDATE_DATA
|
10
|
+
end
|
11
|
+
|
12
|
+
def persist_mandate(mandate)
|
13
|
+
MangoApi::Mandates.create mandate
|
14
|
+
end
|
15
|
+
|
16
|
+
def build_mandate
|
17
|
+
mandate = MangoModel::Mandate.new
|
18
|
+
mandate.bank_account_id = IBAN_ACCOUNT_PERSISTED.id
|
19
|
+
mandate.culture = MangoModel::MandateCultureCode::EN
|
20
|
+
mandate.return_url = 'http://www.my-site.com/returnURL/'
|
21
|
+
mandate
|
22
|
+
end
|
23
|
+
|
24
|
+
def its_the_same_mandate(mandate1, mandate2)
|
25
|
+
mandate1.bank_account_id == mandate2.bank_account_id\
|
26
|
+
&& mandate1.culture.eql?(mandate2.culture)
|
27
|
+
end
|
@@ -0,0 +1,225 @@
|
|
1
|
+
require_relative 'wallet_context'
|
2
|
+
require_relative 'card_context'
|
3
|
+
require_relative 'pre_authorization_context'
|
4
|
+
require_relative 'mandate_context'
|
5
|
+
require_relative '../../lib/mangopay/api/service/pay_ins'
|
6
|
+
require_relative '../../lib/mangopay/model/enum/card_type'
|
7
|
+
require_relative '../../lib/mangopay/model/enum/direct_debit_type'
|
8
|
+
require_relative '../../lib/mangopay/model/entity/pay_in/card_web_pay_in'
|
9
|
+
require_relative '../../lib/mangopay/model/entity/pay_in/card_direct_pay_in'
|
10
|
+
require_relative '../../lib/mangopay/model/entity/pay_in/card_pre_authorized_pay_in'
|
11
|
+
require_relative '../../lib/mangopay/model/entity/pay_in/bank_wire_direct_pay_in'
|
12
|
+
require_relative '../../lib/mangopay/model/entity/pay_in/direct_debit_web_pay_in'
|
13
|
+
require_relative '../../lib/mangopay/model/entity/pay_in/direct_debit_direct_pay_in'
|
14
|
+
require_relative '../../lib/mangopay/common/template_url_options'
|
15
|
+
|
16
|
+
shared_context 'pay_in_context' do
|
17
|
+
include_context 'wallet_context'
|
18
|
+
include_context 'card_context'
|
19
|
+
include_context 'pre_authorization_context'
|
20
|
+
include_context 'mandate_context'
|
21
|
+
|
22
|
+
CARD_WEB_PAY_IN_DATA ||= build_card_web_pay_in
|
23
|
+
CARD_DIRECT_PAY_IN_DATA ||= build_card_direct_pay_in
|
24
|
+
CARD_PRE_AUTH_PAY_IN_DATA ||= build_card_pre_auth_pay_in
|
25
|
+
BANK_WIRE_DIRECT_PAY_IN_DATA ||= build_bank_wire_direct_pay_in
|
26
|
+
DIRECT_DEBIT_WEB_PAY_IN_DATA ||= build_direct_debit_web_pay_in
|
27
|
+
DIRECT_DEBIT_DIRECT_PAY_IN_DATA ||= build_direct_debit_direct_pay_in
|
28
|
+
CARD_WEB_PAY_IN_PERSISTED ||= persist_card_web CARD_WEB_PAY_IN_DATA
|
29
|
+
CARD_DIRECT_PAY_IN_PERSISTED ||= persist_card_direct CARD_DIRECT_PAY_IN_DATA
|
30
|
+
CARD_PRE_AUTH_PAY_IN_PERSISTED ||= persist_card_pre_auth CARD_PRE_AUTH_PAY_IN_DATA
|
31
|
+
BANK_WIRE_DIRECT_PAY_IN_PERSISTED ||= persist_bank_wire_direct BANK_WIRE_DIRECT_PAY_IN_DATA
|
32
|
+
DIRECT_DEBIT_WEB_PAY_IN_PERSISTED ||= persist_direct_debit_web DIRECT_DEBIT_WEB_PAY_IN_DATA
|
33
|
+
DIRECT_DEBIT_DIRECT_PAY_IN_PERSISTED ||= persist_direct_debit_direct DIRECT_DEBIT_DIRECT_PAY_IN_DATA
|
34
|
+
end
|
35
|
+
|
36
|
+
def persist_card_web(pay_in)
|
37
|
+
MangoApi::PayIns.create_card_web pay_in
|
38
|
+
end
|
39
|
+
|
40
|
+
def persist_card_direct(pay_in)
|
41
|
+
MangoApi::PayIns.create_card_direct pay_in
|
42
|
+
end
|
43
|
+
|
44
|
+
def persist_card_pre_auth(pay_in)
|
45
|
+
MangoApi::PayIns.create_card_pre_authorized pay_in
|
46
|
+
end
|
47
|
+
|
48
|
+
def persist_bank_wire_direct(pay_in)
|
49
|
+
MangoApi::PayIns.create_bank_wire_direct pay_in
|
50
|
+
end
|
51
|
+
|
52
|
+
def persist_direct_debit_web(pay_in)
|
53
|
+
MangoApi::PayIns.create_direct_debit_web pay_in
|
54
|
+
end
|
55
|
+
|
56
|
+
def persist_direct_debit_direct(pay_in)
|
57
|
+
MangoApi::PayIns.create_direct_debit_direct pay_in
|
58
|
+
end
|
59
|
+
|
60
|
+
def build_card_web_pay_in
|
61
|
+
pay_in = MangoModel::CardWebPayIn.new
|
62
|
+
pay_in.author_id = NATURAL_USER_PERSISTED.id
|
63
|
+
pay_in.credited_user_id = NATURAL_USER_PERSISTED.id
|
64
|
+
pay_in.debited_funds = MangoModel::Money.new
|
65
|
+
pay_in.debited_funds.currency = MangoModel::CurrencyIso::EUR
|
66
|
+
pay_in.debited_funds.amount = 120
|
67
|
+
pay_in.fees = MangoModel::Money.new
|
68
|
+
pay_in.fees.currency = MangoModel::CurrencyIso::EUR
|
69
|
+
pay_in.fees.amount = 30
|
70
|
+
pay_in.return_url = 'http://www.my-site.com/returnURL/'
|
71
|
+
pay_in.credited_wallet_id = WALLET_PERSISTED.id
|
72
|
+
pay_in.card_type = MangoModel::CardType::CB_VISA_MASTERCARD
|
73
|
+
pay_in.secure_mode = MangoModel::SecureMode::DEFAULT
|
74
|
+
pay_in.culture = MangoModel::CultureCode::EN
|
75
|
+
pay_in.template_url_options = TemplateUrlOptions.new
|
76
|
+
pay_in.template_url_options.payline = 'https://www.mysite.com/template/'
|
77
|
+
pay_in.statement_descriptor = 'Mar2016'
|
78
|
+
pay_in
|
79
|
+
end
|
80
|
+
|
81
|
+
def build_card_direct_pay_in
|
82
|
+
pay_in = MangoModel::CardDirectPayIn.new
|
83
|
+
pay_in.author_id = NATURAL_USER_PERSISTED.id
|
84
|
+
pay_in.credited_user_id = NATURAL_USER_PERSISTED.id
|
85
|
+
pay_in.credited_wallet_id = WALLET_PERSISTED.id
|
86
|
+
pay_in.debited_funds = MangoModel::Money.new
|
87
|
+
pay_in.debited_funds.currency = MangoModel::CurrencyIso::EUR
|
88
|
+
pay_in.debited_funds.amount = 120
|
89
|
+
pay_in.fees = MangoModel::Money.new
|
90
|
+
pay_in.fees.currency = MangoModel::CurrencyIso::EUR
|
91
|
+
pay_in.fees.amount = 30
|
92
|
+
pay_in.secure_mode_return_url = 'http://www.my-site.com/returnURL/'
|
93
|
+
pay_in.card_id = CARD.id
|
94
|
+
pay_in.secure_mode = MangoModel::SecureMode::DEFAULT
|
95
|
+
pay_in.statement_descriptor = 'Mar2016'
|
96
|
+
pay_in
|
97
|
+
end
|
98
|
+
|
99
|
+
def build_card_pre_auth_pay_in
|
100
|
+
pay_in = MangoModel::CardPreAuthorizedPayIn.new
|
101
|
+
pay_in.author_id = NATURAL_USER_PERSISTED.id
|
102
|
+
pay_in.credited_user_id = NATURAL_USER_PERSISTED.id
|
103
|
+
pay_in.credited_wallet_id = WALLET_PERSISTED.id
|
104
|
+
pay_in.debited_funds = MangoModel::Money.new
|
105
|
+
pay_in.debited_funds.currency = MangoModel::CurrencyIso::EUR
|
106
|
+
pay_in.debited_funds.amount = 120
|
107
|
+
pay_in.fees = MangoModel::Money.new
|
108
|
+
pay_in.fees.currency = MangoModel::CurrencyIso::EUR
|
109
|
+
pay_in.fees.amount = 30
|
110
|
+
pay_in.preauthorization_id = PRE_AUTHORIZATION_PERSISTED.id
|
111
|
+
pay_in
|
112
|
+
end
|
113
|
+
|
114
|
+
def build_bank_wire_direct_pay_in
|
115
|
+
pay_in = MangoModel::BankWireDirectPayIn.new
|
116
|
+
pay_in.author_id = NATURAL_USER_PERSISTED.id
|
117
|
+
pay_in.credited_user_id = NATURAL_USER_PERSISTED.id
|
118
|
+
pay_in.credited_wallet_id = WALLET_PERSISTED.id
|
119
|
+
pay_in.declared_debited_funds = MangoModel::Money.new
|
120
|
+
pay_in.declared_debited_funds.currency = MangoModel::CurrencyIso::EUR
|
121
|
+
pay_in.declared_debited_funds.amount = 120
|
122
|
+
pay_in.declared_fees = MangoModel::Money.new
|
123
|
+
pay_in.declared_fees.currency = MangoModel::CurrencyIso::EUR
|
124
|
+
pay_in.declared_fees.amount = 80
|
125
|
+
pay_in
|
126
|
+
end
|
127
|
+
|
128
|
+
def build_direct_debit_web_pay_in
|
129
|
+
pay_in = MangoModel::DirectDebitWebPayIn.new
|
130
|
+
pay_in.author_id = NATURAL_USER_PERSISTED.id
|
131
|
+
pay_in.credited_user_id = NATURAL_USER_PERSISTED.id
|
132
|
+
pay_in.credited_wallet_id = WALLET_PERSISTED.id
|
133
|
+
pay_in.debited_funds = MangoModel::Money.new
|
134
|
+
pay_in.debited_funds.currency = MangoModel::CurrencyIso::EUR
|
135
|
+
pay_in.debited_funds.amount = 120
|
136
|
+
pay_in.fees = MangoModel::Money.new
|
137
|
+
pay_in.fees.currency = MangoModel::CurrencyIso::EUR
|
138
|
+
pay_in.fees.amount = 80
|
139
|
+
pay_in.return_url = 'http://www.my-site.com/returnURL/'
|
140
|
+
pay_in.direct_debit_type = MangoModel::DirectDebitType::SOFORT
|
141
|
+
pay_in.secure_mode = MangoModel::SecureMode::DEFAULT
|
142
|
+
pay_in.culture = MangoModel::CultureCode::EN
|
143
|
+
pay_in.template_url_options = TemplateUrlOptions.new
|
144
|
+
pay_in.template_url_options.payline = 'https://www.mysite.com/template/'
|
145
|
+
pay_in
|
146
|
+
end
|
147
|
+
|
148
|
+
def build_direct_debit_direct_pay_in
|
149
|
+
pay_in = MangoModel::DirectDebitDirectPayIn.new
|
150
|
+
pay_in.author_id = NATURAL_USER_PERSISTED.id
|
151
|
+
pay_in.credited_user_id = NATURAL_USER_PERSISTED.id
|
152
|
+
pay_in.credited_wallet_id = WALLET_PERSISTED.id
|
153
|
+
pay_in.debited_funds = MangoModel::Money.new
|
154
|
+
pay_in.debited_funds.currency = MangoModel::CurrencyIso::EUR
|
155
|
+
pay_in.debited_funds.amount = 120
|
156
|
+
pay_in.fees = MangoModel::Money.new
|
157
|
+
pay_in.fees.currency = MangoModel::CurrencyIso::EUR
|
158
|
+
pay_in.fees.amount = 80
|
159
|
+
pay_in.mandate_id = MANDATE_PERSISTED.id
|
160
|
+
pay_in.statement_descriptor = 'Nov2016'
|
161
|
+
pay_in
|
162
|
+
end
|
163
|
+
|
164
|
+
def its_the_same_card_web(pay_in1, pay_in2)
|
165
|
+
pay_in1.author_id == pay_in2.author_id\
|
166
|
+
&& pay_in1.credited_user_id == pay_in2.credited_user_id\
|
167
|
+
&& its_the_same_money(pay_in1.debited_funds, pay_in2.debited_funds)\
|
168
|
+
&& its_the_same_money(pay_in1.fees, pay_in2.fees)\
|
169
|
+
&& pay_in1.credited_wallet_id == pay_in2.credited_wallet_id\
|
170
|
+
&& pay_in1.card_type.eql?(pay_in2.card_type)\
|
171
|
+
&& pay_in1.secure_mode.eql?(pay_in2.secure_mode)\
|
172
|
+
&& pay_in1.culture.eql?(pay_in2.culture)\
|
173
|
+
&& pay_in1.statement_descriptor == pay_in2.statement_descriptor
|
174
|
+
end
|
175
|
+
|
176
|
+
def its_the_same_card_direct(pay_in1, pay_in2)
|
177
|
+
pay_in1.author_id == pay_in2.author_id\
|
178
|
+
&& pay_in1.credited_user_id == pay_in2.credited_user_id\
|
179
|
+
&& its_the_same_money(pay_in1.debited_funds, pay_in2.debited_funds)\
|
180
|
+
&& its_the_same_money(pay_in1.fees, pay_in2.fees)\
|
181
|
+
&& pay_in1.card_id == pay_in2.card_id\
|
182
|
+
&& pay_in1.secure_mode.eql?(pay_in2.secure_mode)\
|
183
|
+
&& pay_in1.statement_descriptor == pay_in2.statement_descriptor
|
184
|
+
end
|
185
|
+
|
186
|
+
def its_the_same_card_pre_auth(pay_in1, pay_in2)
|
187
|
+
pay_in1.author_id == pay_in2.author_id\
|
188
|
+
&& pay_in1.credited_user_id == pay_in2.credited_user_id\
|
189
|
+
&& its_the_same_money(pay_in1.debited_funds, pay_in2.debited_funds)\
|
190
|
+
&& its_the_same_money(pay_in1.fees, pay_in2.fees)\
|
191
|
+
&& pay_in1.preauthorization_id == pay_in2.preauthorization_id
|
192
|
+
end
|
193
|
+
|
194
|
+
def its_the_same_bank_wire_direct(pay_in1, pay_in2)
|
195
|
+
pay_in1.author_id == pay_in2.author_id\
|
196
|
+
&& pay_in1.credited_user_id == pay_in2.credited_user_id\
|
197
|
+
&& pay_in1.credited_wallet_id == pay_in2.credited_wallet_id\
|
198
|
+
&& its_the_same_money(pay_in1.declared_debited_funds, pay_in2.declared_debited_funds)\
|
199
|
+
&& its_the_same_money(pay_in1.declared_fees, pay_in2.declared_fees)
|
200
|
+
end
|
201
|
+
|
202
|
+
def its_the_same_direct_debit_web(pay_in1, pay_in2)
|
203
|
+
pay_in1.author_id == pay_in2.author_id\
|
204
|
+
&& pay_in1.credited_user_id == pay_in2.credited_user_id\
|
205
|
+
&& its_the_same_money(pay_in1.debited_funds, pay_in2.debited_funds)\
|
206
|
+
&& its_the_same_money(pay_in1.fees, pay_in2.fees)\
|
207
|
+
&& pay_in1.credited_wallet_id == pay_in2.credited_wallet_id\
|
208
|
+
&& pay_in1.direct_debit_type.eql?(pay_in2.direct_debit_type)\
|
209
|
+
&& pay_in1.culture.eql?(pay_in2.culture)
|
210
|
+
end
|
211
|
+
|
212
|
+
def its_the_same_direct_debit_direct(pay_in1, pay_in2)
|
213
|
+
pay_in1.author_id == pay_in2.author_id\
|
214
|
+
&& pay_in1.credited_user_id == pay_in2.credited_user_id\
|
215
|
+
&& pay_in1.credited_wallet_id == pay_in2.credited_wallet_id\
|
216
|
+
&& its_the_same_money(pay_in1.debited_funds, pay_in2.debited_funds)\
|
217
|
+
&& its_the_same_money(pay_in1.fees, pay_in2.fees)\
|
218
|
+
&& pay_in1.mandate_id == pay_in2.mandate_id\
|
219
|
+
&& pay_in1.statement_descriptor == pay_in2.statement_descriptor
|
220
|
+
end
|
221
|
+
|
222
|
+
def its_the_same_money(money1, money2)
|
223
|
+
money1.currency.eql?(money2.currency)\
|
224
|
+
&& money1.amount == money2.amount
|
225
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative 'bank_account_context'
|
2
|
+
require_relative 'pay_in_context'
|
3
|
+
require_relative '../../lib/mangopay/model/entity/pay_out'
|
4
|
+
|
5
|
+
shared_context 'pay_out_context' do
|
6
|
+
include_context 'bank_account_context'
|
7
|
+
include_context 'pay_in_context'
|
8
|
+
|
9
|
+
PAY_OUT_DATA ||= build_pay_out
|
10
|
+
PAY_OUT_PERSISTED ||= persist_pay_out PAY_OUT_DATA
|
11
|
+
end
|
12
|
+
|
13
|
+
def persist_pay_out(pay_out)
|
14
|
+
MangoApi::PayOuts.create pay_out
|
15
|
+
end
|
16
|
+
|
17
|
+
def build_pay_out
|
18
|
+
pay_out = MangoModel::PayOut.new
|
19
|
+
pay_out.author_id = NATURAL_USER_PERSISTED.id
|
20
|
+
pay_out.debited_funds = MangoModel::Money.new
|
21
|
+
pay_out.debited_funds.currency = MangoModel::CurrencyIso::EUR
|
22
|
+
pay_out.debited_funds.amount = 10
|
23
|
+
pay_out.fees = MangoModel::Money.new
|
24
|
+
pay_out.fees.currency = MangoModel::CurrencyIso::EUR
|
25
|
+
pay_out.fees.amount = 0
|
26
|
+
pay_out.bank_account_id = IBAN_ACCOUNT_PERSISTED.id
|
27
|
+
pay_out.debited_wallet_id = WALLET_PERSISTED.id
|
28
|
+
pay_out.bank_wire_ref = 'Invoice 7282'
|
29
|
+
pay_out
|
30
|
+
end
|
31
|
+
|
32
|
+
def its_the_same_pay_out(pay_out1, pay_out2)
|
33
|
+
pay_out1.author_id == pay_out2.author_id\
|
34
|
+
&& its_the_same_money(pay_out1.debited_funds, pay_out2.debited_funds)\
|
35
|
+
&& its_the_same_money(pay_out1.fees, pay_out2.fees)\
|
36
|
+
&& pay_out1.bank_account_id == pay_out2.bank_account_id\
|
37
|
+
&& pay_out1.debited_wallet_id == pay_out2.debited_wallet_id\
|
38
|
+
&& pay_out1.bank_wire_ref == pay_out2.bank_wire_ref
|
39
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative 'user_context'
|
2
|
+
require_relative 'card_context'
|
3
|
+
require_relative '../../lib/mangopay/api/service/pre_authorizations'
|
4
|
+
|
5
|
+
shared_context 'pre_authorization_context' do
|
6
|
+
include_context 'user_context'
|
7
|
+
include_context 'card_context'
|
8
|
+
|
9
|
+
PRE_AUTHORIZATION_DATA ||= build_pre_authorization
|
10
|
+
PRE_AUTHORIZATION_PERSISTED ||= persist_pre_authorization PRE_AUTHORIZATION_DATA
|
11
|
+
|
12
|
+
let(:new_pre_authorization_persisted) { persist_pre_authorization PRE_AUTHORIZATION_DATA }
|
13
|
+
end
|
14
|
+
|
15
|
+
def persist_pre_authorization(pre_auth)
|
16
|
+
MangoApi::PreAuthorizations.create pre_auth
|
17
|
+
end
|
18
|
+
|
19
|
+
def build_pre_authorization
|
20
|
+
pre_auth = MangoModel::PreAuthorization.new
|
21
|
+
pre_auth.author_id = NATURAL_USER_PERSISTED.id
|
22
|
+
pre_auth.debited_funds = MangoModel::Money.new
|
23
|
+
pre_auth.debited_funds.currency = MangoModel::CurrencyIso::EUR
|
24
|
+
pre_auth.debited_funds.amount = 120
|
25
|
+
pre_auth.secure_mode = MangoModel::SecureMode::DEFAULT
|
26
|
+
pre_auth.card_id = CARD.id
|
27
|
+
pre_auth.secure_mode_return_url = 'http://www.my-site.com/returnURL'
|
28
|
+
pre_auth
|
29
|
+
end
|
30
|
+
|
31
|
+
def its_the_same_pre_auth(pre_auth1, pre_auth2)
|
32
|
+
pre_auth1.author_id == pre_auth2.author_id\
|
33
|
+
&& its_the_same_money(pre_auth1.debited_funds, pre_auth2.debited_funds)\
|
34
|
+
&& pre_auth1.secure_mode.eql?(pre_auth2.secure_mode)\
|
35
|
+
&& pre_auth1.card_id == pre_auth2.card_id
|
36
|
+
end
|
37
|
+
|
38
|
+
def its_the_same_money(money1, money2)
|
39
|
+
money1.currency.eql?(money2.currency)\
|
40
|
+
&& money1.amount == money2.amount
|
41
|
+
end
|