Skip to main content

common utils of opps sdk

Project description

opps sdk 工具类

安装

远程下载并安装:

pip install opps-sdk

简介

为了提高客户接入的便捷性,本系统提供 SDK 方式介入,使用本 SDK 将极大的简化开发者的工作,开发者将无需考虑通信、签名、验签等,只需要关注业务参数的输入。

使用方法

  • 初始化SDK

未入网前,可使用以下测试商户参数进行开发测试

import opps_sdk

public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlfkjf2F4xsEsWFwVAjjOoqhEh6u0dMl2Z1xsTL/ytzyGRaMRXJUr47zdwpI6+3OZE+IlJwECp8T0jdFzml5vP8TWENQ4OMFt7aZ1Z/F7F9lpvMAQ+4WvucQ5ypRoLG/md0ZGnYOTb4Vnc8Pc3/fsd5UxD/nzOu5Lf4XU04FG1M0kYyjr4KelYvXPmSAVEIvik7m9kaX4oif/2RSyQhlw6gEO52TzWHrH+5w/PyTGA1xaIBAD9H7hB83nwydl1SW8u1WXiD6KTZmZ+bhi2GjeJ8KJgqBUNbN19g0DHeyHVxUAfSzOif4/ETrKw3JRjOItMpRWnfx6tcU9PmNgWx3ZhwIDAQAB"
private_key = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCiWHVf8ygNPn927zTLeqfdhww/VEIs53a59jOseAmrBwodZIKYeKuUBArEKJeTzT5ny4OG7H2COfglRYV3EO7rZa6u1IoltnSKg7xPzk/ENTPDuC5uemiJ/xIAYrjAN2ThrkjGBFwcteAraoUxs1ac7AlrnyyrKYse2HK1uq+1xowTIhXLmlIg9o07JYbOQrQyuG48u1TjwZLxjOG96DnWOYn0mXmJC8OlAoDtIUos6eJawsEP3s1XyTDiCRQaO30k6pAbMcCSaRLtpEJPB3Yk7OjNybm/TyTsDXiMDlTsZtnPfJeTmkGcLg5KkZQ27Qv9nA5gYIhT7itPj6LaVL6zAgMBAAECggEAGSuf3yWDEzKabqU9yUKWHjmfA36b1/x3IvPyJQ5jaVnpDo+T0/H5oDRUOv+UKL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xVcF5IlqfvKwn5Wpb6wnzeUj3xHOnJevGxpHptSYDsK7V891GQCb4yRI1E0sy9hFOO4XtINw27GiMHBp8ag=="
sys_id = "6666000018269234"
product_id = "SPIN"
opps_sdk.OppsClient.mer_config = opps_sdk.MerConfig(private_key, public_key, sys_id, product_id)

参数说明:

参数

中文名

public_key

公钥

private_key

私钥

sys_id

系统号

product_id

产品号

  • 接口调用

    • 以支付宝支付为例,根据接口文档说明,构建请求参数体

    required_params = {
        "huifu_id": "6666000106120347",
        "trade_type": "A_NATIVE",
        "trans_amt": "1.00",
        "req_date": datetime.datetime.now().strftime('%Y%m%d'),
        "req_seq_id":generate_mer_order_id()
        "merOrdId": str(int(time.time())) + str(random.randint(100000, 9999999)),
        "goods_desc": "goods_desc",
        "notify_url": "virgo://http://www.xxx.com",
    }
    • 调用接口

    url = "https://spin.cloudpnr.com/top/trans/pullPayInfo"
    result = opps_sdk.request_post(url, required_params)
  • 其他调用方式

除了通用的基于 BsPayClient 来调用接口之外,SDK 还针对部分重要交易接口提供了一种更便捷的方法,

将一些默认、非必须、无需特别关注的参数传递,以及数据脱敏、加密处理进行了封装。

使用方法如下所示:

response = opps_sdk.ScanPayment.create(huifu_id=huifu_id,
                                       trade_type=trade_type,
                                       trans_amt=amount,
                                       goods_desc="goods_desc",
                                       notify_url="virgo://http://www.xxx.com",
                                       **extra_info)
print(response)

现支持模块功能列表如下

  • 聚合扫码 ScanPayment
    • 订单创建 - create

    • 订单查询 - query

    • 退款创建 - refund

    • 退款查询 - refund_query

    • 反扫 - scan_pay

    • 关单 - close

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

opps-sdk-0.0.10.tar.gz (15.7 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page