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.
Files changed (126) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ruby_cd.yml +34 -0
  3. data/.github/workflows/ruby_ci.yml +30 -0
  4. data/.gitignore +30 -0
  5. data/.rspec +3 -0
  6. data/CHANGELOG.md +640 -0
  7. data/Gemfile +2 -0
  8. data/LICENSE +20 -0
  9. data/README.md +162 -0
  10. data/Rakefile +5 -0
  11. data/bin/mangopay +9 -0
  12. data/lib/generators/mangopay/install_generator.rb +60 -0
  13. data/lib/generators/templates/mangopay.rb.erb +5 -0
  14. data/lib/mangopay/acquiring.rb +56 -0
  15. data/lib/mangopay/authorization_token.rb +89 -0
  16. data/lib/mangopay/bank_account.rb +49 -0
  17. data/lib/mangopay/bankingaliases.rb +29 -0
  18. data/lib/mangopay/bankingaliases_iban.rb +16 -0
  19. data/lib/mangopay/card.rb +54 -0
  20. data/lib/mangopay/card_registration.rb +9 -0
  21. data/lib/mangopay/client.rb +94 -0
  22. data/lib/mangopay/conversion.rb +49 -0
  23. data/lib/mangopay/deposit.rb +36 -0
  24. data/lib/mangopay/dispute.rb +152 -0
  25. data/lib/mangopay/errors.rb +66 -0
  26. data/lib/mangopay/event.rb +18 -0
  27. data/lib/mangopay/filter_parameters.rb +56 -0
  28. data/lib/mangopay/hook.rb +9 -0
  29. data/lib/mangopay/http_calls.rb +88 -0
  30. data/lib/mangopay/identity_verification.rb +16 -0
  31. data/lib/mangopay/json.rb +14 -0
  32. data/lib/mangopay/kyc_document.rb +83 -0
  33. data/lib/mangopay/legal_user.rb +21 -0
  34. data/lib/mangopay/legal_user_sca.rb +25 -0
  35. data/lib/mangopay/mandate.rb +42 -0
  36. data/lib/mangopay/natural_user.rb +20 -0
  37. data/lib/mangopay/natural_user_sca.rb +25 -0
  38. data/lib/mangopay/pay_in.rb +415 -0
  39. data/lib/mangopay/pay_out.rb +41 -0
  40. data/lib/mangopay/payment_method_metadata.rb +13 -0
  41. data/lib/mangopay/pre_authorization.rb +17 -0
  42. data/lib/mangopay/recipient.rb +35 -0
  43. data/lib/mangopay/refund.rb +19 -0
  44. data/lib/mangopay/regulatory.rb +22 -0
  45. data/lib/mangopay/report.rb +24 -0
  46. data/lib/mangopay/report_v2.rb +21 -0
  47. data/lib/mangopay/resource.rb +21 -0
  48. data/lib/mangopay/settlement.rb +21 -0
  49. data/lib/mangopay/transaction.rb +24 -0
  50. data/lib/mangopay/transfer.rb +20 -0
  51. data/lib/mangopay/ubo.rb +26 -0
  52. data/lib/mangopay/ubo_declaration.rb +32 -0
  53. data/lib/mangopay/user.rb +100 -0
  54. data/lib/mangopay/version.rb +3 -0
  55. data/lib/mangopay/virtual_account.rb +44 -0
  56. data/lib/mangopay/wallet.rb +17 -0
  57. data/lib/mangopay.rb +456 -0
  58. data/mangopay.gemspec +30 -0
  59. data/spec/mangopay/acquiring_spec.rb +176 -0
  60. data/spec/mangopay/authorization_token_spec.rb +70 -0
  61. data/spec/mangopay/bank_account_spec.rb +105 -0
  62. data/spec/mangopay/bankingaliases_spec.rb +29 -0
  63. data/spec/mangopay/card_registration_spec.rb +123 -0
  64. data/spec/mangopay/client_spec.png +0 -0
  65. data/spec/mangopay/client_spec.rb +213 -0
  66. data/spec/mangopay/configuration_spec.rb +249 -0
  67. data/spec/mangopay/conversion_spec.rb +96 -0
  68. data/spec/mangopay/deposit_spec.rb +107 -0
  69. data/spec/mangopay/dispute_spec.png +0 -0
  70. data/spec/mangopay/dispute_spec.rb +294 -0
  71. data/spec/mangopay/event_spec.rb +33 -0
  72. data/spec/mangopay/fetch_filters_spec.rb +63 -0
  73. data/spec/mangopay/hook_spec.rb +37 -0
  74. data/spec/mangopay/idempotency_spec.rb +41 -0
  75. data/spec/mangopay/identity_verification_spec.rb +47 -0
  76. data/spec/mangopay/kyc_document_spec.png +0 -0
  77. data/spec/mangopay/kyc_document_spec.rb +118 -0
  78. data/spec/mangopay/log_requests_filter_spec.rb +26 -0
  79. data/spec/mangopay/mandate_spec.rb +99 -0
  80. data/spec/mangopay/payin_applepay_direct_spec.rb +21 -0
  81. data/spec/mangopay/payin_bancontact_web_spec.rb +30 -0
  82. data/spec/mangopay/payin_bankwire_direct_spec.rb +74 -0
  83. data/spec/mangopay/payin_bankwire_external_instruction_spec.rb +104 -0
  84. data/spec/mangopay/payin_bizum_web_spec.rb +54 -0
  85. data/spec/mangopay/payin_blik_web_spec.rb +41 -0
  86. data/spec/mangopay/payin_card_direct_spec.rb +69 -0
  87. data/spec/mangopay/payin_card_web_spec.rb +64 -0
  88. data/spec/mangopay/payin_directdebit_direct_spec.rb +37 -0
  89. data/spec/mangopay/payin_directdebit_web_spec.rb +38 -0
  90. data/spec/mangopay/payin_giropay_web_spec.rb +30 -0
  91. data/spec/mangopay/payin_googlepay_direct_spec.rb +21 -0
  92. data/spec/mangopay/payin_ideal_web_spec.rb +30 -0
  93. data/spec/mangopay/payin_intent_spec.rb +151 -0
  94. data/spec/mangopay/payin_klarna_web_spec.rb +32 -0
  95. data/spec/mangopay/payin_mbway_web_spec.rb +32 -0
  96. data/spec/mangopay/payin_multibanco_web_spec.rb +31 -0
  97. data/spec/mangopay/payin_paybybank_web_spec.rb +56 -0
  98. data/spec/mangopay/payin_payconiq_web_spec.rb +31 -0
  99. data/spec/mangopay/payin_paypal_web_spec.rb +113 -0
  100. data/spec/mangopay/payin_preauthorized_direct_spec.rb +118 -0
  101. data/spec/mangopay/payin_satispay_web_spec.rb +32 -0
  102. data/spec/mangopay/payin_swish_web_spec.rb +30 -0
  103. data/spec/mangopay/payin_twint_web_spec.rb +30 -0
  104. data/spec/mangopay/payment_method_metadata_spec.rb +15 -0
  105. data/spec/mangopay/payout_bankwire_spec.rb +93 -0
  106. data/spec/mangopay/preauthorization_spec.rb +51 -0
  107. data/spec/mangopay/recipient_spec.rb +134 -0
  108. data/spec/mangopay/recurring_payin_spec.rb +222 -0
  109. data/spec/mangopay/refund_spec.rb +34 -0
  110. data/spec/mangopay/regulatory_spec.rb +26 -0
  111. data/spec/mangopay/report_spec.rb +40 -0
  112. data/spec/mangopay/report_v2_spec.rb +117 -0
  113. data/spec/mangopay/report_wallets_spec.rb +40 -0
  114. data/spec/mangopay/settlement_sample.csv +8 -0
  115. data/spec/mangopay/settlement_spec.rb +38 -0
  116. data/spec/mangopay/shared_resources.rb +1380 -0
  117. data/spec/mangopay/transaction_spec.rb +59 -0
  118. data/spec/mangopay/transfer_spec.rb +77 -0
  119. data/spec/mangopay/ubo_declaration_spec.rb +44 -0
  120. data/spec/mangopay/ubo_spec.rb +39 -0
  121. data/spec/mangopay/user_spec.rb +444 -0
  122. data/spec/mangopay/virtual_account_spec.rb +52 -0
  123. data/spec/mangopay/wallet_spec.rb +100 -0
  124. data/spec/spec_helper.rb +31 -0
  125. data/spec/tmp/.keep +0 -0
  126. metadata +280 -0
@@ -0,0 +1,99 @@
1
+ describe MangoPay::Mandate do
2
+ include_context 'mandates'
3
+
4
+ def check_status(mandate)
5
+ expect(mandate['Status']).to eq('CREATED')
6
+ expect(mandate['MandateType']).to eq('DIRECT_DEBIT')
7
+ expect(mandate['ExecutionType']).to eq('WEB')
8
+ end
9
+
10
+ describe 'CREATE' do
11
+ it 'creates a mandate' do
12
+ mandate = new_mandate
13
+ expect(mandate['Id']).to_not be_nil
14
+ check_status(mandate)
15
+ end
16
+ end
17
+
18
+ describe 'FETCH' do
19
+
20
+ it 'fetches a mandate' do
21
+ created = new_mandate
22
+ fetched = MangoPay::Mandate.fetch(created['Id'])
23
+ expect(fetched['Id']).to eq(created['Id'])
24
+ expect(fetched['CreationDate']).to eq(created['CreationDate'])
25
+ expect(fetched['UserId']).to eq(created['UserId'])
26
+ expect(fetched['BankAccountId']).to eq(created['BankAccountId'])
27
+ check_status(created)
28
+ check_status(fetched)
29
+ end
30
+
31
+ it 'fetches (all) mandates' do
32
+ created1 = create_new_mandate()
33
+ created2 = create_new_mandate()
34
+ fetched = MangoPay::Mandate.fetch({'per_page' => 2, 'sort' => 'CreationDate:desc'})
35
+
36
+ expect(fetched).to be_kind_of(Array)
37
+ expect(fetched.count).to eq 2 # exactly 2 as pagiantion requested
38
+
39
+ # all 2 are at top as lastly created
40
+ # but may share the same CreationDate
41
+ # so the order between them is undetermined
42
+ expect(fetched.map {|m| m['Id']}).to include(created1['Id'], created2['Id'])
43
+ end
44
+
45
+ end
46
+
47
+ describe 'FETCH FOR USER AND BANK ACCOUNT' do
48
+
49
+ it 'fetches mandates for user' do
50
+ created1 = create_new_mandate()
51
+ created2 = create_new_mandate()
52
+ expect(created1['UserId']).to eq(created2['UserId']) # both for same user
53
+
54
+ user_id = created1['UserId']
55
+ fetched = MangoPay::Mandate.fetch_for_user(user_id, {'per_page' => 2, 'sort' => 'CreationDate:desc'})
56
+
57
+ expect(fetched).to be_kind_of(Array)
58
+ expect(fetched.count).to eq 2 # exactly 2 as pagiantion requested
59
+ expect(fetched.map {|m| m['Id']}).to include(created1['Id'], created2['Id'])
60
+ expect((fetched.map {|m| m['UserId']}).uniq).to eq([user_id])
61
+ end
62
+
63
+ it 'fetches mandates for user bank account' do
64
+ created1 = create_new_mandate()
65
+ created2 = create_new_mandate()
66
+ expect(created1['UserId']).to eq(created2['UserId']) # both for same user
67
+ expect(created1['BankAccountId']).to eq(created2['BankAccountId']) # both for same bank account
68
+
69
+ user_id = created1['UserId']
70
+ bank_acc_id = created1['BankAccountId']
71
+ fetched = MangoPay::Mandate.fetch_for_user_bank_account(user_id, bank_acc_id, {'per_page' => 2, 'sort' => 'CreationDate:desc'})
72
+
73
+ expect(fetched).to be_kind_of(Array)
74
+ expect(fetched.count).to eq 2 # exactly 2 as pagiantion requested
75
+ expect(fetched.map {|m| m['Id']}).to include(created1['Id'], created2['Id'])
76
+ expect((fetched.map {|m| m['UserId']}).uniq).to eq([user_id])
77
+ end
78
+
79
+ end
80
+
81
+ describe 'CANCEL' do
82
+ it 'cancels a mandate' do
83
+ created = new_mandate
84
+ expect { MangoPay::Mandate.cancel(created['Id']) }.to raise_error { |err|
85
+ expect(err).to be_a MangoPay::ResponseError
86
+ expect(err.code).to eq '400'
87
+ expect(err.type).to eq 'mandate_cannot_be_cancelled'
88
+ }
89
+ end
90
+ end
91
+
92
+ describe 'FETCH Transactions' do
93
+ it "fetches a mandate's transactions" do
94
+ mandate = new_mandate
95
+ transactions = MangoPay::Mandate.transactions(mandate['Id'])
96
+ expect(transactions).to be_an(Array)
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,21 @@
1
+ describe MangoPay::PayIn::ApplePay::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('APPLEPAY')
8
+ expect(payin['ExecutionType']).to eq('DIRECT')
9
+ expect(payin['Status']).to eq('SUCCEEDED')
10
+ end
11
+
12
+ describe 'CREATE' do
13
+ it 'creates a applepay direct payin' do
14
+ pending("no cards to test for")
15
+ created = new_payin_applepay_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::Bancontact::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('BCMC')
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 bancontact web payin' do
15
+ created = new_payin_bancontact_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_bancontact_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,74 @@
1
+ describe MangoPay::PayIn::BankWire::Direct, type: :feature do
2
+ include_context 'wallets'
3
+ include_context 'payins'
4
+
5
+ def check_type_and_status(payin)
6
+ expect(payin['Type']).to eq('PAYIN')
7
+ expect(payin['Nature']).to eq('REGULAR')
8
+ expect(payin['PaymentType']).to eq('BANK_WIRE')
9
+ expect(payin['ExecutionType']).to eq('DIRECT')
10
+
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 bankwire direct payin' do
19
+ created = new_payin_bankwire_direct
20
+ expect(created['Id']).not_to be_nil
21
+ check_type_and_status(created)
22
+ end
23
+ end
24
+
25
+ describe 'FETCH' do
26
+ it 'fetches a payin' do
27
+ created = new_payin_bankwire_direct
28
+ fetched = MangoPay::PayIn.fetch(created['Id'])
29
+ expect(fetched['Id']).to eq(created['Id'])
30
+ expect(fetched['CreationDate']).to eq(created['CreationDate'])
31
+ expect(fetched['DeclaredDebitedFunds']).to eq(created['DeclaredDebitedFunds'])
32
+ expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
33
+ check_type_and_status(created)
34
+ check_type_and_status(fetched)
35
+ end
36
+ end
37
+
38
+ ###############################################
39
+ # refund not implemented for this type of payin
40
+ ###############################################
41
+ # describe 'REFUND' do
42
+ # it 'refunds a payin' do
43
+ # payin = new_payin_bankwire_direct
44
+ # refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
45
+ # expect(refund['Id']).not_to be_nil
46
+ # expect(refund['Status']).to eq('SUCCEEDED')
47
+ # expect(refund['Type']).to eq('PAYOUT')
48
+ # expect(refund['Nature']).to eq('REFUND')
49
+ # expect(refund['InitialTransactionType']).to eq('PAYIN')
50
+ # expect(refund['InitialTransactionId']).to eq(payin['Id'])
51
+ # expect(refund['DebitedWalletId']).to eq(payin['CreditedWalletId'])
52
+ # end
53
+ # end
54
+ #
55
+ ###############################################
56
+ # status is CREATED instead of SUCCEEDED
57
+ # so no cash flow yet
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_bankwire_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
+ end
@@ -0,0 +1,104 @@
1
+ describe MangoPay::PayIn::BankWire::ExternalInstruction, type: :feature do
2
+ include_context 'wallets'
3
+ include_context 'payins'
4
+
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('BANK_WIRE')
10
+ expect(payin['ExecutionType']).to eq('EXTERNAL_INSTRUCTION')
11
+ end
12
+
13
+ describe 'FETCH' do
14
+ it 'fetches a payin' do
15
+ backupConfig = MangoPay.configuration.clone
16
+ MangoPay.configure do |c|
17
+ c.preproduction = true
18
+ c.client_id = 'sdk-unit-tests'
19
+ c.root_url = 'https://api.sandbox.mangopay.com'
20
+ c.client_apiKey = 'cqFfFrWfCcb7UadHNxx2C9Lo6Djw8ZduLi7J9USTmu8bhxxpju'
21
+ c.http_timeout = 10000
22
+ end
23
+
24
+ id = "payin_m_01JK6199ED4VGBP98ABRJVDS9D"
25
+ payIn = MangoPay::PayIn.fetch(id)
26
+ expect(payIn['Id']).to eq(id)
27
+ check_type_and_status(payIn)
28
+ MangoPay.configuration = backupConfig
29
+ end
30
+
31
+ it 'fetches a bankwire external instruction with iban' do
32
+ backupConfig = MangoPay.configuration.clone
33
+ MangoPay.configure do |c|
34
+ c.preproduction = true
35
+ c.client_id = 'sdk-unit-tests'
36
+ c.root_url = 'https://api.sandbox.mangopay.com'
37
+ c.client_apiKey = 'cqFfFrWfCcb7UadHNxx2C9Lo6Djw8ZduLi7J9USTmu8bhxxpju'
38
+ c.http_timeout = 10000
39
+ end
40
+
41
+ payInId = "payin_m_01JK6199ED4VGBP98ABRJVDS9D"
42
+ payIn = MangoPay::PayIn.fetch(payInId)
43
+ expect(payIn).to_not be(nil)
44
+ expect(payIn['Id']).to eq(payInId)
45
+ check_type_and_status(payIn)
46
+ MangoPay.configuration = backupConfig
47
+ end
48
+
49
+ it 'fetches a bankwire external instruction with account number' do
50
+ backupConfig = MangoPay.configuration.clone
51
+ MangoPay.configure do |c|
52
+ c.preproduction = true
53
+ c.client_id = 'sdk-unit-tests'
54
+ c.root_url = 'https://api.sandbox.mangopay.com'
55
+ c.client_apiKey = 'cqFfFrWfCcb7UadHNxx2C9Lo6Djw8ZduLi7J9USTmu8bhxxpju'
56
+ c.http_timeout = 10000
57
+ end
58
+
59
+ payInId = "payin_m_01JK6199ED4VGBP98ABRJVDS9D"
60
+ payIn = MangoPay::PayIn.fetch(payInId)
61
+ expect(payIn).to_not be(nil)
62
+ expect(payIn['Id']).to eq(payInId)
63
+ check_type_and_status(payIn)
64
+ MangoPay.configuration = backupConfig
65
+ end
66
+ end
67
+
68
+ ###############################################
69
+ # refund not implemented for this type of payin
70
+ ###############################################
71
+ # describe 'REFUND' do
72
+ # it 'refunds a payin' do
73
+ # payin = new_payin_bankwire_direct
74
+ # refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
75
+ # expect(refund['Id']).not_to be_nil
76
+ # expect(refund['Status']).to eq('SUCCEEDED')
77
+ # expect(refund['Type']).to eq('PAYOUT')
78
+ # expect(refund['Nature']).to eq('REFUND')
79
+ # expect(refund['InitialTransactionType']).to eq('PAYIN')
80
+ # expect(refund['InitialTransactionId']).to eq(payin['Id'])
81
+ # expect(refund['DebitedWalletId']).to eq(payin['CreditedWalletId'])
82
+ # end
83
+ # end
84
+ #
85
+ ###############################################
86
+ # status is CREATED instead of SUCCEEDED
87
+ # so no cash flow yet
88
+ ###############################################
89
+ # describe 'CASH FLOW' do
90
+ # it 'changes balances correctly' do
91
+ # wlt = new_wallet
92
+ # wallets_check_amounts(wlt, 0)
93
+ #
94
+ # # payin: feed wlt1 with money
95
+ # payin = create_new_payin_bankwire_direct(wlt, 1000)
96
+ # wallets_reload_and_check_amounts(wlt, 1000)
97
+ #
98
+ # # refund the payin
99
+ # refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
100
+ # wallets_reload_and_check_amounts(wlt, 0)
101
+ # end
102
+ # end
103
+
104
+ end
@@ -0,0 +1,54 @@
1
+ describe MangoPay::PayIn::Bizum::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['PaymentType']).to eq('BIZUM')
8
+ expect(payin['ExecutionType']).to eq('WEB')
9
+ expect(payin['Status']).to eq('CREATED')
10
+ end
11
+
12
+ describe 'CREATE' do
13
+ it 'creates a bizum web payin with phone' do
14
+ created = new_payin_bizum_web_with_phone
15
+ expect(created['Id']).not_to be_nil
16
+ expect(created['Phone']).not_to be_nil
17
+ expect(created['ReturnURL']).to be_nil
18
+ check_type_and_status(created)
19
+ end
20
+
21
+ it 'creates a bizum web payin with return url' do
22
+ created = new_payin_bizum_web_with_return_url
23
+ expect(created['Id']).not_to be_nil
24
+ expect(created['Phone']).to be_nil
25
+ expect(created['ReturnURL']).not_to be_nil
26
+ check_type_and_status(created)
27
+ end
28
+ end
29
+
30
+ describe 'FETCH' do
31
+ it 'fetches a bizum payin with phone' do
32
+ created = new_payin_bizum_web_with_phone
33
+ fetched = MangoPay::PayIn.fetch(created['Id'])
34
+ expect(fetched['Id']).to eq(created['Id'])
35
+ expect(fetched['Phone']).not_to be_nil
36
+ expect(fetched['Phone']).to eq(created['Phone'])
37
+ expect(fetched['ReturnURL']).to be_nil
38
+ expect(fetched['ReturnURL']).to eq(created['ReturnURL'])
39
+ check_type_and_status(created)
40
+ check_type_and_status(fetched)
41
+ end
42
+
43
+ it 'fetches a bizum payin with return url' do
44
+ created = new_payin_bizum_web_with_return_url
45
+ fetched = MangoPay::PayIn.fetch(created['Id'])
46
+ expect(fetched['Id']).to eq(created['Id'])
47
+ expect(fetched['ReturnURL']).not_to be_nil
48
+ expect(fetched['Phone']).to be_nil
49
+ expect(fetched['ReturnURL']).to eq(created['ReturnURL'])
50
+ check_type_and_status(created)
51
+ check_type_and_status(fetched)
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,41 @@
1
+ describe MangoPay::PayIn::Blik::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('BLIK')
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 blik web payin' do
15
+ created = new_payin_blik_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
+
21
+ it 'creates a blik web payin with code' do
22
+ created = new_payin_blik_web_with_code
23
+ expect(created['Id']).not_to be_nil
24
+ expect(created['Code']).not_to be_nil
25
+ expect(created['IpAddress']).not_to be_nil
26
+ expect(created['BrowserInfo']).not_to be_nil
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_blik_web
34
+ fetched = MangoPay::PayIn.fetch(created['Id'])
35
+ expect(fetched['Id']).to eq(created['Id'])
36
+ check_type_and_status(created)
37
+ check_type_and_status(fetched)
38
+ end
39
+ end
40
+
41
+ end
@@ -0,0 +1,69 @@
1
+ describe MangoPay::PayIn::Card::Direct, type: :feature do
2
+ include_context 'wallets'
3
+ include_context 'payins'
4
+
5
+ def check_type_and_status(payin)
6
+ expect(payin['Type']).to eq('PAYIN')
7
+ expect(payin['Nature']).to eq('REGULAR')
8
+ expect(payin['PaymentType']).to eq('CARD')
9
+ expect(payin['ExecutionType']).to eq('DIRECT')
10
+
11
+ # SUCCEEDED
12
+ expect(payin['Status']).to eq('SUCCEEDED')
13
+ expect(payin['ResultCode']).to eq('000000')
14
+ expect(payin['ResultMessage']).to eq('Success')
15
+ expect(payin['ExecutionDate']).to be > 0
16
+ end
17
+
18
+ describe 'CREATE' do
19
+ it 'creates a card direct payin' do
20
+ created = new_payin_card_direct
21
+ expect(created['Id']).not_to be_nil
22
+ # expect(created['Requested3DSVersion']).not_to be_nil
23
+ check_type_and_status(created)
24
+ end
25
+ end
26
+
27
+ describe 'FETCH' do
28
+ it 'fetches a payin' do
29
+ created = new_payin_card_direct
30
+ fetched = MangoPay::PayIn.fetch(created['Id'])
31
+ expect(fetched['Id']).to eq(created['Id'])
32
+ expect(fetched['CreationDate']).to eq(created['CreationDate'])
33
+ expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
34
+ expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
35
+ check_type_and_status(created)
36
+ check_type_and_status(fetched)
37
+ end
38
+ end
39
+
40
+ describe 'REFUND' do
41
+ it 'refunds a payin' do
42
+ payin = new_payin_card_direct
43
+ refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
44
+ expect(refund['Id']).not_to be_nil
45
+ expect(refund['Status']).to eq('SUCCEEDED')
46
+ expect(refund['Type']).to eq('PAYOUT')
47
+ expect(refund['Nature']).to eq('REFUND')
48
+ expect(refund['InitialTransactionType']).to eq('PAYIN')
49
+ expect(refund['InitialTransactionId']).to eq(payin['Id'])
50
+ expect(refund['DebitedWalletId']).to eq(payin['CreditedWalletId'])
51
+ end
52
+ end
53
+
54
+ describe 'CASH FLOW' do
55
+ it 'changes balances correctly' do
56
+ wlt = new_wallet
57
+ wallets_check_amounts(wlt, 0)
58
+
59
+ # payin: feed wlt1 with money
60
+ payin = create_new_payin_card_direct(wlt, 1000)
61
+ wallets_reload_and_check_amounts(wlt, 1000)
62
+
63
+ # refund the payin
64
+ refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
65
+ wallets_reload_and_check_amounts(wlt, 0)
66
+ end
67
+ end
68
+
69
+ end
@@ -0,0 +1,64 @@
1
+ describe MangoPay::PayIn::Card::Web, type: :feature do
2
+ include_context 'payins'
3
+
4
+ def check_type_and_status(payin)
5
+ expect(payin['Type']).to eq('PAYIN')
6
+ expect(payin['Nature']).to eq('REGULAR')
7
+ expect(payin['PaymentType']).to eq('CARD')
8
+ expect(payin['ExecutionType']).to eq('WEB')
9
+
10
+ # not SUCCEEDED yet: waiting for processing
11
+ expect(payin['Status']).to eq('CREATED')
12
+ expect(payin['ResultCode']).to be_nil
13
+ expect(payin['ResultMessage']).to be_nil
14
+ expect(payin['ExecutionDate']).to be_nil
15
+ end
16
+
17
+ describe 'CREATE' do
18
+ it 'creates a card web payin' do
19
+ created = new_payin_card_web
20
+ expect(created['Id']).not_to be_nil
21
+ check_type_and_status(created)
22
+ end
23
+ end
24
+
25
+ describe 'CREATE with PaylineV2' do
26
+ it 'creates a card web payin with payline v2' do
27
+ created = new_payin_card_web_payline
28
+ expect(created['Id']).not_to be_nil
29
+ # expect(created['RedirectURL']).to include('https://www.maysite.com/payline_template/')
30
+ check_type_and_status(created)
31
+ end
32
+ end
33
+
34
+ describe 'EXTENDED' do
35
+ context 'when resource not exists' do
36
+ it 'fetches extended information' do
37
+ expect { MangoPay::PayIn::Card::Web.extended(1000000) }.to \
38
+ raise_error(MangoPay::ResponseError)
39
+ end
40
+ end
41
+ end
42
+
43
+ describe 'FETCH' do
44
+ it 'fetches a payin' do
45
+ created = new_payin_card_web
46
+ fetched = MangoPay::PayIn.fetch(created['Id'])
47
+ expect(fetched['Id']).to eq(created['Id'])
48
+ expect(fetched['CreationDate']).to eq(created['CreationDate'])
49
+ expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
50
+ expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
51
+ check_type_and_status(created)
52
+ check_type_and_status(fetched)
53
+ end
54
+ end
55
+
56
+ describe 'FETCH Refunds' do
57
+ it "fetches the pay-in's refunds" do
58
+ payin = new_payin_card_web
59
+ refunds = MangoPay::PayIn.refunds(payin['Id'])
60
+ expect(refunds).to be_an(Array)
61
+ end
62
+ end
63
+
64
+ end
@@ -0,0 +1,37 @@
1
+ describe MangoPay::PayIn::DirectDebit::Direct, type: :feature do
2
+ include_context 'payins'
3
+
4
+ def check_type_and_status(payin)
5
+ expect(payin['Type']).to eq('PAYIN')
6
+ expect(payin['Nature']).to eq('REGULAR')
7
+ expect(payin['PaymentType']).to eq('DIRECT_DEBIT')
8
+ expect(payin['ExecutionType']).to eq('DIRECT')
9
+
10
+ # FAILED: the related Mandate is not confirmed yet
11
+ expect(payin['Status']).to eq('FAILED')
12
+ expect(payin['ResultMessage']).to eq('The Status of this Mandate does not allow for payments')
13
+ expect(payin['ExecutionDate']).to be_nil
14
+ end
15
+
16
+ describe 'CREATE' do
17
+ it 'creates a directdebit direct payin' do
18
+ created = new_payin_directdebit_direct
19
+ expect(created['Id']).not_to be_nil
20
+ check_type_and_status(created)
21
+ end
22
+ end
23
+
24
+ describe 'FETCH' do
25
+ it 'fetches a payin' do
26
+ created = new_payin_directdebit_direct
27
+ fetched = MangoPay::PayIn.fetch(created['Id'])
28
+ expect(fetched['Id']).to eq(created['Id'])
29
+ expect(fetched['CreationDate']).to eq(created['CreationDate'])
30
+ expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
31
+ expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
32
+ check_type_and_status(created)
33
+ check_type_and_status(fetched)
34
+ end
35
+ end
36
+
37
+ end
@@ -0,0 +1,38 @@
1
+ describe MangoPay::PayIn::DirectDebit::Web, type: :feature do
2
+ include_context 'payins'
3
+
4
+ def check_type_and_status(payin)
5
+ expect(payin['Type']).to eq('PAYIN')
6
+ expect(payin['Nature']).to eq('REGULAR')
7
+ expect(payin['PaymentType']).to eq('DIRECT_DEBIT')
8
+ expect(payin['ExecutionType']).to eq('WEB')
9
+
10
+ # not SUCCEEDED yet: waiting for processing
11
+ expect(payin['Status']).to eq('CREATED')
12
+ expect(payin['ResultCode']).to be_nil
13
+ expect(payin['ResultMessage']).to be_nil
14
+ expect(payin['ExecutionDate']).to be_nil
15
+ end
16
+
17
+ describe 'CREATE' do
18
+ it 'creates a directdebit web payin' do
19
+ created = new_payin_directdebit_web
20
+ expect(created['Id']).not_to be_nil
21
+ check_type_and_status(created)
22
+ end
23
+ end
24
+
25
+ describe 'FETCH' do
26
+ it 'fetches a payin' do
27
+ created = new_payin_directdebit_web
28
+ fetched = MangoPay::PayIn.fetch(created['Id'])
29
+ expect(fetched['Id']).to eq(created['Id'])
30
+ expect(fetched['CreationDate']).to eq(created['CreationDate'])
31
+ expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
32
+ expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
33
+ check_type_and_status(created)
34
+ check_type_and_status(fetched)
35
+ end
36
+ end
37
+
38
+ end
@@ -0,0 +1,30 @@
1
+ describe MangoPay::PayIn::Giropay::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('GIROPAY')
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 giropay web payin' do
15
+ created = new_payin_giropay_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_giropay_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