paynow


Namepaynow JSON
Version 1.0.6 PyPI version JSON
download
home_pagehttps://gitlab.com/paynow-developer-hub/Paynow-Python-SDK
SummaryPaynow Python SDK
upload_time2024-01-17 13:20:13
maintainer
docs_urlNone
authorWebDev Projects
requires_python
license
keywords paynow-api paynow-zimbabwe paynow-zimbabwe-api paynow-zimbabwe-sdk
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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',
	'http://google.com',
	'http://google.com'
	)
```

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',
	'http://google.com',
	'http://google.com'
	)

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": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "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/a3/46/0f316ddda6d8628bed5d646014f207dc0865b9c28b5744c3f8e4cd840ffd/paynow-1.0.6.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'http://google.com',\n\t'http://google.com'\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'http://google.com',\n\t'http://google.com'\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": "",
    "summary": "Paynow Python SDK",
    "version": "1.0.6",
    "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": "da4e29fdad1a734c6d8a0a691e9e7cbd08f5a5fd360e6daedb69589a6871a39a",
                "md5": "137002bc0f0b90ed832b22185f287e9d",
                "sha256": "64ee765f774ac0195cf3bde3f3af82c226c84a33d780cbf40ce4eca240155f05"
            },
            "downloads": -1,
            "filename": "paynow-1.0.6-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "137002bc0f0b90ed832b22185f287e9d",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 7658,
            "upload_time": "2024-01-17T13:20:11",
            "upload_time_iso_8601": "2024-01-17T13:20:11.195472Z",
            "url": "https://files.pythonhosted.org/packages/da/4e/29fdad1a734c6d8a0a691e9e7cbd08f5a5fd360e6daedb69589a6871a39a/paynow-1.0.6-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a3460f316ddda6d8628bed5d646014f207dc0865b9c28b5744c3f8e4cd840ffd",
                "md5": "e5a0acc605908182c876137de2352fea",
                "sha256": "108ab67f194601f9bd5f23d5699200656e7c6347083f0db78038740b2ac190a3"
            },
            "downloads": -1,
            "filename": "paynow-1.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "e5a0acc605908182c876137de2352fea",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7984,
            "upload_time": "2024-01-17T13:20:13",
            "upload_time_iso_8601": "2024-01-17T13:20:13.074586Z",
            "url": "https://files.pythonhosted.org/packages/a3/46/0f316ddda6d8628bed5d646014f207dc0865b9c28b5744c3f8e4cd840ffd/paynow-1.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-17 13:20:13",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "paynow-developer-hub",
    "gitlab_project": "Paynow-Python-SDK",
    "lcname": "paynow"
}
        
Elapsed time: 0.16140s