epayco-sdk-ruby 1.0.2 → 1.1.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 +30 -27
- data/lib/epayco/resources.rb +4 -0
- data/lib/epayco.rb +59 -44
- data/lib/keylang.json +2 -1
- data/lib/keylang_apify.json +29 -0
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 583e33f500757f2f606d53f77eb1fe42588900fe7632d2c58bdc7e5219b28dc4
|
|
4
|
+
data.tar.gz: 6ac2f2cd2e2cf5aaa63edaf47fb12c2decb57c667e57919a2f51ab7fe3083e40
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dbd1fd37a0d9ae5b33bfa6228be75b1ee5ed7f23b43f88101d3a90f0cb32c03ea4ebedb53256f2d47cea6cab264ee79207a18eaab7ef896fb12696bc296a04f5
|
|
7
|
+
data.tar.gz: e35e59ec3aa668a854937c36cc25e2f03f4fa208d3d96cc4f4d09711b85a614adc1545a1f793eaec8d6e22e81826355db86e6c90a762e4bc17c504b68a5268ff
|
data/lib/epayco/operations.rb
CHANGED
|
@@ -7,6 +7,8 @@ module Epayco
|
|
|
7
7
|
# Action create
|
|
8
8
|
def create params={}, extra=nil
|
|
9
9
|
dt=false
|
|
10
|
+
apify = false
|
|
11
|
+
cashdata = false
|
|
10
12
|
if self.url == "token"
|
|
11
13
|
url = "/v1/tokens"
|
|
12
14
|
elsif self.url == "customers"
|
|
@@ -18,39 +20,36 @@ module Epayco
|
|
|
18
20
|
elsif self.url == "bank"
|
|
19
21
|
url = "/restpagos/pagos/debitos.json"
|
|
20
22
|
elsif self.url == "safetypay"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
url = "/restpagos/pagos/safetypays.json"
|
|
23
|
+
apify = true
|
|
24
|
+
url = "/payment/process/safetypay"
|
|
24
25
|
elsif self.url == "cash"
|
|
26
|
+
cashdata = true
|
|
25
27
|
if extra == "efecty"
|
|
26
28
|
url = "/restpagos/v2/efectivo/efecty"
|
|
27
|
-
cashdata = true
|
|
28
29
|
elsif extra == "baloto"
|
|
29
30
|
url = "/restpagos/v2/efectivo/baloto"
|
|
30
|
-
cashdata = true
|
|
31
31
|
elsif extra == "gana"
|
|
32
32
|
url = "/restpagos/v2/efectivo/gana"
|
|
33
|
-
cashdata = true
|
|
34
33
|
elsif extra == "redservi"
|
|
35
34
|
url = "/restpagos/v2/efectivo/redservi"
|
|
36
|
-
cashdata = true
|
|
37
35
|
elsif extra == "puntored"
|
|
38
36
|
url = "/restpagos/v2/efectivo/puntored"
|
|
39
|
-
cashdata = true
|
|
40
37
|
else
|
|
41
38
|
raise Error.new('109', Epayco.lang)
|
|
42
39
|
end
|
|
43
40
|
elsif self.url == "charge"
|
|
44
41
|
url = "/payment/v1/charge/create"
|
|
42
|
+
elsif self.url == "daviplata"
|
|
43
|
+
url = "/payment/process/daviplata"
|
|
44
|
+
apify = true
|
|
45
45
|
end
|
|
46
|
-
Epayco.request :post, url, extra, params, self.switch, cashdata,
|
|
46
|
+
Epayco.request :post, url, extra, params, self.switch, cashdata, dt, apify
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
# Action retrieve from id
|
|
50
50
|
def get uid, params={}, extra=nil
|
|
51
51
|
switch = self.switch;
|
|
52
52
|
cashdata=false
|
|
53
|
-
sp=false
|
|
54
53
|
dt=false
|
|
55
54
|
if self.url == "customers"
|
|
56
55
|
url = "/payment/v1/customer/" + Epayco.apiKey + "/" + uid + "/"
|
|
@@ -65,18 +64,17 @@ module Epayco
|
|
|
65
64
|
url = "/restpagos/transaction/response.json?ref_payco=" + uid + "&public_key=" + Epayco.apiKey
|
|
66
65
|
switch = true
|
|
67
66
|
end
|
|
68
|
-
Epayco.request :get, url, extra, params, switch, cashdata,
|
|
67
|
+
Epayco.request :get, url, extra, params, switch, cashdata, dt, apify = false
|
|
69
68
|
end
|
|
70
69
|
|
|
71
70
|
# Action update
|
|
72
71
|
def update uid, params={}, extra=nil
|
|
73
72
|
cashdata=false
|
|
74
|
-
sp=false
|
|
75
73
|
dt=false
|
|
76
74
|
if self.url == "customers"
|
|
77
75
|
url = "/payment/v1/customer/edit/" + Epayco.apiKey + "/" + uid + "/"
|
|
78
76
|
end
|
|
79
|
-
Epayco.request :post, url, extra, params, self.switch, cashdata,
|
|
77
|
+
Epayco.request :post, url, extra, params, self.switch, cashdata, dt, apify = false
|
|
80
78
|
end
|
|
81
79
|
|
|
82
80
|
# Action update token
|
|
@@ -84,36 +82,32 @@ module Epayco
|
|
|
84
82
|
if self.url == "customers"
|
|
85
83
|
url = "/payment/v1/customer/reasign/card/default"
|
|
86
84
|
cashdata = false
|
|
87
|
-
sp = false
|
|
88
85
|
dt = true
|
|
89
86
|
end
|
|
90
|
-
Epayco.request :post, url, extra, params, self.switch, cashdata,
|
|
87
|
+
Epayco.request :post, url, extra, params, self.switch, cashdata, dt, apify = false
|
|
91
88
|
end
|
|
92
89
|
|
|
93
90
|
def delatetetoken params={}, extra=nil
|
|
94
91
|
if self.url == "customers"
|
|
95
92
|
url = "/v1/remove/token"
|
|
96
93
|
cashdata = false
|
|
97
|
-
sp = false
|
|
98
94
|
dt = true
|
|
99
95
|
end
|
|
100
|
-
Epayco.request :post, url, extra, params, self.switch, cashdata,
|
|
96
|
+
Epayco.request :post, url, extra, params, self.switch, cashdata, dt, apify = false
|
|
101
97
|
end
|
|
102
98
|
|
|
103
99
|
def addtoken params={}, extra=nil
|
|
104
100
|
if self.url == "customers"
|
|
105
101
|
url = "/v1/customer/add/token"
|
|
106
102
|
cashdata = false
|
|
107
|
-
sp = false
|
|
108
103
|
dt = true
|
|
109
104
|
end
|
|
110
|
-
Epayco.request :post, url, extra, params, self.switch, cashdata,
|
|
105
|
+
Epayco.request :post, url, extra, params, self.switch, cashdata, dt, apify = false
|
|
111
106
|
end
|
|
112
107
|
|
|
113
108
|
# Action retrieve all documents from user
|
|
114
109
|
def list params={}, extra=nil
|
|
115
110
|
cashdata=false
|
|
116
|
-
sp=false
|
|
117
111
|
dt=false
|
|
118
112
|
if self.url == "customers"
|
|
119
113
|
url = "/payment/v1/customers/" + Epayco.apiKey + "/"
|
|
@@ -124,43 +118,52 @@ module Epayco
|
|
|
124
118
|
elsif self.url == "bank"
|
|
125
119
|
url = "/restpagos/pse/bancos.json?public_key=" + Epayco.apiKey
|
|
126
120
|
end
|
|
127
|
-
Epayco.request :get, url, extra, params, self.switch, cashdata,
|
|
121
|
+
Epayco.request :get, url, extra, params, self.switch, cashdata, dt, apify = false
|
|
128
122
|
end
|
|
129
123
|
|
|
130
124
|
# Remove data from api
|
|
131
125
|
def delete uid, params={}, extra=nil
|
|
132
126
|
cashdata=false
|
|
133
|
-
sp=false
|
|
134
127
|
dt=false
|
|
135
128
|
if self.url == "plan"
|
|
136
129
|
url = "/recurring/v1/plan/remove/" + Epayco.apiKey + "/" + uid
|
|
137
130
|
end
|
|
138
|
-
Epayco.request :post, url, extra, params, self.switch, cashdata,
|
|
131
|
+
Epayco.request :post, url, extra, params, self.switch, cashdata, dt, apify = false
|
|
139
132
|
end
|
|
140
133
|
|
|
141
134
|
# Cance subscription
|
|
142
135
|
def cancel uid, params={}, extra=nil
|
|
143
136
|
cashdata=false
|
|
144
|
-
sp=false
|
|
145
137
|
dt=false
|
|
146
138
|
params["id"] = uid
|
|
147
139
|
params["public_key"] = Epayco.apiKey
|
|
148
140
|
if self.url == "subscriptions"
|
|
149
141
|
url = "/recurring/v1/subscription/cancel"
|
|
150
142
|
end
|
|
151
|
-
Epayco.request :post, url, extra, params, self.switch, cashdata,
|
|
143
|
+
Epayco.request :post, url, extra, params, self.switch, cashdata, dt, apify = false
|
|
152
144
|
end
|
|
153
145
|
|
|
154
146
|
def charge params={}, extra=nil
|
|
155
147
|
cashdata=false
|
|
156
|
-
sp=false
|
|
157
148
|
dt=false
|
|
158
149
|
if self.url == "subscriptions"
|
|
159
150
|
url = "/payment/v1/charge/subscription/create"
|
|
160
151
|
end
|
|
161
|
-
Epayco.request :post, url, extra, params, self.switch, cashdata,
|
|
152
|
+
Epayco.request :post, url, extra, params, self.switch, cashdata, dt, apify = false
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def confirm params={}
|
|
156
|
+
cashdata=false
|
|
157
|
+
dt=false
|
|
158
|
+
apify=true
|
|
159
|
+
if self.url == "daviplata"
|
|
160
|
+
url = "/payment/confirm/daviplata"
|
|
161
|
+
end
|
|
162
|
+
Epayco.request :post, url, nil, params, self.switch, cashdata, dt, apify
|
|
163
|
+
|
|
162
164
|
end
|
|
163
165
|
|
|
166
|
+
|
|
164
167
|
end
|
|
165
168
|
|
|
166
169
|
# Export methods
|
data/lib/epayco/resources.rb
CHANGED
data/lib/epayco.rb
CHANGED
|
@@ -15,20 +15,27 @@ module Epayco
|
|
|
15
15
|
|
|
16
16
|
# Get code, lang and show custom error
|
|
17
17
|
def initialize code, lang
|
|
18
|
-
file = open("https://
|
|
18
|
+
file = open("https://multimedia.epayco.co/message-api/errors.json").read
|
|
19
19
|
data_hash = JSON.parse(file)
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
error = "Error"
|
|
21
|
+
if(data_hash[code.to_s])
|
|
22
|
+
error = [data_hash[code.to_s][lang]]
|
|
23
|
+
else
|
|
24
|
+
error = [code, lang]
|
|
25
|
+
end
|
|
26
|
+
super error
|
|
27
|
+
@errors = error
|
|
22
28
|
end
|
|
23
29
|
|
|
24
30
|
def each
|
|
25
|
-
@errors.each { |e| yield *e
|
|
31
|
+
@errors.each { |e| yield *e }
|
|
26
32
|
end
|
|
27
33
|
end
|
|
28
34
|
|
|
29
35
|
# Endpoints
|
|
30
36
|
@api_base = 'https://api.secure.payco.co'
|
|
31
37
|
@api_base_secure = 'https://secure.payco.co'
|
|
38
|
+
@api_base_apify = "https://apify.epayco.co"
|
|
32
39
|
|
|
33
40
|
# Init sdk parameters
|
|
34
41
|
class << self
|
|
@@ -36,11 +43,11 @@ module Epayco
|
|
|
36
43
|
end
|
|
37
44
|
|
|
38
45
|
# Eject request and show response or error
|
|
39
|
-
def self.request(method, url, extra=nil, params={}, headers={}, switch, cashdata,
|
|
46
|
+
def self.request(method, url, extra=nil, params={}, headers={}, switch, cashdata, dt, apify)
|
|
40
47
|
method = method.to_sym
|
|
41
48
|
|
|
42
|
-
auth = authent(apiKey ,
|
|
43
|
-
bearer_token = 'Bearer '+ auth[:bearer_token]
|
|
49
|
+
auth = authent(apiKey, privateKey, apify, lang)
|
|
50
|
+
bearer_token = 'Bearer '+ (auth[:bearer_token] || auth[:token])
|
|
44
51
|
|
|
45
52
|
if !apiKey || !privateKey || !lang
|
|
46
53
|
raise Error.new('100', lang)
|
|
@@ -49,8 +56,23 @@ module Epayco
|
|
|
49
56
|
payload = JSON.generate(params) if method == :post || method == :patch
|
|
50
57
|
params = nil unless method == :get
|
|
51
58
|
|
|
52
|
-
# Switch secure or api
|
|
53
|
-
if
|
|
59
|
+
# Switch secure or api or apify
|
|
60
|
+
if apify
|
|
61
|
+
@tags = JSON.parse(payload)
|
|
62
|
+
seted = {}
|
|
63
|
+
file = File.read(File.dirname(__FILE__) + '/keylang_apify.json')
|
|
64
|
+
data_hash = JSON.parse(file)
|
|
65
|
+
@tags.each {
|
|
66
|
+
|key, value|
|
|
67
|
+
if data_hash[key]
|
|
68
|
+
seted[data_hash[key]] = value
|
|
69
|
+
else
|
|
70
|
+
seted[key] = value
|
|
71
|
+
end
|
|
72
|
+
}
|
|
73
|
+
payload = seted.to_json
|
|
74
|
+
url = @api_base_apify + url
|
|
75
|
+
elsif switch
|
|
54
76
|
if method == :post || method == :patch
|
|
55
77
|
if cashdata
|
|
56
78
|
enc = encrypt_aes(payload, true)
|
|
@@ -75,36 +97,23 @@ module Epayco
|
|
|
75
97
|
url = @api_base + url
|
|
76
98
|
end
|
|
77
99
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
:method => method,
|
|
87
|
-
:url => url,
|
|
88
|
-
:payload => payload
|
|
89
|
-
}
|
|
90
|
-
else
|
|
91
|
-
headers = {
|
|
92
|
-
:params => params,
|
|
93
|
-
:content_type => 'application/json',
|
|
94
|
-
:type => 'sdk-jwt',
|
|
95
|
-
:lang => 'RUBY',
|
|
96
|
-
:Authorization => bearer_token,
|
|
97
|
-
}.merge(headers)
|
|
100
|
+
|
|
101
|
+
headers = {
|
|
102
|
+
:params => params,
|
|
103
|
+
:content_type => 'application/json',
|
|
104
|
+
:type => 'sdk-jwt',
|
|
105
|
+
:lang => 'RUBY',
|
|
106
|
+
:Authorization => bearer_token,
|
|
107
|
+
}.merge(headers)
|
|
98
108
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
109
|
+
options = {
|
|
110
|
+
:headers => headers,
|
|
111
|
+
:user => apiKey,
|
|
112
|
+
:method => method,
|
|
113
|
+
:url => url,
|
|
114
|
+
:payload => payload
|
|
115
|
+
}
|
|
106
116
|
|
|
107
|
-
end
|
|
108
117
|
# Open library rest client
|
|
109
118
|
begin
|
|
110
119
|
#puts options
|
|
@@ -190,30 +199,36 @@ module Epayco
|
|
|
190
199
|
data_hash[key]
|
|
191
200
|
end
|
|
192
201
|
|
|
193
|
-
|
|
194
|
-
def self.authent(apiKey, privateKey)
|
|
202
|
+
def self.authent(apiKey, privateKey, apify, lang)
|
|
195
203
|
@parmas = {}
|
|
196
204
|
@parmas["public_key"] = apiKey
|
|
197
205
|
@parmas["private_key"] = privateKey
|
|
206
|
+
|
|
198
207
|
headers = {
|
|
199
208
|
# :params => @parmas,
|
|
200
209
|
:Accept => 'application/json',
|
|
201
210
|
:content_type => 'application/json',
|
|
202
211
|
:type => 'sdk'
|
|
203
|
-
|
|
212
|
+
}
|
|
213
|
+
url = 'https://api.secure.payco.co/v1/auth/login'
|
|
214
|
+
if(apify)
|
|
215
|
+
headers[:Authorization] = "Basic " + Base64.strict_encode64(apiKey + ":" + privateKey)
|
|
216
|
+
url = 'https://apify.epayco.co/login'
|
|
217
|
+
end
|
|
204
218
|
payload = @parmas.to_json
|
|
205
219
|
options = {
|
|
206
220
|
:headers => headers,
|
|
207
221
|
:user => apiKey,
|
|
208
222
|
:method => 'post',
|
|
209
|
-
:url =>
|
|
210
|
-
:payload => payload
|
|
223
|
+
:url => url,
|
|
224
|
+
:payload => if apify then nil else payload end
|
|
211
225
|
}
|
|
212
|
-
|
|
213
226
|
begin
|
|
214
227
|
response = execute_request(options)
|
|
215
228
|
return {} if response.code == 204 and method == :delete
|
|
216
|
-
JSON.parse(response.body, :symbolize_names => true)
|
|
229
|
+
body = JSON.parse(response.body, :symbolize_names => true)
|
|
230
|
+
return body if body[:bearer_token] || body[:token]
|
|
231
|
+
raise Error.new("104", lang)
|
|
217
232
|
rescue RestClient::Exception => e
|
|
218
233
|
handle_errors e
|
|
219
234
|
end
|
data/lib/keylang.json
CHANGED
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"ip": "ip",
|
|
23
23
|
"url_response": "url_respuesta",
|
|
24
24
|
"url_confirmation": "url_confirmacion",
|
|
25
|
-
"method_confirmation": "
|
|
25
|
+
"method_confirmation": "method_confirmation",
|
|
26
|
+
"metodoconfirmacion": "metodoconfirmacion",
|
|
26
27
|
"end_date": "fechaexpiracion",
|
|
27
28
|
"splitpayment": "splitpayment",
|
|
28
29
|
"split_app_id": "split_app_id",
|
|
@@ -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.0
|
|
4
|
+
version: 1.1.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: 2022-03-16 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: rest-client
|
|
@@ -85,6 +85,7 @@ files:
|
|
|
85
85
|
- lib/epayco/operations.rb
|
|
86
86
|
- lib/epayco/resources.rb
|
|
87
87
|
- lib/keylang.json
|
|
88
|
+
- lib/keylang_apify.json
|
|
88
89
|
- tests/test_helper.rb
|
|
89
90
|
- tests/testing.rb
|
|
90
91
|
homepage: https://epayco.co/
|
|
@@ -106,8 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
106
107
|
- !ruby/object:Gem::Version
|
|
107
108
|
version: '0'
|
|
108
109
|
requirements: []
|
|
109
|
-
|
|
110
|
-
rubygems_version: 2.7.6
|
|
110
|
+
rubygems_version: 3.0.3.1
|
|
111
111
|
signing_key:
|
|
112
112
|
specification_version: 4
|
|
113
113
|
summary: Ruby wrapper for Epayco API
|