Skip to main content

Easy Recon SDK for Python

Project description

Easy Recon SDK for Python

Easy Recon 是一个轻量级的对账 SDK,支持实时对账和定时对账策略,旨在帮助开发者快速集成标准化的核账能力。

核心特性

  • 实时对账: 在支付和通知及退款发生时立即进行对账,保证数据一致性。
  • 定时对账: 支持后台定时任务触发的离线核账,作为兜底机制。
  • 退款支持: 支持全额退款和部分退款的核账逻辑。
  • 数据库无关: 基于标准 SQL 构建,兼容 MySQL 和 PostgreSQL。
  • 自动建表: 支持 SDK 初始化时自动创建所需的数据库表结构。

安装

pip install easy-recon-sdk

快速开始

1. 初始化配置

初始化 SDK 并配置数据库连接信息。建议开启自动建表功能以便快速上手。

from config.recon_config import ReconConfig
from core.easy_recon_factory import EasyReconFactory

config = ReconConfig(
    db_host="localhost",
    db_port=3306,
    db_user="root",
    db_password="password",
    db_name="easy_recon",
    auto_create_table=True # 首次运行时自动创建表
)

# 创建 API 客户端实例
easy_recon = EasyReconFactory.create(config)

2. 订单对账 (Reconcile Order)

在发起支付或分账请求时调用:

from entity.recon_order_split_sub import ReconOrderSplitSub

# 定义分账明细
split_subs = [
    ReconOrderSplitSub(
        sub_order_no="SUB_001",
        merchant_id="M_001",
        split_amount=100.00
    )
]

# 执行实时对账
success = easy_recon.recon_order(
    order_no="ORD_20231027001",
    pay_amount=100.00,
    platform_income=0.00,
    pay_fee=0.00,
    split_details=split_subs,
    pay_status=1,   # 1: 成功
    split_status=1, # 1: 成功
    notify_status=0 # 0: 处理中
)

if success:
    print("对账记录创建成功")
else:
    print("对账记录创建失败")

3. 处理通知 (Handle Notification)

当收到下游(如网关或子商户系统)的异步通知时调用:

easy_recon.recon_notify(
    order_no="ORD_20231027001",
    merchant_id="M_001",
    notify_url="http://callback.url",
    notify_status=1, # 1: 成功
    notify_result="Success"
)

4. 退款对账 (Reconcile Refund)

处理退款业务时调用:

easy_recon.recon_refund(
    order_no="ORD_20231027001",
    refund_amount=50.00,
    refund_time=datetime.now(),
    refund_status=1, # 1: 成功
    split_details=...
)

环境要求

  • Python 3.7+
  • MySQL 或 PostgreSQL 数据库

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

easy_recon_sdk-1.0.1.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

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

easy_recon_sdk-1.0.1-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

Details for the file easy_recon_sdk-1.0.1.tar.gz.

File metadata

  • Download URL: easy_recon_sdk-1.0.1.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for easy_recon_sdk-1.0.1.tar.gz
Algorithm Hash digest
SHA256 8eda6ccb2b1507b64451a478b61543818e2d2b3d5987df7ce9b322b42ab705a4
MD5 990e2990c5768cb3f0e4611077adc17c
BLAKE2b-256 c608004943758640d15ad97dcb8b2642a3c711b8d741f3440dcd31c2e4ca5587

See more details on using hashes here.

File details

Details for the file easy_recon_sdk-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: easy_recon_sdk-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 2.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for easy_recon_sdk-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 73a10733c86f753d43f5df5cd5793e7a9f278ec74e0b6c470fed4f67c9daaa04
MD5 d0e454b4d56cc3457b79382434d59d43
BLAKE2b-256 908305229008cb97af405f206c5266a4cfa90aa1bba58a6dccb718fb3631ecfe

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