cobro_digital 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +180 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/cobro_digital.gemspec +40 -0
- data/lib/cobro_digital.rb +67 -0
- data/lib/cobro_digital/boleta.rb +35 -0
- data/lib/cobro_digital/meta.rb +48 -0
- data/lib/cobro_digital/micrositio.rb +17 -0
- data/lib/cobro_digital/operador.rb +22 -0
- data/lib/cobro_digital/pagador.rb +40 -0
- data/lib/cobro_digital/transaccion.rb +15 -0
- data/lib/cobro_digital/version.rb +3 -0
- metadata +207 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 g.edera
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
# CobroDigital
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/cobro_digital`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
Para poder hacer uso de la gema. Require previamente comunicarse con CobroDigital para dar de alta el comercio que se hara uso del servicio. Ellos haran entrega de:
|
6
|
+
|
7
|
+
* id del comercio (requerido para cualquier comunicación con el webservice, es la manera de identificarse con el webservice)
|
8
|
+
* sid del comercio (requerido para cualquier comunicación con el webservice, es la manera de identificarse con el webservice)
|
9
|
+
* Estructura de pagador (Esta estructura debe ser informada por cada comercio. esta estructura es del cliente a facturar)
|
10
|
+
* Plantilla, modelo de boleta para los clientes.
|
11
|
+
* Manual de implementación.
|
12
|
+
|
13
|
+
## Instalación
|
14
|
+
|
15
|
+
Añadir esta linea en el Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'cobro_digital'
|
19
|
+
```
|
20
|
+
|
21
|
+
Luego ejecuta:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
O instala la gema a mano:
|
26
|
+
|
27
|
+
$ gem install cobro_digital
|
28
|
+
|
29
|
+
## Uso
|
30
|
+
|
31
|
+
### Pagadores
|
32
|
+
|
33
|
+
Los Pagadores son los clientes a los que se les facturará, las acciones posibles son las de `crear un pagador`, `editar un pagador`, `verificar un pagador`, `obtener codigo electronico`.
|
34
|
+
|
35
|
+
#### Crear Pagador
|
36
|
+
|
37
|
+
Consiste en crear un pagador en el webservice de CobroDigital, para ello es necesario:
|
38
|
+
|
39
|
+
* Comunicarse con CobroDigital para definir la estructura de pagador que se quiera notificar.
|
40
|
+
* Es importante determinar un identificador unico por pagador.
|
41
|
+
* El webservice de CobroDigital solo verifica que la estructura sea correcta, pero no realiza ninguna tipo de validación, por lo tanto es importante llevar el control de si un pagador ya fue dado de alta o no. Ya que es posible dar de alta eternamente el mismo pagador.
|
42
|
+
|
43
|
+
Para la creación de un pagador simplemente es neceario comunicar:
|
44
|
+
* Estructura de un pagador.
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
comercio_id = 'HA765587' #Brindado por cobrodigital para realizar pruebas
|
48
|
+
comercio_sid = 'wsZ0ya68K791phuu76gQ5L662J6F2Y4j7zqE2Jxa3Mvd22TWNn4iip6L9yq' #Brindado por cobrodigital para realizar pruebas
|
49
|
+
estructura_pagador = 'Apellido y nombres' => "Santos Torrealba", 'Id' => 1234, 'Documento' => 33123456, 'Direccion del cliente' => "Falsa 1234", 'Telefono' => "222314", 'E-mail' => "santos.torrealba@who.com" # Estructura brindada por cobrodigital para realizar pruebas
|
50
|
+
pagador = CobroDigital.Pagador.crear(estructura_pagador)
|
51
|
+
response = pagador.call(comercio_id, comercio_sid)
|
52
|
+
```
|
53
|
+
|
54
|
+
#### Editar un Pagador
|
55
|
+
|
56
|
+
Consiste en editar algun dato dentro de la estructura de pagador de uno especifico.
|
57
|
+
|
58
|
+
Para la edición de un pagador simplemente es necesario comunicar:
|
59
|
+
* Nombre del identificador.
|
60
|
+
* Valor del identificador.
|
61
|
+
* Nueva configuración de la estructura pagador.
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
comercio_id = 'HA765587' #Brindado por cobrodigital para realizar pruebas
|
65
|
+
comercio_sid = 'wsZ0ya68K791phuu76gQ5L662J6F2Y4j7zqE2Jxa3Mvd22TWNn4iip6L9yq' #Brindado por cobrodigital para realizar pruebas
|
66
|
+
estructura_pagador = 'Apellido y nombres' => "Probando Probando", 'Id' => 1234, 'Documento' => 33123456, 'Direccion del cliente' => "Falsa 1234", 'Telefono' => "222314", 'E-mail' => "santos.torrealba@who.com" # Estructura brindada por cobrodigital para realizar pruebas
|
67
|
+
pagador = CobroDigital.Pagador.editar('id', 1234, estructura_pagador)
|
68
|
+
response = pagador.call(comercio_id, comercio_sid)
|
69
|
+
```
|
70
|
+
|
71
|
+
#### Verificar Pagador
|
72
|
+
|
73
|
+
Permite verificar la existencia o no de un pagador en el webservice.
|
74
|
+
|
75
|
+
Para la verificación de un pagador simplemente es necesario comunicar:
|
76
|
+
* Nombre del identificador.
|
77
|
+
* Valor del identificador.
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
comercio_id = 'HA765587' #Brindado por cobrodigital para realizar pruebas
|
81
|
+
comercio_sid = 'wsZ0ya68K791phuu76gQ5L662J6F2Y4j7zqE2Jxa3Mvd22TWNn4iip6L9yq' #Brindado por cobrodigital para realizar pruebas
|
82
|
+
pagador = CobroDigital.Pagador.verificar('id', 1234)
|
83
|
+
response = pagador.call(comercio_id, comercio_sid)
|
84
|
+
```
|
85
|
+
|
86
|
+
#### Codigo Electronico
|
87
|
+
|
88
|
+
Para obtener el codigo electronico con el cual le posibilitara a las personas realizar pagos por medio de pagosmiscuentas y linkpagos.
|
89
|
+
|
90
|
+
Para la verificación de un pagador simplemente es necesario comunicar:
|
91
|
+
* Nombre del identificador.
|
92
|
+
* Valor del identificador.
|
93
|
+
|
94
|
+
Retorno el numero de codigo electronico.
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
comercio_id = 'HA765587' #Brindado por cobrodigital para realizar pruebas
|
98
|
+
comercio_sid = 'wsZ0ya68K791phuu76gQ5L662J6F2Y4j7zqE2Jxa3Mvd22TWNn4iip6L9yq' #Brindado por cobrodigital para realizar pruebas
|
99
|
+
pagador = CobroDigital.Pagador.codigo_electronico('id', 1234)
|
100
|
+
response = pagador.call(comercio_id, comercio_sid)
|
101
|
+
```
|
102
|
+
|
103
|
+
### Boleta
|
104
|
+
|
105
|
+
Las boletas es la menera de informar la factura a CobroDigital para poder realizar el cobro por algunos de los medios proporcionados por ellos, las acciones posibles son las de `generar boleta`, `inhabilitar boleta`, `obtener codigo de barras`.
|
106
|
+
|
107
|
+
#### Generar Boleta
|
108
|
+
|
109
|
+
Es la menera de informar una factura a cobrar.
|
110
|
+
|
111
|
+
Para la generación de una boleta es necesario comunicar:
|
112
|
+
* nombre del identificador.
|
113
|
+
* el valor del identificador.
|
114
|
+
* Array de vencimientos como maximo 4. Siempre la primera fecha deberá ser la fecha de emisión. ejemplo: [Date.today, Date.today+10.days, Date.today+20.days]
|
115
|
+
* Array de importes como maximo 4. Siempre el primer monto es el valor de la factura, los siguientes son con los recargos. [100, 110, 120]
|
116
|
+
* concepto, una simple leyenda.
|
117
|
+
* plantilla, es la plantilla de la boleta (Cada comercio debe proporcionar esta plantilla)
|
118
|
+
|
119
|
+
Retorna un numero de boleta.
|
120
|
+
|
121
|
+
```ruby
|
122
|
+
comercio_id = 'HA765587' #Brindado por cobrodigital para realizar pruebas
|
123
|
+
comercio_sid = 'wsZ0ya68K791phuu76gQ5L662J6F2Y4j7zqE2Jxa3Mvd22TWNn4iip6L9yq' #Brindado por cobrodigital para realizar pruebas
|
124
|
+
nombre_identificador = 'id'
|
125
|
+
valor_identificador = 1234
|
126
|
+
vencimientos = [Date.today, Date.today+10.days, Date.today+20.days]
|
127
|
+
importes = [100,110,120]
|
128
|
+
concepto = "Factura A 10"
|
129
|
+
plantilla = 'init_273' #Proporcionado por CobroDigital para realizar pruebas.
|
130
|
+
boleta = CobroDigital.Boleta.generar(nombre_identificador, valor_identificador, vencimientos, importes, concepto, plantilla)
|
131
|
+
response = boleta.call(comercio_id, comercio_sid)
|
132
|
+
```
|
133
|
+
|
134
|
+
#### Inhabilitar Boleta
|
135
|
+
|
136
|
+
Dar de baja una boleta ya generada en el webservice.
|
137
|
+
|
138
|
+
Para la inhabilitación de una boleta es necesario comunicar:
|
139
|
+
* numero de boleta (obtenida en la generación)
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
comercio_id = 'HA765587' #Brindado por cobrodigital para realizar pruebas
|
143
|
+
comercio_sid = 'wsZ0ya68K791phuu76gQ5L662J6F2Y4j7zqE2Jxa3Mvd22TWNn4iip6L9yq' #Brindado por cobrodigital para realizar pruebas
|
144
|
+
numero_boleta = 123
|
145
|
+
boleta = CobroDigital.Boleta.inhabilitar(numero_boleta)
|
146
|
+
response = boleta.call(comercio_id, comercio_sid)
|
147
|
+
```
|
148
|
+
|
149
|
+
#### Obtener codigo de barras
|
150
|
+
|
151
|
+
Obtener el string de los codigos de barras. Seran tantos como vencimientos e importes informados. En caso de querer renderizarlo a imagen debera de hacer uso del codigo 128b, para ello se puede hacer uso de la gema barby.
|
152
|
+
|
153
|
+
Para la obtención de los codigos de barra es necesario comunicar:
|
154
|
+
* numero de boleta (obtenida en la generación)
|
155
|
+
|
156
|
+
|
157
|
+
```ruby
|
158
|
+
comercio_id = 'HA765587' #Brindado por cobrodigital para realizar pruebas
|
159
|
+
comercio_sid = 'wsZ0ya68K791phuu76gQ5L662J6F2Y4j7zqE2Jxa3Mvd22TWNn4iip6L9yq' #Brindado por cobrodigital para realizar pruebas
|
160
|
+
numero_boleta = 123
|
161
|
+
boleta = CobroDigital.Boleta.obtener_codigo_de_barras(numero_boleta)
|
162
|
+
response = boleta.call(comercio_id, comercio_sid)
|
163
|
+
```
|
164
|
+
|
165
|
+
|
166
|
+
## Development
|
167
|
+
|
168
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
169
|
+
|
170
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
171
|
+
|
172
|
+
## Contributing
|
173
|
+
|
174
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cobro_digital. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
175
|
+
|
176
|
+
|
177
|
+
## License
|
178
|
+
|
179
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
180
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "cobro_digital"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cobro_digital/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cobro_digital"
|
8
|
+
spec.version = CobroDigital::VERSION
|
9
|
+
spec.authors = ["g.edera"]
|
10
|
+
spec.email = ["gab.edera@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Adaptador CobroDigital"
|
13
|
+
spec.description = "Adaptador para el Web Service de CobroDigital"
|
14
|
+
spec.homepage = "https://github.com/gedera/cobro_digital"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
# end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec"
|
33
|
+
|
34
|
+
spec.add_runtime_dependency(%q<savon>, ["= 2.4.0"])
|
35
|
+
|
36
|
+
spec.add_dependency(%q<nokogiri>, ["~> 1.6"])
|
37
|
+
spec.add_dependency(%q<wasabi>, ["~> 3.2.3"])
|
38
|
+
spec.add_dependency(%q<akami>, ["~> 1.1"])
|
39
|
+
spec.add_dependency(%q<nori>, ["~> 2.3.0"])
|
40
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require "cobro_digital/version"
|
3
|
+
require "cobro_digital/operador"
|
4
|
+
require "cobro_digital/pagador"
|
5
|
+
require "cobro_digital/boleta"
|
6
|
+
require "cobro_digital/transaccion"
|
7
|
+
require "cobro_digital/micrositio"
|
8
|
+
require "cobro_digital/meta"
|
9
|
+
|
10
|
+
module CobroDigital
|
11
|
+
|
12
|
+
SOAP = 'soap'
|
13
|
+
HTTPS = 'https'
|
14
|
+
|
15
|
+
CLIENTS = [SOAP, HTTPS]
|
16
|
+
URI = 'https://www.cobrodigital.com:14365/ws3/'
|
17
|
+
WSDL = 'https://www.cobrodigital.com:14365/ws3/?wsdl'
|
18
|
+
|
19
|
+
module Https
|
20
|
+
POST = 'Post'
|
21
|
+
GET = 'Get'
|
22
|
+
end
|
23
|
+
|
24
|
+
class Client
|
25
|
+
|
26
|
+
attr_accessor :id_comercio, :sid, :client_to_use, :http_method, :pagadores, :boletas, :transacciones, :micrositios, :requests
|
27
|
+
|
28
|
+
def initialize(attrs={})
|
29
|
+
@id_comercio = attrs[:id_comercio]
|
30
|
+
@sid = attrs[:sid]
|
31
|
+
@client_to_use = attrs[:con_client].present? ? attrs[:con_client] : CobroDigital::SOAP
|
32
|
+
# @with_handshake = attrs[:handshake].present? ? attrs[:handshake] : true
|
33
|
+
@pagadores = []
|
34
|
+
@boletas = []
|
35
|
+
@transacciones = []
|
36
|
+
@micrositios = []
|
37
|
+
end
|
38
|
+
|
39
|
+
def soap_client(params)
|
40
|
+
client = Savon.client( wsdl: CobroDigital::WSDL, log_level: :debug, pretty_print_xml: true)
|
41
|
+
client.call(:webservice_cobrodigital, message: { 'parametros_de_entrada' => params.to_json })
|
42
|
+
end
|
43
|
+
|
44
|
+
def https_client(params)
|
45
|
+
case http_method
|
46
|
+
when CobroDigital::Https::POST
|
47
|
+
uri = URI(CobroDigital::URI)
|
48
|
+
req = "Net::HTTP::#{http_method}".constantize.new(uri)
|
49
|
+
req.set_form_data(params)
|
50
|
+
when CobroDigital::Https::GET
|
51
|
+
uri = URI([CobroDigital::URI, URI.encode_www_form(data)].join('?'))
|
52
|
+
req = "Net::HTTP::#{http_method}".constantize.new(uri)
|
53
|
+
end
|
54
|
+
|
55
|
+
Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == CobroDigital::HTTPS) { |http| http.request(req) }
|
56
|
+
end
|
57
|
+
|
58
|
+
def call(request)
|
59
|
+
send("#{client_to_use}_client", comercio.merge(request))
|
60
|
+
end
|
61
|
+
|
62
|
+
def comercio
|
63
|
+
{ 'idComercio' => @id_comercio, 'sid' => @sid, 'handshake' => Digest::MD5.hexdigest(Time.now.to_f.to_s) }
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module CobroDigital
|
2
|
+
class Boleta < CobroDigital::Operador
|
3
|
+
|
4
|
+
GENERAR_BOLETA_WS = 'generar_boleta'
|
5
|
+
INHABILITAR_BOLETA_WS = 'inhabilitar_boleta'
|
6
|
+
OBTENER_CODIGO_BARRA_WS = 'obtener_codigo_de_barras'
|
7
|
+
|
8
|
+
# { 'identificador' => 'Su_identificador', 'buscar' => '1AF8', 'fechas_vencimiento' => ['20170901','20170905'], 'importes' => [100.98, 102], 'concepto' => 'Boleta de Prueba', 'plantilla' => 'init' }
|
9
|
+
def self.generar(identificador, buscar, fechas_vencimiento, importes, concepto, plantilla=nil)
|
10
|
+
CobroDigital::Boleta.new( :http_method => CobroDigital::Https::POST,
|
11
|
+
:webservice => GENERAR_BOLETA_WS,
|
12
|
+
:render => { :identificador => identificador,
|
13
|
+
:buscar => buscar,
|
14
|
+
:fechas_vencimiento => fechas_vencimiento.map{ |date| date.strftime('%Y%m%d') },
|
15
|
+
:importes => importes,
|
16
|
+
:concepto => concepto,
|
17
|
+
:plantilla => plantilla })
|
18
|
+
end
|
19
|
+
|
20
|
+
# { 'nro_boleta'=>'1' }
|
21
|
+
def self.inhabilitar(nro_boleta)
|
22
|
+
CobroDigital::Boleta.new( :http_method => CobroDigital::Https::POST,
|
23
|
+
:webservice => INHABILITAR_BOLETA_WS,
|
24
|
+
:render => { :nro_boleta => nro_boleta } )
|
25
|
+
end
|
26
|
+
|
27
|
+
# { 'nro_boleta'=>'1' }
|
28
|
+
def self.obtener_codigo_de_barras(nro_boleta)
|
29
|
+
CobroDigital::Boleta.new( :http_method => CobroDigital::Https::GET,
|
30
|
+
:webservice => OBTENER_CODIGO_BARRA_WS,
|
31
|
+
:render => { :nro_boleta => nro_boleta } )
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module CobroDigital
|
2
|
+
class Meta < CobroDigital::Operador
|
3
|
+
|
4
|
+
META_WS = 'meta'
|
5
|
+
|
6
|
+
# md5(microtime(true)*rand())
|
7
|
+
# { 'handshake'=>Digest::MD5.hexdigest(Time.now.to_f.to_s),
|
8
|
+
# 'metodo_webservice'=>'meta',
|
9
|
+
# '0' => { 'metodo_webservice' => 'crear_pagador',
|
10
|
+
# 'handshake' => Digest::MD5.hexdigest(Time.now.to_f.to_s),
|
11
|
+
# 'pagador' => { 'Nombre' => 'Juan',
|
12
|
+
# 'Su_identificador' => '1AF8',
|
13
|
+
# 'Unidad' => '201' } },
|
14
|
+
# '1' => { 'metodo_webservice' => 'crear_pagador',
|
15
|
+
# 'handshake' => Digest::MD5.hexdigest(Time.now.to_f.to_s),
|
16
|
+
# 'pagador'=> { 'Nombre'=>'Pedro',
|
17
|
+
# 'Su_identificador'=>'1AG9',
|
18
|
+
# 'Unidad'=>'202' } },
|
19
|
+
# '2' => { 'metodo_webservice' => 'generar_boleta',
|
20
|
+
# 'handshake' => Digest::MD5.hexdigest(Time.now.to_f.to_s),
|
21
|
+
# 'identificador' => 'Su_identificador',
|
22
|
+
# 'buscar' => '1AF8',
|
23
|
+
# 'importes'=> [10.50],
|
24
|
+
# 'fechas_vencimiento' => ['20160930'],
|
25
|
+
# 'plantilla' => 'init',
|
26
|
+
# 'concepto' => 'Test I'},
|
27
|
+
# '3' => { 'metodo_webservice' => 'generar_boleta',
|
28
|
+
# 'handshake' => Digest::MD5.hexdigest(Time.now.to_f.to_s),
|
29
|
+
# 'identificador' => 'Su_identificador',
|
30
|
+
# 'buscar' => '1AG9',
|
31
|
+
# 'importes'=> [11.99],
|
32
|
+
# 'fechas_vencimiento' => ['20160929'],
|
33
|
+
# 'plantilla' => 'init',
|
34
|
+
# 'concepto' => 'Test II'},
|
35
|
+
# '4' => { 'metodo_webservice' => 'inhabilitar_boleta',
|
36
|
+
# 'handshake' => Digest::MD5.hexdigest(Time.now.to_f.to_s),
|
37
|
+
# 'nro_boleta' => '4' },
|
38
|
+
# '5' => { 'metodo_webservice' => 'inhabilitar_boleta',
|
39
|
+
# 'handshake' => Digest::MD5.hexdigest(Time.now.to_f.to_s),
|
40
|
+
# 'nro_boleta' => '65' } }
|
41
|
+
def self.meta(params)
|
42
|
+
CobroDigital::Meta.new( :http_method => CobroDigital::Https::POST,
|
43
|
+
:webservice => META_WS,
|
44
|
+
:render => params )
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module CobroDigital
|
2
|
+
class Micrositio < CobroDigital::Operador
|
3
|
+
|
4
|
+
CONSULTAR_ACTIVIDAD_MICROSITIO_WS = 'consultar_actividad_micrositio'
|
5
|
+
|
6
|
+
# { 'identificador'=>'Su_identificador', 'buscar'=>'1AF8', 'desde'=>'20160720', 'hasta'=>'20160801' }
|
7
|
+
def self.consultar_actividad(identificador, buscar, desde, hasta)
|
8
|
+
CobroDigital::Micrositio.new( :http_method => CobroDigital::Https::GET,
|
9
|
+
:webservice => CONSULTAR_ACTIVIDAD_MICROSITIO_WS,
|
10
|
+
:render => { :identificador => identificador,
|
11
|
+
:buscar => buscar,
|
12
|
+
:desde => desde.strftime('%Y%m%d'),
|
13
|
+
:hasta => hasta.strftime('%Y%m%d') } )
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module CobroDigital
|
2
|
+
class Operador
|
3
|
+
|
4
|
+
attr_accessor :http_method, :webservice, :render, :response
|
5
|
+
|
6
|
+
def initialize(attrs={})
|
7
|
+
@http_method = attrs[:http_method]
|
8
|
+
@webservice = attrs[:webservice]
|
9
|
+
@render = attrs[:render]
|
10
|
+
end
|
11
|
+
|
12
|
+
def request
|
13
|
+
{ :metodo_webservice => @webservice }.merge(render)
|
14
|
+
end
|
15
|
+
|
16
|
+
def call(id_comercio, sid, opt={})
|
17
|
+
client = CobroDigital::Client.new(opt.merge(:id_comercio => id_comercio, :sid => sid, :http_method => http_method))
|
18
|
+
@response = client.call(request)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module CobroDigital
|
2
|
+
class Pagador < CobroDigital::Operador
|
3
|
+
|
4
|
+
CREAR_PAGADOR_WS = 'crear_pagador'
|
5
|
+
EDITAR_PAGADOR_WS = 'editar_pagador'
|
6
|
+
VERIFICAR_PAGADOR_WS = 'verificar_existencia_pagador'
|
7
|
+
OBTENER_CODIGO_ELECTRONICO_WS = 'obtener_codigo_electronico'
|
8
|
+
|
9
|
+
# { 'Nombre' => 'Juan', 'Su_identificador' => '1AF8', 'Unidad' => '201' }
|
10
|
+
def self.crear(pagador)
|
11
|
+
CobroDigital::Pagador.new( :http_method => CobroDigital::Https::POST,
|
12
|
+
:webservice => CREAR_PAGADOR_WS,
|
13
|
+
:render => { :pagador => pagador } )
|
14
|
+
end
|
15
|
+
|
16
|
+
# { 'identificador' => 'Su_identificador', 'buscar' => '1AF8', 'pagador' => { 'Nombre'=>'Juan Pablo' } }
|
17
|
+
def self.editar(identificador, buscar, pagador)
|
18
|
+
CobroDigital::Pagador.new( :http_method => CobroDigital::Https::POST,
|
19
|
+
:webservice => EDITAR_PAGADOR_WS,
|
20
|
+
:render => { :identificador => identificador,
|
21
|
+
:buscar => buscar,
|
22
|
+
:pagador => pagador })
|
23
|
+
end
|
24
|
+
|
25
|
+
# { 'identificador' => 'Su_identificador', 'buscar'=>'1AF8' }
|
26
|
+
def self.verificar(identificador, buscar)
|
27
|
+
CobroDigital::Pagador.new( :http_method => CobroDigital::Https::GET,
|
28
|
+
:webservice => VERIFICAR_PAGADOR_WS,
|
29
|
+
:render => { :identificador => identificador,
|
30
|
+
:buscar => buscar })
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.codigo_electronico(identificador, buscar)
|
34
|
+
CobroDigital::Pagador.new( :http_method => CobroDigital::Https::GET,
|
35
|
+
:webservice => OBTENER_CODIGO_ELECTRONICO_WS,
|
36
|
+
:render => { :identificador => identificador,
|
37
|
+
:buscar => buscar })
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module CobroDigital
|
2
|
+
class Transaccion < CobroDigital::Operador
|
3
|
+
|
4
|
+
CONSULTAR_TRANSACCIONES_WS = 'consultar_transacciones'
|
5
|
+
|
6
|
+
# { 'desde'=>'20160932', 'hasta'=>'20161001' }
|
7
|
+
def self.consultar(desde, hasta)
|
8
|
+
CobroDigital::Transaccion.new( :http_method => CobroDigital::Https::GET,
|
9
|
+
:webservice => CONSULTAR_TRANSACCIONES_WS,
|
10
|
+
:render => { :desde => desde.strftime('%Y%m%d'),
|
11
|
+
:hasta => hasta.strftime('%Y%m%d') } )
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,207 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cobro_digital
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- g.edera
|
14
|
+
autorequire:
|
15
|
+
bindir: exe
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2016-10-28 00:00:00 -03:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: bundler
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 27
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 10
|
33
|
+
version: "1.10"
|
34
|
+
type: :development
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 35
|
45
|
+
segments:
|
46
|
+
- 10
|
47
|
+
- 0
|
48
|
+
version: "10.0"
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: rspec
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
type: :development
|
64
|
+
version_requirements: *id003
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: savon
|
67
|
+
prerelease: false
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - "="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 31
|
74
|
+
segments:
|
75
|
+
- 2
|
76
|
+
- 4
|
77
|
+
- 0
|
78
|
+
version: 2.4.0
|
79
|
+
type: :runtime
|
80
|
+
version_requirements: *id004
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: nokogiri
|
83
|
+
prerelease: false
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 3
|
90
|
+
segments:
|
91
|
+
- 1
|
92
|
+
- 6
|
93
|
+
version: "1.6"
|
94
|
+
type: :runtime
|
95
|
+
version_requirements: *id005
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: wasabi
|
98
|
+
prerelease: false
|
99
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ~>
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
hash: 9
|
105
|
+
segments:
|
106
|
+
- 3
|
107
|
+
- 2
|
108
|
+
- 3
|
109
|
+
version: 3.2.3
|
110
|
+
type: :runtime
|
111
|
+
version_requirements: *id006
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: akami
|
114
|
+
prerelease: false
|
115
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ~>
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
hash: 13
|
121
|
+
segments:
|
122
|
+
- 1
|
123
|
+
- 1
|
124
|
+
version: "1.1"
|
125
|
+
type: :runtime
|
126
|
+
version_requirements: *id007
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: nori
|
129
|
+
prerelease: false
|
130
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
132
|
+
requirements:
|
133
|
+
- - ~>
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
hash: 3
|
136
|
+
segments:
|
137
|
+
- 2
|
138
|
+
- 3
|
139
|
+
- 0
|
140
|
+
version: 2.3.0
|
141
|
+
type: :runtime
|
142
|
+
version_requirements: *id008
|
143
|
+
description: Adaptador para el Web Service de CobroDigital
|
144
|
+
email:
|
145
|
+
- gab.edera@gmail.com
|
146
|
+
executables: []
|
147
|
+
|
148
|
+
extensions: []
|
149
|
+
|
150
|
+
extra_rdoc_files: []
|
151
|
+
|
152
|
+
files:
|
153
|
+
- .gitignore
|
154
|
+
- .rspec
|
155
|
+
- .travis.yml
|
156
|
+
- CODE_OF_CONDUCT.md
|
157
|
+
- Gemfile
|
158
|
+
- LICENSE.txt
|
159
|
+
- README.md
|
160
|
+
- Rakefile
|
161
|
+
- bin/console
|
162
|
+
- bin/setup
|
163
|
+
- cobro_digital.gemspec
|
164
|
+
- lib/cobro_digital.rb
|
165
|
+
- lib/cobro_digital/boleta.rb
|
166
|
+
- lib/cobro_digital/meta.rb
|
167
|
+
- lib/cobro_digital/micrositio.rb
|
168
|
+
- lib/cobro_digital/operador.rb
|
169
|
+
- lib/cobro_digital/pagador.rb
|
170
|
+
- lib/cobro_digital/transaccion.rb
|
171
|
+
- lib/cobro_digital/version.rb
|
172
|
+
has_rdoc: true
|
173
|
+
homepage: https://github.com/gedera/cobro_digital
|
174
|
+
licenses:
|
175
|
+
- MIT
|
176
|
+
post_install_message:
|
177
|
+
rdoc_options: []
|
178
|
+
|
179
|
+
require_paths:
|
180
|
+
- lib
|
181
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
182
|
+
none: false
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
hash: 3
|
187
|
+
segments:
|
188
|
+
- 0
|
189
|
+
version: "0"
|
190
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
191
|
+
none: false
|
192
|
+
requirements:
|
193
|
+
- - ">="
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
hash: 3
|
196
|
+
segments:
|
197
|
+
- 0
|
198
|
+
version: "0"
|
199
|
+
requirements: []
|
200
|
+
|
201
|
+
rubyforge_project:
|
202
|
+
rubygems_version: 1.6.2
|
203
|
+
signing_key:
|
204
|
+
specification_version: 3
|
205
|
+
summary: Adaptador CobroDigital
|
206
|
+
test_files: []
|
207
|
+
|