payture_ruby 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/payture/client/vwapi.rb +8 -0
- data/lib/payture/request.rb +11 -3
- data/lib/payture/version.rb +1 -1
- data/test/cassettes/charge/blocked.yml +36 -0
- data/test/cassettes/init/existing_user.yml +7 -7
- data/test/cassettes/init/new_user.yml +37 -0
- data/test/cassettes/pay/new_user/block.yml +36 -0
- data/test/cassettes/pay_status/blocked.yml +37 -0
- data/test/payture/client/vwapi_test.rb +71 -4
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9d5fe52809080eb02835086de37d7a19940586a
|
4
|
+
data.tar.gz: 60a539edd939204a6f9ec3f8d0bd33b1cf693973
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 765e2e1af294349e0dbbb55753db7eb32af75f740f5c414799a346c85eb1b09fd030a32fe4fcf843e4768e143d2bbf21ba6a43243155174cdfa3142eba92db6a
|
7
|
+
data.tar.gz: fd954f6bc85875a7af743ed22f887c37a46666e4f80961cec43cdcad4d8117027ec3a54f9133ad074d383f3ba9308aa485a6de7cd3ace8236670c914645ae5d4
|
data/lib/payture/client/vwapi.rb
CHANGED
@@ -15,6 +15,14 @@ module Payture
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
def charge options={}
|
19
|
+
options = hash_to_camelcase(options)
|
20
|
+
response = connection(false).get do |request|
|
21
|
+
request.url('Charge', options)
|
22
|
+
end
|
23
|
+
return Response.create(response.body).charge
|
24
|
+
end
|
25
|
+
|
18
26
|
end
|
19
27
|
end
|
20
28
|
end
|
data/lib/payture/request.rb
CHANGED
@@ -35,11 +35,19 @@ module Payture
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def encoded_string hash
|
38
|
-
|
39
|
-
CGI.escape
|
38
|
+
h = convert_to_camelcase hash
|
39
|
+
CGI.escape h.join(';')
|
40
40
|
end
|
41
41
|
|
42
|
-
def convert_to_camelcase
|
42
|
+
def convert_to_camelcase hash
|
43
|
+
hash.map{|k,v| "#{to_camelcase(k)}=#{v}"}
|
44
|
+
end
|
45
|
+
|
46
|
+
def hash_to_camelcase hash
|
47
|
+
Hash[hash.map {|k, v| [to_camelcase(k.capitalize), v] }]
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_camelcase(key)
|
43
51
|
key = key.to_s
|
44
52
|
if key.split('_').count > 1
|
45
53
|
key.split('_').collect(&:capitalize).join
|
data/lib/payture/version.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://sandbox.payture.com/vwapi/Charge?Amount=1000&OrderId=new123&Password=123&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.2
|
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, 11 Sep 2014 00:34:50 GMT
|
25
|
+
Content-Type:
|
26
|
+
- text/xml; charset=utf-8
|
27
|
+
Content-Length:
|
28
|
+
- '76'
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
body:
|
32
|
+
encoding: UTF-8
|
33
|
+
string: <Charge Success="True" OrderId="new123" Amount="1000" />
|
34
|
+
http_version:
|
35
|
+
recorded_at: Thu, 11 Sep 2014 00:34:50 GMT
|
36
|
+
recorded_with: VCR 2.9.2
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://sandbox.payture.com/vwapi/Init?DATA=SessionType%253DBlock%253BVWUserLgn%253Dfucker1%2540dom.com%253BVWUserPsw%253D123%253Bip%253D123.123.122.111%253Bamount%253D1000%253BOrderId%
|
5
|
+
uri: https://sandbox.payture.com/vwapi/Init?DATA=SessionType%253DBlock%253BVWUserLgn%253Dfucker1%2540dom.com%253BVWUserPsw%253D123%253Bip%253D123.123.122.111%253Bamount%253D1000%253BOrderId%253Dasdfasfafa1234345&VWID=VWMerchant
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -10,7 +10,7 @@ http_interactions:
|
|
10
10
|
Accept:
|
11
11
|
- application/xml; charset=utf-8
|
12
12
|
User-Agent:
|
13
|
-
- Payture Ruby Gem 0.0.
|
13
|
+
- Payture Ruby Gem 0.0.2
|
14
14
|
Accept-Encoding:
|
15
15
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
16
|
response:
|
@@ -21,17 +21,17 @@ http_interactions:
|
|
21
21
|
Server:
|
22
22
|
- nginx
|
23
23
|
Date:
|
24
|
-
- Wed, 10 Sep 2014 22:
|
24
|
+
- Wed, 10 Sep 2014 23:22:01 GMT
|
25
25
|
Content-Type:
|
26
26
|
- text/xml; charset=utf-8
|
27
27
|
Content-Length:
|
28
|
-
- '
|
28
|
+
- '137'
|
29
29
|
Connection:
|
30
30
|
- keep-alive
|
31
31
|
body:
|
32
32
|
encoding: UTF-8
|
33
|
-
string: <Init Success="True" OrderId="
|
33
|
+
string: <Init Success="True" OrderId="asdfasfafa1234345" Amount="1000" SessionId="b324fe03-f70b-4a3d-8265-526c8e718c49"
|
34
34
|
SessionType="Block" />
|
35
|
-
http_version:
|
36
|
-
recorded_at: Wed, 10 Sep 2014 22:
|
35
|
+
http_version:
|
36
|
+
recorded_at: Wed, 10 Sep 2014 23:22:01 GMT
|
37
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/Init?DATA=SessionType%253DBlock%253BVWUserLgn%253Dnew%2540dom.com%253BVWUserPsw%253D123%253Bip%253D123.123.122.111%253Bamount%253D1000%253BOrderId%253Dnew123&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.2
|
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, 11 Sep 2014 00:26:08 GMT
|
25
|
+
Content-Type:
|
26
|
+
- text/xml; charset=utf-8
|
27
|
+
Content-Length:
|
28
|
+
- '130'
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
body:
|
32
|
+
encoding: UTF-8
|
33
|
+
string: <Init Success="True" OrderId="new123" Amount="1000" SessionId="ede6348e-ff39-41a0-8a9b-bf28d106de13"
|
34
|
+
SessionType="Block" />
|
35
|
+
http_version:
|
36
|
+
recorded_at: Thu, 11 Sep 2014 00:26:08 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/Pay?DATA=VWUserLgn%253Dnew%2540dom.com%253BVWUserPsw%253D123%253BCardId%253DFreePay%253BCardNumber%253D4111111111111112%253BEMonth%253D12%253BEYear%253D15%253BCardHolder%253DIvan%2BIvanov%253BSecureCode%253D123%253BPhoneNumber%253D79001234567%253BOrderId%253Dnew123%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.2
|
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, 11 Sep 2014 00:30:21 GMT
|
25
|
+
Content-Type:
|
26
|
+
- text/xml; charset=utf-8
|
27
|
+
Content-Length:
|
28
|
+
- '86'
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
body:
|
32
|
+
encoding: UTF-8
|
33
|
+
string: <Pay VWUserLgn="" OrderId="new123" Success="True" Amount="1000" />
|
34
|
+
http_version:
|
35
|
+
recorded_at: Thu, 11 Sep 2014 00:30:21 GMT
|
36
|
+
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/PayStatus?DATA=OrderId%253Dnew123&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.2
|
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, 11 Sep 2014 00:31:49 GMT
|
25
|
+
Content-Type:
|
26
|
+
- text/xml; charset=utf-8
|
27
|
+
Content-Length:
|
28
|
+
- '116'
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
body:
|
32
|
+
encoding: UTF-8
|
33
|
+
string: <PayStatus Success="True" VWUserLgn="" OrderId="new123" Amount="1000"
|
34
|
+
CardId="" Status="Authorized" />
|
35
|
+
http_version:
|
36
|
+
recorded_at: Thu, 11 Sep 2014 00:31:49 GMT
|
37
|
+
recorded_with: VCR 2.9.2
|
@@ -258,8 +258,7 @@ module Payture
|
|
258
258
|
end
|
259
259
|
|
260
260
|
describe '.init' do
|
261
|
-
let(:email) { '
|
262
|
-
let(:card_id) { "e43544ba-cf4f-4702-85ef-313df89577eb" }
|
261
|
+
let(:email) { 'new@dom.com' }
|
263
262
|
let(:options) {
|
264
263
|
{
|
265
264
|
session_type: 'Block',
|
@@ -267,13 +266,81 @@ module Payture
|
|
267
266
|
v_w_user_psw: 123,
|
268
267
|
ip: '123.123.122.111',
|
269
268
|
amount: 1000,
|
270
|
-
order_id: '
|
269
|
+
order_id: 'new123'
|
271
270
|
}
|
272
271
|
}
|
273
272
|
subject { client.init options }
|
274
273
|
|
275
274
|
it "returns success status" do
|
276
|
-
VCR.use_cassette('init/
|
275
|
+
VCR.use_cassette('init/new_user') do
|
276
|
+
subject.success.must_equal "True"
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
describe '.pay to block after init' do
|
282
|
+
let(:email) { 'new@dom.com' }
|
283
|
+
let(:card_number) { 4111111111111112 }
|
284
|
+
let(:order_id) { 'new123' }
|
285
|
+
let(:options) {
|
286
|
+
{
|
287
|
+
v_w_user_lgn: email,
|
288
|
+
v_w_user_psw: 123,
|
289
|
+
card_id: 'FreePay',
|
290
|
+
card_number: card_number,
|
291
|
+
e_month: 12,
|
292
|
+
e_year: 15,
|
293
|
+
card_holder: 'Ivan Ivanov',
|
294
|
+
secure_code: 123,
|
295
|
+
phone_number: 79001234567,
|
296
|
+
order_id: order_id,
|
297
|
+
amount: '1000',
|
298
|
+
ip: '123.123.122.111'
|
299
|
+
}
|
300
|
+
}
|
301
|
+
subject { client.pay options }
|
302
|
+
|
303
|
+
|
304
|
+
it "returns success status" do
|
305
|
+
VCR.use_cassette('pay/new_user/block') do
|
306
|
+
subject.success.must_equal "True"
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
end
|
311
|
+
|
312
|
+
describe '.pay_status' do
|
313
|
+
let(:options) {
|
314
|
+
{
|
315
|
+
order_id: 'new123',
|
316
|
+
}
|
317
|
+
}
|
318
|
+
subject { client.pay_status options }
|
319
|
+
|
320
|
+
it "returns success status" do
|
321
|
+
VCR.use_cassette('pay_status/blocked') do
|
322
|
+
subject.success.must_equal "True"
|
323
|
+
end
|
324
|
+
end
|
325
|
+
it "returns payment status" do
|
326
|
+
VCR.use_cassette('pay_status/blocked') do
|
327
|
+
subject.status.must_equal "Authorized"
|
328
|
+
end
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
describe '.charge' do
|
333
|
+
let(:options) {
|
334
|
+
{
|
335
|
+
amount: 1000,
|
336
|
+
order_id: 'new123',
|
337
|
+
password: 123
|
338
|
+
}
|
339
|
+
}
|
340
|
+
subject { client.charge options }
|
341
|
+
|
342
|
+
it "returns success status" do
|
343
|
+
VCR.use_cassette('charge/blocked') do
|
277
344
|
subject.success.must_equal "True"
|
278
345
|
end
|
279
346
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: payture_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Davydov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -181,10 +181,14 @@ files:
|
|
181
181
|
- test/cassettes/activate/existing_user/existing_card.yml
|
182
182
|
- test/cassettes/add/new_user/existing_card.yml
|
183
183
|
- test/cassettes/add/new_user/new_card.yml
|
184
|
+
- test/cassettes/charge/blocked.yml
|
184
185
|
- test/cassettes/get_list/existing_user.yml
|
185
186
|
- test/cassettes/init/existing_user.yml
|
187
|
+
- test/cassettes/init/new_user.yml
|
186
188
|
- test/cassettes/pay/existing_user/active_card.yml
|
187
189
|
- test/cassettes/pay/existing_user/inactive_card.yml
|
190
|
+
- test/cassettes/pay/new_user/block.yml
|
191
|
+
- test/cassettes/pay_status/blocked.yml
|
188
192
|
- test/cassettes/register/duplicate.yml
|
189
193
|
- test/cassettes/register/new.yml
|
190
194
|
- test/payture/api_test.rb
|
@@ -220,10 +224,14 @@ test_files:
|
|
220
224
|
- test/cassettes/activate/existing_user/existing_card.yml
|
221
225
|
- test/cassettes/add/new_user/existing_card.yml
|
222
226
|
- test/cassettes/add/new_user/new_card.yml
|
227
|
+
- test/cassettes/charge/blocked.yml
|
223
228
|
- test/cassettes/get_list/existing_user.yml
|
224
229
|
- test/cassettes/init/existing_user.yml
|
230
|
+
- test/cassettes/init/new_user.yml
|
225
231
|
- test/cassettes/pay/existing_user/active_card.yml
|
226
232
|
- test/cassettes/pay/existing_user/inactive_card.yml
|
233
|
+
- test/cassettes/pay/new_user/block.yml
|
234
|
+
- test/cassettes/pay_status/blocked.yml
|
227
235
|
- test/cassettes/register/duplicate.yml
|
228
236
|
- test/cassettes/register/new.yml
|
229
237
|
- test/payture/api_test.rb
|