Skip to main content

A tool to integrate BillDesk in Django Site

Project description

django-billdesk

Usage

An tool to ease the process to integrate billdesk payment gateway with your django project. All you need to do is to create these variables in your settings.py file.
MID = '<merchant-id>'
SEC_ID = '<sercet-id>'

BILL_URL = 'https://uat.billdesk.com/pgidsk/PGIMerchantPayment'
CONF_BILL_URL = 'https://uat.billdesk.com/pgidsk/PGIQueryController'
CHECKSUM_KEY = '<checksum-key>'
REVERSE_URL = '<reverse url>'

To know excatly what these variables mean have at look at my gist

STEP 1

Now to use this in your project,you simply need to do
from django_billdesk import ResponseMessage, GetMessage

STEP 2

Now GetMessage gives the message to be posted in the required format along with the checksum. All you need to do is
msg = GetMessage().message(uniqueID, amount, ExInfo1, ExInfo2, ExInfo3, ExInfo4)

NOTE:

  1. uniqueID mentioned above should be truely unique for all the transactions requested by you.If not, the transaction will be declined by billdesk.
  2. The order of arguments being passed should not be changed.
  3. Atleast 4 (billdesk says 3 but for extra security) ExtraInfo should be passed about the transaction. For ex - emailId of person making transaction, his phone number, his name, his ID in your company or website.

Suggested format

msg = GetMessage().message(uniqueID, amount, some_id, email, name, mnumber)

Important : some_id shouldn't be confused with uniqueID. uniqueID will be created by you everytime a transaction is requested and is ensured that it is truely unique and never before has any request been made with the same id, whereas some_id is the id which you allocate to a user when he or she registers on your site. So a same person, when will make multiple transactions, will have same 'some_id' but different uniqueID

STEP 3

Now make a 'POST' request to the billdesk url with the msg you obtained. You can obtain the template and complete code to do so from my gist

STEP 4

Now you will receive a response at the return url. You will send that resposne to ResponseMessage as shown:
values = ResponseMessage.respMsg(<The response msg>)

Note :

  1. Make sure your function which is called at response url is csrf exempted as you are receiving a POST request from a website outside of your domain.
  2. You will get a dictionary in the variable 'values' as mentioned above. But before doing anything make sure the variable 'values' is not False.
if values not False:
    <do everything in here>

cuz if the value is false, it means there had been a breach as Checksum verification failed.

STEP 4

Now you can update your database based on the response and values in the variable 'values'
Structure of 'values':
{'MID': '', 'OrderID': '', 'TaxnNo': '', 'AMNT': '', 'TStat': '', 'DnT': '', 'TMode': ''}

All the variables in the dictionary above will hold values as received in the response message from billdesk

  1. MID = will hold the merchant ID to which payment was made
  2. OrderID = will hold the unique order id for the transaction
  3. TaxnNo = will hold the unique taxation number generated by the respective bank
  4. AMNT = will hold the amount for which the transaction was made
  5. TStat = will hold the transaction status number. See the possible outcomes and their meaning
  6. DnT = will hold the date and time at which the transaction was made.
  7. TMode = will hold the mode of transaction. For ex- UPI, Internet Banking.

Extra

STEP 1

All the transactions may not get successful instantly and sometimes give status as PENDING which generally means that BillDesk is waiting for the response from the bank. In such cases you need to verify again with billdesk about the payment through Query Api.The message sent using query API has a bit different format and can be achieved using
msg = GetMessage().schedule_msg(uniqueID)

'msg' will have the message to be sent using POST method. NOTE :You can Python's requests module to send POST requests to the Query API but while sending POST requests for the payment request,you need to do it from template forms like this so that the user can be properly redirected to billdesk page.

<html>
<body>
<form action="{{url}}" method="post" name="billdesk">
    <input name="msg" type="hidden" value="{{msg}}">
</form>
</body>
<script>

  document.billdesk.submit();
</script>
</html>

STEP 2

To access the values returned by billdesk for the Query API, pass the response like this to,
values = ResponseMessage.schedule_resp(<the recieved response>)

Now again proceed only after making sure that values is not equal to False.If it is not,then it will hold a dictionary with the following structure.

{'MID': '', 'OrderID': '', 'TaxnNo': '', 'AMNT': '', 'TStat': '', 'RfndStat': ''}

Variables have their usual meaning as stated above.RfndStat contains the refund status of the transaction.
Important Always use combination of auth status and refund status to update you database.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_billdesk-0.0.2.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_billdesk-0.0.2-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file django_billdesk-0.0.2.tar.gz.

File metadata

  • Download URL: django_billdesk-0.0.2.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.5.0.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for django_billdesk-0.0.2.tar.gz
Algorithm Hash digest
SHA256 8dfcf33453ae9289035e67d35b0fb2adedf5023add25f07889d25125edd38894
MD5 1e0447e0b6e8cea08ba9f27eebbc8321
BLAKE2b-256 5478da1e9ffe5a3e2b287a234b221fec0b7d9356f5d5f7b0c640159d0473f05b

See more details on using hashes here.

File details

Details for the file django_billdesk-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: django_billdesk-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.5.0.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for django_billdesk-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 50dfc5ced2091a999ede685e4213e5e6bbe6202006ba666357d819ced7273931
MD5 2a30910fe9779a89e8d5a614e742a276
BLAKE2b-256 7b1ef9063f92f79f4d09b8f2c6253f4c0c60ff19aac35fec11f955091ffb46de

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page