This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

TrustPay payment solution integration helpers.


$ pip install trustpaylib


Form approach

First merge payment request with environment variables, validate it and sign. trustpaylib.TrustPay.finalize_request returns prepared payment request. As form action use trustpay_client.environment.api_url.

>>> pay_request = trustpay_client.finalize_request(pay_request)
>>> trustpay_client.initial_data(pay_request)
{'AID': '9876543210', 'REF': u'1234567890', 'AMT': u'123.45', 'SIG': 'DF174E635DABBFF7897A82822521DD739AE8CC2F83D65F6448DD2FF991481EA3', 'CUR': u'EUR'}
>>> trustpay_client.environment.api_url

Redirects handling

There’s not much you can (or should) do with redirect.


Official TrustPay documentation: DO NOT PERFORM ANY ACTION ON THIS REDIRECT. Data is not signed and therefore cannot beconsidered as a verified payment result, such as the signed results sent to Notification URL or NotificationEmail.

But at least you can check the result code.

>>> # data received as get params to redirect
... redirect_data = {"REF": "1234567890", "RES": 3, "PID": "1212321"}
>>> redirect = trustpaylib.build_redirect(**redirect_data)
>>> trustpay_client.get_result_desc_from_redirect(redirect).short
>>> trustpay_client.get_result_desc_from_redirect(redirect).long
'Payment was successfully authorized. Another notification (with result code 0 - success) will be sent when TrustPay receives and processes payment from 3rd party.'

Notifications handling

For received notification, first check signature.

>>> notification_data = {
...     "AID": "1234567890",
...     "TYP": "CRDT",
...     "AMT": "123.45",
...     "CUR": "EUR",
...     "REF": "9876543210",
...     "RES": "0",
...     "TID": "11111",
...     "OID": "1122334455",
...     "TSS": "Y",
...     "SIG": (
...         "97C92D7A0C0AD99CE5DE55C3597D5ADA"
...         "0D423991E2D01938BC0F684244814A37"
...     ),
... }
>>> notification = trustpaylib.build_notification(**notification_data)
>>> assert trustpay_client.check_notification_signature(notification)

Then check result code.

>>> trustpay_client.get_result_desc_from_notification(notification).short
>>> trustpay_client.get_result_desc_from_notification(notification).long
'Payment was successfully processed.'
Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
trustpaylib-0.0.1.tar.gz (8.7 kB) Copy SHA256 Checksum SHA256 Source Jul 24, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting