payture_ruby 0.0.1
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 +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +56 -0
- data/Rakefile +14 -0
- data/lib/faraday/payture_auth.rb +25 -0
- data/lib/faraday/raise_http_exeption.rb +53 -0
- data/lib/faraday/underscore.rb +33 -0
- data/lib/payture/api.rb +27 -0
- data/lib/payture/client/vwapi.rb +20 -0
- data/lib/payture/client.rb +7 -0
- data/lib/payture/configuration.rb +58 -0
- data/lib/payture/connection.rb +30 -0
- data/lib/payture/error.rb +19 -0
- data/lib/payture/helper.rb +7 -0
- data/lib/payture/request.rb +55 -0
- data/lib/payture/response.rb +9 -0
- data/lib/payture/version.rb +3 -0
- data/lib/payture.rb +23 -0
- data/payture.gemspec +31 -0
- data/test/cassettes/activate/existing_user/existing_card.yml +37 -0
- data/test/cassettes/add/new_user/existing_card.yml +37 -0
- data/test/cassettes/add/new_user/new_card.yml +37 -0
- data/test/cassettes/get_list/existing_user.yml +39 -0
- data/test/cassettes/pay/existing_user/active_card.yml +37 -0
- data/test/cassettes/pay/existing_user/inactive_card.yml +37 -0
- data/test/cassettes/register/duplicate.yml +37 -0
- data/test/cassettes/register/new.yml +36 -0
- data/test/payture/api_test.rb +76 -0
- data/test/payture/client/vwapi_test.rb +260 -0
- data/test/payture/configuration_test.rb +13 -0
- data/test/payture_test.rb +15 -0
- data/test/test_helper.rb +20 -0
- metadata +230 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://sandbox.payture.com/vwapi/GetList?DATA=VWUserLgn%253Dfucker%2540dom.com%253BVWUserPsw%253D123&VWID=VWMerchant
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/xml; charset=utf-8
|
12
|
+
User-Agent:
|
13
|
+
- Payture Ruby Gem 0.0.1
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- nginx
|
23
|
+
Date:
|
24
|
+
- Wed, 20 Aug 2014 22:42:05 GMT
|
25
|
+
Content-Type:
|
26
|
+
- text/xml; charset=utf-8
|
27
|
+
Content-Length:
|
28
|
+
- '198'
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
body:
|
32
|
+
encoding: UTF-8
|
33
|
+
string: "<GetList Success=\"True\" VWUserLgn=\"fucker@dom.com\">\r\n <Item
|
34
|
+
CardName=\"411111xxxxxx1112\" CardId=\"7a79e50c-8f91-47ce-bfda-37b1394e3017\"
|
35
|
+
CardHolder=\"Ivan Ivanov\" Status=\"NotActive\" NoCVV=\"false\" Expired=\"false\"
|
36
|
+
/>\r\n</GetList>"
|
37
|
+
http_version:
|
38
|
+
recorded_at: Wed, 20 Aug 2014 22:42:05 GMT
|
39
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,37 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://sandbox.payture.com/vwapi/Pay?DATA=VWUserLgn%253Dfucker1%2540dom.com%253BVWUserPsw%253D123%253BCardId%253De43544ba-cf4f-4702-85ef-313df89577eb%253BOrderId%253D123asdf123FFFdf%253Bamount%253D1000%253Bip%253D123.123.122.111&VWID=VWMerchant
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/xml; charset=utf-8
|
12
|
+
User-Agent:
|
13
|
+
- Payture Ruby Gem 0.0.1
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- nginx
|
23
|
+
Date:
|
24
|
+
- Thu, 21 Aug 2014 12:01:42 GMT
|
25
|
+
Content-Type:
|
26
|
+
- text/xml; charset=utf-8
|
27
|
+
Content-Length:
|
28
|
+
- '107'
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
body:
|
32
|
+
encoding: UTF-8
|
33
|
+
string: <Pay VWUserLgn="fucker1@dom.com" OrderId="123asdf123FFFdf" Success="True"
|
34
|
+
Amount="1000" />
|
35
|
+
http_version:
|
36
|
+
recorded_at: Thu, 21 Aug 2014 12:01:42 GMT
|
37
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,37 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://sandbox.payture.com/vwapi/Pay?DATA=VWUserLgn%253Drom2%2540dom.com%253BVWUserPsw%253D123%253BCardId%253D2e4b31b5-d4db-4cd0-90d8-bdef46cee299%253BOrderId%253D123asdf123%253Bamount%253D1000%253Bip%253D123.123.122.111&VWID=VWMerchant
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/xml; charset=utf-8
|
12
|
+
User-Agent:
|
13
|
+
- Payture Ruby Gem 0.0.1
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- nginx
|
23
|
+
Date:
|
24
|
+
- Thu, 21 Aug 2014 11:55:05 GMT
|
25
|
+
Content-Type:
|
26
|
+
- text/xml; charset=utf-8
|
27
|
+
Content-Length:
|
28
|
+
- '108'
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
body:
|
32
|
+
encoding: UTF-8
|
33
|
+
string: <Pay VWUserLgn="rom2@dom.com" OrderId="123asdf123" Success="False" ErrCode="WRONG_CARD"
|
34
|
+
/>
|
35
|
+
http_version:
|
36
|
+
recorded_at: Thu, 21 Aug 2014 11:55:05 GMT
|
37
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,37 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://sandbox.payture.com/vwapi/Register?DATA=VWUserLgn%253D123%2540ya.ru%253BVWUserPsw%253D123%253BPhoneNumber%253D79156783333&VWID=VWMerchant
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/xml; charset=utf-8
|
12
|
+
User-Agent:
|
13
|
+
- Payture Ruby Gem 0.0.1
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- nginx
|
23
|
+
Date:
|
24
|
+
- Tue, 19 Aug 2014 23:40:12 GMT
|
25
|
+
Content-Type:
|
26
|
+
- text/xml; charset=utf-8
|
27
|
+
Content-Length:
|
28
|
+
- '95'
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
body:
|
32
|
+
encoding: UTF-8
|
33
|
+
string: <Register Success="False" VWUserLgn="123@ya.ru" ErrCode="DUPLICATE_USER"
|
34
|
+
/>
|
35
|
+
http_version:
|
36
|
+
recorded_at: Tue, 19 Aug 2014 23:40:11 GMT
|
37
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,36 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://sandbox.payture.com/vwapi/Register?DATA=VWUserLgn%253D1234567%2540ya.ru%253BVWUserPsw%253D123%253BPhoneNumber%253D79156781234&VWID=VWMerchant
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/xml; charset=utf-8
|
12
|
+
User-Agent:
|
13
|
+
- Payture Ruby Gem 0.0.1
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- nginx
|
23
|
+
Date:
|
24
|
+
- Tue, 19 Aug 2014 23:41:05 GMT
|
25
|
+
Content-Type:
|
26
|
+
- text/xml; charset=utf-8
|
27
|
+
Content-Length:
|
28
|
+
- '73'
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
body:
|
32
|
+
encoding: UTF-8
|
33
|
+
string: <Register Success="True" VWUserLgn="1234567@ya.ru" />
|
34
|
+
http_version:
|
35
|
+
recorded_at: Tue, 19 Aug 2014 23:41:04 GMT
|
36
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
|
+
|
3
|
+
module Payture
|
4
|
+
describe Api do
|
5
|
+
before do
|
6
|
+
@keys = Configuration::VALID_OPTIONS_KEYS
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "with module configuration" do
|
10
|
+
|
11
|
+
before do
|
12
|
+
Payture.configure do |config|
|
13
|
+
@keys.each do |key|
|
14
|
+
config.send("#{key}=", key)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
after do
|
20
|
+
Payture.reset
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should inherit module configuration" do
|
24
|
+
api = Api.new
|
25
|
+
@keys.each do |key|
|
26
|
+
api.send(key).must_equal key
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "with class configuration" do
|
33
|
+
|
34
|
+
before do
|
35
|
+
@configuration = {
|
36
|
+
api_type: :vwapi,
|
37
|
+
host_type: 'sandbox',
|
38
|
+
key: 'MerchantKey',
|
39
|
+
password: nil,
|
40
|
+
user_agent: 'Custom',
|
41
|
+
format: :xml,
|
42
|
+
adapter: :typhoeus
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "during initialization" do
|
47
|
+
|
48
|
+
it "should override module configuration" do
|
49
|
+
api = Api.new(@configuration)
|
50
|
+
@keys.each do |key|
|
51
|
+
api.send(key).must_equal @configuration[key]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
describe "after initilization" do
|
59
|
+
|
60
|
+
it "should override module configuration after initialization" do
|
61
|
+
api = Api.new
|
62
|
+
@configuration.each do |key, value|
|
63
|
+
api.send("#{key}=", value)
|
64
|
+
end
|
65
|
+
@keys.each do |key|
|
66
|
+
api.send(key).must_equal @configuration[key]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,260 @@
|
|
1
|
+
require File.expand_path("../../../test_helper", __FILE__)
|
2
|
+
|
3
|
+
module Payture
|
4
|
+
describe Client do
|
5
|
+
|
6
|
+
|
7
|
+
let(:client) { Client.new }
|
8
|
+
|
9
|
+
describe ".register" do
|
10
|
+
|
11
|
+
let(:options) { {'VWUserLgn' => '123@ya.ru', 'VWUserPsw' => 123, 'PhoneNumber' => 79156783333 } }
|
12
|
+
subject { client.register options }
|
13
|
+
|
14
|
+
describe 'follow doc example' do
|
15
|
+
|
16
|
+
describe "url" do
|
17
|
+
before do
|
18
|
+
data_string = 'VWUserLgn%3D123%40ya.ru%3BVWUserPsw%3D123%3BPhoneNumber%3D79156783333'
|
19
|
+
@get = stub_get("Register")
|
20
|
+
.with(query: {'VWID' => client.key, 'DATA' => data_string})
|
21
|
+
end
|
22
|
+
it 'should be correct' do
|
23
|
+
subject
|
24
|
+
assert_requested @get
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'body' do
|
29
|
+
it "returns status" do
|
30
|
+
VCR.use_cassette('register/duplicate') do
|
31
|
+
subject.success.must_equal "False"
|
32
|
+
subject.err_code.must_equal "DUPLICATE_USER"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'using real credentials' do
|
39
|
+
let(:email) { '1234567@ya.ru' }
|
40
|
+
let(:options) { {'VWUserLgn' => email, 'VWUserPsw' => 123, 'PhoneNumber' => 79156781234 } }
|
41
|
+
subject { client.register options }
|
42
|
+
describe 'with new user' do
|
43
|
+
it "returns success status" do
|
44
|
+
VCR.use_cassette('register/new') do
|
45
|
+
subject.success.must_equal "True"
|
46
|
+
subject.v_w_user_lgn.must_equal email
|
47
|
+
subject.err_code.must_be_nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '.add' do
|
56
|
+
let(:email) { 'rom1@dom.com' }
|
57
|
+
let(:card_number) { 4111111111111112 }
|
58
|
+
let(:options) {
|
59
|
+
{
|
60
|
+
v_w_user_lgn: email,
|
61
|
+
v_w_user_psw: 123,
|
62
|
+
card_number: card_number,
|
63
|
+
e_month: 12,
|
64
|
+
e_year: 15,
|
65
|
+
card_holder: 'Ivan Ivanov',
|
66
|
+
secure_code: 123,
|
67
|
+
phone_number: 79001234567,
|
68
|
+
}
|
69
|
+
}
|
70
|
+
subject { client.add options }
|
71
|
+
describe "request url" do
|
72
|
+
before do
|
73
|
+
data_string = 'VWUserLgn%3Drom1%40dom.com%3BVWUserPsw%3D123%3BCardNumber%3D4111111111111112%3BEMonth%3D12%3BEYear%3D15%3BCardHolder%3DIvan+Ivanov%3BSecureCode%3D123%3BPhoneNumber%3D79001234567'
|
74
|
+
@get = stub_get("Add")
|
75
|
+
.with(query: {'VWID' => client.key, 'DATA' => data_string})
|
76
|
+
end
|
77
|
+
it 'should be correct' do
|
78
|
+
subject
|
79
|
+
assert_requested @get
|
80
|
+
end
|
81
|
+
end
|
82
|
+
# describe 'with existing user' do
|
83
|
+
# it "returns success status" do
|
84
|
+
# VCR.use_cassette('add/existing') do
|
85
|
+
# subject.success.must_equal "True"
|
86
|
+
# subject.v_w_user_lgn.must_equal email
|
87
|
+
# subject.err_code.must_be_nil
|
88
|
+
# end
|
89
|
+
# end
|
90
|
+
# end
|
91
|
+
describe 'with new user' do
|
92
|
+
describe 'with existing card' do
|
93
|
+
it "returns success status" do
|
94
|
+
VCR.use_cassette('add/new_user/existing_card') do
|
95
|
+
subject.success.must_equal "False"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
it 'returns user login' do
|
99
|
+
VCR.use_cassette('add/new_user/existing_card') do
|
100
|
+
subject.v_w_user_lgn.must_equal email
|
101
|
+
end
|
102
|
+
end
|
103
|
+
it 'returns error code' do
|
104
|
+
VCR.use_cassette('add/new_user/existing_card') do
|
105
|
+
subject.err_code.must_equal 'DUPLICATE_CARD'
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
describe 'with new card' do
|
110
|
+
let(:email) { 'fucker1@dom.com' }
|
111
|
+
let(:card_number) { 4111111111111112 }
|
112
|
+
|
113
|
+
it "returns success status" do
|
114
|
+
VCR.use_cassette('add/new_user/new_card') do
|
115
|
+
subject.success.must_equal "True"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
it 'returns user login' do
|
119
|
+
skip 'payture bug'
|
120
|
+
VCR.use_cassette('add/new_user/new_card') do
|
121
|
+
subject.v_w_user_lgn.must_equal email
|
122
|
+
end
|
123
|
+
end
|
124
|
+
it 'returns empty error code' do
|
125
|
+
VCR.use_cassette('add/new_user/new_card') do
|
126
|
+
subject.err_code.must_be_nil
|
127
|
+
end
|
128
|
+
end
|
129
|
+
it 'returns payture card_id' do
|
130
|
+
VCR.use_cassette('add/new_user/new_card') do
|
131
|
+
subject.card_id.wont_be_nil
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe '.activate' do
|
139
|
+
let(:email) { 'fucker1@dom.com' }
|
140
|
+
let(:card_id) { "e43544ba-cf4f-4702-85ef-313df89577eb" }
|
141
|
+
let(:options) {
|
142
|
+
{
|
143
|
+
v_w_user_lgn: email,
|
144
|
+
v_w_user_psw: 123,
|
145
|
+
card_id: card_id,
|
146
|
+
amount: '100',
|
147
|
+
}
|
148
|
+
}
|
149
|
+
subject { client.activate options }
|
150
|
+
|
151
|
+
describe 'with correct data' do
|
152
|
+
|
153
|
+
it "returns success status" do
|
154
|
+
VCR.use_cassette('activate/existing_user/existing_card') do
|
155
|
+
subject.success.must_equal "True"
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'returns user login' do
|
160
|
+
VCR.use_cassette('activate/existing_user/existing_card') do
|
161
|
+
subject.v_w_user_lgn.must_equal email
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'returns payture card_id' do
|
166
|
+
VCR.use_cassette('activate/existing_user/existing_card') do
|
167
|
+
subject.card_id.must_equal card_id
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
describe '.pay' do
|
174
|
+
let(:email) { 'rom2@dom.com' }
|
175
|
+
let(:card_number) { 4111111211111112 }
|
176
|
+
let(:order_id) { '123asdf123' }
|
177
|
+
let(:card_id) { "2e4b31b5-d4db-4cd0-90d8-bdef46cee299" }
|
178
|
+
let(:options) {
|
179
|
+
{
|
180
|
+
v_w_user_lgn: email,
|
181
|
+
v_w_user_psw: 123,
|
182
|
+
card_id: card_id,
|
183
|
+
order_id: order_id,
|
184
|
+
amount: '1000',
|
185
|
+
ip: '123.123.122.111'
|
186
|
+
}
|
187
|
+
}
|
188
|
+
subject { client.pay options }
|
189
|
+
|
190
|
+
describe 'with existing card not activated' do
|
191
|
+
let(:email) { 'rom2@dom.com' }
|
192
|
+
|
193
|
+
it "returns success status" do
|
194
|
+
VCR.use_cassette('pay/existing_user/inactive_card') do
|
195
|
+
subject.success.must_equal "False"
|
196
|
+
end
|
197
|
+
end
|
198
|
+
it 'returns user login' do
|
199
|
+
VCR.use_cassette('pay/existing_user/inactive_card') do
|
200
|
+
subject.v_w_user_lgn.must_equal email
|
201
|
+
end
|
202
|
+
end
|
203
|
+
it 'returns empty error code' do
|
204
|
+
VCR.use_cassette('pay/existing_user/inactive_card') do
|
205
|
+
subject.err_code.must_equal 'WRONG_CARD'
|
206
|
+
end
|
207
|
+
end
|
208
|
+
it 'returns payture card_id' do
|
209
|
+
VCR.use_cassette('pay/existing_user/inactive_card') do
|
210
|
+
subject.order_id.must_equal order_id
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
describe 'with existing activated card' do
|
216
|
+
let(:email) { 'fucker1@dom.com' }
|
217
|
+
let(:card_id) { "e43544ba-cf4f-4702-85ef-313df89577eb" }
|
218
|
+
let(:order_id) { '123asdf123FFFdf' }
|
219
|
+
|
220
|
+
it "returns success status" do
|
221
|
+
VCR.use_cassette('pay/existing_user/active_card') do
|
222
|
+
subject.success.must_equal "True"
|
223
|
+
end
|
224
|
+
end
|
225
|
+
it 'returns user login' do
|
226
|
+
VCR.use_cassette('pay/existing_user/active_card') do
|
227
|
+
subject.v_w_user_lgn.must_equal email
|
228
|
+
end
|
229
|
+
end
|
230
|
+
it 'returns empty error code' do
|
231
|
+
VCR.use_cassette('pay/existing_user/active_card') do
|
232
|
+
subject.err_code.must_be_nil
|
233
|
+
end
|
234
|
+
end
|
235
|
+
it 'returns ORDER_id' do
|
236
|
+
VCR.use_cassette('pay/existing_user/active_card') do
|
237
|
+
subject.order_id.must_equal order_id
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
describe '.get_list' do
|
244
|
+
let(:email) { 'fucker@dom.com' }
|
245
|
+
let(:options) {
|
246
|
+
{
|
247
|
+
v_w_user_lgn: email,
|
248
|
+
v_w_user_psw: 123,
|
249
|
+
}
|
250
|
+
}
|
251
|
+
subject { client.get_list options }
|
252
|
+
|
253
|
+
it "returns success status" do
|
254
|
+
VCR.use_cassette('get_list/existing_user') do
|
255
|
+
subject.success.must_equal "True"
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
|
+
|
3
|
+
module Payture
|
4
|
+
describe Configuration do
|
5
|
+
Configuration::VALID_OPTIONS_KEYS.each do |key|
|
6
|
+
describe ".#{key}" do
|
7
|
+
it 'returns default value' do
|
8
|
+
Payture.send(key).must_equal Configuration.const_get("DEFAULT_#{key.upcase}")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path("../test_helper", __FILE__)
|
2
|
+
|
3
|
+
describe Payture do
|
4
|
+
it "is valid" do
|
5
|
+
Payture.must_be_kind_of Module
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'has host' do
|
9
|
+
Payture.host.must_equal 'https://sandbox.payture.com/vwapi/'
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'converts to underscore' do
|
13
|
+
Payture.convert_to_underscore('AssDf').must_equal 'ass_df'
|
14
|
+
end
|
15
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'payture'
|
2
|
+
require 'minitest'
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'minitest/spec'
|
5
|
+
require 'webmock/minitest'
|
6
|
+
require "vcr"
|
7
|
+
# require "minitest-vcr"
|
8
|
+
|
9
|
+
VCR.configure do |c|
|
10
|
+
c.cassette_library_dir = 'test/cassettes'
|
11
|
+
c.hook_into :webmock
|
12
|
+
c.allow_http_connections_when_no_cassette = true
|
13
|
+
# c.hook_into :faraday
|
14
|
+
end
|
15
|
+
|
16
|
+
# MinitestVcr::Spec.configure!
|
17
|
+
|
18
|
+
def stub_get(path)
|
19
|
+
stub_request(:get, Payture.host + path)
|
20
|
+
end
|