mangopay 3.0.25 → 3.0.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +30 -28
  3. data/.rspec +2 -2
  4. data/.travis.yml +13 -4
  5. data/Gemfile +2 -2
  6. data/LICENSE +20 -20
  7. data/README.md +126 -126
  8. data/bin/mangopay +9 -9
  9. data/lib/generators/mangopay/install_generator.rb +60 -60
  10. data/lib/generators/templates/mangopay.rb.erb +5 -5
  11. data/lib/mangopay.rb +228 -225
  12. data/lib/mangopay/authorization_token.rb +88 -88
  13. data/lib/mangopay/bank_account.rb +38 -38
  14. data/lib/mangopay/bankingaliases.rb +29 -0
  15. data/lib/mangopay/bankingaliases_iban.rb +16 -0
  16. data/lib/mangopay/card.rb +8 -8
  17. data/lib/mangopay/card_registration.rb +9 -9
  18. data/lib/mangopay/client.rb +74 -74
  19. data/lib/mangopay/dispute.rb +130 -130
  20. data/lib/mangopay/errors.rb +61 -61
  21. data/lib/mangopay/event.rb +18 -18
  22. data/lib/mangopay/filter_parameters.rb +46 -46
  23. data/lib/mangopay/hook.rb +9 -9
  24. data/lib/mangopay/http_calls.rb +85 -85
  25. data/lib/mangopay/json.rb +14 -14
  26. data/lib/mangopay/kyc_document.rb +70 -70
  27. data/lib/mangopay/legal_user.rb +15 -15
  28. data/lib/mangopay/mandate.rb +32 -32
  29. data/lib/mangopay/natural_user.rb +14 -14
  30. data/lib/mangopay/pay_in.rb +96 -85
  31. data/lib/mangopay/pay_out.rb +14 -14
  32. data/lib/mangopay/pre_authorization.rb +13 -13
  33. data/lib/mangopay/refund.rb +7 -7
  34. data/lib/mangopay/report.rb +17 -17
  35. data/lib/mangopay/resource.rb +21 -21
  36. data/lib/mangopay/transaction.rb +24 -24
  37. data/lib/mangopay/transfer.rb +9 -9
  38. data/lib/mangopay/user.rb +43 -43
  39. data/lib/mangopay/version.rb +3 -3
  40. data/lib/mangopay/wallet.rb +17 -17
  41. data/mangopay.gemspec +30 -30
  42. data/spec/mangopay/authorization_token_spec.rb +70 -70
  43. data/spec/mangopay/bank_account_spec.rb +97 -97
  44. data/spec/mangopay/bankingaliases_spec.rb +29 -0
  45. data/spec/mangopay/card_registration_spec.rb +73 -73
  46. data/spec/mangopay/client_spec.rb +110 -110
  47. data/spec/mangopay/configuration_spec.rb +95 -95
  48. data/spec/mangopay/dispute_spec.rb +262 -262
  49. data/spec/mangopay/event_spec.rb +31 -31
  50. data/spec/mangopay/fetch_filters_spec.rb +63 -63
  51. data/spec/mangopay/hook_spec.rb +37 -37
  52. data/spec/mangopay/idempotency_spec.rb +41 -41
  53. data/spec/mangopay/kyc_document_spec.rb +103 -103
  54. data/spec/mangopay/log_requests_filter_spec.rb +25 -25
  55. data/spec/mangopay/mandate_spec.rb +92 -92
  56. data/spec/mangopay/payin_bankwire_direct_spec.rb +74 -74
  57. data/spec/mangopay/payin_card_direct_spec.rb +68 -68
  58. data/spec/mangopay/payin_card_web_spec.rb +47 -38
  59. data/spec/mangopay/payin_directdebit_direct_spec.rb +37 -37
  60. data/spec/mangopay/payin_directdebit_web_spec.rb +38 -38
  61. data/spec/mangopay/payin_paypal_web_spec.rb +38 -38
  62. data/spec/mangopay/payin_preauthorized_direct_spec.rb +68 -68
  63. data/spec/mangopay/payout_bankwire_spec.rb +54 -54
  64. data/spec/mangopay/preauthorization_spec.rb +42 -42
  65. data/spec/mangopay/refund_spec.rb +21 -21
  66. data/spec/mangopay/report_spec.rb +39 -39
  67. data/spec/mangopay/shared_resources.rb +397 -381
  68. data/spec/mangopay/transaction_spec.rb +54 -54
  69. data/spec/mangopay/transfer_spec.rb +69 -69
  70. data/spec/mangopay/user_spec.rb +137 -137
  71. data/spec/mangopay/wallet_spec.rb +80 -80
  72. data/spec/spec_helper.rb +31 -31
  73. metadata +7 -6
  74. data/lib/mangopay/temp.rb +0 -74
  75. data/spec/mangopay/temp_paymentcard_spec.rb +0 -31
@@ -1,38 +1,47 @@
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 'FETCH' do
26
- it 'fetches a payin' do
27
- created = new_payin_card_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
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 'EXTENDED' do
26
+ context 'when resource not exists' do
27
+ it 'fetches extended information' do
28
+ expect { MangoPay::PayIn::Card::Web.extended(1000000) }.to \
29
+ raise_error(MangoPay::ResponseError)
30
+ end
31
+ end
32
+ end
33
+
34
+ describe 'FETCH' do
35
+ it 'fetches a payin' do
36
+ created = new_payin_card_web
37
+ fetched = MangoPay::PayIn.fetch(created['Id'])
38
+ expect(fetched['Id']).to eq(created['Id'])
39
+ expect(fetched['CreationDate']).to eq(created['CreationDate'])
40
+ expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
41
+ expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
42
+ check_type_and_status(created)
43
+ check_type_and_status(fetched)
44
+ end
45
+ end
46
+
47
+ end
@@ -1,37 +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
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
@@ -1,38 +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
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
@@ -1,38 +1,38 @@
1
- describe MangoPay::PayIn::PayPal::Web, type: :feature do
2
- include_context 'payins'
3
-
4
- def check_type_and_status(payin)
5
- expect(payin['Type']).to eq('PAYIN')
6
- expect(payin['Nature']).to eq('REGULAR')
7
- expect(payin['PaymentType']).to eq('PAYPAL')
8
- expect(payin['ExecutionType']).to eq('WEB')
9
-
10
- # not SUCCEEDED yet: waiting for processing
11
- expect(payin['Status']).to eq('CREATED')
12
- expect(payin['ResultCode']).to be_nil
13
- expect(payin['ResultMessage']).to be_nil
14
- expect(payin['ExecutionDate']).to be_nil
15
- end
16
-
17
- describe 'CREATE' do
18
- it 'creates a paypal web payin' do
19
- created = new_payin_paypal_web
20
- expect(created['Id']).not_to be_nil
21
- check_type_and_status(created)
22
- end
23
- end
24
-
25
- describe 'FETCH' do
26
- it 'fetches a payin' do
27
- created = new_payin_paypal_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
1
+ describe MangoPay::PayIn::PayPal::Web, type: :feature do
2
+ include_context 'payins'
3
+
4
+ def check_type_and_status(payin)
5
+ expect(payin['Type']).to eq('PAYIN')
6
+ expect(payin['Nature']).to eq('REGULAR')
7
+ expect(payin['PaymentType']).to eq('PAYPAL')
8
+ expect(payin['ExecutionType']).to eq('WEB')
9
+
10
+ # not SUCCEEDED yet: waiting for processing
11
+ expect(payin['Status']).to eq('CREATED')
12
+ expect(payin['ResultCode']).to be_nil
13
+ expect(payin['ResultMessage']).to be_nil
14
+ expect(payin['ExecutionDate']).to be_nil
15
+ end
16
+
17
+ describe 'CREATE' do
18
+ it 'creates a paypal web payin' do
19
+ created = new_payin_paypal_web
20
+ expect(created['Id']).not_to be_nil
21
+ check_type_and_status(created)
22
+ end
23
+ end
24
+
25
+ describe 'FETCH' do
26
+ it 'fetches a payin' do
27
+ created = new_payin_paypal_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
@@ -1,68 +1,68 @@
1
- describe MangoPay::PayIn::PreAuthorized::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('PREAUTHORIZED')
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 preauthorized direct payin' do
20
- created = new_payin_preauthorized_direct
21
- expect(created['Id']).not_to be_nil
22
- check_type_and_status(created)
23
- end
24
- end
25
-
26
- describe 'FETCH' do
27
- it 'fetches a payin' do
28
- created = new_payin_preauthorized_direct
29
- fetched = MangoPay::PayIn.fetch(created['Id'])
30
- expect(fetched['Id']).to eq(created['Id'])
31
- expect(fetched['CreationDate']).to eq(created['CreationDate'])
32
- expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
33
- expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
34
- check_type_and_status(created)
35
- check_type_and_status(fetched)
36
- end
37
- end
38
-
39
- describe 'REFUND' do
40
- it 'refunds a payin' do
41
- payin = new_payin_preauthorized_direct
42
- refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
43
- expect(refund['Id']).not_to be_nil
44
- expect(refund['Status']).to eq('SUCCEEDED')
45
- expect(refund['Type']).to eq('PAYOUT')
46
- expect(refund['Nature']).to eq('REFUND')
47
- expect(refund['InitialTransactionType']).to eq('PAYIN')
48
- expect(refund['InitialTransactionId']).to eq(payin['Id'])
49
- expect(refund['DebitedWalletId']).to eq(payin['CreditedWalletId'])
50
- end
51
- end
52
-
53
- describe 'CASH FLOW' do
54
- it 'changes balances correctly' do
55
- wlt = new_wallet
56
- wallets_check_amounts(wlt, 0)
57
-
58
- # payin: feed wlt1 with money
59
- payin = create_new_payin_preauthorized_direct(wlt, 1000)
60
- wallets_reload_and_check_amounts(wlt, 1000)
61
-
62
- # refund the payin
63
- refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
64
- wallets_reload_and_check_amounts(wlt, 0)
65
- end
66
- end
67
-
68
- end
1
+ describe MangoPay::PayIn::PreAuthorized::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('PREAUTHORIZED')
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 preauthorized direct payin' do
20
+ created = new_payin_preauthorized_direct
21
+ expect(created['Id']).not_to be_nil
22
+ check_type_and_status(created)
23
+ end
24
+ end
25
+
26
+ describe 'FETCH' do
27
+ it 'fetches a payin' do
28
+ created = new_payin_preauthorized_direct
29
+ fetched = MangoPay::PayIn.fetch(created['Id'])
30
+ expect(fetched['Id']).to eq(created['Id'])
31
+ expect(fetched['CreationDate']).to eq(created['CreationDate'])
32
+ expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
33
+ expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
34
+ check_type_and_status(created)
35
+ check_type_and_status(fetched)
36
+ end
37
+ end
38
+
39
+ describe 'REFUND' do
40
+ it 'refunds a payin' do
41
+ payin = new_payin_preauthorized_direct
42
+ refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
43
+ expect(refund['Id']).not_to be_nil
44
+ expect(refund['Status']).to eq('SUCCEEDED')
45
+ expect(refund['Type']).to eq('PAYOUT')
46
+ expect(refund['Nature']).to eq('REFUND')
47
+ expect(refund['InitialTransactionType']).to eq('PAYIN')
48
+ expect(refund['InitialTransactionId']).to eq(payin['Id'])
49
+ expect(refund['DebitedWalletId']).to eq(payin['CreditedWalletId'])
50
+ end
51
+ end
52
+
53
+ describe 'CASH FLOW' do
54
+ it 'changes balances correctly' do
55
+ wlt = new_wallet
56
+ wallets_check_amounts(wlt, 0)
57
+
58
+ # payin: feed wlt1 with money
59
+ payin = create_new_payin_preauthorized_direct(wlt, 1000)
60
+ wallets_reload_and_check_amounts(wlt, 1000)
61
+
62
+ # refund the payin
63
+ refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
64
+ wallets_reload_and_check_amounts(wlt, 0)
65
+ end
66
+ end
67
+
68
+ end