PayTM | Django REST Framework
A package for PayTM integration in Django REST Framework
PayTM | Django REST Framework is a Django packaged app that provides necessary views based in Django REST Framework.
It enables easy integration of PayTM Payment Gateway with Web/Mobile Application with a RESTful API based server.
Contributors: WE'RE LOOKING FOR SOMEONE WHO CAN CONTRIBUTE IN DOCS
- Civil Machines Technologies Private Limited: For providing me platform and
funds for research work. This project is hosted currently with
CMTonly. - Himanshu Shankar: Himanshu Shankar has initiated this project and worked on this project to collect useful functions and classes that are being used in various projects.
Installation
- Download and Install via
pip
pip install drf_paytm
or
Download and Install via easy_install
easy_install drf_paytm
- Add, if wanted,
drfaddonsinINSTALLED_APPS(This is although not required!)
INSTALLED_APPS = [
...
'drf_paytm',
...
]
- Also add other dependencies in
INSTALLED_APPS
INSTALLED_APPS = [
...
'drfaddons',
...
]
- Include urls of
drf_paytminurls.py
urlpatterns = [
...
path('api/paytm/', include('drf_paytm.urls')),
...
]
# or
urlpatterns = [
...
url(r'^api/paytm/', include('drf_paytm.urls')),
...
]
- Run migrate command:
python manage.py migrate
Frontend API Integration Guideline
- Prepare
jsondata to post onrequest/view:{"oid": "ORDER_ID", "amount": "200", "callback_url": "FRONT_END APP URL"} callback_url: FrontEnd URL to open when payment is successful. Must not have any queryset as?oid=ORDER_IDis appended.- Post to
request/and parse response to prepare a HTML form as per code shown below. - Don't add
<input>for empty andnullfields from json response ofrequest/API. - Set
CALLBACK_URLin HTML frompaytm_callback_urlof JSON. - Once the payment is done, user is redirected to
response/view which will verify payment. - If payment is verified by Django Backend, user is redirected to
http://callback_url?oid=ORDER_ID. - Access
order/ORDER_ID/API to getis_completedstatus. If it'sfalse, checklast_payment_status.
Note: In case of critical failure, server's JSON response is shown.
Sample HTML Code to be generated by FrontEnd App(from PayTM)
<html>
<head>
<title>Merchant Check Out Page</title>
</head>
<body>
<center><h1>Please do not refresh this page...</h1></center>
<form method="post" action="https://securegw-stage.paytm.in/theia/processTransaction" name="f1">
<table border="1">
<tbody>
<input type="hidden" name="MID" value="rxazcv89315285244163">
<input type="hidden" name="WEBSITE" value="WEBSTAGING">
<input type="hidden" name="ORDER_ID" value="order1">
<input type="hidden" name="CUST_ID" value="cust123">
<input type="hidden" name="MOBILE_NO" value="7777777777">
<input type="hidden" name="EMAIL" value="username@emailprovider.com">
<input type="hidden" name="INDUSTRY_TYPE_ID" value="Retail">
<input type="hidden" name="CHANNEL_ID" value="WEB">
<input type="hidden" name="TXN_AMOUNT" value="100.12">
<input type="hidden" name="CALLBACK_URL" value="https://Merchant_Response_URL>">
<input type="hidden" name="CHECKSUMHASH" value="ZWdMJOr1yGiFh1nns2U8sDC9VzgUDHVnQpG
pVnHyrrPb6bthwro1Z8AREUKdUR/K46x3XvFs6Xv7EnoSOLZT29qbZJKXXvyEuEWQIJGkw=">
</tbody>
</table>
<script type="text/javascript">
document.f1.submit();
</script>
</form>
</body>
</html>
MODELS
The application has three models:
PayTMConfiguration: You need to define your PayTM configurations in this model. Only one object can haveis_activeset toTruewhich will be used with PayTM API.TransactionRequest: This will contain all the PayTM Transaction Request that one will create with PayTM.TransactionResponse: This will contain all the responses received from PayTM API against transaction.
VIEWS
The application has following views:
ListAddTransactionRequestView: All payment request should be made on this view. Requires a logged in user. It'll provide user with required data, includingchecksum hashthat will be used with PayTM API.AddTransactionResponseView: Response from PayTM is posted on this view. URL for this view should go asCALLBACK_URL. This view then redirects user to FrontEnd app withOIDas queryset parameter.PayNowTransaction: This view is for testing w/o a frontend client. It will open PayTM payment page.
URLS
request/: All payment request to be made via this URL.response/: All response from PayTM is posted on this URL.order/OID/: Retrieve specific payment request data.now/: For immediate testing of API, open this url.
Quickstart Guide
- Complete
Installation Steps(mentioned above) - Create a configuration via
Django AdmininPayTM Configuration. - Provide
base_urlof your Backend Server. - Set
is_activetoTrue - Note: Use sandbox mode credential at first
- Test API by accessing
/api/paytm/now/endpoint - Use
PayTM Testing Credential:
Mobile: 7777777777
OTP: 489871
Password: Paytm12345
Metadata
Release files for drf-paytm 0.0.3
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 |
|---|---|---|---|---|
| drf_paytm-0.0.3.tar.gz | 16.9 kB | Without provenance | Details for drf_paytm-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| drf_paytm-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for drf_paytm-0.0.3-py3-none-any.whl |
Total release size: 48.4 kB
Release files / drf_paytm-0.0.3.tar.gz
| Download URL | drf_paytm-0.0.3.tar.gz |
|---|---|
| Size | 16.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
91826dea19a4a70e453f916e38604fe961f3896004153d92a95f112e77c8beb2
|
|
BLAKE2b-256 checksum How to use checksums |
edbac30c773dbda4b7a83b7d19b8b4175a3bea0c21fed32b7b21e3f828a4cdd6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7
|
Release files / drf_paytm-0.0.3-py3-none-any.whl
| Download URL | drf_paytm-0.0.3-py3-none-any.whl |
|---|---|
| Size | 31.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f3ec9c831312ecd48847f43080608054b271e7407bbac1950020e6af7b5f233b
|
|
BLAKE2b-256 checksum How to use checksums |
8ad0f34f182ccfd75629391bfa4a80dd597b94b3e2d7a7e92a8d5db94a2d71dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7
|
Security for drf-paytm 0.0.3
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.