Error 199 in JazzCash Sandbox Testing During Django Integration
I'm trying to integrate the JazzCash Payment Gateway with my Django project using the HTTP POST Redirect method, but I'm encountering Error 199 from their portal. I've followed the setup in their documentation and am testing using their sandbox environment.
Code: Below is a snippet of my integration code, followed by the error response JSON.
from django.views.decorators.csrf import csrf_exempt
from django.shortcuts import render
from datetime import datetime, timedelta
import hashlib
import hmac
JAZZCASH_MERCHANT_ID = ""
JAZZCASH_PASSWORD = ""
JAZZCASH_RETURN_URL = ""
JAZZCASH_INTEGRITY_SALT = ""
def calculate_jazzcash_secure_hash(request_data, integrity_salt):
sorted_data = {k: v for k, v in sorted(request_data.items()) if k != "pp_SecureHash"}
final_string = integrity_salt + '&' + '&'.join(str(v) for v in sorted_data.values() if v)
secure_hash = hmac.new(
integrity_salt.encode(),
final_string.encode(),
hashlib.sha256
).hexdigest().upper()
return secure_hash
def checkout(request):
product_name = "Sample Product"
product_price = 100
pp_Amount = int(product_price * 100) # in paisa
current_datetime = datetime.now()
pp_TxnDateTime = current_datetime.strftime('%Y%m%d%H%M%S')
pp_TxnExpiryDateTime = (current_datetime + timedelta(hours=1)).strftime('%Y%m%d%H%M%S')
pp_TxnRefNo = 'T' + pp_TxnDateTime
post_data = {
"pp_Version": "1.1",
"pp_TxnType": "MWALLET",
"pp_Language": "EN",
"pp_MerchantID": JAZZCASH_MERCHANT_ID,
"pp_SubMerchantID": "",
"pp_Password": JAZZCASH_PASSWORD,
"pp_BankID": "TBANK",
"pp_ProductID": "RETL",
"pp_TxnRefNo": pp_TxnRefNo,
"pp_Amount": pp_Amount,
"pp_TxnCurrency": "PKR",
"pp_TxnDateTime": pp_TxnDateTime,
"pp_BillReference": "billRef",
"pp_Description": "Test transaction",
"pp_TxnExpiryDateTime": pp_TxnExpiryDateTime,
"pp_ReturnURL": JAZZCASH_RETURN_URL,
"ppmpf_1": "1",
"ppmpf_2": "2",
"ppmpf_3": "3",
"ppmpf_4": "4",
"ppmpf_5": "5",
}
post_data['pp_SecureHash'] = calculate_jazzcash_secure_hash(post_data, JAZZCASH_INTEGRITY_SALT)
return render(request, 'index.html', {'product_name': product_name, 'product_price': product_price, 'post_data': post_data})
@csrf_exempt
def success(request):
# Placeholder for handling JazzCash success response
return render(request, 'success.html')
Error 199:
request.json
{
"pp_Version": "1.1",
"pp_TxnType": "MWALLET",
"pp_Language": "EN",
"pp_MerchantID": "MERCHANT_ID",
"pp_SubMerchantID": "",
"pp_UsageMode": "PR",
"pp_Password": "PASSWORD",
"pp_BankID": "TBANK",
"pp_ProductID": "RETL",
"pp_TxnRefNo": "T20241103183926",
"pp_Amount": "10000",
"pp_DiscountedAmount": "",
"pp_TxnCurrency": "PKR",
"pp_TxnDateTime": "20241103183926",
"pp_BillReference": "billRef",
"pp_Description": "Test transaction",
"pp_TxnExpiryDateTime": "20241103193926",
"pp_ReturnURL": "RETURN_URL",
"pp_SecureHash": "A59624AF8240E4E1A158855F9CA5087B741A064CCBEF52D23FE8F459E3A904B4",
"ppmpf_1": "1",
"ppmpf_2": "2",
"ppmpf_3": "3",
"ppmpf_4": "4",
"ppmpf_5": "5",
"pp_MobileNumber": "Number",
"DiscountProfileId": null,
"ppTxnOrderIdentifier": null,
"pp_PaymentInstrumentNumber": "Number",
"pp_PaymentInstrumentID": "0"
}
Response JSON
{
"pp_Amount": "10000",
"pp_AuthCode": "",
"pp_BankID": "",
"pp_BillReference": "billRef",
"pp_Language": "EN",
"pp_MerchantID": "MERVHANT_ID",
"pp_ResponseCode": "199",
"pp_ResponseMessage": "Sorry! Your transaction was not successful. Please try again later.",
"pp_RetreivalReferenceNo": "241103130002",
"pp_SecureHash": "03123C048CD00F8E58C278FC70EA7BA735DA894010CE73FCA0FDDF0689F53948",
"pp_SettlementExpiry": "",
"pp_SubMerchantId": "",
"pp_TxnCurrency": "PKR",
"pp_TxnDateTime": "20241103183926",
"pp_TxnRefNo": "T20241103183926",
"pp_TxnType": "MWALLET",
"pp_Version": "1.1",
"ppmpf_1": "1",
"ppmpf_2": "2",
"ppmpf_3": "3",
"ppmpf_4": "4",
"ppmpf_5": "5"
Here’s what I’ve tried:
Deployed the project: I hosted the project on Vercel, thinking it might be an issue with running locally. Contacted support: I reached out to JazzCash support via email but haven’t received any feedback yet.