Sslcommerz SDK for python
Project description
Python SDK for SSLCOMMERZ configurable with Sqlalchemy, PynamoDB or Django ORM.
Getting Started
Install it via pip (python>=3.0).
pip install sslcommerz-sdk
How to Use
Create the views below depending on framework you are using.
from sslcommerz_sdk.enums import TransactionStatus
# TODO: create payment_handler.py file
from .payment_handler import payment_handler, store
def payment_init_view():
# TODO: Freeze the cart, see what cart freezing is
session, created = payment_handler.get_or_create_session(
store=store,
tran_id="test",
currency="BDT",
total_amount=100,
cus_name="test",
cus_email="test@test.com",
cus_add1="test",
cus_city="test",
cus_postcode="1234",
cus_country="test",
cus_phone="123456",
success_url="<URL to redirect cutomer when transaction is successful>",
fail_url="<URL to redirect cutomer when transaction is failed>",
cancel_url="<URL to redirect cutomer when transaction is cancelled>",
ipn_url="<URL of ipn_view>",
)
# TODO: Redirect customer to session.redirect_url
def ipn_view():
# TODO: Make this URL public, i.e accessible without logging in
# TODO: Disable CSRF protection for this view
# TODO: post_dict = {dict of request POST values}
session, verified_right_now = payment_handler.verify_transaction(
payload=post_dict,
)
if verified_right_now:
if session.status == TransactionStatus.VALID:
print(f"Tran ID: {session.tran_id} successful...")
# TODO: Update order payment status in your database
else:
print("Transaction failed/cancelled!")
# TODO: Unfreeze the cart sothat customer can modify/delete the cart
Next Steps
- Setup Payment Handler with any of the following ORM.
Contributing
PR should pass the tests and lint commands, checkout the following to get started.
License
This project is published under MIT LICENSE.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sslcommerz-sdk-1.0.4.tar.gz
(12.6 kB
view hashes)
Built Distribution
Close
Hashes for sslcommerz_sdk-1.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4a7c282c662790fdf1cda8bcfc20262f0e2b96169bfaa54a9350aa5083cb9a3 |
|
MD5 | cee370d666556d80d7fd34c1a2f29e87 |
|
BLAKE2b-256 | 3379f33e3a854afc00cbb6f1b7237fca4ce5558f104383c62f62cab728e1de9b |