ddiazpinto / python-redsys Goto Github PK
View Code? Open in Web Editor NEWA simple, clean and less dependant client for handle payments through RedSys.
License: MIT License
A simple, clean and less dependant client for handle payments through RedSys.
License: MIT License
See #2 please.
Just wondering if this 3 things are implemented,
Thanks!
I share the problem that I had some days ago, finally I solved! :) I tried to contact with redsys support and told me that they don't offer support of 3rd code... so then here you have the solution of my problem:
The function prepare_request from Client, returns values as binary b'string', if you send it directly to template when using Flask and render_template, the variable of hidden fields converts b'string' to HTML b'string'
to avoid that before passing variables to render_template you have to convert them to unicode (or string)
_redsys = {
"Ds_MerchantParameters":_redsys2.get("Ds_MerchantParameters").decode('utf-8'),
"Ds_SignatureVersion":_redsys2.get("Ds_SignatureVersion"),
"Ds_Signature":_redsys2.get("Ds_Signature").decode('utf-8')
}
I will send to render_template the variable called _redsys
Here you have the example code using python3.5 + flask + render_template + boostrap
Add to file views.py
from decimal import Decimal as D, ROUND_HALF_UP
from redsys import currencies, languages, transactions
from redsys.client import RedirectClient
@app2.route('/order')
def order():
_error = "0"
form = ""
_data = {'url' : 'https://sis-t.redsys.es:25443/sis/realizarPago' }
secret_key = u'XXX'
sandbox = True
client = RedirectClient(secret_key, sandbox)
request = client.create_request()
request.merchant_code = u'XXX'
request.terminal = u'1'
request.transaction_type = transactions.STANDARD_PAYMENT
request.currency = currencies.EUR
request.order = u'000000001'
# The amount must be defined as decimal and pre-formated with only two decimals
request.amount = D('10.56489').quantize(D('.01'), ROUND_HALF_UP)
request.merchant_data = 'merchant data for tracking purpose like order_id, session_key, ...'
request.merchant_name = "your company name"
request.titular = "customer name"
request.product_description = "product description"
request.merchant_url = "https://sis-t.redsys.es:25443/sis/realizarPago"
_redsys2 = client.prepare_request(request)
_redsys = {
"Ds_MerchantParameters":_redsys2.get("Ds_MerchantParameters").decode('utf-8'),
"Ds_SignatureVersion":_redsys2.get("Ds_SignatureVersion"),
"Ds_Signature":_redsys2.get("Ds_Signature").decode('utf-8')
}
return render_template('pages/order.html', form=form, error=_error, data=_data, redsys=_redsys)
Then in template file pages/order.html:
<form action="{{ data['url'] }}" method="post" role="form">
<input type="hidden" name="Ds_SignatureVersion" value="{{ redsys['Ds_SignatureVersion'] }}"/>
<input type="hidden" name="Ds_MerchantParameters" value="{{ redsys['Ds_MerchantParameters'] }}"/>
<input type="hidden" name="Ds_Signature" value="{{ redsys['Ds_Signature'] }}"/>
<button type="submit" class="btn btn-default">Submit Button</button>
<button type="reset" class="btn btn-default">Reset Button</button>
</form>
Take care to install using pip3 install the missing modules
I wish it could be helpful to someone some day :)
Thanks you much!
Is this package available in PyPi?
pip search redsys
returns several packages, but none seems to correspond to this one.
If it is not released, can it be done? It might require some renaming, though, since redsys
name is taken by another project.
Hi!
Maybe it's a dumb question... but reading the code I'm not able to see where the ENDPOINT is used.
Indeed, I can only found the endpoint = None, and self.endpoint = ....
Is this library yet finished or is still missing the conection with redsys?
I ask it, due to If y try to pass the parameters to Response() nothing is been stored.
Thank you
Hello, I recently deploy my e-commerce with redsys and BBVA and I changed my integration to production mode some days ago. I have this error code when I try to pay with a international debit card.
esp: "Comercio con “titular seguro” y titular sin clave de compra segura"
eng: "Commerce with "secure holder" and holder without secure purchase key"
I ask to the support and they said that it is because the redirect is asking for a code or something.
esp: "la operación se está denegando debido a que se solicita la doble verificación al titular de la tarjeta, pero este no dispone de esta opción, por lo que debe remitir el cliente a su entidad, para que le habilite dicha opción"
eng: "the operation is being denied because double verification is requested from the cardholder, but the cardholder does not have this option, so the client must send it to their entity, so that they enable said option".
So, the question is. How can I do to solve this problem?
Hi,
I'm using it in my project and notice that response returns error trying to retrieve Ds_Card_Number, so I wasn't able to check payment status.
I've solved it just modifying response.py
1: Adding the var:
CARD_NUMBER = "Ds_Card_Number"
2: including it into MERCHANT_PARAMETERS_MAP:
MERCHANT_PARAMETERS_MAP = {
"response": RESPONSE,
"date": DATE,
"hour": HOUR,
...
"card_number": CARD_NUMBER
}
Regards.
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.