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.
- checksums.yaml +4 -4
- data/.gitignore +28 -28
- data/.rspec +2 -2
- data/.travis.yml +4 -13
- data/Gemfile +2 -2
- data/LICENSE +20 -20
- data/README.md +126 -126
- data/bin/mangopay +9 -9
- data/lib/generators/mangopay/install_generator.rb +60 -60
- data/lib/generators/templates/mangopay.rb.erb +5 -5
- data/lib/mangopay.rb +225 -225
- data/lib/mangopay/authorization_token.rb +88 -88
- data/lib/mangopay/bank_account.rb +38 -38
- data/lib/mangopay/card.rb +8 -8
- data/lib/mangopay/card_registration.rb +9 -9
- data/lib/mangopay/client.rb +74 -74
- data/lib/mangopay/dispute.rb +130 -130
- data/lib/mangopay/errors.rb +61 -61
- data/lib/mangopay/event.rb +18 -18
- data/lib/mangopay/filter_parameters.rb +46 -46
- data/lib/mangopay/hook.rb +9 -9
- data/lib/mangopay/http_calls.rb +85 -85
- data/lib/mangopay/json.rb +14 -14
- data/lib/mangopay/kyc_document.rb +70 -70
- data/lib/mangopay/legal_user.rb +15 -15
- data/lib/mangopay/mandate.rb +32 -32
- data/lib/mangopay/natural_user.rb +14 -14
- data/lib/mangopay/pay_in.rb +85 -85
- data/lib/mangopay/pay_out.rb +14 -14
- data/lib/mangopay/pre_authorization.rb +13 -13
- data/lib/mangopay/refund.rb +7 -7
- data/lib/mangopay/report.rb +17 -17
- data/lib/mangopay/resource.rb +21 -21
- data/lib/mangopay/temp.rb +74 -74
- data/lib/mangopay/transaction.rb +24 -24
- data/lib/mangopay/transfer.rb +9 -9
- data/lib/mangopay/user.rb +43 -43
- data/lib/mangopay/version.rb +3 -3
- data/lib/mangopay/wallet.rb +17 -17
- data/mangopay.gemspec +30 -31
- data/spec/mangopay/authorization_token_spec.rb +70 -70
- data/spec/mangopay/bank_account_spec.rb +97 -97
- data/spec/mangopay/card_registration_spec.rb +73 -73
- data/spec/mangopay/client_spec.rb +110 -110
- data/spec/mangopay/configuration_spec.rb +95 -95
- data/spec/mangopay/dispute_spec.rb +262 -262
- data/spec/mangopay/event_spec.rb +31 -31
- data/spec/mangopay/fetch_filters_spec.rb +63 -63
- data/spec/mangopay/hook_spec.rb +37 -37
- data/spec/mangopay/idempotency_spec.rb +41 -41
- data/spec/mangopay/kyc_document_spec.rb +103 -103
- data/spec/mangopay/log_requests_filter_spec.rb +25 -25
- data/spec/mangopay/mandate_spec.rb +92 -92
- data/spec/mangopay/payin_bankwire_direct_spec.rb +74 -74
- data/spec/mangopay/payin_card_direct_spec.rb +68 -68
- data/spec/mangopay/payin_card_web_spec.rb +38 -38
- data/spec/mangopay/payin_directdebit_direct_spec.rb +37 -37
- data/spec/mangopay/payin_directdebit_web_spec.rb +38 -38
- data/spec/mangopay/payin_paypal_web_spec.rb +38 -38
- data/spec/mangopay/payin_preauthorized_direct_spec.rb +68 -68
- data/spec/mangopay/payout_bankwire_spec.rb +54 -54
- data/spec/mangopay/preauthorization_spec.rb +42 -42
- data/spec/mangopay/refund_spec.rb +21 -21
- data/spec/mangopay/report_spec.rb +39 -39
- data/spec/mangopay/shared_resources.rb +381 -381
- data/spec/mangopay/temp_paymentcard_spec.rb +31 -31
- data/spec/mangopay/transaction_spec.rb +54 -54
- data/spec/mangopay/transfer_spec.rb +69 -69
- data/spec/mangopay/user_spec.rb +137 -137
- data/spec/mangopay/wallet_spec.rb +80 -80
- data/spec/spec_helper.rb +31 -31
- 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.
|
9
|
-
s.
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
s.
|
16
|
-
s.
|
17
|
-
s.
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
s.add_development_dependency('
|
25
|
-
|
26
|
-
|
27
|
-
s.
|
28
|
-
s.
|
29
|
-
s.
|
30
|
-
|
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
|