==============
django-pesapal
==============
.. image:: https://badge.fury.io/py/django-pesapal.png
:target: https://badge.fury.io/py/django-pesapal
.. image:: https://travis-ci.org/odero/django-pesapal.png?branch=master
:target: https://travis-ci.org/odero/django-pesapal
.. image:: https://coveralls.io/repos/odero/django-pesapal/badge.png?branch=master
:target: https://coveralls.io/r/odero/django-pesapal?branch=master
.. image:: https://img.shields.io/pypi/status/django-pesapal.svg
:target: https://pypi.python.org/pypi/django-pesapal/
:alt: Development Status
A django port of pesapal payment gateway
Documentation
-------------
The full documentation is at https://django-pesapal.readthedocs.org.
Quickstart
----------
Install django-pesapal::
pip install django-pesapal
Then use it in a project::
import django_pesapalv3
#. Add `django_pesapalv3` to your `INSTALLED_APPS` setting like this::
INSTALLED_APPS = (
...
'django_pesapalv3', # use this if using v3 api
# 'django_pesapal', # use this if using v1/classic api
)
#. Include the `django_pesapal` URLconf in your project urls.py like this::
url(r"^v3/payments", include("django_pesapalv3.urls")),
# url(r'^payments/', include('django_pesapal.urls')), # use this if using v1/classic api
#. You can set your own return url by adding this to `settings.py`::
PESAPAL_TRANSACTION_DEFAULT_REDIRECT_URL = 'app_name:url_name' # this needs to be a reversible
#. Run `python manage.py migrate` to create the models.
#. Create a method that receives payment details and returns the pesapal iframe url::
from django_pesapalv3.views import PaymentRequestMixin
class PaymentView(PaymentRequestMixin, TemplateView):
def get_pesapal_payment_iframe(self):
'''
Authenticates with pesapal to get the payment iframe src
'''
ipn = self.get_default_ipn() # you can replace this with your own ipn registration method
order_info = {
"id": self.request.GET.get("id", uuid.uuid4().hex), # replace this with a valid merchant id
"currency": "KES",
"amount": 10,
"description": "Payment for X",
"callback_url": self.build_url(
reverse("django_pesapalv3:transaction_completed")
),
"notification_id": ipn,
"billing_address": {
"first_name": "John",
"last_name": "Doe",
"email": "pesapal@example.com",
},
}
req = self.submit_order_request(**order_info)
iframe_src_url = req["redirect_url"]
return iframe_src_url
#. In case you are using v1/classic api, use this instead::
from django_pesapal.views import PaymentRequestMixin
class PaymentView(PaymentRequestMixin, TemplateView):
def get_pesapal_payment_iframe(self):
'''
Authenticates with pesapal to get the payment iframe src
'''
order_info = {
'first_name': 'Some',
'last_name': 'User',
'amount': 100,
'description': 'Payment for X',
'reference': 2, # some object id
'email': 'user@example.com',
}
iframe_src_url = self.get_payment_url(**order_info)
return iframe_src_url
#. Once payment has been processed, you will be redirected to an intermediate screen where the user can finish ordering. Clicking the "Check status" button will check the payment status to ensure that the payment was successful and then redirects the user to `PESAPAL_TRANSACTION_DEFAULT_REDIRECT_URL`.
Configuration
-------------
+---------------------------------------------+--------------------------------------------------------+
| Setting | Default Value |
+=============================================+========================================================+
| PESAPAL_DEMO | True |
+---------------------------------------------+--------------------------------------------------------+
| PESAPAL_CONSUMER_KEY | '' |
+---------------------------------------------+--------------------------------------------------------+
| PESAPAL_CONSUMER_SECRET | '' |
+---------------------------------------------+--------------------------------------------------------+
| PESAPAL_OAUTH_CALLBACK_URL | 'transaction_completed' |
+---------------------------------------------+--------------------------------------------------------+
| PESAPAL_OAUTH_SIGNATURE_METHOD | 'SignatureMethod_HMAC_SHA1' |
+---------------------------------------------+--------------------------------------------------------+
| PESAPAL_TRANSACTION_DEFAULT_REDIRECT_URL | '/' or '/v3/' |
+---------------------------------------------+--------------------------------------------------------+
| PESAPAL_TRANSACTION_FAILED_REDIRECT_URL | '' |
+---------------------------------------------+--------------------------------------------------------+
| PESAPAL_REDIRECT_WITH_REFERENCE | True |
+---------------------------------------------+--------------------------------------------------------+
| PESAPAL_TRANSACTION_MODEL | 'django_pesapal.Transaction' |
+---------------------------------------------+--------------------------------------------------------+
| PESAPAL_IPN_URL (for v3) | 'django_pesapalv3:transaction_ipn' |
+---------------------------------------------+--------------------------------------------------------+
| PESAPAL_CALLBACK_URL (for v3) | 'django_pesapalv3:transaction_completed' |
+---------------------------------------------+--------------------------------------------------------+
History
-------
2.0 (2024-12-27)
++++++++++++++++++
- Support for Django 5.1
- Update dependencies
- Support Py310, Py311
- Add support for pesapal v3 API
- Breaking change - Update Transaction model - change merchant_reference field from int to string
- Add payment_account field to Transaction model
1.3.3 (2023-01-26)
++++++++++++++++++
- Bug fix: Handling invalid data
1.3.2 (2022-01-21)
++++++++++++++++++
- Support for Django 3.9
- Update dependencies
- Support Py38, Py39
- Remove EOL py27
1.3.1 (2019-07-16)
++++++++++++++++++
- Update dependencies
- Support Py37
- Remove EOL py34
1.3.0 (2018-09-29)
++++++++++++++++++
- Support for Django 2.1
- Support Py36
1.2.0 (2016-12-11)
++++++++++++++++++
- Dropped support for Django 1.7
- Fixes and Upgrades to support Django 1.8 - 1.10
- Use Django's UUIDField
1.1.0 (2016-05-03)
++++++++++++++++++
- Support Django 1.9
- Update payment_method field length from 16 to 24
- Remove support for Py33. Support Py35
1.0.1 (2015-11-21)
++++++++++++++++++
- Fix querydict bug
1.0.0 (2015-11-11)
++++++++++++++++++
- Support Django 1.8
- Support Py33 and Py34
- Return proper IPN response
0.3.4 (2015-08-12)
++++++++++++++++++
- Restructure flow to better support IPN processing
0.3.3 (2015-06-29)
++++++++++++++++++
- Setup build had not packaged the templates
0.3.2 (2015-06-13)
++++++++++++++++++
- Fix documentation formatting issues
0.3.1 (2015-06-13)
++++++++++++++++++
- Allow specifying own transaction model
- Pass all transaction info when redirecting
- Update intermediate template
0.3 (2015-06-12)
++++++++++++++++++
- Introduce intermediate payment processing screen
- Update Django version to 1.7+
- Add support to receive and process IPN
- Save all details about the transaction and status
0.2.1 (2015-04-03)
++++++++++++++++++
- Added test sandbox
- Updated Django version
- Updated django-uuidfield
0.2 (2015-03-17)
++++++++++++++++++
- Support anonymous checkouts
- Add support for getting payment status
- Major structural refactoring. Use mixins
- Use Mixins and XML Builder
0.1.5 (2014-09-25)
++++++++++++++++++
- Pin dependencies to specific versions
- Update how imports should be done
- Remove imports from __init__.py
0.1.4 (2014-09-23)
++++++++++++++++++
- Fix import bug. Tests for projects using this fail in Shippable
- Set max Django version to 1.7
0.1.3 (2014-07-18)
++++++++++++++++++
- Packaging for PyPi
0.1.2 (2014-06-30)
++++++++++++++++++
- Fix import bug in urls.py
- Fix how callback url is constructed
- Fix: Live URL uses https
0.1.1 (2014-06-30)
++++++++++++++++++
- Refactor handling of redirect urls. Model validation of transaction and merchant reference
- Rename settings to conf. Set default oauth redirect url
- Add django-uuidfield to dependencies
0.1.0 (2014-06-30)
++++++++++++++++++
* First release on PyPI.
Raw data
{
"_id": null,
"home_page": "https://github.com/odero/django-pesapal",
"name": "django-pesapal",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "django-pesapal payment pesapal",
"author": "Billy Odero",
"author_email": "odero@xx.com",
"download_url": "https://files.pythonhosted.org/packages/36/59/b8d69306ceb89093eeb3d1001006f2120d53352f4f20d4c81a6db18823ee/django-pesapal-2.0.tar.gz",
"platform": null,
"description": "==============\r\ndjango-pesapal\r\n==============\r\n\r\n.. image:: https://badge.fury.io/py/django-pesapal.png\r\n :target: https://badge.fury.io/py/django-pesapal\r\n\r\n.. image:: https://travis-ci.org/odero/django-pesapal.png?branch=master\r\n :target: https://travis-ci.org/odero/django-pesapal\r\n\r\n.. image:: https://coveralls.io/repos/odero/django-pesapal/badge.png?branch=master\r\n :target: https://coveralls.io/r/odero/django-pesapal?branch=master\r\n\r\n.. image:: https://img.shields.io/pypi/status/django-pesapal.svg\r\n :target: https://pypi.python.org/pypi/django-pesapal/\r\n :alt: Development Status\r\n\r\nA django port of pesapal payment gateway\r\n\r\nDocumentation\r\n-------------\r\n\r\nThe full documentation is at https://django-pesapal.readthedocs.org.\r\n\r\nQuickstart\r\n----------\r\n\r\nInstall django-pesapal::\r\n\r\n pip install django-pesapal\r\n\r\nThen use it in a project::\r\n\r\n import django_pesapalv3\r\n\r\n#. Add `django_pesapalv3` to your `INSTALLED_APPS` setting like this::\r\n\r\n INSTALLED_APPS = (\r\n ...\r\n 'django_pesapalv3', # use this if using v3 api\r\n # 'django_pesapal', # use this if using v1/classic api\r\n )\r\n\r\n#. Include the `django_pesapal` URLconf in your project urls.py like this::\r\n\r\n url(r\"^v3/payments\", include(\"django_pesapalv3.urls\")),\r\n # url(r'^payments/', include('django_pesapal.urls')), # use this if using v1/classic api\r\n\r\n#. You can set your own return url by adding this to `settings.py`::\r\n\r\n PESAPAL_TRANSACTION_DEFAULT_REDIRECT_URL = 'app_name:url_name' # this needs to be a reversible\r\n\r\n#. Run `python manage.py migrate` to create the models.\r\n\r\n#. Create a method that receives payment details and returns the pesapal iframe url::\r\n\r\n from django_pesapalv3.views import PaymentRequestMixin\r\n\r\n class PaymentView(PaymentRequestMixin, TemplateView):\r\n\r\n def get_pesapal_payment_iframe(self):\r\n\r\n '''\r\n Authenticates with pesapal to get the payment iframe src\r\n '''\r\n ipn = self.get_default_ipn() # you can replace this with your own ipn registration method\r\n\r\n order_info = {\r\n \"id\": self.request.GET.get(\"id\", uuid.uuid4().hex), # replace this with a valid merchant id\r\n \"currency\": \"KES\",\r\n \"amount\": 10,\r\n \"description\": \"Payment for X\",\r\n \"callback_url\": self.build_url(\r\n reverse(\"django_pesapalv3:transaction_completed\")\r\n ),\r\n \"notification_id\": ipn,\r\n \"billing_address\": {\r\n \"first_name\": \"John\",\r\n \"last_name\": \"Doe\",\r\n \"email\": \"pesapal@example.com\",\r\n },\r\n }\r\n req = self.submit_order_request(**order_info)\r\n iframe_src_url = req[\"redirect_url\"]\r\n return iframe_src_url\r\n\r\n#. In case you are using v1/classic api, use this instead::\r\n\r\n from django_pesapal.views import PaymentRequestMixin\r\n\r\n class PaymentView(PaymentRequestMixin, TemplateView):\r\n\r\n def get_pesapal_payment_iframe(self):\r\n\r\n '''\r\n Authenticates with pesapal to get the payment iframe src\r\n '''\r\n order_info = {\r\n 'first_name': 'Some',\r\n 'last_name': 'User',\r\n 'amount': 100,\r\n 'description': 'Payment for X',\r\n 'reference': 2, # some object id\r\n 'email': 'user@example.com',\r\n }\r\n\r\n iframe_src_url = self.get_payment_url(**order_info)\r\n return iframe_src_url\r\n\r\n#. Once payment has been processed, you will be redirected to an intermediate screen where the user can finish ordering. Clicking the \"Check status\" button will check the payment status to ensure that the payment was successful and then redirects the user to `PESAPAL_TRANSACTION_DEFAULT_REDIRECT_URL`.\r\n\r\n\r\nConfiguration\r\n-------------\r\n\r\n+---------------------------------------------+--------------------------------------------------------+\r\n| Setting | Default Value |\r\n+=============================================+========================================================+\r\n| PESAPAL_DEMO | True |\r\n+---------------------------------------------+--------------------------------------------------------+\r\n| PESAPAL_CONSUMER_KEY | '' |\r\n+---------------------------------------------+--------------------------------------------------------+\r\n| PESAPAL_CONSUMER_SECRET | '' |\r\n+---------------------------------------------+--------------------------------------------------------+\r\n| PESAPAL_OAUTH_CALLBACK_URL | 'transaction_completed' |\r\n+---------------------------------------------+--------------------------------------------------------+\r\n| PESAPAL_OAUTH_SIGNATURE_METHOD | 'SignatureMethod_HMAC_SHA1' |\r\n+---------------------------------------------+--------------------------------------------------------+\r\n| PESAPAL_TRANSACTION_DEFAULT_REDIRECT_URL | '/' or '/v3/' |\r\n+---------------------------------------------+--------------------------------------------------------+\r\n| PESAPAL_TRANSACTION_FAILED_REDIRECT_URL | '' |\r\n+---------------------------------------------+--------------------------------------------------------+\r\n| PESAPAL_REDIRECT_WITH_REFERENCE | True |\r\n+---------------------------------------------+--------------------------------------------------------+\r\n| PESAPAL_TRANSACTION_MODEL | 'django_pesapal.Transaction' |\r\n+---------------------------------------------+--------------------------------------------------------+\r\n| PESAPAL_IPN_URL (for v3) | 'django_pesapalv3:transaction_ipn' |\r\n+---------------------------------------------+--------------------------------------------------------+\r\n| PESAPAL_CALLBACK_URL (for v3) | 'django_pesapalv3:transaction_completed' |\r\n+---------------------------------------------+--------------------------------------------------------+\r\n\r\n\r\n\r\n\r\nHistory\r\n-------\r\n2.0 (2024-12-27)\r\n++++++++++++++++++\r\n- Support for Django 5.1\r\n- Update dependencies\r\n- Support Py310, Py311\r\n- Add support for pesapal v3 API\r\n- Breaking change - Update Transaction model - change merchant_reference field from int to string\r\n- Add payment_account field to Transaction model\r\n\r\n1.3.3 (2023-01-26)\r\n++++++++++++++++++\r\n- Bug fix: Handling invalid data\r\n\r\n1.3.2 (2022-01-21)\r\n++++++++++++++++++\r\n- Support for Django 3.9\r\n- Update dependencies\r\n- Support Py38, Py39\r\n- Remove EOL py27\r\n\r\n1.3.1 (2019-07-16)\r\n++++++++++++++++++\r\n- Update dependencies\r\n- Support Py37\r\n- Remove EOL py34\r\n\r\n1.3.0 (2018-09-29)\r\n++++++++++++++++++\r\n- Support for Django 2.1\r\n- Support Py36\r\n\r\n1.2.0 (2016-12-11)\r\n++++++++++++++++++\r\n- Dropped support for Django 1.7\r\n- Fixes and Upgrades to support Django 1.8 - 1.10\r\n- Use Django's UUIDField\r\n\r\n1.1.0 (2016-05-03)\r\n++++++++++++++++++\r\n- Support Django 1.9\r\n- Update payment_method field length from 16 to 24\r\n- Remove support for Py33. Support Py35\r\n\r\n1.0.1 (2015-11-21)\r\n++++++++++++++++++\r\n- Fix querydict bug\r\n\r\n1.0.0 (2015-11-11)\r\n++++++++++++++++++\r\n- Support Django 1.8\r\n- Support Py33 and Py34\r\n- Return proper IPN response\r\n\r\n0.3.4 (2015-08-12)\r\n++++++++++++++++++\r\n- Restructure flow to better support IPN processing\r\n\r\n0.3.3 (2015-06-29)\r\n++++++++++++++++++\r\n- Setup build had not packaged the templates\r\n\r\n0.3.2 (2015-06-13)\r\n++++++++++++++++++\r\n- Fix documentation formatting issues\r\n\r\n0.3.1 (2015-06-13)\r\n++++++++++++++++++\r\n- Allow specifying own transaction model\r\n- Pass all transaction info when redirecting\r\n- Update intermediate template\r\n\r\n0.3 (2015-06-12)\r\n++++++++++++++++++\r\n- Introduce intermediate payment processing screen\r\n- Update Django version to 1.7+\r\n- Add support to receive and process IPN\r\n- Save all details about the transaction and status\r\n\r\n0.2.1 (2015-04-03)\r\n++++++++++++++++++\r\n- Added test sandbox\r\n- Updated Django version\r\n- Updated django-uuidfield\r\n\r\n0.2 (2015-03-17)\r\n++++++++++++++++++\r\n- Support anonymous checkouts\r\n- Add support for getting payment status\r\n- Major structural refactoring. Use mixins\r\n- Use Mixins and XML Builder\r\n\r\n0.1.5 (2014-09-25)\r\n++++++++++++++++++\r\n- Pin dependencies to specific versions\r\n- Update how imports should be done\r\n- Remove imports from __init__.py\r\n\r\n0.1.4 (2014-09-23)\r\n++++++++++++++++++\r\n- Fix import bug. Tests for projects using this fail in Shippable\r\n- Set max Django version to 1.7\r\n\r\n0.1.3 (2014-07-18)\r\n++++++++++++++++++\r\n- Packaging for PyPi\r\n\r\n0.1.2 (2014-06-30)\r\n++++++++++++++++++\r\n- Fix import bug in urls.py\r\n- Fix how callback url is constructed\r\n- Fix: Live URL uses https\r\n\r\n0.1.1 (2014-06-30)\r\n++++++++++++++++++\r\n- Refactor handling of redirect urls. Model validation of transaction and merchant reference\r\n- Rename settings to conf. Set default oauth redirect url\r\n- Add django-uuidfield to dependencies\r\n\r\n0.1.0 (2014-06-30)\r\n++++++++++++++++++\r\n\r\n* First release on PyPI.\r\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "A django port of pesapal payment gateway",
"version": "2.0",
"project_urls": {
"Homepage": "https://github.com/odero/django-pesapal"
},
"split_keywords": [
"django-pesapal",
"payment",
"pesapal"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9457b5ee9bac9266a70ee7c42e8b0d10bdbf441c061c93556090d1ea2befaef9",
"md5": "5b14865203ca3265303df5d1d471d0f3",
"sha256": "9bff8669cc71cc19fc16b4de6812ef18211b56ba7d8cf0a7acec31cbbd95f319"
},
"downloads": -1,
"filename": "django_pesapal-2.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "5b14865203ca3265303df5d1d471d0f3",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 21883,
"upload_time": "2024-12-27T11:04:40",
"upload_time_iso_8601": "2024-12-27T11:04:40.203466Z",
"url": "https://files.pythonhosted.org/packages/94/57/b5ee9bac9266a70ee7c42e8b0d10bdbf441c061c93556090d1ea2befaef9/django_pesapal-2.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3659b8d69306ceb89093eeb3d1001006f2120d53352f4f20d4c81a6db18823ee",
"md5": "9f55802888b4545b5c3096e97a8d9f0f",
"sha256": "bdc1bc1e615f9f4662d114c09fdc246a97ec504ab25a263c059bcf1d09817f1e"
},
"downloads": -1,
"filename": "django-pesapal-2.0.tar.gz",
"has_sig": false,
"md5_digest": "9f55802888b4545b5c3096e97a8d9f0f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 20462,
"upload_time": "2024-12-27T11:04:42",
"upload_time_iso_8601": "2024-12-27T11:04:42.639296Z",
"url": "https://files.pythonhosted.org/packages/36/59/b8d69306ceb89093eeb3d1001006f2120d53352f4f20d4c81a6db18823ee/django-pesapal-2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-27 11:04:42",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "odero",
"github_project": "django-pesapal",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "Django",
"specs": [
[
">=",
"2.2"
],
[
"<=",
"5.1"
]
]
},
{
"name": "wheel",
"specs": [
[
">=",
"0.37.1"
]
]
},
{
"name": "oauth2",
"specs": [
[
"==",
"1.9.0.post1"
]
]
},
{
"name": "requests",
"specs": [
[
">=",
"2.20.0"
]
]
}
],
"tox": true,
"lcname": "django-pesapal"
}