Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ customer_info = {
last_name: "Doe", #This parameter is optional
email: "joe@payco.co",
phone: "3005234321",
city: "Bogota",
address: "Cr 4 # 55 36",
default: true
}

Expand Down Expand Up @@ -309,6 +311,7 @@ pse_info = {
last_name: "PAYCO",
email: "no-responder@payco.co",
country: "CO",
city: "Bogota",
cell_phone: "3010000001",
ip: "190.000.000.000", #client's IP, it is required
url_response: "https://tudominio.com/respuesta.php",
Expand Down Expand Up @@ -391,6 +394,8 @@ cash_info = {
email: "test@mailinator.com",
cell_phone: "3010000001",
end_date: "2017-12-05",
country: "CO",
city: "bogota",
ip: "190.000.000.000", #This is the client's IP, it is required
url_response: "https://tudominio.com/respuesta.php",
url_confirmation: "https://tudominio.com/confirmacion.php",
Expand Down Expand Up @@ -481,6 +486,8 @@ payment_info = {
tax: "16000",
tax_base: "100000",
ip: "190.000.000.000", #This is the client's IP, it is required
country: "CO",
city: "bogota",
url_response: "https://tudominio.com/respuesta.php",
url_confirmation: "https://tudominio.com/confirmacion.php",
method_confirmation: "GET",
Expand Down Expand Up @@ -560,5 +567,111 @@ rescue Epayco::Error => e
end
```

### Daviplata

### Create
```ruby
payment_info = {
doc_type: "CC",
document: "1053814580414720",
name: "Testing",
last_name: "PAYCO",
email: "exmaple@epayco.co",
ind_country: "57",
phone: "314853222200033",
country: "CO",
city: "bogota",
address: "Calle de prueba",
ip: "189.176.0.1",
currency: "COP",
description: "ejemplo de transaccion con daviplata",
value: "100",
tax: "0",
ico: "0"
tax_base: "0",
method_confirmation: "GET",
url_response: "https://tudominio.com/respuesta.php",
url_confirmation: "https://tudominio.com/confirmacion.php",
extra1: "",
extra2: "",
extra3: "",
extra4: "",
extra5: "",
extra6: "",
extra7: "",
extra8: "",
extra9: "",
extra10: ""
}

begin
daviplata = Epayco::Daviplata.create payment_info
rescue Epayco::Error => e
puts e
end
```

### confirm transaccion

```ruby
confirm = {
ref_payco: "45508846", # It is obtained from the create response
id_session_token: "45081749", # It is obtained from the create response
otp: "2580"
}
begin
daviplata = Epayco::Daviplata.confirm confirm
rescue Epayco::Error => e
puts e
end
```

### Safetypay

### Create

```ruby
payment_info = {
cash: "1",
end_date: "2021-08-05",
doc_type: "CC",
document: "123456789",
name: "Jhon",
last_name: "doe",
email: "jhon.doe@yopmail.com",
ind_country: "57",
phone: "3003003434",
country: "CO",
invoice: "fac-01", # opcional
city: "N/A",
address: "N/A",
ip: "192.168.100.100",
currency: "COP",
description: "Thu Jun 17 2021 11:37:01 GMT-0400 (hora de Venezuela)",
value: 100000,
tax: 0,
ico: 0,
tax_base: 0,
url_confirmation: "https://tudominio.com/respuesta.php",
url_response: "https://tudominio.com/respuesta.php",
method_confirmation: "POST",
extra1: "",
extra2: "",
extra3: "",
extra4: "",
extra5: "",
extra6: "",
extra7: "",
extra8: "",
extra9: "",
extra10: ""
}
begin
safetypay = Epayco::Safetypay.create payment_info
rescue Epayco::Error => e
puts e
end

```


3 changes: 2 additions & 1 deletion epayco-sdk-ruby.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Gem::Specification.new do |s|
s.name = "epayco-sdk-ruby"
s.version = "1.0.3"
s.version = "1.1.1"
s.summary = "Ruby wrapper for Epayco API"
s.description = "API to interact with Epayco\nhttps://epayco.co"
s.authors = ["Epayco development team", "Ricardo Saldarriaga", "Gerson Vasquez"]
Expand All @@ -21,6 +21,7 @@ Gem::Specification.new do |s|
bin/epayco
lib/epayco.rb
lib/keylang.json
lib/keylang_apify.json
lib/epayco-sdk-ruby.rb
lib/epayco/resources.rb
lib/epayco/operations.rb
Expand Down
31 changes: 15 additions & 16 deletions lib/epayco.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,21 @@ def self.request(method, url, extra=nil, params={}, headers={}, switch, cashdata

# Switch secure or api or apify
if apify
@tags = JSON.parse(payload)
seted = {}
file = File.read(File.dirname(__FILE__) + '/keylang_apify.json')
data_hash = JSON.parse(file)
@tags.each {
|key, value|
if data_hash[key]
seted[data_hash[key]] = value
else
seted[key] = value
end
}
payload = seted.to_json
if method == :post
@tags = JSON.parse(payload)
seted = {}
file = File.read(File.dirname(__FILE__) + '/keylang_apify.json')
data_hash = JSON.parse(file)
@tags.each {
|key, value|
if data_hash[key]
seted[data_hash[key]] = value
else
seted[key] = value
end
}
payload = seted.to_json
end
url = @api_base_apify + url
elsif switch
if method == :post || method == :patch
Expand Down Expand Up @@ -116,10 +118,7 @@ def self.request(method, url, extra=nil, params={}, headers={}, switch, cashdata

# Open library rest client
begin
#puts options
#abort("Message goes here 1")
response = execute_request(options)
#puts response.body
return {} if response.code == 204 and method == :delete
JSON.parse(response.body, :symbolize_names => true)
rescue RestClient::Exception => e
Expand Down
40 changes: 23 additions & 17 deletions lib/epayco/operations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,25 @@ def create params={}, extra=nil
url = "/payment/process/safetypay"
elsif self.url == "cash"
cashdata = true
if extra == "efecty"
url = "/restpagos/v2/efectivo/efecty"
elsif extra == "baloto"
url = "/restpagos/v2/efectivo/baloto"
elsif extra == "gana"
url = "/restpagos/v2/efectivo/gana"
elsif extra == "redservi"
url = "/restpagos/v2/efectivo/redservi"
elsif extra == "puntored"
url = "/restpagos/v2/efectivo/puntored"
else
if extra.downcase == 'baloto'
raise Error.new('109', Epayco.lang)
end
methods_payment = Epayco.request :get, "/payment/cash/entities", extra, {}, false, false, dt, true

if(methods_payment[:success].nil? || !methods_payment[:success])
raise Error.new('104', Epayco.lang)
end

if methods_payment[:data].nil? || !methods_payment[:data].kind_of?(Array)
raise Error.new('106', Epayco.lang)
end
entities = methods_payment[:data].map do |item|
item[:name].gsub(/\s+/, "").downcase
end
if !entities.include? extra.downcase
raise Error.new('109', Epayco.lang)
end
url = "/restpagos/v2/efectivo/" + extra
elsif self.url == "charge"
url = "/payment/v1/charge/create"
elsif self.url == "daviplata"
Expand All @@ -52,11 +58,11 @@ def get uid, params={}, extra=nil
cashdata=false
dt=false
if self.url == "customers"
url = "/payment/v1/customer/" + Epayco.apiKey + "/" + uid + "/"
url = "/payment/v1/customer/" + Epayco.apiKey + "/" + uid
elsif self.url == "plan"
url = "/recurring/v1/plan/" + Epayco.apiKey + "/" + uid + "/"
url = "/recurring/v1/plan/" + Epayco.apiKey + "/" + uid
elsif self.url == "subscriptions"
url = "/recurring/v1/subscription/" + uid + "/" + Epayco.apiKey + "/"
url = "/recurring/v1/subscription/" + uid + "/" + Epayco.apiKey
elsif self.url == "bank"
url = "/restpagos/pse/transactioninfomation.json?transactionID=" + uid + "&public_key=" + Epayco.apiKey
switch = true
Expand All @@ -72,7 +78,7 @@ def update uid, params={}, extra=nil
cashdata=false
dt=false
if self.url == "customers"
url = "/payment/v1/customer/edit/" + Epayco.apiKey + "/" + uid + "/"
url = "/payment/v1/customer/edit/" + Epayco.apiKey + "/" + uid
end
Epayco.request :post, url, extra, params, self.switch, cashdata, dt, apify = false
end
Expand Down Expand Up @@ -110,9 +116,9 @@ def list params={}, extra=nil
cashdata=false
dt=false
if self.url == "customers"
url = "/payment/v1/customers/" + Epayco.apiKey + "/"
url = "/payment/v1/customers/" + Epayco.apiKey
elsif self.url == "plan"
url = "/recurring/v1/plans/" + Epayco.apiKey + "/"
url = "/recurring/v1/plans/" + Epayco.apiKey
elsif self.url == "subscriptions"
url = "/recurring/v1/subscriptions/" + Epayco.apiKey
elsif self.url == "bank"
Expand Down