epayco-ruby 0.0.5
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 +7 -0
- data/bin/epayco +1 -0
- data/lib/epayco-ruby.rb +2 -0
- data/lib/epayco.rb +148 -0
- data/lib/epayco/operations.rb +106 -0
- data/lib/epayco/resources.rb +48 -0
- data/lib/keylang.json +26 -0
- data/tests/test_helper.rb +123 -0
- data/tests/testing.rb +209 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d14ab1c47083da981f32de52f7c3df2f63dbb1bd
|
4
|
+
data.tar.gz: e1486095edce95c71976a768c44dbb01cb75c130
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cba2946a945f7f26c15de902ea606dcc7cd8688c89d261be7128e3dd9609cf3cad5484bf7cbd2cde33496679ce5a799e0b048c210fe44d353ce0990abfc73b06
|
7
|
+
data.tar.gz: f9f0be852dc5c76587e535b080093a4153716df5800ce4460f06b4409747706141a58897edf558f2fc71ad7ce00dbe350be10eb64fc8cc8512cbb1593dd3abfb
|
data/bin/epayco
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
data/lib/epayco-ruby.rb
ADDED
data/lib/epayco.rb
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'json'
|
3
|
+
require 'openssl'
|
4
|
+
require 'base64'
|
5
|
+
require 'open-uri'
|
6
|
+
require 'socket'
|
7
|
+
require_relative 'epayco/resources'
|
8
|
+
|
9
|
+
module Epayco
|
10
|
+
|
11
|
+
# Set custom error
|
12
|
+
class Error < StandardError
|
13
|
+
include Enumerable
|
14
|
+
attr_accessor :errors
|
15
|
+
|
16
|
+
# Get code, lang and show custom error
|
17
|
+
def initialize code, lang
|
18
|
+
file = open("https://s3-us-west-2.amazonaws.com/epayco/message_api/errors.json").read
|
19
|
+
data_hash = JSON.parse(file)
|
20
|
+
super data_hash[code][lang]
|
21
|
+
@errors = errors
|
22
|
+
end
|
23
|
+
|
24
|
+
def each
|
25
|
+
@errors.each { |e| yield *e.first }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Endpoints
|
30
|
+
@api_base = 'https://api.secure.payco.co'
|
31
|
+
@api_base_secure = 'https://secure.payco.co'
|
32
|
+
|
33
|
+
# Init sdk parameters
|
34
|
+
class << self
|
35
|
+
attr_accessor :apiKey, :privateKey, :lang, :test
|
36
|
+
end
|
37
|
+
|
38
|
+
# Eject request and show response or error
|
39
|
+
def self.request(method, url, extra=nil, params={}, headers={}, switch)
|
40
|
+
method = method.to_sym
|
41
|
+
|
42
|
+
if !apiKey || !privateKey || !lang || !test
|
43
|
+
raise Error.new('100', lang)
|
44
|
+
end
|
45
|
+
|
46
|
+
payload = JSON.generate(params) if method == :post || method == :patch
|
47
|
+
params = nil unless method == :get
|
48
|
+
|
49
|
+
# Switch secure or api
|
50
|
+
if switch
|
51
|
+
if method == :post || method == :patch
|
52
|
+
enc = encrypt_aes(payload)
|
53
|
+
payload = enc.to_json
|
54
|
+
end
|
55
|
+
url = @api_base_secure + url
|
56
|
+
else
|
57
|
+
if method == :post || method == :patch
|
58
|
+
rb_hash = JSON.parse(payload)
|
59
|
+
rb_hash["test"] = test ? "TRUE" : "FALSE"
|
60
|
+
rb_hash["ip"] = local_ip
|
61
|
+
payload = rb_hash.to_json
|
62
|
+
end
|
63
|
+
url = @api_base + url
|
64
|
+
end
|
65
|
+
|
66
|
+
headers = {
|
67
|
+
:params => params,
|
68
|
+
:content_type => 'application/json',
|
69
|
+
:type => 'sdk'
|
70
|
+
}.merge(headers)
|
71
|
+
|
72
|
+
options = {
|
73
|
+
:headers => headers,
|
74
|
+
:user => apiKey,
|
75
|
+
:method => method,
|
76
|
+
:url => url,
|
77
|
+
:payload => payload
|
78
|
+
}
|
79
|
+
|
80
|
+
# Open library rest client
|
81
|
+
begin
|
82
|
+
response = execute_request(options)
|
83
|
+
return {} if response.code == 204 and method == :delete
|
84
|
+
JSON.parse(response.body, :symbolize_names => true)
|
85
|
+
rescue RestClient::Exception => e
|
86
|
+
handle_errors e
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
# Get response successful
|
93
|
+
def self.execute_request(options)
|
94
|
+
RestClient::Request.execute(options)
|
95
|
+
end
|
96
|
+
|
97
|
+
# Get response with errors
|
98
|
+
def self.handle_errors exception
|
99
|
+
body = JSON.parse exception.http_body
|
100
|
+
raise Error.new(exception.to_s, body['errors'])
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.local_ip
|
104
|
+
orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true
|
105
|
+
UDPSocket.open do |s|
|
106
|
+
s.connect '64.233.187.99', 1
|
107
|
+
s.addr.last
|
108
|
+
end
|
109
|
+
ensure
|
110
|
+
Socket.do_not_reverse_lookup = orig
|
111
|
+
end
|
112
|
+
|
113
|
+
def self.encrypt_aes data
|
114
|
+
sandbox = Epayco.test ? "TRUE" : "FALSE"
|
115
|
+
@tags = JSON.parse(data)
|
116
|
+
@seted = {}
|
117
|
+
@tags.each {
|
118
|
+
|key, value|
|
119
|
+
@seted[lang_key(key)] = encrypt(value, Epayco.privateKey)
|
120
|
+
}
|
121
|
+
@seted["public_key"] = Epayco.apiKey
|
122
|
+
@seted["i"] = Base64.encode64("0000000000000000")
|
123
|
+
@seted["enpruebas"] = encrypt(sandbox, Epayco.privateKey)
|
124
|
+
@seted["lenguaje"] = "ruby"
|
125
|
+
@seted["ip"] = encrypt(local_ip, Epayco.privateKey)
|
126
|
+
@seted["p"] = ""
|
127
|
+
return @seted
|
128
|
+
end
|
129
|
+
|
130
|
+
def self.encrypt(str, key)
|
131
|
+
cipher = OpenSSL::Cipher.new('AES-128-CBC')
|
132
|
+
cipher.encrypt
|
133
|
+
iv = "0000000000000000"
|
134
|
+
cipher.iv = iv
|
135
|
+
cipher.key = key
|
136
|
+
str = iv + str
|
137
|
+
data = cipher.update(str) + cipher.final
|
138
|
+
Base64.urlsafe_encode64(data)
|
139
|
+
end
|
140
|
+
|
141
|
+
# Traslate secure petitions
|
142
|
+
def self.lang_key key
|
143
|
+
file = File.read(File.dirname(__FILE__) + '/keylang.json')
|
144
|
+
data_hash = JSON.parse(file)
|
145
|
+
data_hash[key]
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
module Epayco
|
2
|
+
module Operations
|
3
|
+
module ClassMethods
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
# Action create
|
8
|
+
def create params={}, extra=nil
|
9
|
+
if self.url == "token"
|
10
|
+
url = "/v1/tokens"
|
11
|
+
elsif self.url == "customers"
|
12
|
+
url = "/payment/v1/customer/create"
|
13
|
+
elsif self.url == "plan"
|
14
|
+
url = "/recurring/v1/plan/create"
|
15
|
+
elsif self.url == "subscriptions"
|
16
|
+
url = "/recurring/v1/subscription/create"
|
17
|
+
elsif self.url == "bank"
|
18
|
+
url = "/restpagos/pagos/debitos.json"
|
19
|
+
elsif self.url == "cash"
|
20
|
+
if extra == "efecty"
|
21
|
+
url = "/restpagos/pagos/efecties.json"
|
22
|
+
elsif extra == "baloto"
|
23
|
+
url = "/restpagos/pagos/balotos.json"
|
24
|
+
elsif extra == "gana"
|
25
|
+
url = "/restpagos/pagos/ganas.json"
|
26
|
+
else
|
27
|
+
raise Error.new('109', Epayco.lang)
|
28
|
+
end
|
29
|
+
elsif self.url == "charge"
|
30
|
+
url = "/payment/v1/charge/create"
|
31
|
+
end
|
32
|
+
Epayco.request :post, url, extra, params, self.switch
|
33
|
+
end
|
34
|
+
|
35
|
+
# Action retrieve from id
|
36
|
+
def get uid, params={}, extra=nil
|
37
|
+
switch = self.switch;
|
38
|
+
if self.url == "customers"
|
39
|
+
url = "/payment/v1/customer/" + Epayco.apiKey + "/" + uid + "/"
|
40
|
+
elsif self.url == "plan"
|
41
|
+
url = "/recurring/v1/plan/" + Epayco.apiKey + "/" + uid + "/"
|
42
|
+
elsif self.url == "subscriptions"
|
43
|
+
url = "/recurring/v1/subscription/" + uid + "/" + Epayco.apiKey + "/"
|
44
|
+
elsif self.url == "bank"
|
45
|
+
url = "/restpagos/pse/transactioninfomation.json?transactionID=" + uid + "&public_key=" + Epayco.apiKey
|
46
|
+
switch = true
|
47
|
+
elsif self.url == "cash" || self.url == "charge"
|
48
|
+
url = "/restpagos/transaction/response.json?ref_payco=" + uid + "&public_key=" + Epayco.apiKey
|
49
|
+
switch = true
|
50
|
+
end
|
51
|
+
Epayco.request :get, url, extra, params, switch
|
52
|
+
end
|
53
|
+
|
54
|
+
# Action update
|
55
|
+
def update uid, params={}, extra=nil
|
56
|
+
if self.url == "customers"
|
57
|
+
url = "/payment/v1/customer/edit/" + Epayco.apiKey + "/" + uid + "/"
|
58
|
+
end
|
59
|
+
Epayco.request :post, url, extra, params, self.switch
|
60
|
+
end
|
61
|
+
|
62
|
+
# Action retrieve all documents from user
|
63
|
+
def list params={}, extra=nil
|
64
|
+
if self.url == "customers"
|
65
|
+
url = "/payment/v1/customers/" + Epayco.apiKey + "/"
|
66
|
+
elsif self.url == "plan"
|
67
|
+
url = "/recurring/v1/plans/" + Epayco.apiKey + "/"
|
68
|
+
elsif self.url == "subscriptions"
|
69
|
+
url = "/recurring/v1/subscriptions/" + Epayco.apiKey
|
70
|
+
end
|
71
|
+
Epayco.request :get, url, extra, params, self.switch
|
72
|
+
end
|
73
|
+
|
74
|
+
# Remove data from api
|
75
|
+
def delete uid, params={}, extra=nil
|
76
|
+
if self.url == "plan"
|
77
|
+
url = "/recurring/v1/plan/remove/" + Epayco.apiKey + "/" + uid + "/"
|
78
|
+
end
|
79
|
+
Epayco.request :post, url, extra, params, self.switch
|
80
|
+
end
|
81
|
+
|
82
|
+
# Cance subscription
|
83
|
+
def cancel uid, params={}, extra=nil
|
84
|
+
params["id"] = uid
|
85
|
+
params["public_key"] = Epayco.apiKey
|
86
|
+
if self.url == "subscriptions"
|
87
|
+
url = "/recurring/v1/subscription/cancel"
|
88
|
+
end
|
89
|
+
Epayco.request :post, url, extra, params, self.switch
|
90
|
+
end
|
91
|
+
|
92
|
+
def charge params={}, extra=nil
|
93
|
+
if self.url == "subscriptions"
|
94
|
+
url = "/payment/v1/charge/subscription/create"
|
95
|
+
end
|
96
|
+
Epayco.request :post, url, extra, params, self.switch
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
# Export methods
|
102
|
+
def self.included(base)
|
103
|
+
base.extend(ClassMethods)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,48 @@
|
|
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
|
+
end
|
17
|
+
|
18
|
+
# Resources and CRUD
|
19
|
+
|
20
|
+
class Token < Resource
|
21
|
+
public_class_method :create
|
22
|
+
end
|
23
|
+
|
24
|
+
class Customers < Resource
|
25
|
+
public_class_method :create, :get, :list, :update
|
26
|
+
end
|
27
|
+
|
28
|
+
class Plan < Resource
|
29
|
+
public_class_method :create, :get, :list, :delete
|
30
|
+
end
|
31
|
+
|
32
|
+
class Subscriptions < Resource
|
33
|
+
public_class_method :create, :get, :list, :cancel, :charge
|
34
|
+
end
|
35
|
+
|
36
|
+
class Bank < Resource
|
37
|
+
public_class_method :create, :get
|
38
|
+
end
|
39
|
+
|
40
|
+
class Cash < Resource
|
41
|
+
public_class_method :create, :get
|
42
|
+
end
|
43
|
+
|
44
|
+
class Charge < Resource
|
45
|
+
public_class_method :create, :get
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
data/lib/keylang.json
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"bank": "banco",
|
3
|
+
"invoice": "factura",
|
4
|
+
"description": "descripcion",
|
5
|
+
"value": "valor",
|
6
|
+
"tax": "iva",
|
7
|
+
"tax_base": "baseiva",
|
8
|
+
"currency": "moneda",
|
9
|
+
"type_person": "tipo_persona",
|
10
|
+
"doc_type": "tipo_doc",
|
11
|
+
"doc_number": "documento",
|
12
|
+
"name": "nombres",
|
13
|
+
"last_name": "apellidos",
|
14
|
+
"email": "email",
|
15
|
+
"country": "pais",
|
16
|
+
"department": "depto",
|
17
|
+
"city": "ciudad",
|
18
|
+
"phone": "telefono",
|
19
|
+
"cell_phone": "celular",
|
20
|
+
"address": "direccion",
|
21
|
+
"ip": "ip",
|
22
|
+
"url_response": "url_respuesta",
|
23
|
+
"url_confirmation": "url_confirmacion",
|
24
|
+
"method_confirmation": "metodoconfirmacion",
|
25
|
+
"end_date": "fechaexpiracion"
|
26
|
+
}
|
@@ -0,0 +1,123 @@
|
|
1
|
+
|
2
|
+
module Epayco
|
3
|
+
@mock_rest_client = nil
|
4
|
+
|
5
|
+
def self.mock_rest_client=(mock_client)
|
6
|
+
@mock_rest_client = mock_client
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def credit_info
|
11
|
+
{
|
12
|
+
"card[number]" => "4575623182290326",
|
13
|
+
"card[exp_year]" => "2017",
|
14
|
+
"card[exp_month]" => "07",
|
15
|
+
"card[cvc]" => "123"
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def customer_info
|
20
|
+
{
|
21
|
+
token_card: "eXj5Wdqgj7xzvC7AR",
|
22
|
+
name: "Joe Doe",
|
23
|
+
email: "joe@payco.co",
|
24
|
+
phone: "3005234321",
|
25
|
+
default: true
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def update_customer_info
|
30
|
+
{
|
31
|
+
name: "Juan"
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def plan_info
|
36
|
+
{
|
37
|
+
id_plan: "coursereact",
|
38
|
+
name: "Course react js",
|
39
|
+
description: "Course react and redux",
|
40
|
+
amount: 30000,
|
41
|
+
currency: "cop",
|
42
|
+
interval: "month",
|
43
|
+
interval_count: 1,
|
44
|
+
trial_days: 30
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def subscription_info
|
49
|
+
{
|
50
|
+
id_plan: "coursereact",
|
51
|
+
customer: "A6ZGiJ6rgxK5RB2WT",
|
52
|
+
token_card: "eXj5Wdqgj7xzvC7AR",
|
53
|
+
doc_type: "CC",
|
54
|
+
doc_number: "5234567"
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
def pse_info
|
59
|
+
{
|
60
|
+
bank: "1007",
|
61
|
+
invoice: "1472050778",
|
62
|
+
description: "Pago pruebas",
|
63
|
+
value: "10000",
|
64
|
+
tax: "0",
|
65
|
+
tax_base: "0",
|
66
|
+
currency: "COP",
|
67
|
+
type_person: "0",
|
68
|
+
doc_type: "CC",
|
69
|
+
doc_number: "10358519",
|
70
|
+
name: "PRUEBAS",
|
71
|
+
last_name: "PAYCO",
|
72
|
+
email: "no-responder@payco.co",
|
73
|
+
country: "CO",
|
74
|
+
cell_phone: "3010000001",
|
75
|
+
ip: "186.116.10.133",
|
76
|
+
url_response: "https:/secure.payco.co/restpagos/testRest/endpagopse.php",
|
77
|
+
url_confirmation: "https:/secure.payco.co/restpagos/testRest/endpagopse.php",
|
78
|
+
method_confirmation: "GET",
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
def cash_info
|
83
|
+
{
|
84
|
+
invoice: "1472050778",
|
85
|
+
description: "Pago pruebas",
|
86
|
+
value: "20000",
|
87
|
+
tax: "0",
|
88
|
+
tax_base: "0",
|
89
|
+
currency: "COP",
|
90
|
+
type_person: "0",
|
91
|
+
doc_type: "CC",
|
92
|
+
doc_number: "10358519",
|
93
|
+
name: "PRUEBAS",
|
94
|
+
last_name: "PAYCO",
|
95
|
+
email: "test@mailinator.com",
|
96
|
+
cell_phone: "3010000001",
|
97
|
+
end_date: "2017-12-05",
|
98
|
+
ip: "186.116.10.133",
|
99
|
+
url_response: "https:/secure.payco.co/restpagos/testRest/endpagopse.php",
|
100
|
+
url_confirmation: "https:/secure.payco.co/restpagos/testRest/endpagopse.php",
|
101
|
+
method_confirmation: "GET",
|
102
|
+
}
|
103
|
+
end
|
104
|
+
|
105
|
+
def payment_info
|
106
|
+
{
|
107
|
+
token_card: "eXj5Wdqgj7xzvC7AR",
|
108
|
+
customer_id: "A6ZGiJ6rgxK5RB2WT",
|
109
|
+
doc_type: "CC",
|
110
|
+
doc_number: "1035851980",
|
111
|
+
name: "John",
|
112
|
+
last_name: "Doe",
|
113
|
+
email: "example@email.com",
|
114
|
+
ip: "192.198.2.114",
|
115
|
+
bill: "OR-1234",
|
116
|
+
description: "Test Payment",
|
117
|
+
value: "116000",
|
118
|
+
tax: "16000",
|
119
|
+
tax_base: "100000",
|
120
|
+
currency: "COP",
|
121
|
+
dues: "12"
|
122
|
+
}
|
123
|
+
end
|
data/tests/testing.rb
ADDED
@@ -0,0 +1,209 @@
|
|
1
|
+
require File.expand_path("../lib/epayco", File.dirname(__FILE__))
|
2
|
+
require File.expand_path("test_helper", File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require "cutest"
|
5
|
+
require "mocha/api"
|
6
|
+
include Mocha::API
|
7
|
+
|
8
|
+
prepare do
|
9
|
+
Epayco.apiKey = '491d6a0b6e992cf924edd8d3d088aff1'
|
10
|
+
Epayco.privateKey = '268c8e0162990cf2ce97fa7ade2eff5a'
|
11
|
+
Epayco.lang = 'ES'
|
12
|
+
Epayco.test = true
|
13
|
+
end
|
14
|
+
|
15
|
+
setup do
|
16
|
+
Epayco.mock_rest_client = mock
|
17
|
+
end
|
18
|
+
|
19
|
+
test "create token" do |mock|
|
20
|
+
begin
|
21
|
+
token = Epayco::Token.create credit_info
|
22
|
+
assert(token)
|
23
|
+
rescue Epayco::Error => e
|
24
|
+
puts e
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Customers
|
29
|
+
|
30
|
+
test "create customer" do |mock|
|
31
|
+
begin
|
32
|
+
customer = Epayco::Customers.create customer_info
|
33
|
+
assert(customer)
|
34
|
+
rescue Epayco::Error => e
|
35
|
+
puts e
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
test "retrieve customer" do |mock|
|
40
|
+
begin
|
41
|
+
customer = Epayco::Customers.get "123"
|
42
|
+
assert(customer)
|
43
|
+
rescue Epayco::Error => e
|
44
|
+
puts e
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
test "list customers" do |mock|
|
49
|
+
begin
|
50
|
+
customer = Epayco::Customers.list
|
51
|
+
assert(customer)
|
52
|
+
rescue Epayco::Error => e
|
53
|
+
puts e
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
test "update customer" do |mock|
|
58
|
+
begin
|
59
|
+
customer = Epayco::Customers.update "123", update_customer_info
|
60
|
+
assert(customer)
|
61
|
+
rescue Epayco::Error => e
|
62
|
+
puts e
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Plan
|
67
|
+
|
68
|
+
test "create plan" do |mock|
|
69
|
+
begin
|
70
|
+
plan = Epayco::Plan.create plan_info
|
71
|
+
assert(plan)
|
72
|
+
rescue Epayco::Error => e
|
73
|
+
puts e
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
test "retrieve plan" do |mock|
|
78
|
+
begin
|
79
|
+
plan = Epayco::Plan.get "coursereact"
|
80
|
+
assert(plan)
|
81
|
+
rescue Epayco::Error => e
|
82
|
+
puts e
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
test "list plan" do |mock|
|
87
|
+
begin
|
88
|
+
plan = Epayco::Plan.list
|
89
|
+
assert(plan)
|
90
|
+
rescue Epayco::Error => e
|
91
|
+
puts e
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
test "remove plan" do |mock|
|
96
|
+
begin
|
97
|
+
plan = Epayco::Plan.delete "coursereact"
|
98
|
+
assert(plan)
|
99
|
+
rescue Epayco::Error => e
|
100
|
+
puts e
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# Subscriptions
|
105
|
+
|
106
|
+
test "create subscription" do |mock|
|
107
|
+
begin
|
108
|
+
sub = Epayco::Subscriptions.create subscription_info
|
109
|
+
assert(sub)
|
110
|
+
rescue Epayco::Error => e
|
111
|
+
puts e
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
test "charge subscription" do |mock|
|
116
|
+
begin
|
117
|
+
sub = Epayco::Subscriptions.charge subscription_info
|
118
|
+
assert(sub)
|
119
|
+
rescue Epayco::Error => e
|
120
|
+
puts e
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
test "retrieve subscriptions" do |mock|
|
125
|
+
begin
|
126
|
+
sub = Epayco::Subscriptions.get "123"
|
127
|
+
assert(sub)
|
128
|
+
rescue Epayco::Error => e
|
129
|
+
puts e
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
test "list subscriptions" do |mock|
|
134
|
+
begin
|
135
|
+
sub = Epayco::Subscriptions.list
|
136
|
+
assert(sub)
|
137
|
+
rescue Epayco::Error => e
|
138
|
+
puts e
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
test "cancel subscriptions" do |mock|
|
143
|
+
begin
|
144
|
+
sub = Epayco::Subscriptions.cancel "123"
|
145
|
+
assert(sub)
|
146
|
+
rescue Epayco::Error => e
|
147
|
+
puts e
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
# PSE
|
152
|
+
|
153
|
+
test "create pse" do |mock|
|
154
|
+
begin
|
155
|
+
pse = Epayco::Bank.create pse_info
|
156
|
+
assert(pse)
|
157
|
+
rescue Epayco::Error => e
|
158
|
+
puts e
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
test "retrieve pse" do |mock|
|
163
|
+
begin
|
164
|
+
pse = Epayco::Bank.get "123"
|
165
|
+
assert(pse)
|
166
|
+
rescue Epayco::Error => e
|
167
|
+
puts e
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
# Cash
|
172
|
+
|
173
|
+
test "create cash" do |mock|
|
174
|
+
begin
|
175
|
+
cash = Epayco::Cash.create cash_info, "efecty"
|
176
|
+
assert(cash)
|
177
|
+
rescue Epayco::Error => e
|
178
|
+
puts e
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
test "retrieve cash" do |mock|
|
183
|
+
begin
|
184
|
+
cash = Epayco::Cash.get "123"
|
185
|
+
assert(cash)
|
186
|
+
rescue Epayco::Error => e
|
187
|
+
puts e
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
# Payment
|
192
|
+
|
193
|
+
test "create payment" do |mock|
|
194
|
+
begin
|
195
|
+
pay = Epayco::Charge.create payment_info
|
196
|
+
assert(pay)
|
197
|
+
rescue Epayco::Error => e
|
198
|
+
puts e
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
test "retrieve payment" do |mock|
|
203
|
+
begin
|
204
|
+
pay = Epayco::Charge.get "123"
|
205
|
+
assert(pay)
|
206
|
+
rescue Epayco::Error => e
|
207
|
+
puts e
|
208
|
+
end
|
209
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: epayco-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Epayco development team
|
8
|
+
- Jonathan Aguirre
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2017-04-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rest-client
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.7'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.7'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: json
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '2.0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '2.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: cutest
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ~>
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.2'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.2'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: mocha
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '1.1'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.1'
|
70
|
+
description: |-
|
71
|
+
API to interact with Epayco
|
72
|
+
https://epayco.co
|
73
|
+
email:
|
74
|
+
- jaguirre@payco.co
|
75
|
+
executables:
|
76
|
+
- epayco
|
77
|
+
extensions: []
|
78
|
+
extra_rdoc_files: []
|
79
|
+
files:
|
80
|
+
- bin/epayco
|
81
|
+
- lib/epayco.rb
|
82
|
+
- lib/keylang.json
|
83
|
+
- lib/epayco-ruby.rb
|
84
|
+
- lib/epayco/resources.rb
|
85
|
+
- lib/epayco/operations.rb
|
86
|
+
- tests/testing.rb
|
87
|
+
- tests/test_helper.rb
|
88
|
+
homepage: https://epayco.co/
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.0.14.1
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Ruby wrapper for Epayco API
|
112
|
+
test_files:
|
113
|
+
- tests/testing.rb
|
114
|
+
- tests/test_helper.rb
|