epayco-sdk-ruby 0.0.9 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/epayco +1 -1
- data/lib/epayco/operations.rb +174 -169
- data/lib/epayco/resources.rb +58 -54
- data/lib/epayco-sdk-ruby.rb +2 -2
- data/lib/epayco.rb +238 -222
- data/lib/keylang.json +36 -26
- data/lib/keylang_apify.json +29 -0
- data/tests/test_helper.rb +123 -123
- data/tests/testing.rb +209 -209
- metadata +6 -3
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/bin/epayco
CHANGED
@@ -1 +1 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
1
|
+
#!/usr/bin/env ruby
|
data/lib/epayco/operations.rb
CHANGED
@@ -1,169 +1,174 @@
|
|
1
|
-
module Epayco
|
2
|
-
module Operations
|
3
|
-
module ClassMethods
|
4
|
-
|
5
|
-
private
|
6
|
-
|
7
|
-
# Action create
|
8
|
-
def create params={}, extra=nil
|
9
|
-
dt=false
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
url = "/
|
14
|
-
elsif self.url == "
|
15
|
-
url = "/
|
16
|
-
elsif self.url == "
|
17
|
-
url = "/recurring/v1/
|
18
|
-
elsif self.url == "
|
19
|
-
url = "/
|
20
|
-
elsif self.url == "
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
elsif extra == "gana"
|
32
|
-
url = "/restpagos/v2/efectivo/gana"
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
46
|
-
Epayco.request :post, url, extra, params, self.switch, cashdata,
|
47
|
-
end
|
48
|
-
|
49
|
-
# Action retrieve from id
|
50
|
-
def get uid, params={}, extra=nil
|
51
|
-
switch = self.switch;
|
52
|
-
cashdata=false
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
url = "/
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
dt=false
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
end
|
168
|
-
|
169
|
-
|
1
|
+
module Epayco
|
2
|
+
module Operations
|
3
|
+
module ClassMethods
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
# Action create
|
8
|
+
def create params={}, extra=nil
|
9
|
+
dt=false
|
10
|
+
apify = false
|
11
|
+
cashdata = false
|
12
|
+
if self.url == "token"
|
13
|
+
url = "/v1/tokens"
|
14
|
+
elsif self.url == "customers"
|
15
|
+
url = "/payment/v1/customer/create"
|
16
|
+
elsif self.url == "plan"
|
17
|
+
url = "/recurring/v1/plan/create"
|
18
|
+
elsif self.url == "subscriptions"
|
19
|
+
url = "/recurring/v1/subscription/create"
|
20
|
+
elsif self.url == "bank"
|
21
|
+
url = "/restpagos/pagos/debitos.json"
|
22
|
+
elsif self.url == "safetypay"
|
23
|
+
apify = true
|
24
|
+
url = "/payment/process/safetypay"
|
25
|
+
elsif self.url == "cash"
|
26
|
+
cashdata = true
|
27
|
+
if extra == "efecty"
|
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
|
+
else
|
38
|
+
raise Error.new('109', Epayco.lang)
|
39
|
+
end
|
40
|
+
elsif self.url == "charge"
|
41
|
+
url = "/payment/v1/charge/create"
|
42
|
+
elsif self.url == "daviplata"
|
43
|
+
url = "/payment/process/daviplata"
|
44
|
+
apify = true
|
45
|
+
end
|
46
|
+
Epayco.request :post, url, extra, params, self.switch, cashdata, dt, apify
|
47
|
+
end
|
48
|
+
|
49
|
+
# Action retrieve from id
|
50
|
+
def get uid, params={}, extra=nil
|
51
|
+
switch = self.switch;
|
52
|
+
cashdata=false
|
53
|
+
dt=false
|
54
|
+
if self.url == "customers"
|
55
|
+
url = "/payment/v1/customer/" + Epayco.apiKey + "/" + uid + "/"
|
56
|
+
elsif self.url == "plan"
|
57
|
+
url = "/recurring/v1/plan/" + Epayco.apiKey + "/" + uid + "/"
|
58
|
+
elsif self.url == "subscriptions"
|
59
|
+
url = "/recurring/v1/subscription/" + uid + "/" + Epayco.apiKey + "/"
|
60
|
+
elsif self.url == "bank"
|
61
|
+
url = "/restpagos/pse/transactioninfomation.json?transactionID=" + uid + "&public_key=" + Epayco.apiKey
|
62
|
+
switch = true
|
63
|
+
elsif self.url == "cash" || self.url == "charge"
|
64
|
+
url = "/restpagos/transaction/response.json?ref_payco=" + uid + "&public_key=" + Epayco.apiKey
|
65
|
+
switch = true
|
66
|
+
end
|
67
|
+
Epayco.request :get, url, extra, params, switch, cashdata, dt, apify = false
|
68
|
+
end
|
69
|
+
|
70
|
+
# Action update
|
71
|
+
def update uid, params={}, extra=nil
|
72
|
+
cashdata=false
|
73
|
+
dt=false
|
74
|
+
if self.url == "customers"
|
75
|
+
url = "/payment/v1/customer/edit/" + Epayco.apiKey + "/" + uid + "/"
|
76
|
+
end
|
77
|
+
Epayco.request :post, url, extra, params, self.switch, cashdata, dt, apify = false
|
78
|
+
end
|
79
|
+
|
80
|
+
# Action update token
|
81
|
+
def updatetoken params={}, extra=nil
|
82
|
+
if self.url == "customers"
|
83
|
+
url = "/payment/v1/customer/reasign/card/default"
|
84
|
+
cashdata = false
|
85
|
+
dt = true
|
86
|
+
end
|
87
|
+
Epayco.request :post, url, extra, params, self.switch, cashdata, dt, apify = false
|
88
|
+
end
|
89
|
+
|
90
|
+
def delatetetoken params={}, extra=nil
|
91
|
+
if self.url == "customers"
|
92
|
+
url = "/v1/remove/token"
|
93
|
+
cashdata = false
|
94
|
+
dt = true
|
95
|
+
end
|
96
|
+
Epayco.request :post, url, extra, params, self.switch, cashdata, dt, apify = false
|
97
|
+
end
|
98
|
+
|
99
|
+
def addtoken params={}, extra=nil
|
100
|
+
if self.url == "customers"
|
101
|
+
url = "/v1/customer/add/token"
|
102
|
+
cashdata = false
|
103
|
+
dt = true
|
104
|
+
end
|
105
|
+
Epayco.request :post, url, extra, params, self.switch, cashdata, dt, apify = false
|
106
|
+
end
|
107
|
+
|
108
|
+
# Action retrieve all documents from user
|
109
|
+
def list params={}, extra=nil
|
110
|
+
cashdata=false
|
111
|
+
dt=false
|
112
|
+
if self.url == "customers"
|
113
|
+
url = "/payment/v1/customers/" + Epayco.apiKey + "/"
|
114
|
+
elsif self.url == "plan"
|
115
|
+
url = "/recurring/v1/plans/" + Epayco.apiKey + "/"
|
116
|
+
elsif self.url == "subscriptions"
|
117
|
+
url = "/recurring/v1/subscriptions/" + Epayco.apiKey
|
118
|
+
elsif self.url == "bank"
|
119
|
+
url = "/restpagos/pse/bancos.json?public_key=" + Epayco.apiKey
|
120
|
+
end
|
121
|
+
Epayco.request :get, url, extra, params, self.switch, cashdata, dt, apify = false
|
122
|
+
end
|
123
|
+
|
124
|
+
# Remove data from api
|
125
|
+
def delete uid, params={}, extra=nil
|
126
|
+
cashdata=false
|
127
|
+
dt=false
|
128
|
+
if self.url == "plan"
|
129
|
+
url = "/recurring/v1/plan/remove/" + Epayco.apiKey + "/" + uid
|
130
|
+
end
|
131
|
+
Epayco.request :post, url, extra, params, self.switch, cashdata, dt, apify = false
|
132
|
+
end
|
133
|
+
|
134
|
+
# Cance subscription
|
135
|
+
def cancel uid, params={}, extra=nil
|
136
|
+
cashdata=false
|
137
|
+
dt=false
|
138
|
+
params["id"] = uid
|
139
|
+
params["public_key"] = Epayco.apiKey
|
140
|
+
if self.url == "subscriptions"
|
141
|
+
url = "/recurring/v1/subscription/cancel"
|
142
|
+
end
|
143
|
+
Epayco.request :post, url, extra, params, self.switch, cashdata, dt, apify = false
|
144
|
+
end
|
145
|
+
|
146
|
+
def charge params={}, extra=nil
|
147
|
+
cashdata=false
|
148
|
+
dt=false
|
149
|
+
if self.url == "subscriptions"
|
150
|
+
url = "/payment/v1/charge/subscription/create"
|
151
|
+
end
|
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
|
+
|
164
|
+
end
|
165
|
+
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
# Export methods
|
170
|
+
def self.included(base)
|
171
|
+
base.extend(ClassMethods)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
data/lib/epayco/resources.rb
CHANGED
@@ -1,54 +1,58 @@
|
|
1
|
-
require_relative 'operations'
|
2
|
-
|
3
|
-
module Epayco
|
4
|
-
class Resource
|
5
|
-
include Operations
|
6
|
-
|
7
|
-
# Def url endpoint
|
8
|
-
def self.url id=nil
|
9
|
-
self.name.split('::').last.downcase
|
10
|
-
end
|
11
|
-
|
12
|
-
# Case switch secure or api
|
13
|
-
def self.switch
|
14
|
-
self.url == "bank" || self.url == "cash" ? true : false
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
# Resources and CRUD
|
21
|
-
|
22
|
-
class Token < Resource
|
23
|
-
public_class_method :create
|
24
|
-
end
|
25
|
-
|
26
|
-
class Customers < Resource
|
27
|
-
public_class_method :create, :get, :list, :update, :updatetoken, :delatetetoken, :addtoken
|
28
|
-
end
|
29
|
-
|
30
|
-
class Plan < Resource
|
31
|
-
public_class_method :create, :get, :list, :delete
|
32
|
-
end
|
33
|
-
|
34
|
-
class Subscriptions < Resource
|
35
|
-
public_class_method :create, :get, :list, :cancel, :charge
|
36
|
-
end
|
37
|
-
|
38
|
-
class Bank < Resource
|
39
|
-
public_class_method :create, :get
|
40
|
-
end
|
41
|
-
|
42
|
-
class Cash < Resource
|
43
|
-
public_class_method :create, :get
|
44
|
-
end
|
45
|
-
|
46
|
-
class Charge < Resource
|
47
|
-
public_class_method :create, :get
|
48
|
-
end
|
49
|
-
|
50
|
-
class Safetypay < Resource
|
51
|
-
public_class_method :create
|
52
|
-
end
|
53
|
-
|
54
|
-
|
1
|
+
require_relative 'operations'
|
2
|
+
|
3
|
+
module Epayco
|
4
|
+
class Resource
|
5
|
+
include Operations
|
6
|
+
|
7
|
+
# Def url endpoint
|
8
|
+
def self.url id=nil
|
9
|
+
self.name.split('::').last.downcase
|
10
|
+
end
|
11
|
+
|
12
|
+
# Case switch secure or api
|
13
|
+
def self.switch
|
14
|
+
self.url == "bank" || self.url == "cash" ? true : false
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
# Resources and CRUD
|
21
|
+
|
22
|
+
class Token < Resource
|
23
|
+
public_class_method :create
|
24
|
+
end
|
25
|
+
|
26
|
+
class Customers < Resource
|
27
|
+
public_class_method :create, :get, :list, :update, :updatetoken, :delatetetoken, :addtoken
|
28
|
+
end
|
29
|
+
|
30
|
+
class Plan < Resource
|
31
|
+
public_class_method :create, :get, :list, :delete
|
32
|
+
end
|
33
|
+
|
34
|
+
class Subscriptions < Resource
|
35
|
+
public_class_method :create, :get, :list, :cancel, :charge
|
36
|
+
end
|
37
|
+
|
38
|
+
class Bank < Resource
|
39
|
+
public_class_method :create, :get, :list
|
40
|
+
end
|
41
|
+
|
42
|
+
class Cash < Resource
|
43
|
+
public_class_method :create, :get
|
44
|
+
end
|
45
|
+
|
46
|
+
class Charge < Resource
|
47
|
+
public_class_method :create, :get
|
48
|
+
end
|
49
|
+
|
50
|
+
class Safetypay < Resource
|
51
|
+
public_class_method :create
|
52
|
+
end
|
53
|
+
|
54
|
+
class Daviplata < Resource
|
55
|
+
public_class_method :create, :confirm
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
data/lib/epayco-sdk-ruby.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
# Describe global library
|
2
|
-
require File.dirname(__FILE__) + '/epayco'
|
1
|
+
# Describe global library
|
2
|
+
require File.dirname(__FILE__) + '/epayco'
|