epayco-sdk-ruby 1.5.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 +24 -9
- data/lib/keylang_apify.json +29 -0
- metadata +22 -7
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,7 +4,7 @@ require 'openssl'
|
|
4
4
|
require 'base64'
|
5
5
|
require 'open-uri'
|
6
6
|
require 'socket'
|
7
|
-
|
7
|
+
require 'dotenv/load'
|
8
8
|
require_relative 'epayco/resources'
|
9
9
|
|
10
10
|
module Epayco
|
@@ -15,9 +15,21 @@ module Epayco
|
|
15
15
|
attr_accessor :errors
|
16
16
|
|
17
17
|
# Get code, lang and show custom error
|
18
|
-
def initialize
|
19
|
-
|
20
|
-
|
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
|
+
|
21
33
|
error = "Error"
|
22
34
|
if(data_hash[code.to_s])
|
23
35
|
error = [data_hash[code.to_s][lang]]
|
@@ -36,10 +48,11 @@ module Epayco
|
|
36
48
|
# Endpoints
|
37
49
|
@api_base = 'https://api.secure.payco.co'
|
38
50
|
@api_base_secure = 'https://secure.payco.co'
|
39
|
-
@api_base_apify =
|
51
|
+
@api_base_apify = 'https://apify.epayco.co'
|
40
52
|
@api_entorno = "/restpagos"
|
41
53
|
|
42
54
|
|
55
|
+
|
43
56
|
# Init sdk parameters
|
44
57
|
class << self
|
45
58
|
attr_accessor :apiKey, :privateKey, :lang, :test
|
@@ -58,7 +71,7 @@ module Epayco
|
|
58
71
|
params["extras_epayco"] = {extra5:"P45"}
|
59
72
|
payload = JSON.generate(params) if method == :post || method == :patch
|
60
73
|
params = nil unless method == :get
|
61
|
-
|
74
|
+
|
62
75
|
# Switch secure or api or apify
|
63
76
|
if apify
|
64
77
|
if method == :post
|
@@ -118,14 +131,15 @@ module Epayco
|
|
118
131
|
:url => url,
|
119
132
|
:payload => payload
|
120
133
|
}
|
121
|
-
|
134
|
+
|
122
135
|
# Open library rest client
|
123
136
|
begin
|
124
137
|
response = execute_request(options)
|
125
138
|
return {} if response.code == 204 and method == :delete
|
126
139
|
JSON.parse(response.body, :symbolize_names => true)
|
127
140
|
rescue RestClient::Exception => e
|
128
|
-
handle_errors e
|
141
|
+
#handle_errors e
|
142
|
+
return e.response
|
129
143
|
end
|
130
144
|
end
|
131
145
|
|
@@ -237,7 +251,8 @@ module Epayco
|
|
237
251
|
return body if body[:bearer_token] || body[:token]
|
238
252
|
raise Error.new("104", lang)
|
239
253
|
rescue RestClient::Exception => e
|
240
|
-
|
254
|
+
return e.response
|
255
|
+
#handle_errors e
|
241
256
|
end
|
242
257
|
|
243
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/
|
@@ -106,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
121
|
- !ruby/object:Gem::Version
|
107
122
|
version: '0'
|
108
123
|
requirements: []
|
109
|
-
rubygems_version: 3.3
|
124
|
+
rubygems_version: 3.2.3
|
110
125
|
signing_key:
|
111
126
|
specification_version: 4
|
112
127
|
summary: Ruby wrapper for Epayco API
|