mangopay 3.0.25 → 3.0.26

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 (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,80 +1,80 @@
1
- describe MangoPay::Wallet do
2
- include_context 'wallets'
3
- include_context 'payins'
4
- include_context 'payouts'
5
-
6
- describe 'CREATE' do
7
- it 'creates a wallet' do
8
- expect(new_wallet['Id']).to_not be_nil
9
- expect(new_wallet['Balance']['Currency']).to eq('EUR')
10
- expect(new_wallet['Balance']['Amount']).to eq(0)
11
- end
12
- end
13
-
14
- describe 'UPDATE' do
15
- it 'updates a wallet' do
16
- updated_wallet = MangoPay::Wallet.update(new_wallet['Id'], {
17
- Description: 'Updated Description',
18
- Tag: 'Updated Tag'
19
- })
20
- expect(updated_wallet['Description']).to eq('Updated Description')
21
- expect(updated_wallet['Tag']).to eq('Updated Tag')
22
- end
23
- end
24
-
25
- describe 'FETCH' do
26
- it 'fetches a wallet' do
27
- wallet = MangoPay::Wallet.fetch(new_wallet['Id'])
28
- expect(wallet['Id']).to eq(new_wallet['Id'])
29
- end
30
- end
31
-
32
- describe 'FETCH TRANSACTIONS' do
33
-
34
- it 'fetches empty list of transactions if no transactions done' do
35
- transactions = MangoPay::Wallet.transactions(new_wallet['Id'])
36
- expect(transactions).to be_kind_of(Array)
37
- expect(transactions).to be_empty
38
- end
39
-
40
- it 'fetches list with single transaction after payin done' do
41
- payin = new_payin_card_direct
42
- transactions = MangoPay::Wallet.transactions(new_wallet['Id'])
43
- expect(transactions).to be_kind_of(Array)
44
- expect(transactions.count).to eq 1
45
- expect(transactions.first['Id']).to eq payin['Id']
46
- end
47
-
48
- it 'fetches list with two transactions after payin and payout done' do
49
- payin = new_payin_card_direct
50
- payout = create_new_payout_bankwire(payin)
51
- transactions = MangoPay::Wallet.transactions(new_wallet['Id'])
52
-
53
- expect(transactions).to be_kind_of(Array)
54
- expect(transactions.count).to eq 2
55
-
56
- transactions_ids = transactions.map {|t| t['Id']}
57
- expect(transactions_ids).to include payin['Id']
58
- expect(transactions_ids).to include payout['Id']
59
- end
60
-
61
- it 'accepts filtering params' do
62
- payin = new_payin_card_direct
63
- payout = create_new_payout_bankwire(payin)
64
- wallet_id = new_wallet['Id']
65
-
66
- by_nature_reg = MangoPay::Wallet.transactions(wallet_id, {'Nature' => 'REGULAR'})
67
- by_nature_ref = MangoPay::Wallet.transactions(wallet_id, {'Nature' => 'REFUND'})
68
- expect(by_nature_reg.count).to eq 2
69
- expect(by_nature_ref.count).to eq 0
70
-
71
- by_type_pyin = MangoPay::Wallet.transactions(wallet_id, {'Type' => 'PAYIN'})
72
- by_type_pyout = MangoPay::Wallet.transactions(wallet_id, {'Type' => 'PAYOUT'})
73
- expect(by_type_pyin.count).to eq 1
74
- expect(by_type_pyout.count).to eq 1
75
- expect(by_type_pyin.first['Id']).to eq payin['Id']
76
- expect(by_type_pyout.first['Id']).to eq payout['Id']
77
- end
78
-
79
- end
80
- end
1
+ describe MangoPay::Wallet do
2
+ include_context 'wallets'
3
+ include_context 'payins'
4
+ include_context 'payouts'
5
+
6
+ describe 'CREATE' do
7
+ it 'creates a wallet' do
8
+ expect(new_wallet['Id']).to_not be_nil
9
+ expect(new_wallet['Balance']['Currency']).to eq('EUR')
10
+ expect(new_wallet['Balance']['Amount']).to eq(0)
11
+ end
12
+ end
13
+
14
+ describe 'UPDATE' do
15
+ it 'updates a wallet' do
16
+ updated_wallet = MangoPay::Wallet.update(new_wallet['Id'], {
17
+ Description: 'Updated Description',
18
+ Tag: 'Updated Tag'
19
+ })
20
+ expect(updated_wallet['Description']).to eq('Updated Description')
21
+ expect(updated_wallet['Tag']).to eq('Updated Tag')
22
+ end
23
+ end
24
+
25
+ describe 'FETCH' do
26
+ it 'fetches a wallet' do
27
+ wallet = MangoPay::Wallet.fetch(new_wallet['Id'])
28
+ expect(wallet['Id']).to eq(new_wallet['Id'])
29
+ end
30
+ end
31
+
32
+ describe 'FETCH TRANSACTIONS' do
33
+
34
+ it 'fetches empty list of transactions if no transactions done' do
35
+ transactions = MangoPay::Wallet.transactions(new_wallet['Id'])
36
+ expect(transactions).to be_kind_of(Array)
37
+ expect(transactions).to be_empty
38
+ end
39
+
40
+ it 'fetches list with single transaction after payin done' do
41
+ payin = new_payin_card_direct
42
+ transactions = MangoPay::Wallet.transactions(new_wallet['Id'])
43
+ expect(transactions).to be_kind_of(Array)
44
+ expect(transactions.count).to eq 1
45
+ expect(transactions.first['Id']).to eq payin['Id']
46
+ end
47
+
48
+ it 'fetches list with two transactions after payin and payout done' do
49
+ payin = new_payin_card_direct
50
+ payout = create_new_payout_bankwire(payin)
51
+ transactions = MangoPay::Wallet.transactions(new_wallet['Id'])
52
+
53
+ expect(transactions).to be_kind_of(Array)
54
+ expect(transactions.count).to eq 2
55
+
56
+ transactions_ids = transactions.map {|t| t['Id']}
57
+ expect(transactions_ids).to include payin['Id']
58
+ expect(transactions_ids).to include payout['Id']
59
+ end
60
+
61
+ it 'accepts filtering params' do
62
+ payin = new_payin_card_direct
63
+ payout = create_new_payout_bankwire(payin)
64
+ wallet_id = new_wallet['Id']
65
+
66
+ by_nature_reg = MangoPay::Wallet.transactions(wallet_id, {'Nature' => 'REGULAR'})
67
+ by_nature_ref = MangoPay::Wallet.transactions(wallet_id, {'Nature' => 'REFUND'})
68
+ expect(by_nature_reg.count).to eq 2
69
+ expect(by_nature_ref.count).to eq 0
70
+
71
+ by_type_pyin = MangoPay::Wallet.transactions(wallet_id, {'Type' => 'PAYIN'})
72
+ by_type_pyout = MangoPay::Wallet.transactions(wallet_id, {'Type' => 'PAYOUT'})
73
+ expect(by_type_pyin.count).to eq 1
74
+ expect(by_type_pyout.count).to eq 1
75
+ expect(by_type_pyin.first['Id']).to eq payin['Id']
76
+ expect(by_type_pyout.first['Id']).to eq payout['Id']
77
+ end
78
+
79
+ end
80
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,31 +1,31 @@
1
- require 'mangopay'
2
- require_relative 'mangopay/shared_resources'
3
-
4
-
5
- ################################################################################
6
- # mangopay test account config (re-called once in configuration_spec)
7
- def reset_mangopay_configuration
8
- MangoPay.configure do |c|
9
- c.preproduction = true
10
- c.client_id = 'sdk-unit-tests'
11
-
12
- # sandbox environment:
13
- c.root_url = 'https://api.sandbox.mangopay.com'
14
- c.client_passphrase = 'cqFfFrWfCcb7UadHNxx2C9Lo6Djw8ZduLi7J9USTmu8bhxxpju'
15
-
16
- c.temp_dir = File.expand_path('../tmp', __FILE__)
17
- require 'fileutils'
18
- FileUtils.mkdir_p(c.temp_dir) unless File.directory?(c.temp_dir)
19
- end
20
- end
21
- reset_mangopay_configuration
22
-
23
-
24
- ################################################################################
25
- # uncomment it for logging all http calls in tests
26
- # require 'pp'
27
- # require 'http_logger'
28
- # require 'logger'
29
- # HttpLogger.logger = Logger.new(STDOUT)
30
- # HttpLogger.colorize = true
31
- # HttpLogger.log_headers = true # false
1
+ require 'mangopay'
2
+ require_relative 'mangopay/shared_resources'
3
+
4
+
5
+ ################################################################################
6
+ # mangopay test account config (re-called once in configuration_spec)
7
+ def reset_mangopay_configuration
8
+ MangoPay.configure do |c|
9
+ c.preproduction = true
10
+ c.client_id = 'sdk-unit-tests'
11
+
12
+ # sandbox environment:
13
+ c.root_url = 'https://api.sandbox.mangopay.com'
14
+ c.client_passphrase = 'cqFfFrWfCcb7UadHNxx2C9Lo6Djw8ZduLi7J9USTmu8bhxxpju'
15
+
16
+ c.temp_dir = File.expand_path('../tmp', __FILE__)
17
+ require 'fileutils'
18
+ FileUtils.mkdir_p(c.temp_dir) unless File.directory?(c.temp_dir)
19
+ end
20
+ end
21
+ reset_mangopay_configuration
22
+
23
+
24
+ ################################################################################
25
+ # uncomment it for logging all http calls in tests
26
+ # require 'pp'
27
+ # require 'http_logger'
28
+ # require 'logger'
29
+ # HttpLogger.logger = Logger.new(STDOUT)
30
+ # HttpLogger.colorize = true
31
+ # HttpLogger.log_headers = true # false
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mangopay
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.25
4
+ version: 3.0.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geoffroy Lorieux
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-10-12 00:00:00.000000000 Z
12
+ date: 2017-03-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -75,6 +75,8 @@ files:
75
75
  - lib/mangopay.rb
76
76
  - lib/mangopay/authorization_token.rb
77
77
  - lib/mangopay/bank_account.rb
78
+ - lib/mangopay/bankingaliases.rb
79
+ - lib/mangopay/bankingaliases_iban.rb
78
80
  - lib/mangopay/card.rb
79
81
  - lib/mangopay/card_registration.rb
80
82
  - lib/mangopay/client.rb
@@ -95,7 +97,6 @@ files:
95
97
  - lib/mangopay/refund.rb
96
98
  - lib/mangopay/report.rb
97
99
  - lib/mangopay/resource.rb
98
- - lib/mangopay/temp.rb
99
100
  - lib/mangopay/transaction.rb
100
101
  - lib/mangopay/transfer.rb
101
102
  - lib/mangopay/user.rb
@@ -104,6 +105,7 @@ files:
104
105
  - mangopay.gemspec
105
106
  - spec/mangopay/authorization_token_spec.rb
106
107
  - spec/mangopay/bank_account_spec.rb
108
+ - spec/mangopay/bankingaliases_spec.rb
107
109
  - spec/mangopay/card_registration_spec.rb
108
110
  - spec/mangopay/client_spec.png
109
111
  - spec/mangopay/client_spec.rb
@@ -130,7 +132,6 @@ files:
130
132
  - spec/mangopay/refund_spec.rb
131
133
  - spec/mangopay/report_spec.rb
132
134
  - spec/mangopay/shared_resources.rb
133
- - spec/mangopay/temp_paymentcard_spec.rb
134
135
  - spec/mangopay/transaction_spec.rb
135
136
  - spec/mangopay/transfer_spec.rb
136
137
  - spec/mangopay/user_spec.rb
@@ -157,13 +158,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
158
  version: '0'
158
159
  requirements: []
159
160
  rubyforge_project:
160
- rubygems_version: 2.6.7
161
+ rubygems_version: 2.6.8
161
162
  signing_key:
162
163
  specification_version: 4
163
164
  summary: Ruby bindings for the version 2 of the MANGOPAY API
164
165
  test_files:
165
166
  - spec/mangopay/authorization_token_spec.rb
166
167
  - spec/mangopay/bank_account_spec.rb
168
+ - spec/mangopay/bankingaliases_spec.rb
167
169
  - spec/mangopay/card_registration_spec.rb
168
170
  - spec/mangopay/client_spec.png
169
171
  - spec/mangopay/client_spec.rb
@@ -190,7 +192,6 @@ test_files:
190
192
  - spec/mangopay/refund_spec.rb
191
193
  - spec/mangopay/report_spec.rb
192
194
  - spec/mangopay/shared_resources.rb
193
- - spec/mangopay/temp_paymentcard_spec.rb
194
195
  - spec/mangopay/transaction_spec.rb
195
196
  - spec/mangopay/transfer_spec.rb
196
197
  - spec/mangopay/user_spec.rb
data/lib/mangopay/temp.rb DELETED
@@ -1,74 +0,0 @@
1
- module MangoPay
2
-
3
- module Temp
4
-
5
- # As part of our migration project to allow users
6
- # to move from v1 to v2 of our API,
7
- # we have added a couple of temporary calls to the v2 API.
8
- #
9
- # They are not documented in normal way, but the calls are related to:
10
- # - registering a card (POST & GET /temp/paymentcards)
11
- # - and doing a web card payin with this card (POST /temp/immediate-payins)
12
- # For the latter, a GET or refunds are done
13
- # via the previously existing resources.
14
- #
15
- # !!! WARNING !!!
16
- # These are TEMPORARY functions and WILL BE REMOVED in the future!
17
- # You should CONTACT SUPPORT TEAM before using these features
18
- # or if you have any questions.
19
- class PaymentCard < Resource
20
-
21
- # POST /temp/paymentcards
22
- #
23
- # Sent data:
24
- # - UserId e.g. "12424242"
25
- # - Tag e.g. "my tag"
26
- # - Culture e.g. "FR"
27
- # - ReturnURL e.g. "http://mysite.com/return"
28
- # - TemplateURL e.g. "http://mysite.com/template"
29
- #
30
- # Received data:
31
- # - UserId e.g. "12424242"
32
- # - Tag e.g. "my tag"
33
- # - Culture e.g. "FR"
34
- # - ReturnURL e.g. "http://mysite.com/return"
35
- # - TemplateURL e.g. "http://mysite.com/template"
36
- # - RedirectURL e.g. "http://payline.com/redirect"
37
- # - Alias e.g. null (but would be e.g. 497010XXXXXX4422 once the user has inputed their info and the card has been successfully registered"
38
- # - Id: "1213131"
39
- # - CreationDate: "13452522657"
40
- include HTTPCalls::Create
41
-
42
- # GET /temp/paymentcards
43
- # Received data: as above
44
- include HTTPCalls::Fetch
45
-
46
- # POST /temp/immediate-payins
47
- #
48
- # Sent data:
49
- # - AuthorId e.g. "121412"
50
- # - CreditUserId e.g. "121412"
51
- # - PaymentCardId e.g. "322311"
52
- # - Tag e.g. "my tag"
53
- # - CreditedWalletId e.g. "123134"
54
- # - DebitedFunds e.g. normal Money object of Currency and Amount
55
- # - Fees e.g. normal Money object of Currency and Amount
56
- #
57
- # Received data:
58
- # Normal card web payin transaction, with the addition of:
59
- # - PaymentCardId e.g. "322311"
60
- def self.immediate_payin(params, idempotency_key = nil)
61
- url = "#{MangoPay.api_path}/temp/immediate-payins"
62
- MangoPay.request(:post, url, params, {}, idempotency_key)
63
- end
64
-
65
- def self.url(id = nil)
66
- if id
67
- "#{MangoPay.api_path}/temp/paymentcards/#{CGI.escape(id.to_s)}"
68
- else
69
- "#{MangoPay.api_path}/temp/paymentcards"
70
- end
71
- end
72
- end
73
- end
74
- end
@@ -1,31 +0,0 @@
1
- describe MangoPay::Temp::PaymentCard do
2
- include_context 'users'
3
-
4
- def new_temp_paymentcard
5
- MangoPay::Temp::PaymentCard.create({
6
- Tag: 'Test temp payment card',
7
- UserId: new_natural_user['Id'],
8
- Culture: 'FR',
9
- ReturnURL: 'https://mysite.com/return',
10
- TemplateURL: 'https://mysite.com/template'
11
- })
12
- end
13
-
14
- describe 'CREATE' do
15
- it 'creates a temp payment card' do
16
- created = new_temp_paymentcard
17
- expect(created['Id']).to_not be_nil
18
- expect(created['UserId']).to eq(new_natural_user['Id'])
19
- end
20
- end
21
-
22
- describe 'FETCH' do
23
- it 'fetches a temp payment card' do
24
- created = new_temp_paymentcard
25
- fetched = MangoPay::Temp::PaymentCard.fetch(created['Id'])
26
- expect(fetched['Id']).to eq(created['Id'])
27
- expect(fetched['UserId']).to eq(created['UserId'])
28
- end
29
- end
30
-
31
- end