payler_api 0.0.5 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -0
- data/lib/payler_api/request.rb +2 -3
- data/lib/payler_api/response.rb +10 -0
- data/lib/payler_api.rb +1 -1
- data/payler_api.gemspec +3 -3
- data/test/cassettes/test_0001_should_send_3ds_continue_request.yml +40 -0
- data/test/spec_payler_api.rb +10 -3
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 400ee81f33ecb6c2fd39de0ef2c85f93f88403df
|
4
|
+
data.tar.gz: 7532276828c414dda1f27fba5d533cb2d4ffcb0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 453521b575927e85a4e2e3959cd71ffd216259bc9832e59b74edd853f1520f5191422dbb61265c44c1e3a84907f3d8fabee1d552d974956383ac4bc493b99bec
|
7
|
+
data.tar.gz: 61eb73bb671192fd14bf44d5eafd9d5fbc55e4bf8d84912a0aa4d40aebd70f3203c0fec0353f67032d091dda9e5744154ad59dddf098a9c27f0dbf4329f80daa
|
data/README.md
CHANGED
@@ -13,6 +13,7 @@ Simple ruby wrapper for [Payler Merchant API](http://payler.com/docs/acquiring_d
|
|
13
13
|
$ cat config/initializers/payler_api.rb:
|
14
14
|
|
15
15
|
PaylerAPI.configure do |config|
|
16
|
+
config.host = 'HOST'
|
16
17
|
config.access_key = 'ACCESS_KEY'
|
17
18
|
end
|
18
19
|
|
@@ -39,3 +40,39 @@ Simple ruby wrapper for [Payler Merchant API](http://payler.com/docs/acquiring_d
|
|
39
40
|
|
40
41
|
PaylerAPI.get_status order_id: 'some_uniq_order' # => return PaylerAPI::Response with order data
|
41
42
|
...
|
43
|
+
|
44
|
+
## 3DS
|
45
|
+
|
46
|
+
# step 0: authorize 3ds transaction
|
47
|
+
|
48
|
+
PaylerAPI.configuration.access_key = 3DS_key_ID
|
49
|
+
response = PaylerAPI.pay {
|
50
|
+
card_number: "*",
|
51
|
+
expired_year: "*",
|
52
|
+
expired_month: "*",
|
53
|
+
secure_code: "*",
|
54
|
+
order_id: "*",
|
55
|
+
amount: "10000"
|
56
|
+
}
|
57
|
+
|
58
|
+
response.ok? # => true
|
59
|
+
response.three_ds? # => true
|
60
|
+
|
61
|
+
attrs = response.three_ds_attributes # => {url: "acs_url", pa_req: "%big_key%", md: "%small_key%"}
|
62
|
+
|
63
|
+
# step 1: redirect customer to bank site with special params from three_ds_attributes
|
64
|
+
str = "<form name='form' action='#{attrs['url']}' method='post' >
|
65
|
+
<input type='hidden' name='TermUrl' value='%callback_url%' >
|
66
|
+
<input type='hidden' name='MD' value='#{attrs['md']}' >
|
67
|
+
<input type='hidden' name='PaReq' value='#{attrs['pa_req']}' >
|
68
|
+
</form><script type='text/javascript'>document.form.submit()</script>"
|
69
|
+
|
70
|
+
# step 2: callback request from bank(with md and pares keys), send finished request to payler
|
71
|
+
finished_response = PaylerAPI.send_3ds md: md_key, pares: pares_key
|
72
|
+
finished_response.ok? # => true if transaction is successed
|
73
|
+
|
74
|
+
|
75
|
+
## dev
|
76
|
+
|
77
|
+
# run specs
|
78
|
+
ruby -Ilib test/spec_payler_api.rb
|
data/lib/payler_api/request.rb
CHANGED
@@ -19,11 +19,10 @@ module PaylerAPI
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def protected_method?
|
22
|
-
[:refund, :charge, :retrieve].include? method
|
22
|
+
[ :refund, :charge, :retrieve ].include? method
|
23
23
|
end
|
24
24
|
|
25
25
|
private
|
26
|
-
|
27
26
|
def config; PaylerAPI.configuration; end
|
28
27
|
|
29
28
|
def headers
|
@@ -31,7 +30,7 @@ module PaylerAPI
|
|
31
30
|
end
|
32
31
|
|
33
32
|
def camel_case_url_path
|
34
|
-
'/'+method.to_s.split('_').collect(&:capitalize).join
|
33
|
+
'/'+method.to_s.split('_').collect(&:capitalize).join.sub("3ds","3DS")
|
35
34
|
end
|
36
35
|
|
37
36
|
end
|
data/lib/payler_api/response.rb
CHANGED
@@ -23,6 +23,16 @@ module PaylerAPI
|
|
23
23
|
data.has_key? 'error'
|
24
24
|
end
|
25
25
|
|
26
|
+
def three_ds_attributes
|
27
|
+
if three_ds?
|
28
|
+
{ url: data['acs_url'],
|
29
|
+
pa_req: data['pareq'],
|
30
|
+
md: data['md'] }
|
31
|
+
else
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
26
36
|
def error_code
|
27
37
|
data['error']['code'] if error?
|
28
38
|
end
|
data/lib/payler_api.rb
CHANGED
@@ -2,7 +2,7 @@ require 'payler_api/response'
|
|
2
2
|
require 'payler_api/request'
|
3
3
|
|
4
4
|
module PaylerAPI
|
5
|
-
AvailableMethods = [:pay, :block, :charge, :refund, :retrieve, :get_status]
|
5
|
+
AvailableMethods = [:pay, :block, :charge, :refund, :retrieve, :get_status, :send_3ds]
|
6
6
|
|
7
7
|
def self.method_missing(method, *arguments, &block)
|
8
8
|
return super unless AvailableMethods.include? method
|
data/payler_api.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'payler_api'
|
3
|
-
s.version = '0.
|
4
|
-
s.date = '2016-01-
|
3
|
+
s.version = '0.1.1'
|
4
|
+
s.date = '2016-01-26'
|
5
5
|
s.description = 'Simple ruby wrapper for payler merchant api'
|
6
6
|
s.summary = 'Payler Merchant API Wrapper'
|
7
|
-
s.homepage = 'https://github.com/
|
7
|
+
s.homepage = 'https://github.com/sletix/payler_api'
|
8
8
|
s.license = 'MIT'
|
9
9
|
s.authors = ['Oleg Artamonov']
|
10
10
|
s.email = 'oleg@artamonov.ru'
|
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://host.payler.com/mapi/Send3DS?key=test-key&md=test_md&pares=test_pares
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/x-www-form-urlencoded
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message: OK
|
16
|
+
headers:
|
17
|
+
Server:
|
18
|
+
- nginx
|
19
|
+
Date:
|
20
|
+
- Mon, 25 Jan 2016 14:09:19 GMT
|
21
|
+
Content-Type:
|
22
|
+
- text/json; charset=utf-8
|
23
|
+
Content-Length:
|
24
|
+
- '78'
|
25
|
+
Connection:
|
26
|
+
- keep-alive
|
27
|
+
Content-Security-Policy:
|
28
|
+
- frame-ancestors 'none'
|
29
|
+
X-Frame-Options:
|
30
|
+
- deny
|
31
|
+
Strict-Transport-Security:
|
32
|
+
- max-age=31536000;
|
33
|
+
body:
|
34
|
+
encoding: UTF-8
|
35
|
+
string: "{\r\n \"auth_type\": 0,\r\n \"amount\": 30000,\r\n \"order_id\":
|
36
|
+
\"test_pay_order_01\"\r\n}"
|
37
|
+
http_version:
|
38
|
+
recorded_at: Mon, 25 Jan 2016 14:09:19 GMT
|
39
|
+
recorded_with: VCR 3.0.1
|
40
|
+
|
data/test/spec_payler_api.rb
CHANGED
@@ -27,7 +27,7 @@ describe 'PaylerAPI' do
|
|
27
27
|
describe 'block-charge' do
|
28
28
|
let :params do
|
29
29
|
{ order_id: 'test_block_order_05',
|
30
|
-
|
30
|
+
amount: '30000' }.merge(card_params)
|
31
31
|
end
|
32
32
|
|
33
33
|
describe '#block' do
|
@@ -63,12 +63,19 @@ describe 'PaylerAPI' do
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
+
describe '#send_3ds' do
|
67
|
+
it 'should send 3ds continue request' do
|
68
|
+
resp = subject.send_3ds md: 'test_md', pares: 'test_pares'
|
69
|
+
resp.ok?.must_equal true
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
66
73
|
# TODO:
|
67
|
-
#describe('#refund', '#retrieve)
|
74
|
+
# describe('#refund', '#retrieve)
|
68
75
|
|
69
76
|
describe '#configure' do
|
70
77
|
before { PaylerAPI.configure {|config| config.access_key = 'foo-bar' } }
|
71
|
-
after { PaylerAPI.configuration.access_key = 'test-key' }
|
78
|
+
after { PaylerAPI.configuration.access_key = 'test-key' }
|
72
79
|
|
73
80
|
it 'should setup new access_key' do
|
74
81
|
PaylerAPI.configuration.access_key.must_equal 'foo-bar'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: payler_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oleg Artamonov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -94,12 +94,13 @@ files:
|
|
94
94
|
- test/cassettes/test_0001_should_blocks_the_specified_amount_card.yml
|
95
95
|
- test/cassettes/test_0001_should_charge_blocked_order.yml
|
96
96
|
- test/cassettes/test_0001_should_return_data_by_order_id.yml
|
97
|
+
- test/cassettes/test_0001_should_send_3ds_continue_request.yml
|
97
98
|
- test/cassettes/test_0001_should_send_true_request.yml
|
98
99
|
- test/cassettes/test_0002_should_return_duplicate_order_id_error.yml
|
99
100
|
- test/cassettes/test_0002_should_return_error_by_wrong_order_id.yml
|
100
101
|
- test/helper.rb
|
101
102
|
- test/spec_payler_api.rb
|
102
|
-
homepage: https://github.com/
|
103
|
+
homepage: https://github.com/sletix/payler_api
|
103
104
|
licenses:
|
104
105
|
- MIT
|
105
106
|
metadata: {}
|
@@ -119,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
120
|
version: '0'
|
120
121
|
requirements: []
|
121
122
|
rubyforge_project:
|
122
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.5.1
|
123
124
|
signing_key:
|
124
125
|
specification_version: 4
|
125
126
|
summary: Payler Merchant API Wrapper
|