ruby-culqi 1.0.0 → 1.0.2
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/lib/culqi/charge.rb +2 -2
- data/lib/culqi/version.rb +1 -1
- data/lib/culqi-ruby.rb +4 -4
- data/lib/operation/post.rb +4 -4
- data/lib/operation/update.rb +2 -2
- data/lib/util/connect.rb +30 -61
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ac525931f7cc5ec8e5aded7335bec54784379ae631b280ddc1adcb7dff1a35c
|
4
|
+
data.tar.gz: 3388c5f6ebb01dc8793dfd7b3d687cab2c0bf113fb52d37cca76fcc9e3afb740
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f09d3e6770651e93d732213429f32c8c0fcefdfbf2f4cd0eb03a01dc0f7cd5f017a76d0f93093ea1d215864e2e1a58bfa4171002260ef8fb2502905b74dc379c
|
7
|
+
data.tar.gz: f3768a3aecf710d388d0aec20b0b785528b56b8d718b41f7289e8addfb86b4a5b856a0f2d411058cc581613ee7eebbd293c0016b7403f83a13a9fbed6e395c58
|
data/lib/culqi/charge.rb
CHANGED
@@ -11,8 +11,8 @@ module Culqi
|
|
11
11
|
@url = URL
|
12
12
|
|
13
13
|
def self.capture(id)
|
14
|
-
response = Culqi.connect("#{@url}#{id}/capture/", Culqi.secret_key, nil, "post", Culqi::READ_TIMEOUT)
|
15
|
-
return response.read_body
|
14
|
+
response, statuscode = Culqi.connect("#{@url}#{id}/capture/", Culqi.secret_key, nil, "post", Culqi::READ_TIMEOUT)
|
15
|
+
return response.read_body, statuscode
|
16
16
|
end
|
17
17
|
|
18
18
|
end
|
data/lib/culqi/version.rb
CHANGED
data/lib/culqi-ruby.rb
CHANGED
@@ -20,10 +20,10 @@ require 'culqi/yape'
|
|
20
20
|
require 'culqi/order'
|
21
21
|
module Culqi
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
API_BASE = 'https://qa-api.culqi.xyz/v2'
|
26
|
-
API_BASE_SECURE = 'https://qa-secure.culqi.xyz/v2'
|
23
|
+
API_BASE = 'https://api.culqi.com/v2'
|
24
|
+
API_BASE_SECURE = 'https://secure.culqi.com/v2'
|
25
|
+
#API_BASE = 'https://qa-api.culqi.xyz/v2'
|
26
|
+
#API_BASE_SECURE = 'https://qa-secure.culqi.xyz/v2'
|
27
27
|
READ_TIMEOUT = 120
|
28
28
|
LIST_TIMEOUT = 360
|
29
29
|
|
data/lib/operation/post.rb
CHANGED
@@ -14,12 +14,12 @@ module Culqi::Post
|
|
14
14
|
params = Encrypt.encrypt_with_aes_rsa(params, rsa_key, true)
|
15
15
|
end
|
16
16
|
key = Culqi.public_key
|
17
|
-
response = Culqi.connect(@url, key, params, 'post', Culqi::READ_TIMEOUT, true, rsa_id)
|
18
|
-
return response
|
17
|
+
response, statuscode = Culqi.connect(@url, key, params, 'post', Culqi::READ_TIMEOUT, true, rsa_id)
|
18
|
+
return response, statuscode
|
19
19
|
else
|
20
20
|
key = Culqi.secret_key
|
21
|
-
response = Culqi.connect(@url, key, params, 'post', Culqi::READ_TIMEOUT, false, '')
|
22
|
-
return response
|
21
|
+
response, statuscode = Culqi.connect(@url, key, params, 'post', Culqi::READ_TIMEOUT, false, '')
|
22
|
+
return response, statuscode
|
23
23
|
end
|
24
24
|
|
25
25
|
end
|
data/lib/operation/update.rb
CHANGED
@@ -10,8 +10,8 @@ module Culqi::Update
|
|
10
10
|
if(rsa_key != '')
|
11
11
|
params = Encrypt.encrypt_with_aes_rsa(params, rsa_key, true)
|
12
12
|
end
|
13
|
-
response = Culqi.connect("#{@url}#{id}/", Culqi.secret_key, params, 'patch', Culqi::READ_TIMEOUT, rsa_id)
|
14
|
-
return response
|
13
|
+
response, statusCode = Culqi.connect("#{@url}#{id}/", Culqi.secret_key, params, 'patch', Culqi::READ_TIMEOUT, rsa_id)
|
14
|
+
return response, statusCode
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
data/lib/util/connect.rb
CHANGED
@@ -1,72 +1,41 @@
|
|
1
|
-
require 'uri'
|
2
1
|
require 'net/http'
|
3
|
-
require 'openssl'
|
4
2
|
require 'json'
|
5
3
|
require 'culqi-ruby'
|
6
|
-
require 'open3'
|
7
|
-
|
8
4
|
|
9
5
|
module Culqi
|
10
|
-
|
11
6
|
def self.connect(url, api_key, data, type, time_out, secure_url = false, rsa_id='')
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
"-H", auth_header,
|
39
|
-
"-H", content_type_header,
|
40
|
-
"-H", rsa_id_header,
|
41
|
-
"-H", cache_control_header,
|
42
|
-
"-d", data
|
43
|
-
)
|
44
|
-
|
7
|
+
base_url = secure_url ? Culqi::API_BASE_SECURE : Culqi::API_BASE
|
8
|
+
full_url = "#{base_url}#{url}"
|
9
|
+
uri = URI(full_url)
|
10
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
11
|
+
http.use_ssl = uri.scheme == 'https'
|
12
|
+
|
13
|
+
headers = {
|
14
|
+
"Authorization" => "Bearer #{api_key}",
|
15
|
+
"Content-Type" => "application/json",
|
16
|
+
"cache-control" => "no-cache"
|
17
|
+
}
|
18
|
+
headers["x-culqi-rsa-id"] = rsa_id if rsa_id && !rsa_id.empty?
|
19
|
+
|
20
|
+
case type.upcase
|
21
|
+
when 'GET'
|
22
|
+
request = Net::HTTP::Get.new(uri.request_uri, headers)
|
23
|
+
when 'POST'
|
24
|
+
request = Net::HTTP::Post.new(uri.request_uri, headers)
|
25
|
+
request.body = data.to_json if data
|
26
|
+
when 'DELETE'
|
27
|
+
request = Net::HTTP::Delete.new(uri.request_uri, headers)
|
28
|
+
when 'PATCH'
|
29
|
+
request = Net::HTTP::Patch.new(uri.request_uri, headers)
|
30
|
+
request.body = data.to_json if data
|
31
|
+
else
|
32
|
+
raise ArgumentError, "Unsupported request type: #{type}"
|
45
33
|
end
|
46
34
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
command = "curl '#{url}' -G -d '#{URI.encode_www_form(data)}'"
|
51
|
-
else
|
52
|
-
command = "curl '#{url}'"
|
53
|
-
end
|
54
|
-
|
55
|
-
stdout, stderr, status = Open3.capture3("#{command} -H 'Authorization: Bearer #{api_key}' -H 'Content-Type: application/json' -H 'cache-control: no-cache'")
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
if type.upcase == 'DELETE'
|
60
|
-
command = "curl -X DELETE '#{url}' -H 'Authorization: Bearer #{api_key}' -H 'Content-Type: application/json' -H 'cache-control: no-cache'"
|
61
|
-
stdout, stderr, status = Open3.capture3(command)
|
62
|
-
end
|
63
|
-
|
64
|
-
if type.upcase == 'PATCH'
|
65
|
-
command = "curl -X PATCH '#{url}' -H 'Authorization: Bearer #{api_key}' -H 'Content-Type: application/json' -H 'x-culqi-rsa-id: #{rsa_id}' -H 'cache-control: no-cache' -d '#{data.to_json}'"
|
66
|
-
stdout, stderr, status = Open3.capture3(command)
|
67
|
-
end
|
68
|
-
|
69
|
-
return stdout
|
35
|
+
http.read_timeout = time_out
|
36
|
+
response = http.request(request)
|
37
|
+
puts response.body
|
70
38
|
|
39
|
+
return response.body, response.code.to_i
|
71
40
|
end
|
72
41
|
end
|