Saman bank payment gateway. SEP
Project description
درگاه پرداخت Seppy
Seppy یک پکیج پایتون برای ادغام با درگاه پرداخت سامان (SEP) است. این پکیج توابعی ساده برای تولید لینک پرداخت، تایید تراکنش و بازگرداندن تراکنش فراهم میکند.
ویژگیها
- تولید لینک پرداخت برای کاربران.
- بررسی وضعیت تراکنش.
- بازگردانی تراکنش در صورت لزوم.
نصب
برای نصب این پکیج از pip استفاده کنید:
pip install seppy
تنظیمات
قبل از استفاده از این پکیج، مقادیر زیر را در فایل تنظیمات Django (settings.py) اضافه کنید:
SEPPY_TERMINAL_ID = "your_terminal_id"
SEPPY_PRIVATE_KEY_ADDRESS = "./private_key.pem"
# SEPPY_BASE_DOMAIN = "proxy.doamin.com" # اختیاری، برای ارسال پیامها به سرور واسط استفاده میشود
استفاده
ابتدا توابع مورد نیاز را وارد کنید:
from seppy import get_payment_link, verify_transaction, reverse_transaction
1. دریافت لینک پرداخت
از این تابع برای تولید لینک پرداخت و هدایت کاربران به درگاه بانک سامان استفاده کنید:
payment_data = get_payment_link(
amount=100000, # مبلغ به ریال
redirect_url="https://yourwebsite.com/payment/callback",
phone_number="09123456789",
res_number="123456"
)
if payment_data["status"] == 1:
print("آدرس پرداخت:", payment_data["url"])
else:
print("خطا:", payment_data["errorDesc"])
2. تایید تراکنش
پس از انجام پرداخت، میتوانید وضعیت تراکنش را با شماره مرجع بررسی کنید:
success, message = verify_transaction("REF123456")
if success:
print("تراکنش با موفقیت تایید شد")
else:
print("خطای تایید:", message)
3. بازگردانی تراکنش
در صورت نیاز، میتوانید تراکنش را با شماره مرجع بازگردانی کنید:
success, message = reverse_transaction("REF123456")
if success:
print("تراکنش با موفقیت بازگردانی شد")
else:
print("خطای بازگردانی:", message)
مدیریت خطاها
هر تابع پیامهای خطای دقیقی را برای کمک به اشکالزدایی ارائه میدهد. حتماً خطاها را به درستی مدیریت کنید.
مجوز
این پکیج تحت مجوز MIT منتشر شده است.
مشارکت
پیشنهادات و درخواستهای اصلاحی استقبال میشود. لطفاً قبل از ایجاد تغییرات عمده، یک Issue باز کنید.
تماس
برای پشتیبانی با ایمیل freecyberhawk@gmail.com تماس بگیرید.
Seppy Payment Gateway
Seppy is a Python package for integrating with Saman Bank (SEP) Payment Gateway. It provides easy-to-use functions for generating payment links, verifying transactions, and reversing transactions.
Features
- Generate a payment link for users to complete their payment.
- Verify a transaction status.
- Reverse a transaction when necessary.
Installation
Install the package using pip:
pip install seppy
Configuration
Before using the package, add the following settings to your Django settings file (settings.py):
SEPPY_TERMINAL_ID = "your_terminal_id"
SEPPY_PRIVATE_KEY_ADDRESS = "./private_key.pem"
# SEPPY_BASE_DOMAIN = "proxy.doamin.com" # Optional, used for sending messages to an intermediary server
Usage
First, import the required functions:
from seppy import get_payment_link, verify_transaction, reverse_transaction
1. Get Payment Link
Use this function to generate a payment link that redirects users to the Saman Bank payment gateway.
payment_data = get_payment_link(
amount=100000, # Amount in Rials
redirect_url="https://yourwebsite.com/payment/callback",
phone_number="09123456789",
res_number="123456"
)
if payment_data["status"] == 1:
print("Payment URL:", payment_data["url"])
else:
print("Error:", payment_data["errorDesc"])
2. Verify a Transaction
After the payment is completed, you can verify the transaction using the reference number.
success, message = verify_transaction("REF123456")
if success:
print("Transaction Verified Successfully")
else:
print("Verification Failed:", message)
3. Reverse a Transaction
If necessary, you can reverse a transaction using its reference number.
success, message = reverse_transaction("REF123456")
if success:
print("Transaction Reversed Successfully")
else:
print("Reversal Failed:", message)
Error Handling
Each function returns meaningful error messages to help with debugging. Make sure to handle exceptions properly.
License
This package is released under the MIT License.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss your ideas.
Contact
For support, contact freecyberhawk@gmail.com.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file seppay-1.0.0.tar.gz.
File metadata
- Download URL: seppay-1.0.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b4c934dc0678c9d1af99ebb5787cfea3b2282cc07761905a82778fae3aedd2f
|
|
| MD5 |
555ea2f08d0f485dbeaa740fbcbd18a9
|
|
| BLAKE2b-256 |
a8afcf1d40253dab651494dd7b0c1f525b41dd13758428b1b11737f4ac6aae2f
|
File details
Details for the file seppay-1.0.0-py3-none-any.whl.
File metadata
- Download URL: seppay-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77f4618e9b98178cf6089432ff82d15d2513e160c89253f483945f25a90f73dd
|
|
| MD5 |
9a63f0f1a2d966cf9f5b7fc6e8524e71
|
|
| BLAKE2b-256 |
42f19b07711e7bba87f528c6b8b6a4c035a1a1e68bdffec85d633dff4c8e78fc
|