mangopay 3.0.23 → 3.0.25.pre.alpha.pre.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +28 -26
  3. data/.rspec +2 -2
  4. data/.travis.yml +13 -0
  5. data/Gemfile +2 -2
  6. data/LICENSE +20 -20
  7. data/README.md +126 -123
  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 +225 -158
  12. data/lib/mangopay/authorization_token.rb +88 -88
  13. data/lib/mangopay/bank_account.rb +38 -38
  14. data/lib/mangopay/card.rb +8 -8
  15. data/lib/mangopay/card_registration.rb +9 -9
  16. data/lib/mangopay/client.rb +74 -74
  17. data/lib/mangopay/dispute.rb +130 -130
  18. data/lib/mangopay/errors.rb +61 -61
  19. data/lib/mangopay/event.rb +18 -18
  20. data/lib/mangopay/filter_parameters.rb +46 -0
  21. data/lib/mangopay/hook.rb +9 -9
  22. data/lib/mangopay/http_calls.rb +85 -85
  23. data/lib/mangopay/json.rb +14 -14
  24. data/lib/mangopay/kyc_document.rb +70 -70
  25. data/lib/mangopay/legal_user.rb +15 -15
  26. data/lib/mangopay/mandate.rb +32 -32
  27. data/lib/mangopay/natural_user.rb +14 -14
  28. data/lib/mangopay/pay_in.rb +85 -73
  29. data/lib/mangopay/pay_out.rb +14 -14
  30. data/lib/mangopay/pre_authorization.rb +13 -13
  31. data/lib/mangopay/refund.rb +7 -7
  32. data/lib/mangopay/report.rb +17 -17
  33. data/lib/mangopay/resource.rb +21 -21
  34. data/lib/mangopay/temp.rb +74 -74
  35. data/lib/mangopay/transaction.rb +24 -24
  36. data/lib/mangopay/transfer.rb +9 -9
  37. data/lib/mangopay/user.rb +43 -35
  38. data/lib/mangopay/version.rb +3 -3
  39. data/lib/mangopay/wallet.rb +17 -17
  40. data/mangopay.gemspec +31 -30
  41. data/spec/mangopay/authorization_token_spec.rb +70 -70
  42. data/spec/mangopay/bank_account_spec.rb +97 -97
  43. data/spec/mangopay/card_registration_spec.rb +73 -73
  44. data/spec/mangopay/client_spec.rb +110 -110
  45. data/spec/mangopay/configuration_spec.rb +95 -18
  46. data/spec/mangopay/dispute_spec.rb +262 -262
  47. data/spec/mangopay/event_spec.rb +31 -31
  48. data/spec/mangopay/fetch_filters_spec.rb +63 -63
  49. data/spec/mangopay/hook_spec.rb +37 -37
  50. data/spec/mangopay/idempotency_spec.rb +41 -41
  51. data/spec/mangopay/kyc_document_spec.rb +103 -103
  52. data/spec/mangopay/log_requests_filter_spec.rb +25 -0
  53. data/spec/mangopay/mandate_spec.rb +92 -92
  54. data/spec/mangopay/payin_bankwire_direct_spec.rb +74 -74
  55. data/spec/mangopay/payin_card_direct_spec.rb +68 -68
  56. data/spec/mangopay/payin_card_web_spec.rb +38 -38
  57. data/spec/mangopay/payin_directdebit_direct_spec.rb +37 -37
  58. data/spec/mangopay/payin_directdebit_web_spec.rb +38 -38
  59. data/spec/mangopay/payin_paypal_web_spec.rb +38 -0
  60. data/spec/mangopay/payin_preauthorized_direct_spec.rb +68 -68
  61. data/spec/mangopay/payout_bankwire_spec.rb +54 -54
  62. data/spec/mangopay/preauthorization_spec.rb +42 -42
  63. data/spec/mangopay/refund_spec.rb +21 -21
  64. data/spec/mangopay/report_spec.rb +39 -39
  65. data/spec/mangopay/shared_resources.rb +381 -365
  66. data/spec/mangopay/temp_paymentcard_spec.rb +31 -31
  67. data/spec/mangopay/transaction_spec.rb +54 -54
  68. data/spec/mangopay/transfer_spec.rb +69 -69
  69. data/spec/mangopay/user_spec.rb +137 -122
  70. data/spec/mangopay/wallet_spec.rb +80 -80
  71. data/spec/spec_helper.rb +31 -31
  72. metadata +11 -5
@@ -1,24 +1,24 @@
1
- module MangoPay
2
- class Transaction < Resource
3
- class << self
4
- # Fetches list of transactions belonging to the given +wallet_id+.
5
- # See also transactions for user: MangoPay::User#transactions
6
- #
7
- # Optional +filters+ is a hash accepting following keys:
8
- # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
9
- # - +Status+: TransactionStatus {CREATED, SUCCEEDED, FAILED}
10
- # - +Type+: TransactionType {PAYIN, PAYOUT, TRANSFER}
11
- # - +Nature+: TransactionNature {NORMAL, REFUND, REPUDIATION}
12
- # - +BeforeDate+ (timestamp): filters transactions with CreationDate _before_ this date
13
- # - +AfterDate+ (timestamp): filters transactions with CreationDate _after_ this date
14
- # See https://docs.mangopay.com/api-references/sort-lists/
15
- def fetch(wallet_id, filters={})
16
- MangoPay.request(:get, url(wallet_id), {}, filters)
17
- end
18
-
19
- def url(wallet_id)
20
- "#{MangoPay.api_path}/wallets/#{CGI.escape(wallet_id.to_s)}/transactions"
21
- end
22
- end
23
- end
24
- end
1
+ module MangoPay
2
+ class Transaction < Resource
3
+ class << self
4
+ # Fetches list of transactions belonging to the given +wallet_id+.
5
+ # See also transactions for user: MangoPay::User#transactions
6
+ #
7
+ # Optional +filters+ is a hash accepting following keys:
8
+ # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
9
+ # - +Status+: TransactionStatus {CREATED, SUCCEEDED, FAILED}
10
+ # - +Type+: TransactionType {PAYIN, PAYOUT, TRANSFER}
11
+ # - +Nature+: TransactionNature {NORMAL, REFUND, REPUDIATION}
12
+ # - +BeforeDate+ (timestamp): filters transactions with CreationDate _before_ this date
13
+ # - +AfterDate+ (timestamp): filters transactions with CreationDate _after_ this date
14
+ # See https://docs.mangopay.com/api-references/sort-lists/
15
+ def fetch(wallet_id, filters={})
16
+ MangoPay.request(:get, url(wallet_id), {}, filters)
17
+ end
18
+
19
+ def url(wallet_id)
20
+ "#{MangoPay.api_path}/wallets/#{CGI.escape(wallet_id.to_s)}/transactions"
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,9 +1,9 @@
1
- module MangoPay
2
-
3
- # See http://docs.mangopay.com/api-references/transfers/
4
- class Transfer < Resource
5
- include HTTPCalls::Create
6
- include HTTPCalls::Fetch
7
- include HTTPCalls::Refund
8
- end
9
- end
1
+ module MangoPay
2
+
3
+ # See http://docs.mangopay.com/api-references/transfers/
4
+ class Transfer < Resource
5
+ include HTTPCalls::Create
6
+ include HTTPCalls::Fetch
7
+ include HTTPCalls::Refund
8
+ end
9
+ end
data/lib/mangopay/user.rb CHANGED
@@ -1,35 +1,43 @@
1
- module MangoPay
2
-
3
- # See http://docs.mangopay.com/api-references/users/
4
- # See also children classes:
5
- # - MangoPay::NaturalUser
6
- # - MangoPay::LegalUser
7
- class User < Resource
8
- include HTTPCalls::Create
9
- include HTTPCalls::Update
10
- include HTTPCalls::Fetch
11
- class << self
12
- # Fetches list of wallets belonging to the given +user_id+.
13
- # Optional +filters+ is a hash accepting following keys:
14
- # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
15
- def wallets(user_id, filters={})
16
- MangoPay.request(:get, url(user_id) + '/wallets', {}, filters)
17
- end
18
-
19
- # Fetches list of cards belonging to the given +user_id+.
20
- # Optional +filters+ is a hash accepting following keys:
21
- # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
22
- def cards(user_id, filters={})
23
- MangoPay.request(:get, url(user_id) + '/cards', {}, filters)
24
- end
25
-
26
- # Fetches list of transactions belonging to the given +user_id+.
27
- # Optional +filters+ is a hash accepting following keys:
28
- # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
29
- # - other keys specific for transactions filtering (see MangoPay::Transaction#fetch)
30
- def transactions(user_id, filters={})
31
- MangoPay.request(:get, url(user_id) + '/transactions', {}, filters)
32
- end
33
- end
34
- end
35
- end
1
+ module MangoPay
2
+
3
+ # See http://docs.mangopay.com/api-references/users/
4
+ # See also children classes:
5
+ # - MangoPay::NaturalUser
6
+ # - MangoPay::LegalUser
7
+ class User < Resource
8
+ include HTTPCalls::Create
9
+ include HTTPCalls::Update
10
+ include HTTPCalls::Fetch
11
+ class << self
12
+ # Fetches list of wallets belonging to the given +user_id+.
13
+ # Optional +filters+ is a hash accepting following keys:
14
+ # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
15
+ def wallets(user_id, filters={})
16
+ MangoPay.request(:get, url(user_id) + '/wallets', {}, filters)
17
+ end
18
+
19
+ # Fetches list of bank accounts belonging to the given +user_id+.
20
+ # Optional +filters+ is a hash accepting following keys:
21
+ # - +page+, +per_page+, +sort+: pagination and sorting params
22
+ # (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
23
+ def bank_accounts(user_id, filters={})
24
+ MangoPay.request(:get, url(user_id) + '/bankaccounts', {}, filters)
25
+ end
26
+
27
+ # Fetches list of cards belonging to the given +user_id+.
28
+ # Optional +filters+ is a hash accepting following keys:
29
+ # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
30
+ def cards(user_id, filters={})
31
+ MangoPay.request(:get, url(user_id) + '/cards', {}, filters)
32
+ end
33
+
34
+ # Fetches list of transactions belonging to the given +user_id+.
35
+ # Optional +filters+ is a hash accepting following keys:
36
+ # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
37
+ # - other keys specific for transactions filtering (see MangoPay::Transaction#fetch)
38
+ def transactions(user_id, filters={})
39
+ MangoPay.request(:get, url(user_id) + '/transactions', {}, filters)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,3 +1,3 @@
1
- module MangoPay
2
- VERSION = '3.0.23'
3
- end
1
+ module MangoPay
2
+ VERSION = '3.0.25'
3
+ end
@@ -1,17 +1,17 @@
1
- module MangoPay
2
-
3
- # See http://docs.mangopay.com/api-references/wallets/
4
- class Wallet < Resource
5
- include HTTPCalls::Create
6
- include HTTPCalls::Update
7
- include HTTPCalls::Fetch
8
-
9
- # Fetches list of transactions belonging to the given +wallet_id+.
10
- # Optional +filters+ is a hash accepting following keys:
11
- # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
12
- # - other keys specific for transactions filtering (see MangoPay::Transaction.fetch)
13
- def self.transactions(wallet_id, filters = {})
14
- Transaction.fetch(wallet_id, filters)
15
- end
16
- end
17
- end
1
+ module MangoPay
2
+
3
+ # See http://docs.mangopay.com/api-references/wallets/
4
+ class Wallet < Resource
5
+ include HTTPCalls::Create
6
+ include HTTPCalls::Update
7
+ include HTTPCalls::Fetch
8
+
9
+ # Fetches list of transactions belonging to the given +wallet_id+.
10
+ # Optional +filters+ is a hash accepting following keys:
11
+ # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
12
+ # - other keys specific for transactions filtering (see MangoPay::Transaction.fetch)
13
+ def self.transactions(wallet_id, filters = {})
14
+ Transaction.fetch(wallet_id, filters)
15
+ end
16
+ end
17
+ end
data/mangopay.gemspec CHANGED
@@ -1,30 +1,31 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
2
-
3
- require 'mangopay/version'
4
-
5
- Gem::Specification.new do |s|
6
- s.name = 'mangopay'
7
- s.version = MangoPay::VERSION
8
- s.summary = "Ruby bindings for the version 2 of the MANGOPAY API"
9
- s.description = <<-EOF
10
- The mangopay Gem makes interacting with MANGOPAY Services much easier.
11
- For any questions regarding the use of MANGOPAY's Services feel free to contact us at http://www.mangopay.com/get-started-2/
12
- You can find more documentation about MANGOPAY Services at http://docs.mangopay.com/
13
- EOF
14
- s.authors = ['Geoffroy Lorieux', 'Sergiusz Woznicki']
15
- s.email = 'support@mangopay.com'
16
- s.homepage = 'http://docs.mangopay.com/'
17
- s.license = 'MIT'
18
-
19
- s.required_ruby_version = '>= 1.9.2'
20
-
21
- s.add_dependency('multi_json', '>= 1.7.7')
22
-
23
- s.add_development_dependency('rake', '>= 10.1.0')
24
- s.add_development_dependency('rspec', '>= 3.0.0')
25
-
26
- s.files = `git ls-files`.split("\n")
27
- s.test_files = `git ls-files -- spec/*`.split("\n")
28
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
29
- s.require_paths = ['lib']
30
- end
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
2
+
3
+ require 'mangopay/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'mangopay'
7
+ s.version = MangoPay::VERSION
8
+ s.version = "#{s.version}-alpha-#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS']
9
+ s.summary = "Ruby bindings for the version 2 of the MANGOPAY API"
10
+ s.description = <<-EOF
11
+ The mangopay Gem makes interacting with MANGOPAY Services much easier.
12
+ For any questions regarding the use of MANGOPAY's Services feel free to contact us at http://www.mangopay.com/get-started-2/
13
+ You can find more documentation about MANGOPAY Services at http://docs.mangopay.com/
14
+ EOF
15
+ s.authors = ['Geoffroy Lorieux', 'Sergiusz Woznicki']
16
+ s.email = 'support@mangopay.com'
17
+ s.homepage = 'http://docs.mangopay.com/'
18
+ s.license = 'MIT'
19
+
20
+ s.required_ruby_version = '>= 1.9.2'
21
+
22
+ s.add_dependency('multi_json', '>= 1.7.7')
23
+
24
+ s.add_development_dependency('rake', '>= 10.1.0')
25
+ s.add_development_dependency('rspec', '>= 3.0.0')
26
+
27
+ s.files = `git ls-files`.split("\n")
28
+ s.test_files = `git ls-files -- spec/*`.split("\n")
29
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
30
+ s.require_paths = ['lib']
31
+ end
@@ -1,70 +1,70 @@
1
- describe MangoPay::AuthorizationToken do
2
-
3
- _default_static_storage = MangoPay::AuthorizationToken::Manager.storage
4
- _new_file_storage = MangoPay::AuthorizationToken::FileStorage.new
5
-
6
- it 'uses StaticStorage strategy by default' do
7
- storage = _default_static_storage
8
- expect(storage).to be_kind_of MangoPay::AuthorizationToken::StaticStorage
9
- end
10
-
11
- it 'allows set different storage strategies' do
12
-
13
- # set to FileStorage
14
- file_storage = _new_file_storage
15
- MangoPay::AuthorizationToken::Manager.storage = file_storage
16
- storage = MangoPay::AuthorizationToken::Manager.storage
17
- expect(storage).to be file_storage
18
-
19
- # reset to StaticStorage
20
- static_storage = _default_static_storage
21
- MangoPay::AuthorizationToken::Manager.storage = static_storage
22
- storage = MangoPay::AuthorizationToken::Manager.storage
23
- expect(storage).to be static_storage
24
- end
25
-
26
- describe MangoPay::AuthorizationToken::StaticStorage do
27
- it 'shares tokens between calls' do
28
- MangoPay::AuthorizationToken::Manager.storage = _default_static_storage
29
- users1 = MangoPay::User.fetch
30
- token1 = MangoPay::AuthorizationToken::Manager.get_token
31
- users2 = MangoPay::User.fetch
32
- token2 = MangoPay::AuthorizationToken::Manager.get_token
33
- expect(token1).to eq token2
34
- expect(token1).to be token2 # moreover, it's the same instance
35
- end
36
- end
37
-
38
- describe MangoPay::AuthorizationToken::FileStorage do
39
- it 'shares tokens between calls' do
40
- MangoPay::AuthorizationToken::Manager.storage = _new_file_storage
41
-
42
- users1 = MangoPay::User.fetch
43
- token1 = MangoPay::AuthorizationToken::Manager.get_token
44
- users2 = MangoPay::User.fetch
45
- token2 = MangoPay::AuthorizationToken::Manager.get_token
46
- expect(token1).to eq token2
47
- expect(token1).not_to be token2 # it's NOT the same instance
48
-
49
- MangoPay::AuthorizationToken::Manager.storage = _default_static_storage # cleanup
50
- end
51
-
52
- it 'uses temp file with serialized token' do
53
- MangoPay::AuthorizationToken::Manager.storage = _new_file_storage
54
-
55
- file_path = _new_file_storage.file_path
56
- dir_path = MangoPay.configuration.temp_dir
57
- expect(file_path.start_with? dir_path).to be(true)
58
-
59
- token = MangoPay::AuthorizationToken::Manager.get_token
60
- expect(File.exists? file_path).to be(true)
61
-
62
- f = File.open(file_path, File::RDONLY)
63
- txt = f.read
64
- f.close
65
- expect(txt.include? token['access_token']).to be(true)
66
-
67
- MangoPay::AuthorizationToken::Manager.storage = _default_static_storage # cleanup
68
- end
69
- end
70
- end
1
+ describe MangoPay::AuthorizationToken do
2
+
3
+ _default_static_storage = MangoPay::AuthorizationToken::Manager.storage
4
+ _new_file_storage = MangoPay::AuthorizationToken::FileStorage.new
5
+
6
+ it 'uses StaticStorage strategy by default' do
7
+ storage = _default_static_storage
8
+ expect(storage).to be_kind_of MangoPay::AuthorizationToken::StaticStorage
9
+ end
10
+
11
+ it 'allows set different storage strategies' do
12
+
13
+ # set to FileStorage
14
+ file_storage = _new_file_storage
15
+ MangoPay::AuthorizationToken::Manager.storage = file_storage
16
+ storage = MangoPay::AuthorizationToken::Manager.storage
17
+ expect(storage).to be file_storage
18
+
19
+ # reset to StaticStorage
20
+ static_storage = _default_static_storage
21
+ MangoPay::AuthorizationToken::Manager.storage = static_storage
22
+ storage = MangoPay::AuthorizationToken::Manager.storage
23
+ expect(storage).to be static_storage
24
+ end
25
+
26
+ describe MangoPay::AuthorizationToken::StaticStorage do
27
+ it 'shares tokens between calls' do
28
+ MangoPay::AuthorizationToken::Manager.storage = _default_static_storage
29
+ users1 = MangoPay::User.fetch
30
+ token1 = MangoPay::AuthorizationToken::Manager.get_token
31
+ users2 = MangoPay::User.fetch
32
+ token2 = MangoPay::AuthorizationToken::Manager.get_token
33
+ expect(token1).to eq token2
34
+ expect(token1).to be token2 # moreover, it's the same instance
35
+ end
36
+ end
37
+
38
+ describe MangoPay::AuthorizationToken::FileStorage do
39
+ it 'shares tokens between calls' do
40
+ MangoPay::AuthorizationToken::Manager.storage = _new_file_storage
41
+
42
+ users1 = MangoPay::User.fetch
43
+ token1 = MangoPay::AuthorizationToken::Manager.get_token
44
+ users2 = MangoPay::User.fetch
45
+ token2 = MangoPay::AuthorizationToken::Manager.get_token
46
+ expect(token1).to eq token2
47
+ expect(token1).not_to be token2 # it's NOT the same instance
48
+
49
+ MangoPay::AuthorizationToken::Manager.storage = _default_static_storage # cleanup
50
+ end
51
+
52
+ it 'uses temp file with serialized token' do
53
+ MangoPay::AuthorizationToken::Manager.storage = _new_file_storage
54
+
55
+ file_path = _new_file_storage.file_path
56
+ dir_path = MangoPay.configuration.temp_dir
57
+ expect(file_path.start_with? dir_path).to be(true)
58
+
59
+ token = MangoPay::AuthorizationToken::Manager.get_token
60
+ expect(File.exists? file_path).to be(true)
61
+
62
+ f = File.open(file_path, File::RDONLY)
63
+ txt = f.read
64
+ f.close
65
+ expect(txt.include? token['access_token']).to be(true)
66
+
67
+ MangoPay::AuthorizationToken::Manager.storage = _default_static_storage # cleanup
68
+ end
69
+ end
70
+ end
@@ -1,97 +1,97 @@
1
- describe MangoPay::BankAccount do
2
- include_context 'bank_accounts'
3
-
4
- def create(params)
5
- user = new_natural_user
6
- params_fixed = { OwnerName: 'John', OwnerAddress: user['Address'] }.merge(params)
7
- MangoPay::BankAccount.create(user['Id'], params_fixed)
8
- end
9
-
10
- describe 'CREATE' do
11
-
12
- it 'creates a new IBAN bank detail' do
13
- expect(new_bank_account['Id']).not_to be_nil
14
- end
15
-
16
- it 'creates a new GB bank detail' do
17
- created = create({
18
- Type: 'GB',
19
- AccountNumber: '63956474',
20
- SortCode: '200000',
21
- })
22
- expect(created['Id']).not_to be_nil
23
- expect(created['Type']).to eq('GB')
24
- expect(created['AccountNumber']).to eq('63956474')
25
- expect(created['SortCode']).to eq('200000')
26
- end
27
-
28
- it 'creates a new US bank detail' do
29
- created = create({
30
- Type: 'US',
31
- AccountNumber: '234234234234',
32
- ABA: '234334789',
33
- })
34
- expect(created['Id']).not_to be_nil
35
- expect(created['Type']).to eq('US')
36
- expect(created['AccountNumber']).to eq('234234234234')
37
- expect(created['ABA']).to eq('234334789')
38
- end
39
-
40
- it 'creates a new CA bank detail' do
41
- created = create({
42
- Type: 'CA',
43
- BankName: 'TestBankName',
44
- BranchCode: '12345',
45
- AccountNumber: '234234234234',
46
- InstitutionNumber: '123',
47
- })
48
- expect(created['Id']).not_to be_nil
49
- expect(created['Type']).to eq('CA')
50
- expect(created['BankName']).to eq('TestBankName')
51
- expect(created['BranchCode']).to eq('12345')
52
- expect(created['AccountNumber']).to eq('234234234234')
53
- expect(created['InstitutionNumber']).to eq('123')
54
- end
55
-
56
- it 'creates a new OTHER bank detail' do
57
- created = create({
58
- Type: 'OTHER',
59
- Country: 'FR',
60
- AccountNumber: '234234234234',
61
- BIC: 'BINAADADXXX',
62
- })
63
- expect(created['Id']).not_to be_nil
64
- expect(created['Type']).to eq('OTHER')
65
- expect(created['Country']).to eq('FR')
66
- expect(created['AccountNumber']).to eq('234234234234')
67
- expect(created['BIC']).to eq('BINAADADXXX')
68
- end
69
-
70
- end
71
-
72
- describe 'FETCH' do
73
-
74
- it 'fetches all the bank details' do
75
- list = MangoPay::BankAccount.fetch(new_bank_account['UserId'])
76
- expect(list).to be_kind_of(Array)
77
- expect(list[0]['Id']).to eq(new_bank_account['Id'])
78
- end
79
-
80
- it 'fetches single bank detail' do
81
- single = MangoPay::BankAccount.fetch(new_bank_account['UserId'], new_bank_account['Id'])
82
- expect(single['Id']).to eq(new_bank_account['Id'])
83
- end
84
- end
85
-
86
- describe 'UPDATE' do
87
- it 'disactivates a bank account' do
88
- usr_id = new_bank_account['UserId']
89
- acc_id = new_bank_account['Id']
90
-
91
- changed = MangoPay::BankAccount.update(usr_id, acc_id, {Active: false})
92
- fetched = MangoPay::BankAccount.fetch(usr_id, acc_id)
93
- expect(changed['Active']).to eq(false)
94
- expect(fetched['Active']).to eq(false)
95
- end
96
- end
97
- end
1
+ describe MangoPay::BankAccount do
2
+ include_context 'bank_accounts'
3
+
4
+ def create(params)
5
+ user = new_natural_user
6
+ params_fixed = { OwnerName: 'John', OwnerAddress: user['Address'] }.merge(params)
7
+ MangoPay::BankAccount.create(user['Id'], params_fixed)
8
+ end
9
+
10
+ describe 'CREATE' do
11
+
12
+ it 'creates a new IBAN bank detail' do
13
+ expect(new_bank_account['Id']).not_to be_nil
14
+ end
15
+
16
+ it 'creates a new GB bank detail' do
17
+ created = create({
18
+ Type: 'GB',
19
+ AccountNumber: '63956474',
20
+ SortCode: '200000',
21
+ })
22
+ expect(created['Id']).not_to be_nil
23
+ expect(created['Type']).to eq('GB')
24
+ expect(created['AccountNumber']).to eq('63956474')
25
+ expect(created['SortCode']).to eq('200000')
26
+ end
27
+
28
+ it 'creates a new US bank detail' do
29
+ created = create({
30
+ Type: 'US',
31
+ AccountNumber: '234234234234',
32
+ ABA: '234334789',
33
+ })
34
+ expect(created['Id']).not_to be_nil
35
+ expect(created['Type']).to eq('US')
36
+ expect(created['AccountNumber']).to eq('234234234234')
37
+ expect(created['ABA']).to eq('234334789')
38
+ end
39
+
40
+ it 'creates a new CA bank detail' do
41
+ created = create({
42
+ Type: 'CA',
43
+ BankName: 'TestBankName',
44
+ BranchCode: '12345',
45
+ AccountNumber: '234234234234',
46
+ InstitutionNumber: '123',
47
+ })
48
+ expect(created['Id']).not_to be_nil
49
+ expect(created['Type']).to eq('CA')
50
+ expect(created['BankName']).to eq('TestBankName')
51
+ expect(created['BranchCode']).to eq('12345')
52
+ expect(created['AccountNumber']).to eq('234234234234')
53
+ expect(created['InstitutionNumber']).to eq('123')
54
+ end
55
+
56
+ it 'creates a new OTHER bank detail' do
57
+ created = create({
58
+ Type: 'OTHER',
59
+ Country: 'FR',
60
+ AccountNumber: '234234234234',
61
+ BIC: 'BINAADADXXX',
62
+ })
63
+ expect(created['Id']).not_to be_nil
64
+ expect(created['Type']).to eq('OTHER')
65
+ expect(created['Country']).to eq('FR')
66
+ expect(created['AccountNumber']).to eq('234234234234')
67
+ expect(created['BIC']).to eq('BINAADADXXX')
68
+ end
69
+
70
+ end
71
+
72
+ describe 'FETCH' do
73
+
74
+ it 'fetches all the bank details' do
75
+ list = MangoPay::BankAccount.fetch(new_bank_account['UserId'])
76
+ expect(list).to be_kind_of(Array)
77
+ expect(list[0]['Id']).to eq(new_bank_account['Id'])
78
+ end
79
+
80
+ it 'fetches single bank detail' do
81
+ single = MangoPay::BankAccount.fetch(new_bank_account['UserId'], new_bank_account['Id'])
82
+ expect(single['Id']).to eq(new_bank_account['Id'])
83
+ end
84
+ end
85
+
86
+ describe 'UPDATE' do
87
+ it 'disactivates a bank account' do
88
+ usr_id = new_bank_account['UserId']
89
+ acc_id = new_bank_account['Id']
90
+
91
+ changed = MangoPay::BankAccount.update(usr_id, acc_id, {Active: false})
92
+ fetched = MangoPay::BankAccount.fetch(usr_id, acc_id)
93
+ expect(changed['Active']).to eq(false)
94
+ expect(fetched['Active']).to eq(false)
95
+ end
96
+ end
97
+ end