Install:
$ pip install django-payu
Integration Process:
NOTE: Here, you need to make the transaction request to the test-server and not on the production-server. Once you
are ready and understood the entire payment flow, you can move to the production server.
2. To initialise the transaction, you need to generate a post request to the below urls with the parameters mentioned below
3. Add the following information in the setting file using the details from your PayU account
PAYU_MERCHANT_KEY = "Your MerchantID",
PAYU_MERCHANT_SALT = "Your MerchantSALT",
# Change the PAYU_MODE to 'LIVE' for production.
PAYU_MODE = "TEST"
autosize($("#content-7-value"));
get_hash() method.
4. When the user click on the checkout button in your template, generate the mandatory parameter named "hash"
using the get_hash() method.
from payu import get_hash
from uuid import uuid4
data = {
'txnid':uuid4().hex, 'amount':10.00, 'productinfo': 'Sample Product',
'firstname': 'test', 'email': '[email protected]', 'udf1': 'Userdefined field',
}
hash_value = get_hash(data)
5. Then, send a post request to the PayU server using the HTML form filled with the data submitted by the buyer
containing all the fields mentioned above.
6. When the transaction "post request" hits the PayU server, a new transaction is created in the PayU Database. For
every new transaction in the PayU Database, a unique identifier is created every time at PayU’s end. This identifier is
known as the PayU ID (or MihPayID).
7. Then the customer would be re-directed to PayU’s payment page. After the entire payment process, PayU provides
the transaction response string to the merchant through a "post response". In this response, you would receive the
status of the transaction and the hash.
8. Similar to Step 4, you need verify this hash value at your end and then only you should accept/reject the invoice
order. You can verfy this hash using check_hash() method.
from django.http import HttpResponse
from payu import check_hash
from uuid import uuid4
def success_response(request):
if check_hash(request.POST):
return HttpResponse("Transaction has been Successful.")
In this "django-payu" package, there are many other functions to Capture, Refund, Cancel etc., For the detailed documentation, see here.