Esewa Latest Web Check Out And Epay-V2 SDK | How to Integrate latest esewa in django

Опубликовано: 05 Октябрь 2024
на канале: Coding Sword
2,049
27

#python #django #djangotutorial
🚀 Mastering EsewaPayment Gateway Integration in Django 🌐💳
Learn how to seamlessly integrate a payment gateway into your Django web app! 💻💰 Join our step-by-step tutorial and take your project to the next level. Don't miss it!

Github: https://github.com/alijarai12/esewa-i...
Code for generating SHA:
import hmac
import hashlib
import uuid

def genSha256(key, message):
key = key.encode('utf-8')
message = message.encode('utf-8')

hmac_sha256 = hmac.new(key, message, hashlib.sha256)
digest = hmac_sha256.digest()

Convert the digest to a Base64-encoded string
signature = base64.b64encode(digest).decode('utf-8')

return signature

uuid_val = uuid.uuid4()
Example usage:
secret_key = "8gBm/:&EnhH.1/q"
data_to_sign = f"total_amount={total_amount},transaction_uuid={uid},product_code=EPAYTEST"

result = genSha256(secret_key, data_to_sign)

Code to convert base64encoded string:
import base64
decoded_data = base64.b64decode(data).decode('utf-8')
print(decoded_data)
map_data = json.loads(decoded_data)