Python

Integrate Hesabe Payment Gateway into your Python application. This comprehensive script provides encryption, decryption, and transaction handling for seamless payment processing.

Quick Start

Before you begin, ensure you have the necessary encryption library installed for AES functions:

Required Libraries

pip install hesabe-test-checkout

This installs Hesabe's hesabe package, whose hesabe.crypt module provides encrypt and decrypt (it depends on pycryptodome). The same code is on GitHub.

Obtain Live Credentials

To use this payment integration in a live environment, you need to obtain live credentials from Hesabe. Please contact our support team to request these credentials.

Set Return URLs

You must configure the return URLs for both successful and failed transactions. These URLs will be used to redirect users after a transaction is processed. Set these URLs in your application's homepage or backend configuration.

Handle Transaction Responses

The script will receive transaction responses in the form of encrypted data. You need to decrypt this data and handle it accordingly:

import json
import os

from hesabe.crypt import decrypt

MERCHANT_SECRET_KEY = os.environ["HESABE_SECRET_KEY"]  # secret key provided by Hesabe
MERCHANT_IV = os.environ["HESABE_IV_KEY"]              # IV key provided by Hesabe

response_data = request.args.get('data')
if response_data:
    decrypted_data = decrypt(response_data, MERCHANT_SECRET_KEY, MERCHANT_IV)
    response_json = json.loads(decrypted_data)
    # Process the response_json as needed

Download Kit

Python KitDownload Link
Complete Python integration kit with demo examplesClick here