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

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 (72) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +28 -28
  3. data/.rspec +2 -2
  4. data/.travis.yml +4 -13
  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 +225 -225
  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 -46
  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 -85
  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 -43
  38. data/lib/mangopay/version.rb +3 -3
  39. data/lib/mangopay/wallet.rb +17 -17
  40. data/mangopay.gemspec +30 -31
  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 -95
  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 -25
  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 -38
  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 -381
  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 -137
  70. data/spec/mangopay/wallet_spec.rb +80 -80
  71. data/spec/spec_helper.rb +31 -31
  72. metadata +5 -5
data/mangopay.gemspec CHANGED
@@ -1,31 +1,30 @@
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
+ $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,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
@@ -1,73 +1,73 @@
1
- describe MangoPay::CardRegistration do
2
- include_context 'users'
3
- include_context 'payins'
4
-
5
- describe 'CREATE' do
6
- it 'creates a new card registration' do
7
- created = new_card_registration
8
- expect(created['Id']).not_to be_nil
9
- expect(created['Id'].to_i).to be > 0
10
- expect(created['AccessKey']).not_to be_nil
11
- expect(created['PreregistrationData']).not_to be_nil
12
- expect(created['CardRegistrationURL']).not_to be_nil
13
- expect(created['RegistrationData']).to be_nil
14
- expect(created['CardId']).to be_nil
15
- expect(created['UserId']).to eq(new_natural_user["Id"])
16
- expect(created['Currency']).to eq('EUR')
17
- expect(created['Status']).to eq('CREATED')
18
- end
19
- end
20
-
21
- describe 'UPDATE' do
22
- it 'updates a card registration' do
23
- created = new_card_registration
24
- updated = MangoPay::CardRegistration.update(created['Id'] ,{
25
- RegistrationData: 'test RegistrationData'
26
- })
27
- expect(updated['RegistrationData']).to eq('test RegistrationData')
28
- end
29
- end
30
-
31
- describe 'FETCH' do
32
- it 'fetches a card registration' do
33
- created = new_card_registration
34
- fetched = MangoPay::CardRegistration.fetch(created['Id'])
35
- expect(fetched['Id']).to eq(created['Id'])
36
- expect(fetched['UserId']).to eq(created['UserId'])
37
- expect(fetched['Tag']).to eq(created['Tag'])
38
- end
39
- end
40
-
41
- describe 'TOKENIZATION PROCESS' do
42
- it 'fills-in registration data and links it to a newly created card' do
43
- completed = new_card_registration_completed
44
- reg_data = completed['RegistrationData']
45
- card_id = completed['CardId']
46
-
47
- # reg data filled-in
48
- expect(reg_data).not_to be_nil
49
- expect(reg_data).to be_kind_of String
50
- expect(reg_data).not_to be_empty
51
-
52
- # card id filled-in...
53
- expect(card_id).not_to be_nil
54
- expect(card_id.to_i).to be > 0
55
-
56
- # ...and points to existing (newly created) card
57
- card = MangoPay::Card.fetch(card_id)
58
- expect(card['Id']).to eq card_id
59
-
60
- ################################################################################
61
- # cannot test updating: one can only put a CARD from "VALID" to "INVALID"
62
- # # let's test updating the card too
63
- # expect(card['Validity']).to eq 'UNKNOWN'
64
- # card_updated = MangoPay::Card.update(card_id ,{
65
- # Validity: 'INVALID'
66
- # })
67
- # expect(card_updated['Validity']).to eq 'INVALID'
68
- # expect(MangoPay::Card.fetch(card_id)['Validity']).to eq 'INVALID'
69
- ################################################################################
70
- end
71
- end
72
-
73
- end
1
+ describe MangoPay::CardRegistration do
2
+ include_context 'users'
3
+ include_context 'payins'
4
+
5
+ describe 'CREATE' do
6
+ it 'creates a new card registration' do
7
+ created = new_card_registration
8
+ expect(created['Id']).not_to be_nil
9
+ expect(created['Id'].to_i).to be > 0
10
+ expect(created['AccessKey']).not_to be_nil
11
+ expect(created['PreregistrationData']).not_to be_nil
12
+ expect(created['CardRegistrationURL']).not_to be_nil
13
+ expect(created['RegistrationData']).to be_nil
14
+ expect(created['CardId']).to be_nil
15
+ expect(created['UserId']).to eq(new_natural_user["Id"])
16
+ expect(created['Currency']).to eq('EUR')
17
+ expect(created['Status']).to eq('CREATED')
18
+ end
19
+ end
20
+
21
+ describe 'UPDATE' do
22
+ it 'updates a card registration' do
23
+ created = new_card_registration
24
+ updated = MangoPay::CardRegistration.update(created['Id'] ,{
25
+ RegistrationData: 'test RegistrationData'
26
+ })
27
+ expect(updated['RegistrationData']).to eq('test RegistrationData')
28
+ end
29
+ end
30
+
31
+ describe 'FETCH' do
32
+ it 'fetches a card registration' do
33
+ created = new_card_registration
34
+ fetched = MangoPay::CardRegistration.fetch(created['Id'])
35
+ expect(fetched['Id']).to eq(created['Id'])
36
+ expect(fetched['UserId']).to eq(created['UserId'])
37
+ expect(fetched['Tag']).to eq(created['Tag'])
38
+ end
39
+ end
40
+
41
+ describe 'TOKENIZATION PROCESS' do
42
+ it 'fills-in registration data and links it to a newly created card' do
43
+ completed = new_card_registration_completed
44
+ reg_data = completed['RegistrationData']
45
+ card_id = completed['CardId']
46
+
47
+ # reg data filled-in
48
+ expect(reg_data).not_to be_nil
49
+ expect(reg_data).to be_kind_of String
50
+ expect(reg_data).not_to be_empty
51
+
52
+ # card id filled-in...
53
+ expect(card_id).not_to be_nil
54
+ expect(card_id.to_i).to be > 0
55
+
56
+ # ...and points to existing (newly created) card
57
+ card = MangoPay::Card.fetch(card_id)
58
+ expect(card['Id']).to eq card_id
59
+
60
+ ################################################################################
61
+ # cannot test updating: one can only put a CARD from "VALID" to "INVALID"
62
+ # # let's test updating the card too
63
+ # expect(card['Validity']).to eq 'UNKNOWN'
64
+ # card_updated = MangoPay::Card.update(card_id ,{
65
+ # Validity: 'INVALID'
66
+ # })
67
+ # expect(card_updated['Validity']).to eq 'INVALID'
68
+ # expect(MangoPay::Card.fetch(card_id)['Validity']).to eq 'INVALID'
69
+ ################################################################################
70
+ end
71
+ end
72
+
73
+ end