SSLCommerz Python

Python wrapper for SSLCommerz, Bangladesh's largest payment gateway.

PythonSSLCommerz APIDataclasses
View source on GitHub

A typed Python SDK for the SSLCommerz payment gateway, covering payment initiation, transaction validation, and IPN signature verification. Published on PyPI as sslcommerz-python-api and requires Python 3.10 or newer.

Install from PyPI

pip install sslcommerz-python-api

Typed request and response

Payments are described with dataclasses — `PaymentRequest`, `CustomerInfo`, `ShippingInfo` — rather than assembled as dictionaries against the vendor's field names, so a typo is a type error rather than a runtime rejection from the gateway.

`initiate_payment` returns a `PaymentResponse` carrying `status`, `session_key`, `gateway_url` to redirect the user to, and an `is_success` convenience property.

Typed errors

Failures raise rather than returning a status code to check: `SSLCommerzAPIError` on a failed request, `SSLCommerzValidationError` when transaction validation fails.

That matters most for the IPN path, where silently treating a failed validation as success is the expensive kind of bug.

Validation and IPN

`validate_transaction` takes the `val_id` from an IPN callback and returns the validated status along with the full raw response dictionary, so nothing the gateway sent is hidden from the caller.

`verify_ipn` checks the webhook signature before the order is processed, which is the step that separates a real callback from a forged one.

All projects