Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hash generation issue #21

Open
sandeepbalagopal09 opened this issue Mar 27, 2019 · 1 comment
Open

hash generation issue #21

sandeepbalagopal09 opened this issue Mar 27, 2019 · 1 comment

Comments

@sandeepbalagopal09
Copy link

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
Copy link
Author

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()`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant