Skip to main content

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

seppay-1.0.3.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

seppay-1.0.3-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file seppay-1.0.3.tar.gz.

File metadata

  • Download URL: seppay-1.0.3.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for seppay-1.0.3.tar.gz
Algorithm Hash digest
SHA256 810342329e2c12d7708030bad5c1bd894643b7da3fc219d02c01fa04a9004581
MD5 87cd83b6752cb37851cd05f21602d975
BLAKE2b-256 0c60b9001d14f97132b3141d98ef521214ce290229aaed4a011380cafcfae6a6

See more details on using hashes here.

File details

Details for the file seppay-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: seppay-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for seppay-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b2bd6a7de8a5478e043b6059eb68cf18b002d2ae2593c3dbc52426262561566a
MD5 29d466fcc0f3efeb21af9caf2672a1ef
BLAKE2b-256 34dd5b7837a5e1c1b424b093a5873bd86b29f65c98fe1edeb858984e13daddf4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page