open-pay / openpay-ruby Goto Github PK
View Code? Open in Web Editor NEWOpenpay Ruby bindings
License: Other
Openpay Ruby bindings
License: Other
Exceptions should be standarized across the application.
Please review and document if needed.
Al crear un pago SPEI devuelve error
@openpay=OpenpayApi.new(merchant_id,private_key)
@charges[email protected](:charges)
request_hash={
"method" => "bank_account",
"amount" => 200.00,
"description" => "Cargo con banco",
"order_id" => "oid-00051"
}
[email protected](request_hash.to_hash)
causa error.
Traceback (most recent call last):
1: from (irb):18
OpenpayTransactionException (OpenpayTransactionException)
el ejemplo tomado del tutorial https://www.openpay.mx/docs/bank-charge.html# con mis credenciales de ambiente de prueba.
Existe alguna forma de saber cual es el error?
There are some folders and files using the camelCase conventions this is causing some problem on the git repos with case insensitive configuration.
Charges should have the ability to be confirmed via the API.
An amount should be passed as can be read at:
http://www.openpay.mx/docs/api/?shell#confirmar-un-cargo
The Subscription
class is using a variable name which could lead to confusions.
plan_id
should be customer_id
def create(subscription,plan_id)
customers=@api_hook.create(:customers)
customers.create_subscription(subscription,plan_id)
end
Parece que cuando regresan una respuesta de servidor no disponible(Ayer ocurrieron varias entre las 5 y las 8pm), el json que devuelve el servidor no lo puede interpretar y devuelve esta excepción:
JSON::ParserError: A JSON text must at least contain two octets!
vendor/bundle/ruby/2.0.0/gems/json-1.8.2/lib/json/common.rb:155 in initialize
vendor/bundle/ruby/2.0.0/gems/json-1.8.2/lib/json/common.rb:155 in new
vendor/bundle/ruby/2.0.0/gems/json-1.8.2/lib/json/common.rb:155 in parse
vendor/bundle/ruby/2.0.0/gems/openpay-1.0.7/lib/openpay/errors/openpay_exception.rb:13 in initialize
vendor/bundle/ruby/2.0.0/gems/openpay-1.0.7/lib/openpay/errors/openpay_exception_factory.rb:43 in new
vendor/bundle/ruby/2.0.0/gems/openpay-1.0.7/lib/openpay/errors/openpay_exception_factory.rb:43 in create
vendor/bundle/ruby/2.0.0/gems/openpay-1.0.7/lib/openpay/open_pay_resource.rb:157 in rescue in post
vendor/bundle/ruby/2.0.0/gems/openpay-1.0.7/lib/openpay/open_pay_resource.rb:138 in post
vendor/bundle/ruby/2.0.0/gems/openpay-1.0.7/lib/openpay/charges.rb:88 in create
Subscriptions
do not implement the update method to be able to update its data documented at http://www.openpay.mx/docs/api/?shell#actualizar-una-suscripción:
There are some test cases failing.
97 examples, 6 failures, 5 pending
Failed examples:
rspec ./test/spec/customers_spec.rb:50 # Customers.create fails when passing invalid information
rspec ./test/spec/customers_spec.rb:113 # Customers.each list all customers
rspec ./test/spec/customers_spec.rb:165 # Customers.all list all the customers
rspec ./test/spec/customers_spec.rb:193 # Customers.delete_all deletes all customer records
rspec ./test/spec/exceptions_spec.rb:39 # Openpay Exceptions OpenpayTransactionException should fail when an invalid field-value is passed in *email
rspec ./test/spec/exceptions_spec.rb:113 # Openpay Exceptions OpenpayConnectionException raise an OpenpayConnectionException when provided credentials are invalid
rspec ./test/spec/payouts_spec.rb:25 # Payouts.create creates a merchant payout
rspec ./test/spec/payouts_spec.rb:94 # Payouts.get gets a merchant payout
rspec ./test/spec/payouts_spec.rb:132 # Payouts.all all merchant payouts
These should be fixed to have a 📗 build.
¡Qué tal!
Debido a que el caso de uso de la librería es en producción (24 hrs al día, a comparación de las veces que corre en modo "desarrollo"), creo que el default de la librería es que utilice la URL de producción en vez de el sandbox, que es el comportamiento actual:
#To enable production mode you should pass a third argument as true.
#openpay_prod=OpenpayApi.new(merchant_id,private_key,true)
Aunado a ésto, en la documentación/README deberían sugerir (y así mostrarlo en los ejemplos) el utilizar variables de entorno para configurar un cliente de OpenPay nuevo.
@charges.capture(...) debería regresar un Hash y no un String de JSON para ser consistente con el resto del API
@charges[email protected](:charges)
@charges.capture(transaction_id, customer_id) => String
Hola,
Actualmente estamos usando esta librería en Heroku. Este proveedor nos obliga a tener un request con un tiempo de respuesta máximo de 30 segundos.
He notado que en la clase de OpenPayResource se crea el request de RestClient con un tiempo default de 90 segundos. Nos ayudaría mucho poder customizar esta variable para manejar un timeout hacia openpay que sea menor al de nuestro proveedor.
Actualmente lo que estamos haciendo es setear manualmente la variable de instancia de timeout pero sería bueno tenerlo como configuración de la librería y/o como opción del método create de las clase OpenpayApi.
Saludos
La versión de rest-client en la cual depende openpay está desactualizada:
Bundler could not find compatible versions for gem "rest-client": │
In snapshot (Gemfile.lock): │
rest-client (= 1.7.2) │
│
In Gemfile: │
openpay (>= 0) ruby depends on │
rest-client (~> 1.6.7) ruby │
│
rest-client (>= 1.6.0) ruby
Estoy tratando de hacer un cargo a la tarjeta guardada de un cliente. El cliente ya lo tengo guardado y también una tarjeta.
Cuando consulto las tarjetas de mi cliente (en modo sandbox) obtengo mi tarjeta:
[{"id"=>"k4xfvbu1x3uoqqbrfuj0",
"type"=>"debit",
"brand"=>"visa",
"address"=>
{"line1"=>"Av 5 de Febrero",
"line2"=>"Roble 207",
"line3"=>"",
"state"=>"Queretaro",
"city"=>"Queretaro",
"postal_code"=>"76900",
"country_code"=>"MX"},
"card_number"=>"411111XXXXXX1111",
"holder_name"=>"Juan Perez Ramirez",
"expiration_year"=>"20",
"expiration_month"=>"12",
"allows_charges"=>true,
"allows_payouts"=>true,
"creation_date"=>"2018-10-14T21:19:43-05:00",
"bank_name"=>"Banamex",
"customer_id"=>"alzchegsfqp5odgg9dmj",
"bank_code"=>"002"}]
Como se puede ver tengo la tarjeta con id
: k4xfvbu1x3uoqqbrfuj0
guardada en OpenPay, al tratar de hacer un cargo a esa tarjeta como dice la documentación me pide un source_id
el cual de acuerdo a la documentación se describe como:
string (requerido, longitud = 45)
ID de la tarjeta guardada o el id del token creado de donde se retirarán los fondos.
Entiendo que puede usarse el ID de la tarjeta (o sea k4xfvbu1x3uoqqbrfuj0
) o bien el token
, estoy utilizando el ID debido a que el token se uso solo para guardar la tarjeta.
Al ejecutar el método @charges.create(request_hash)
como se indica en la documentación me regresa el error: Please specify a valid source_id
NOTA: También vi que el la documentación hace mención a lo siguiente:
Si desea crear un cliente y llevar un historial de sus cargos consulte como crear un cliente y realice el cargo a nivel cliente.
Pero nunca encontré como hacer el cargo a nivel cliente explícitamente en la documentación, me parece que "hacer el cargo a nivel cliente" es justamente lo que estoy haciendo.
Agradezco cualquier ayuda.
Hello,
openpay-ruby gem is trowing a warning message about json 1.8.6 and Ruby 2.7.0, it is polluting all log output in a rails app.
The warning was fixed in json gem 2.3.0, It would be nice you guys could update this dependency.
Here is the reference for the commit fixing the issue in json gem 2.3.0: flori/json@7e1e97d
Here is the warning message:
json-1.8.6/lib/json/common.rb:155: warning: Using the last argument as keyword parameters is deprecated
Thanks!
There are some classes without the each
or all
methods. Implement this where needed.
The list
method requires to be implemented as the documentation dictates for most resources.
It should accept a set of parameters to act as a filter.
http://www.openpay.mx/docs/api/?ruby#confirmar-un-cargo
@charges[email protected](:charges)
@charges.capture(transaction_id, customer_id)
capture, solo acepta dos argumentos y no se puede pasar el parámetro amount especificado en la documentación
Que tal, estoy tratando de iniciar con los servicios de OpenPay, pero estoy recibiendo constemente el siguiente error:
2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in `require': cannot load such file -- openpay (LoadError)
Utilizo Ruby version 2.3.1 Y Rails 4
Muchas gracias
Me está regresando esta excepción de parte de la librería en algunos casos aún cuando realizan un cobro exitoso.
Les dejo el backtrace:
TypeError: no implicit conversion of nil into String
/vendor/bundle/ruby/2.0.0/gems/json-1.8.1/lib/json/common.rb:155 in "initialize"
/vendor/bundle/ruby/2.0.0/gems/json-1.8.1/lib/json/common.rb:155 in "new"
/vendor/bundle/ruby/2.0.0/gems/json-1.8.1/lib/json/common.rb:155 in "parse"
/vendor/bundle/ruby/2.0.0/gems/openpay-1.0.4/lib/openpay/errors/openpay_exception.rb:13 in "initialize"
/vendor/bundle/ruby/2.0.0/gems/openpay-1.0.4/lib/openpay/errors/openpay_exception_factory.rb:37 in "new"
/vendor/bundle/ruby/2.0.0/gems/openpay-1.0.4/lib/openpay/errors/openpay_exception_factory.rb:37 in "create"
/vendor/bundle/ruby/2.0.0/gems/openpay-1.0.4/lib/openpay/open_pay_resource.rb:157 in "rescue in post"
/vendor/bundle/ruby/2.0.0/gems/openpay-1.0.4/lib/openpay/open_pay_resource.rb:138 in "post"
/vendor/bundle/ruby/2.0.0/gems/openpay-1.0.4/lib/openpay/charges.rb:88 in "create"
Revisándolo con los log del dashboard, veo que la respuesta es exitosa pero por alguna razón se lanza esa excepción.
Les dejo algunos ejemplos(Ha sucedido 39 veces en Reserbus):
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.