django-payu icon indicating copy to clipboard operation
django-payu copied to clipboard

hash generation issue

Open sandeepbalagopal09 opened this issue 6 years ago • 1 comments

The get_hash() function is not proper. It is supposed to apply sha512 to the entire string, but instead it is now applying it to the 'PAYU_MERCHANT_KEY ' only. https://github.com/MicroPyramid/django-payu/blob/master/payu/gateway.py#L21

sandeepbalagopal09 avatar Mar 27 '19 04:03 sandeepbalagopal09

Below get_hash() function worked for me

`def get_hash(data): # Generate hash sequence before posting the transaction to PayU: # sha512(key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||SALT)

hash_value = str(getattr(settings, 'PAYU_MERCHANT_KEY', None))

for key in KEYS:
    if data.get(key) == None:
        hash_value += "%s%s" % ('|', str(''))
    else:
        hash_value += ("%s%s" % ('|', str(data.get(key, ''))))

hash_value += "%s%s" % ('|', getattr(settings, 'PAYU_MERCHANT_SALT', None))


hash_value = sha512(hash_value.encode('utf-8'))
# Create transaction record
Transaction.objects.create(
    transaction_id=data.get('txnid'), amount=data.get('amount'))
return hash_value.hexdigest().lower()`

sandeepbalagopal09 avatar Mar 27 '19 04:03 sandeepbalagopal09