epayco-sdk-ruby 1.4.0 → 1.6.0
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/epayco/operations.rb +31 -23
- data/lib/epayco/resources.rb +1 -1
- data/lib/epayco.rb +42 -22
- data/lib/keylang_apify.json +29 -0
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ac204064b4c7e2006797715b7ca7247bb46e637df9b7fec143a0dc63371cadb
|
4
|
+
data.tar.gz: 375584fdb81c7413e433a3a54da813c8aea9184834995fddd355e14052b09f4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9034fb30d135b0c6ffc27b5815e3b2b61334335e05be3734dbc40e2ace63504b0b02a94083e4f9c198b966885cf226a1b9e0b019bcf456c05caa00e2579cf15
|
7
|
+
data.tar.gz: 42d22c49633d50ba91c26aee4152d02747cc518f23731115ed3f88e4fd2b95f12f9a226b72b59e0c025a1eb2d0f8b1268ad21ef9da0acfe7254088810bb91430
|
data/lib/epayco/operations.rb
CHANGED
@@ -18,27 +18,31 @@ module Epayco
|
|
18
18
|
elsif self.url == "subscriptions"
|
19
19
|
url = "/recurring/v1/subscription/create"
|
20
20
|
elsif self.url == "bank"
|
21
|
-
url = "/
|
21
|
+
url = "/pagos/debitos.json"
|
22
22
|
elsif self.url == "safetypay"
|
23
23
|
apify = true
|
24
24
|
url = "/payment/process/safetypay"
|
25
25
|
elsif self.url == "cash"
|
26
26
|
cashdata = true
|
27
|
-
if extra ==
|
28
|
-
url = "/restpagos/v2/efectivo/efecty"
|
29
|
-
elsif extra == "baloto"
|
30
|
-
url = "/restpagos/v2/efectivo/baloto"
|
31
|
-
elsif extra == "gana"
|
32
|
-
url = "/restpagos/v2/efectivo/gana"
|
33
|
-
elsif extra == "redservi"
|
34
|
-
url = "/restpagos/v2/efectivo/redservi"
|
35
|
-
elsif extra == "puntored"
|
36
|
-
url = "/restpagos/v2/efectivo/puntored"
|
37
|
-
elsif extra == "sured"
|
38
|
-
url = "/restpagos/v2/efectivo/sured"
|
39
|
-
else
|
27
|
+
if extra.downcase == 'baloto'
|
40
28
|
raise Error.new('109', Epayco.lang)
|
41
29
|
end
|
30
|
+
methods_payment = Epayco.request :get, "/payment/cash/entities", extra, {}, false, false, dt, true
|
31
|
+
|
32
|
+
if(methods_payment[:success].nil? || !methods_payment[:success])
|
33
|
+
raise Error.new('104', Epayco.lang)
|
34
|
+
end
|
35
|
+
|
36
|
+
if methods_payment[:data].nil? || !methods_payment[:data].kind_of?(Array)
|
37
|
+
raise Error.new('106', Epayco.lang)
|
38
|
+
end
|
39
|
+
entities = methods_payment[:data].map do |item|
|
40
|
+
item[:name].gsub(/\s+/, "").downcase
|
41
|
+
end
|
42
|
+
if !entities.include? extra.downcase
|
43
|
+
raise Error.new('109', Epayco.lang)
|
44
|
+
end
|
45
|
+
url = "/v2/efectivo/" + extra
|
42
46
|
elsif self.url == "charge"
|
43
47
|
url = "/payment/v1/charge/create"
|
44
48
|
elsif self.url == "daviplata"
|
@@ -54,16 +58,16 @@ module Epayco
|
|
54
58
|
cashdata=false
|
55
59
|
dt=false
|
56
60
|
if self.url == "customers"
|
57
|
-
url = "/payment/v1/customer/" + Epayco.apiKey + "/" + uid
|
61
|
+
url = "/payment/v1/customer/" + Epayco.apiKey + "/" + uid
|
58
62
|
elsif self.url == "plan"
|
59
|
-
url = "/recurring/v1/plan/" + Epayco.apiKey + "/" + uid
|
63
|
+
url = "/recurring/v1/plan/" + Epayco.apiKey + "/" + uid
|
60
64
|
elsif self.url == "subscriptions"
|
61
|
-
url = "/recurring/v1/subscription/" + uid + "/" + Epayco.apiKey
|
65
|
+
url = "/recurring/v1/subscription/" + uid + "/" + Epayco.apiKey
|
62
66
|
elsif self.url == "bank"
|
63
|
-
url = "/
|
67
|
+
url = "/pse/transactioninfomation.json?transactionID=" + uid + "&public_key=" + Epayco.apiKey
|
64
68
|
switch = true
|
65
69
|
elsif self.url == "cash" || self.url == "charge"
|
66
|
-
url = "/
|
70
|
+
url = "/transaction/response.json?ref_payco=" + uid + "&public_key=" + Epayco.apiKey
|
67
71
|
switch = true
|
68
72
|
end
|
69
73
|
Epayco.request :get, url, extra, params, switch, cashdata, dt, apify = false
|
@@ -74,7 +78,9 @@ module Epayco
|
|
74
78
|
cashdata=false
|
75
79
|
dt=false
|
76
80
|
if self.url == "customers"
|
77
|
-
url = "/payment/v1/customer/edit/" + Epayco.apiKey + "/" + uid
|
81
|
+
url = "/payment/v1/customer/edit/" + Epayco.apiKey + "/" + uid
|
82
|
+
elsif self.url == "plan"
|
83
|
+
url = "/recurring/v1/plan/edit/" + uid
|
78
84
|
end
|
79
85
|
Epayco.request :post, url, extra, params, self.switch, cashdata, dt, apify = false
|
80
86
|
end
|
@@ -122,13 +128,15 @@ module Epayco
|
|
122
128
|
cashdata=false
|
123
129
|
dt=false
|
124
130
|
if self.url == "customers"
|
125
|
-
|
131
|
+
page = params[:page] || nil
|
132
|
+
per_page = params[:perPage] || nil
|
133
|
+
url = (page && per_page) ? "/payment/v1/customers/?page=#{page}&perPage=#{per_page}" : "/payment/v1/customers/" + Epayco.apiKey + "/"
|
126
134
|
elsif self.url == "plan"
|
127
|
-
url = "/recurring/v1/plans/" + Epayco.apiKey
|
135
|
+
url = "/recurring/v1/plans/" + Epayco.apiKey
|
128
136
|
elsif self.url == "subscriptions"
|
129
137
|
url = "/recurring/v1/subscriptions/" + Epayco.apiKey
|
130
138
|
elsif self.url == "bank"
|
131
|
-
url = "/
|
139
|
+
url = "/pse/bancos.json?public_key=" + Epayco.apiKey
|
132
140
|
end
|
133
141
|
Epayco.request :get, url, extra, params, self.switch, cashdata, dt, apify = false
|
134
142
|
end
|
data/lib/epayco/resources.rb
CHANGED
data/lib/epayco.rb
CHANGED
@@ -4,6 +4,7 @@ require 'openssl'
|
|
4
4
|
require 'base64'
|
5
5
|
require 'open-uri'
|
6
6
|
require 'socket'
|
7
|
+
require 'dotenv/load'
|
7
8
|
require_relative 'epayco/resources'
|
8
9
|
|
9
10
|
module Epayco
|
@@ -14,9 +15,21 @@ module Epayco
|
|
14
15
|
attr_accessor :errors
|
15
16
|
|
16
17
|
# Get code, lang and show custom error
|
17
|
-
def initialize
|
18
|
-
|
19
|
-
|
18
|
+
def initialize(code, lang)
|
19
|
+
begin
|
20
|
+
file = open("https://multimedia.epayco.co/message-api/errors.json").read
|
21
|
+
data_hash = JSON.parse(file)
|
22
|
+
rescue OpenURI::HTTPError, Errno::ENOENT => e
|
23
|
+
# Si no se puede acceder al archivo remoto, usar un archivo local como respaldo
|
24
|
+
local_file_path = File.join(File.dirname(__FILE__), 'errors.json')
|
25
|
+
if File.exist?(local_file_path)
|
26
|
+
file = File.read(local_file_path)
|
27
|
+
data_hash = JSON.parse(file)
|
28
|
+
else
|
29
|
+
raise "No se pudo cargar el archivo de errores: #{e.message}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
20
33
|
error = "Error"
|
21
34
|
if(data_hash[code.to_s])
|
22
35
|
error = [data_hash[code.to_s][lang]]
|
@@ -35,7 +48,10 @@ module Epayco
|
|
35
48
|
# Endpoints
|
36
49
|
@api_base = 'https://api.secure.payco.co'
|
37
50
|
@api_base_secure = 'https://secure.payco.co'
|
38
|
-
@api_base_apify =
|
51
|
+
@api_base_apify = 'https://apify.epayco.co'
|
52
|
+
@api_entorno = "/restpagos"
|
53
|
+
|
54
|
+
|
39
55
|
|
40
56
|
# Init sdk parameters
|
41
57
|
class << self
|
@@ -55,22 +71,24 @@ module Epayco
|
|
55
71
|
params["extras_epayco"] = {extra5:"P45"}
|
56
72
|
payload = JSON.generate(params) if method == :post || method == :patch
|
57
73
|
params = nil unless method == :get
|
58
|
-
|
74
|
+
|
59
75
|
# Switch secure or api or apify
|
60
76
|
if apify
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
77
|
+
if method == :post
|
78
|
+
@tags = JSON.parse(payload)
|
79
|
+
seted = {}
|
80
|
+
file = File.read(File.dirname(__FILE__) + '/keylang_apify.json')
|
81
|
+
data_hash = JSON.parse(file)
|
82
|
+
@tags.each {
|
83
|
+
|key, value|
|
84
|
+
if data_hash[key]
|
85
|
+
seted[data_hash[key]] = value
|
86
|
+
else
|
87
|
+
seted[key] = value
|
88
|
+
end
|
89
|
+
}
|
90
|
+
payload = seted.to_json
|
91
|
+
end
|
74
92
|
url = @api_base_apify + url
|
75
93
|
elsif switch
|
76
94
|
if method == :post || method == :patch
|
@@ -82,7 +100,7 @@ module Epayco
|
|
82
100
|
payload = enc.to_json
|
83
101
|
end
|
84
102
|
end
|
85
|
-
url = @api_base_secure + url
|
103
|
+
url = @api_base_secure + @api_entorno + url
|
86
104
|
else
|
87
105
|
if method == :post || method == :patch
|
88
106
|
rb_hash = JSON.parse(payload)
|
@@ -113,14 +131,15 @@ module Epayco
|
|
113
131
|
:url => url,
|
114
132
|
:payload => payload
|
115
133
|
}
|
116
|
-
|
134
|
+
|
117
135
|
# Open library rest client
|
118
136
|
begin
|
119
137
|
response = execute_request(options)
|
120
138
|
return {} if response.code == 204 and method == :delete
|
121
139
|
JSON.parse(response.body, :symbolize_names => true)
|
122
140
|
rescue RestClient::Exception => e
|
123
|
-
handle_errors e
|
141
|
+
#handle_errors e
|
142
|
+
return e.response
|
124
143
|
end
|
125
144
|
end
|
126
145
|
|
@@ -232,7 +251,8 @@ module Epayco
|
|
232
251
|
return body if body[:bearer_token] || body[:token]
|
233
252
|
raise Error.new("104", lang)
|
234
253
|
rescue RestClient::Exception => e
|
235
|
-
|
254
|
+
return e.response
|
255
|
+
#handle_errors e
|
236
256
|
end
|
237
257
|
|
238
258
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
{
|
2
|
+
"cash": "cash",
|
3
|
+
"end_date": "expirationDate",
|
4
|
+
"ref_payco": "refPayco",
|
5
|
+
"id_session_token": "idSessionToken",
|
6
|
+
"otp": "otp",
|
7
|
+
"invoice": "invoice",
|
8
|
+
"description": "description",
|
9
|
+
"value": "value",
|
10
|
+
"tax": "tax",
|
11
|
+
"ico": "ico",
|
12
|
+
"tax_base": "taxBase",
|
13
|
+
"currency": "currency",
|
14
|
+
"doc_type": "docType",
|
15
|
+
"doc_number": "document",
|
16
|
+
"name": "name",
|
17
|
+
"last_name": "lastName",
|
18
|
+
"email": "email",
|
19
|
+
"ind_country": "indCountry",
|
20
|
+
"country": "country",
|
21
|
+
"city": "city",
|
22
|
+
"phone": "phone",
|
23
|
+
"address": "address",
|
24
|
+
"ip": "ip",
|
25
|
+
"test": "testMode",
|
26
|
+
"url_response": "urlResponse",
|
27
|
+
"url_confirmation": "urlConfirmation",
|
28
|
+
"method_confirmation": "methodConfirmation"
|
29
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epayco-sdk-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Epayco development team
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2025-04-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
@@ -32,14 +32,28 @@ dependencies:
|
|
32
32
|
requirements:
|
33
33
|
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: '2.
|
35
|
+
version: '2.7'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '2.
|
42
|
+
version: '2.7'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: dotenv
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '2.8'
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '2.8'
|
43
57
|
- !ruby/object:Gem::Dependency
|
44
58
|
name: cutest
|
45
59
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,14 +74,14 @@ dependencies:
|
|
60
74
|
requirements:
|
61
75
|
- - "~>"
|
62
76
|
- !ruby/object:Gem::Version
|
63
|
-
version: '
|
77
|
+
version: '2.7'
|
64
78
|
type: :development
|
65
79
|
prerelease: false
|
66
80
|
version_requirements: !ruby/object:Gem::Requirement
|
67
81
|
requirements:
|
68
82
|
- - "~>"
|
69
83
|
- !ruby/object:Gem::Version
|
70
|
-
version: '
|
84
|
+
version: '2.7'
|
71
85
|
description: |-
|
72
86
|
API to interact with Epayco
|
73
87
|
https://epayco.co
|
@@ -85,6 +99,7 @@ files:
|
|
85
99
|
- lib/epayco/operations.rb
|
86
100
|
- lib/epayco/resources.rb
|
87
101
|
- lib/keylang.json
|
102
|
+
- lib/keylang_apify.json
|
88
103
|
- tests/test_helper.rb
|
89
104
|
- tests/testing.rb
|
90
105
|
homepage: https://epayco.co/
|