paidy 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/Gemfile.lock +5 -5
- data/lib/paidy.rb +13 -11
- data/lib/paidy/charge.rb +15 -0
- data/lib/paidy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60b7d42b64dfcec3324ca3cafadc777d1e74182d54ae8569cfb59c3eca7ddedc
|
4
|
+
data.tar.gz: 1f0e3bcccbb0057c8bb9b2f964a0a44306850d205391d9e0766e44c327eaf0b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cce61e83e5a263a032b8c09464c2a0e6a9b938d2f7e6081a8310acea635d86404130d0c58f321fd3ea16f4daa984aba15f7b5f8a0d052d931d2dc40c3bfd00d8
|
7
|
+
data.tar.gz: c652a90eb5301997e503bbe6435aa275c7219cc9da2bc2fc0966e6f79f5beec0713796829910b78504ffba8d3721ae9ecbad0df90d98bc01acfa8c2ad97437cc
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
paidy (0.0.
|
4
|
+
paidy (0.0.3)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -12,15 +12,15 @@ GEM
|
|
12
12
|
rspec-core (~> 3.9.0)
|
13
13
|
rspec-expectations (~> 3.9.0)
|
14
14
|
rspec-mocks (~> 3.9.0)
|
15
|
-
rspec-core (3.9.
|
16
|
-
rspec-support (~> 3.9.
|
17
|
-
rspec-expectations (3.9.
|
15
|
+
rspec-core (3.9.2)
|
16
|
+
rspec-support (~> 3.9.3)
|
17
|
+
rspec-expectations (3.9.2)
|
18
18
|
diff-lcs (>= 1.2.0, < 2.0)
|
19
19
|
rspec-support (~> 3.9.0)
|
20
20
|
rspec-mocks (3.9.1)
|
21
21
|
diff-lcs (>= 1.2.0, < 2.0)
|
22
22
|
rspec-support (~> 3.9.0)
|
23
|
-
rspec-support (3.9.
|
23
|
+
rspec-support (3.9.3)
|
24
24
|
|
25
25
|
PLATFORMS
|
26
26
|
ruby
|
data/lib/paidy.rb
CHANGED
@@ -33,20 +33,22 @@ module Paidy
|
|
33
33
|
uri = api_uri(path: path)
|
34
34
|
|
35
35
|
case method.to_s.downcase.to_sym
|
36
|
-
|
37
|
-
|
36
|
+
when :get
|
37
|
+
uri += (uri.query.present? ? '&' : '?') + query_parameter(params) if params.present?
|
38
|
+
req = Net::HTTP::Get.new(uri)
|
38
39
|
when :post
|
39
40
|
req = Net::HTTP::Post.new(uri)
|
40
|
-
req['Content-Type'] = 'application/json'
|
41
|
-
req['Paidy-Version'] = @api_version
|
42
|
-
req['Authorization'] = "Bearer #{secret_key}"
|
43
41
|
req.body = params.to_json
|
44
|
-
|
45
|
-
req_options = {
|
46
|
-
use_ssl: @use_ssl,
|
47
|
-
}
|
48
42
|
end
|
49
43
|
|
44
|
+
req['Content-Type'] = 'application/json'
|
45
|
+
req['Paidy-Version'] = @api_version
|
46
|
+
req['Authorization'] = "Bearer #{secret_key}"
|
47
|
+
|
48
|
+
req_options = {
|
49
|
+
use_ssl: @use_ssl,
|
50
|
+
}
|
51
|
+
|
50
52
|
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
51
53
|
http.request(req)
|
52
54
|
end
|
@@ -65,9 +67,9 @@ module Paidy
|
|
65
67
|
def self.query_parameter(params)
|
66
68
|
params.map do |k, v|
|
67
69
|
if v.is_a?(Array)
|
68
|
-
v.map{ |vv| "#{k}[]=#{CGI.
|
70
|
+
v.map{ |vv| "#{k}[]=#{CGI.escape(vv)}" }.join('&')
|
69
71
|
else
|
70
|
-
"#{k}=#{CGI.
|
72
|
+
"#{k}=#{CGI.escape(v)}"
|
71
73
|
end
|
72
74
|
end.join('&')
|
73
75
|
end
|
data/lib/paidy/charge.rb
CHANGED
@@ -6,6 +6,13 @@ module Paidy
|
|
6
6
|
|
7
7
|
self.new(res['id'])
|
8
8
|
end
|
9
|
+
|
10
|
+
def retrieve(id)
|
11
|
+
instance = self.new(id)
|
12
|
+
instance.refresh
|
13
|
+
|
14
|
+
instance
|
15
|
+
end
|
9
16
|
end
|
10
17
|
|
11
18
|
def initialize(id)
|
@@ -42,6 +49,14 @@ module Paidy
|
|
42
49
|
end
|
43
50
|
end
|
44
51
|
|
52
|
+
def refresh
|
53
|
+
res = Paidy.request(:get, "payments/#{id}")
|
54
|
+
|
55
|
+
if res['status'] == 'closed' && res['captures'].present?
|
56
|
+
@capture_id = res['captures'][0]['id']
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
45
60
|
private
|
46
61
|
|
47
62
|
def base_path
|
data/lib/paidy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paidy
|
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
|
- rn0rno
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|