open-pay / openpay-python Goto Github PK
View Code? Open in Web Editor NEWOpenpay Python Bindings
Openpay Python Bindings
hola buen dia , viendo la documentación no veo la manera en la cual se pueda agregar la tarjeta a un customer mediante el token de la tarjeta esto para el registro de tarjeta mediante dispositivos moviles. podrian proporcionarme un ejemplo de como hacerlo, o actualizar su documentación para estos casos en php lo realice mediante un add pero este ejemplo similar no lo veo aqui . Ya que estoy usando python como servicio web para mis aplicaciones.
Hola @marcosAlvarado,
Gracias por actualizar la documentación. Era muy necesario desde hace tiempo.
Tengo una duda con respecto al ejemplo de charges. Incluiste un ejemplo de cómo generar un charge a nivel merchant (comercio). Si no me equivoco, la única diferencia para crear el charge a nivel de cliente sería que debemos pasar el String customer_id a la hora de crear el charge, correcto?
La sintaxis sería la siguiente?
charge = openpay.Charge.create_as_customer( source_id="k2trvya1nxpcytgww4rt", customer_id="cz4nkhrlcu9k7qd4lwqx", method="card", amount=100, description="Fourth charge", )
Saludos,
Hola. Estaba revisando la librería pero no veo alguna forma de usar 3d Secure. O si la hay cómo sería?, porque tampoco la encuentro en la documentación
I can't delete bank account, this is my in python code:
account = customer.back_accounts.retrieve("someID")
account.delete()
it gives me this error:
Request method 'DELETE' not supported, error code: 1000
I can delete customers and cards without any problems. Deleting bank accounts is supported by the API:
http://www.openpay.mx/docs/api/?shell#eliminar-una-cuenta-bancaria
but is not working with this python client
thanks in advance
Hola!
Estoy haciendo la integración de openpay con una aplicación creada en react en el client side y utilizo django para el back.
Estoy siguiendo la ruta marcada de OpenPay.js; de crear una tarjeta sin que pase por el servidor usando tokens, sin embargo, en ningún lugar de la documentación viene como asignar una tarjeta creada en el cliente side a través del método:
# Uso window porque es React.
window.OpenPay.token.create(
{
card_number: card,
holder_name: state.ccName,
expiration_year: expYear,
expiration_month: expMonth,
cvv2: cvc,
......etc
El token generado lo estoy pasando al back pero a la hora querer ejecutar algo similar a:
customer.cards.create(token)
Me da un error.
Vi que en esta sección había un método con node para crear una tarjeta siguiendo estos pasos:
var cardRequest = {
'token_id' : 'tokgslwpdcrkhlgxqi9a',
'device_session_id' : '8VIoXj0hN5dswYHQ9X1mVCiB72M7FY9o'
}
openpay.customers.cards.create('a9pvykxz4g5rg0fplze0', cardRequest, function(error, card) {
// ...
});
Sin embargo, no me fue posible crear una tarjeta en un cliente resultadon en el siguiente error:
>>> card_request = {
... 'device_session_id': device,
... 'token_id':token,
... }
>>> openpay.customers.cards.create(customer_id, card_request)
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: module 'openpay' has no attribute 'customers'
Ni de esta manera:
>>> customer.cards.create(card_request)
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: create() takes 1 positional argument but 2 were given
Tambien intenté de esta forma
>>> token = "xxxxxx"
>>> device = "zxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
>>> from django.conf import settings
>>> openpay = settings.OPENPAY
>>> customer = openpay.Customer.retrieve('ayp7zw9xrp1gx05jjvje')
>>> card = {
... 'source_id':token,
... 'device_session_id': device
... }
>>> new_card = customer.cards.create(card=card)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/xxxxxxxxxxxxxxxxx", line 237, in create
return self.request('post', self['url'], params)
File "/hxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", line 142, in request
response, api_key = requestor.request(method, url, params)
File "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, line 75, in request
resp = self.interpret_response(rbody, rcode)
File "xxxxxxxxxxxxxxxxxxxxxxxxxxx", line 181, in interpret_response
self.handle_api_error(rbody, rcode, resp)
File "xxxxxxxxxxxxxxxxxxxxxx", line 84, in handle_api_error
raise error.InvalidRequestError(
openpay.error.InvalidRequestError: holder_name is required, card_number is required, expiration_month is required, error code: 1001
La única manera en la que he podido hacerlo es con un request derecho:
headers = {'Content-type': 'application/json'}
data = {
'token_id': token_id,
'device_session_id': device_session_id
}
url = (
f'https://sandbox-api.openpay.mx/v1/\
{merchant_id}/customers/{customer.id}/cards'
)
new_card = requests.post(
url, headers=headers, json=data, auth=(api_key, ''))
use_2to3
fue removido de setuptools hace unas versiones y nuevos buildpacks de python están fallando. La referencia a esta librería debería de ser removida.
Hola, quiero consultar sobre cómo realizar pagos en tiendas. Según el flujo entiendo que primero el cliente debe seleccionar una tienda (cuál es el método o en todo caso endpoint para obtener las tiendas?) y luego crear un "charge" de tipo "store" . Ahora cómo se asocia la tienda seleccionada al store? Gracias.
La versión que se encuentra en pip es 0.6, actualmente el último release tag es de 3.0, el archivo openpay/version.py indica que es la versión 1.0
. Considero importante que actualizar en el index de pip sobre todo porque la documentación en el README
hace referencia a pip para su instalación.
Hola, estoy creando un API interno para manejar los cobros usando OpenPay vía Python, pero no queda claro como generar el device_session_id desde un backend.
gracias.
Buenos días, leyendo su documentación https://www.openpay.mx/docs/card-charge.html, note que no se tiene el ejemplo realizado para python.
Mi duda es si es posible realizar dicho proceso con esta librería y de no ser así, ¿qué alternativas proporcionarían para ello?
Hi.
As official docs refer, you can create a charge on
When you send the "customer" parameter to the create method of the charge resource, the URL must be the first one, not the second one.
Error here:
if params and 'customer' in list(params.keys()):
return "/v1/{0}/customers/{1}/{2}s".format(
merchant_id, params.get('customer'), cls_name)
else:
return "/v1/%s/%ss" % (merchant_id, cls_name)
Fix:
if params and 'customer' in list(params.keys()):
return "/v1/%s/%ss" % (merchant_id, cls_name)
else:
return "/v1/{0}/customers/{1}/{2}s".format(
merchant_id, params.get('customer'), cls_name)
Al usar la instrucción
subscription = customer.subscriptions.all()[0]
subscription.delete()
arroja un error KeyError 0
Lo cambié a
subscriptions = customer.subscriptions.all()
subscription = subscriptions['data'][0]
subscription.delete()
Y funcionó
Hi there!! I am sorry for bothering you, but I have been using your library for a while and I have detected multiple problems and details. I'll just write you a list of the problems I have detected in hopes that you (or maybe another contributor) can read it and use it.
device_session_id
to execute some actions. Apparently the concept of device_session_id
was introduced thanks to the javascript version of this project and this python library was never updated to use the SJCL library for an antifraud feature.create
function does not longer work like in the examples. It now requires another parameter: device_session_id
.capture
function does not longer work. The API replies with a 1005 code error. I do not know what the real problem is, but if I had to guess, it would be that while in Sandbox mode the API does not search for the transactions as expected. (No documentation text supports this idea)refund
function has an error due to a del
out of place (instead of being in line 439 it should be right after the 436 inside the if
clause). A work around is to always send the boolean parameter merchantrefund
function is having the exact same problem as the capture
function (described two bullets up)Los clientes tienen la opción de realizar los pagos en las tiendas de conveniencia, se sigue esta estructura
https://www.openpay.mx/api/#cargo-en-tienda
There is a problem in the refund method, as the parameter "merchant" is optional, the line 439 in resources.py is trying to delete the key even if there is no a parameter with that name.
So, I had to always sent the "merchant" as a parameter to avoid the error, making the refund always as merchant=True.
Comparing with the function "capture", that line must be inside the previous if
Hi,
As far as I can see openpay library specifically requires version 0.15.2
of "future" package that was released back in 2015.
https://pypi.org/project/future/#history
There were several newer version released for this library since that time. Now I'm trying to solve dependency conflict in my project with openpay and several other packages requesting different "future" versions.
Could you please update openpay not to require specific version of "future" but accept 0.15.2
, 0.16.0
, 0.17.0
and 0.17.1
?
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.