tbk - Transbank’s Webpay protocol
Attention: Beta not ready for production
Python implementation of Transbank’s Webpay protocol.
Installation
pip install tbk
Usage
Set environment variable for Commerce and initialize.
os.environ['TBK_COMMERCE_ID'] = "597026007976" os.environ['TBK_COMMERCE_KEY'] = "-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAn3HzPC1ZBzCO3edUCf/XJiwj3bzJpjjTi/zBO9O+DDzZCaMp..."" from tbk.webpay.commerce import Commerce commerce = Commerce.create_commerce() # for development purposes you can use # commerce = Commerce(testing=True)
If you want to set the official webpay log (for certification issues):
from tbk.webpay.logging import configure_logger from tbk.webpay.logging.official import WebpayOfficialHandler configure_logger(WebpayOfficialHandler(LOG_BASE_PATH))
Create a new payment and redirect user.
from tbk.webpay.payment import Payment
payment = Payment(
request_ip='123.123.123.123',
commerce=commerce,
success_url='http://localhost:8080/webpay/success/',
confirmation_url='http://127.0.0.1:8080/webpay/confirmation/',
failure_url='http://localhost:8080/webpay/failure/',
session_id='SOME_SESSION_VALUE',
amount=123456,
order_id=1,
)
payment.redirect_url
Then to confirm payment, use an endpoint with:
from tbk.webpay.confirmation import Confirmation
def confirmation(request):
conf = Confirmation(
commerce=commerce,
request_ip=request.ip_address,
data=request.POST
)
# validate_confirmation validate if order_id and amount are valid.
if conf.is_success() and validate_confirmation(conf) and not conf.is_timeout():
return HttpResponse(commerce.acknowledge)
return HttpResponse(commerce.reject)
About webpay communication protocol: http://sagmor.com/rants/technical/webpay-communication-protocol/
Metadata
Release files for tbk 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| tbk-0.2.0.tar.gz | 16.3 kB | Without provenance | Details |
Release files / tbk-0.2.0.tar.gz
| Download URL | tbk-0.2.0.tar.gz |
|---|---|
| Size | 16.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
70fabaa6f5c31cc7caf94f5ee4f21b1d5ab374dfe80af88f9398b641c9672691
|
|
BLAKE2b-256 checksum How to use checksums |
7cc0ac32b0129d595af6b393fb40d8ec97614fcac9db83cb29c7dd525d9fd43f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for tbk 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.