ThePay
Library for accesing ThePay payment gateway from python
Example
Configure ThePay account
from thepay.config import Config
config = Config()
config.setCredentials(12345, 12345, 'abcdefg12345', 'abcdefg12345') # Credentials from ThePay account settings
List available payment methods
from thepay.dataApi import DataApi
data_api = DataApi(config)
payments = data_api.getPaymentMethods()
print methods as radio buttons with images
<div>
{% for payment in payments %}
<div class="payment-method">
<input type="radio" name="payment_method" value="{{ payment.id }}" id="payment_{{ payment.id }}">
<label for="payment_{{ payment.id }}" title="{{ payment.name }}">
<img src='http://www.thepay.cz/gate/images/logos/public/209x127/{{ payment.id }}.png' alt="{{ payment.name }}">
</label>
</div>
{% endfor %}
</div>
Redirect user to ThePay - create payment
from thepay.payment import Payment
payment = Payment(config)
payment.setValue(321)
payment.setMethodId(13) # ID of payment method from above
payment.setCustomerEmail('test@test.te')
payment.setDescription('Order 123 payment')
payment.setReturnUrl('https://example.com/payment') # where to redirect user after payment
payment.setMerchantData(123) # Any custom data - not visible to user
payment.getCreateUrl() # Redirect user to this URL to begin payment
Check incomming payment
This code should be run on returnUrl from above code
from thepay.payment import ReturnPayment
return_payment = ReturnPayment(config)
return_payment.parseData(self.request.GET) # Pass all GET received data in form of dict()
if not return_payment.checkSignature():
return False # Invalid payment signature
return_payment.getMerchantData() # -> 123, previously saved custom data
return_payment.getValue() # -> 321
return_payment.getStatus() # Order status, see next paragraph
- Order statuses
2 = STATUS_OK
3 = STATUS_CANCELED
4 = STATUS_ERROR
6 = STATUS_UNDERPAID
7 = STATUS_WAITING
9 = STATUS_CARD_DEPOSIT
Get info about payment
payment_id = return_payment.getPaymentId()
payment = data_api.getPayment(payment_id) # returns object with all payment data
License
LGPL
Metadata
Release files for nijel-thepay 0.5
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 | Actions |
|---|---|---|---|---|
| nijel-thepay-0.5.tar.gz | 9.6 kB | Without provenance | Details for nijel-thepay-0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nijel_thepay-0.5-py3-none-any.whl | Python 3 | none | any | Details for nijel_thepay-0.5-py3-none-any.whl |
Total release size: 21.1 kB
Release files / nijel-thepay-0.5.tar.gz
| Download URL | nijel-thepay-0.5.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
77dff6e0b6bf5faf80fd7065caf50c1d5cc3d0e37f8640c4a65153808f6b3aca
|
|
BLAKE2b-256 checksum How to use checksums |
74efe7843b85bdc5bb8bef65ba2ca734834b537b4a9e8da4d821d7d6885d43f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7
|
Release files / nijel_thepay-0.5-py3-none-any.whl
| Download URL | nijel_thepay-0.5-py3-none-any.whl |
|---|---|
| Size | 11.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b9e7d4013f52e7cbc4d3c82729bec9ded7ff534e7d45cf7fd650ae69953c7543
|
|
BLAKE2b-256 checksum How to use checksums |
7f5a78b049d730e310f0db4eceae87a119188f513cc12341dfaf5bf15fd79aee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7
|
Security for nijel-thepay 0.5
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.