# Paynow Zimbabwe Python SDK
Python SDK for Paynow Zimbabwe's API
# Prerequisites
This library has a set of prerequisites that must be met for it to work
1. requests
# Installation
Install the library using pip
```sh
$ pip install paynow
```
and import the Paynow class into your project
```python
from paynow import Paynow
# Do stuff
```
---
# Usage example
Create an instance of the Paynow class optionally setting the result and return url(s)
```python
paynow = Paynow(
'INTEGRATION_ID',
'INTEGRATION_KEY',
'https://example.com/paynow/return', # Return url
'https://example.com/paynow/result/update' # Result url
)
```
Create a new payment passing in the reference for that payment (e.g invoice id, or anything that you can use to identify the transaction and the user's email address
```python
payment = paynow.create_payment('Order #100', 'test@example.com')
```
You can then start adding items to the payment
```python
# Passing in the name of the item and the price of the item
payment.add('Bananas', 2.50)
payment.add('Apples', 3.40)
```
When you're finally ready to send your payment to Paynow, you can use the `send` method in the `paynow` object.
```python
# Save the response from paynow in a variable
response = paynow.send(payment)
```
The response from Paynow will b have some useful information like whether the request was successful or not. If it was, for example, it contains the url to redirect the user so they can make the payment. You can view the full list of data contained in the response in our wiki
If request was successful, you should consider saving the poll url sent from Paynow in the database
```python
if response.success:
# Get the link to redirect the user to, then use it as you see fit
link = response.redirect_url
# Get the poll url (used to check the status of a transaction). You might want to save this in your DB
pollUrl = response.poll_url
```
---
> Mobile Transactions
If you want to send an express (mobile) checkout request instead, the only thing that differs is the last step. You make a call to the `send_mobile` in the `paynow` object
instead of the `send` method.
The `send_mobile` method unlike the `send` method takes in two additional arguments i.e The phone number to send the payment request to and the mobile money method to use for the request. **Note that currently only ecocash is supported**
```python
# Save the response from paynow in a variable
response = paynow.send_mobile(payment, '0777777777', 'ecocash')
```
The response object is almost identical to the one you get if you send a normal request. With a few differences, firstly, you don't get a url to redirect to. Instead you instructions (which ideally should be shown to the user instructing them how to make payment on their mobile phone)
```python
if(response.success) :
# Get the poll url (used to check the status of a transaction). You might want to save this in your DB
poll_url = response.poll_url
instructions = response.instructions
```
# Checking transaction status
The SDK exposes a handy method that you can use to check the status of a transaction. Once you have instantiated the Paynow class.
```python
# Check the status of the transaction with the specified poll url
# Now you see why you need to save that url ;-)
status = paynow.check_transaction_status(poll_url)
if status.paid :
# Yay! Transaction was paid for. Update transaction?
else :
# Handle that
```
# Full Usage Example
```python
from paynow import Paynow
paynow = Paynow(
'INTEGRATION_ID',
'INTEGRATION_KEY',
'https://example.com/paynow/return', # Return url
'https://example.com/paynow/result/update' # Result url
)
payment = paynow.create_payment('Order', 'test@example.com')
payment.add('Payment for stuff', 1)
response = paynow.send_mobile(payment, '0777832735', 'ecocash')
if(response.success):
poll_url = response.poll_url
print("Poll Url: ", poll_url)
status = paynow.check_transaction_status(poll_url)
time.sleep(30)
print("Payment Status: ", status.status)
```
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/paynow-developer-hub/Paynow-Python-SDK",
"name": "paynow",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "paynow-api paynow-zimbabwe paynow-zimbabwe-api paynow-zimbabwe-sdk",
"author": "WebDev Projects",
"author_email": "pkg-dev@webdevworld.com",
"download_url": "https://files.pythonhosted.org/packages/a4/92/f4d160f755a53049932827377d0f7aa974e54d1fa6ef4d9cd6cee3177ffc/paynow-1.0.8.tar.gz",
"platform": null,
"description": "# Paynow Zimbabwe Python SDK\n\nPython SDK for Paynow Zimbabwe's API\n\n# Prerequisites\n\nThis library has a set of prerequisites that must be met for it to work\n\n1. requests\n\n# Installation\n\nInstall the library using pip\n\n```sh\n$ pip install paynow\n```\n\nand import the Paynow class into your project\n\n```python\n\tfrom paynow import Paynow\n\n\t# Do stuff\n```\n\n---\n\n# Usage example\n\nCreate an instance of the Paynow class optionally setting the result and return url(s)\n\n```python\npaynow = Paynow(\n\t'INTEGRATION_ID',\n\t'INTEGRATION_KEY',\n\t'https://example.com/paynow/return', # Return url\n 'https://example.com/paynow/result/update' # Result url \n\n\t)\n```\n\nCreate a new payment passing in the reference for that payment (e.g invoice id, or anything that you can use to identify the transaction and the user's email address\n\n```python\npayment = paynow.create_payment('Order #100', 'test@example.com')\n```\n\nYou can then start adding items to the payment\n\n```python\n# Passing in the name of the item and the price of the item\npayment.add('Bananas', 2.50)\npayment.add('Apples', 3.40)\n```\n\nWhen you're finally ready to send your payment to Paynow, you can use the `send` method in the `paynow` object.\n\n```python\n# Save the response from paynow in a variable\nresponse = paynow.send(payment)\n```\n\nThe response from Paynow will b have some useful information like whether the request was successful or not. If it was, for example, it contains the url to redirect the user so they can make the payment. You can view the full list of data contained in the response in our wiki\n\nIf request was successful, you should consider saving the poll url sent from Paynow in the database\n\n```python\nif response.success:\n\n # Get the link to redirect the user to, then use it as you see fit\n\tlink = response.redirect_url\n\n\t# Get the poll url (used to check the status of a transaction). You might want to save this in your DB\n\tpollUrl = response.poll_url\n```\n\n---\n\n> Mobile Transactions\n\nIf you want to send an express (mobile) checkout request instead, the only thing that differs is the last step. You make a call to the `send_mobile` in the `paynow` object\ninstead of the `send` method.\n\nThe `send_mobile` method unlike the `send` method takes in two additional arguments i.e The phone number to send the payment request to and the mobile money method to use for the request. **Note that currently only ecocash is supported**\n\n```python\n# Save the response from paynow in a variable\nresponse = paynow.send_mobile(payment, '0777777777', 'ecocash')\n```\n\nThe response object is almost identical to the one you get if you send a normal request. With a few differences, firstly, you don't get a url to redirect to. Instead you instructions (which ideally should be shown to the user instructing them how to make payment on their mobile phone)\n\n```python\nif(response.success) :\n\t# Get the poll url (used to check the status of a transaction). You might want to save this in your DB\n poll_url = response.poll_url\n\n instructions = response.instructions\n```\n\n# Checking transaction status\n\nThe SDK exposes a handy method that you can use to check the status of a transaction. Once you have instantiated the Paynow class.\n\n```python\n# Check the status of the transaction with the specified poll url\n# Now you see why you need to save that url ;-)\nstatus = paynow.check_transaction_status(poll_url)\n\nif status.paid :\n\t# Yay! Transaction was paid for. Update transaction?\nelse :\n\t# Handle that\n```\n\n# Full Usage Example\n\n```python\nfrom paynow import Paynow\n\n\npaynow = Paynow(\n\t'INTEGRATION_ID',\n\t'INTEGRATION_KEY',\n\t'https://example.com/paynow/return', # Return url\n 'https://example.com/paynow/result/update' # Result url \n\t)\n\npayment = paynow.create_payment('Order', 'test@example.com')\n\npayment.add('Payment for stuff', 1)\n\nresponse = paynow.send_mobile(payment, '0777832735', 'ecocash')\n\n\nif(response.success):\n poll_url = response.poll_url\n\n print(\"Poll Url: \", poll_url)\n\n status = paynow.check_transaction_status(poll_url)\n\n time.sleep(30)\n\n print(\"Payment Status: \", status.status)\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Paynow Python SDK",
"version": "1.0.8",
"project_urls": {
"Bug Reports": "https://gitlab.com/paynow-developer-hub/Paynow-Python-SDK/issues",
"Homepage": "https://gitlab.com/paynow-developer-hub/Paynow-Python-SDK",
"Source": "https://gitlab.com/paynow-developer-hub/Paynow-Python-SDK"
},
"split_keywords": [
"paynow-api",
"paynow-zimbabwe",
"paynow-zimbabwe-api",
"paynow-zimbabwe-sdk"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "eaff566d37ea83857b8e3c6268d0a3b6966993b5e18ea2a9bdb76ab69830f569",
"md5": "ad7c9a4b60429165d1b3375c48aaf2c4",
"sha256": "1e925deabbdc32fe16c93c031f16e2f804bb19934f60830e3043805fa8634c83"
},
"downloads": -1,
"filename": "paynow-1.0.8-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "ad7c9a4b60429165d1b3375c48aaf2c4",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 7694,
"upload_time": "2024-10-15T13:07:07",
"upload_time_iso_8601": "2024-10-15T13:07:07.815342Z",
"url": "https://files.pythonhosted.org/packages/ea/ff/566d37ea83857b8e3c6268d0a3b6966993b5e18ea2a9bdb76ab69830f569/paynow-1.0.8-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a492f4d160f755a53049932827377d0f7aa974e54d1fa6ef4d9cd6cee3177ffc",
"md5": "cc71142c98e8b16c5b6ef15ecb2357d7",
"sha256": "d3a7d4e01e53d59075e915fe831d3cba255da112a284edafbbd674de099ebd6d"
},
"downloads": -1,
"filename": "paynow-1.0.8.tar.gz",
"has_sig": false,
"md5_digest": "cc71142c98e8b16c5b6ef15ecb2357d7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8030,
"upload_time": "2024-10-15T13:07:09",
"upload_time_iso_8601": "2024-10-15T13:07:09.421823Z",
"url": "https://files.pythonhosted.org/packages/a4/92/f4d160f755a53049932827377d0f7aa974e54d1fa6ef4d9cd6cee3177ffc/paynow-1.0.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-15 13:07:09",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "paynow-developer-hub",
"gitlab_project": "Paynow-Python-SDK",
"lcname": "paynow"
}