alipay-sdk


Namealipay-sdk JSON
Version 2.0.0 PyPI version JSON
download
home_pagehttps://github.com/block-cat/alipay_sdk
SummaryAliPay Python SDK
upload_time2025-08-10 09:26:13
maintainerNone
docs_urlNone
authorblackcat
requires_pythonNone
licenseGNU
keywords alipay sdk
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![alipay](alipay.png)

[![Build Status](https://travis-ci.org/block-cat/alipay_sdk.svg?branch=master)](https://travis-ci.org/block-cat/alipay_sdk)
[![Coverage Status](https://coveralls.io/repos/github/block-cat/alipay_sdk/badge.svg?branch=master)](https://coveralls.io/github/block-cat/alipay_sdk?branch=master)
![PyPI](https://img.shields.io/pypi/v/alipay_sdk)
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/block-cat/alipay_sdk)


支付宝第三方 Python SDK

# About

由于官方sdk有很大的嫌疑是从java拷贝过来的,因此,重新起了这个项目

### Main functionalities

* 支付功能
* 口碑功能

> 由于沙箱环境缺少口碑权限支持,仅定义了接口功能,未进行完整的单元测试

更多功能正在开发中...

### Requirements

python >= 3.6

### Install

```
pip install alipay_sdk
```

### How to use

首先要到[支付宝开放平台](https://openhome.alipay.com/)注册一个开发者账号,并创建一个应用并获取应用ID(AppID)。

通知需要配置应用密钥、商户密钥和支付宝公钥,详情参考[官方文档](https://docs.open.alipay.com/291/105971/)

假设我们的AppId是12345,商户密钥文件是1.txt,支付宝公钥是2.txt
那么我们的可以这么使用:

```python
with open("1.txt", "r") as f:
    private_key = RSA.importKey(f.read())
with open("2.txt", "r") as f:
    publick_key = RSA.importKey(f.read())
alipay = Alipay("12345",private_key,private_key,
    sign_type="rsa2", ali_public_key=publick_key)
```

> 0.0.3 版本起,支持直接传入密钥文本

注意:支付宝公钥等可以使用官方提供的工具生成,但是对于非java平台的语言,需要补齐密钥格式中的格式头:

```txt
-----BEGIN RSA PRIVATE KEY-----
..........
-----END RSA PRIVATE KEY-----
```

接下来就可以使用sdk来调用接口了,以统一下单接口为例:

```python
res = alipay.pay.trade_create(self.alipay.pay.trade_create(
        "5489763229687797", 1.01, "测试统一下单", buyer_id="208810217951438X"))
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/block-cat/alipay_sdk",
    "name": "alipay-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "alipay sdk",
    "author": "blackcat",
    "author_email": "kfx2007@163.com",
    "download_url": "https://files.pythonhosted.org/packages/dd/aa/02761f1f0f4727ea1c936c00e53b6897b6e3ece25f8f7b67aca0db6df634/alipay_sdk-2.0.0.tar.gz",
    "platform": null,
    "description": "![alipay](alipay.png)\n\n[![Build Status](https://travis-ci.org/block-cat/alipay_sdk.svg?branch=master)](https://travis-ci.org/block-cat/alipay_sdk)\n[![Coverage Status](https://coveralls.io/repos/github/block-cat/alipay_sdk/badge.svg?branch=master)](https://coveralls.io/github/block-cat/alipay_sdk?branch=master)\n![PyPI](https://img.shields.io/pypi/v/alipay_sdk)\n![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/block-cat/alipay_sdk)\n\n\n\u652f\u4ed8\u5b9d\u7b2c\u4e09\u65b9 Python SDK\n\n# About\n\n\u7531\u4e8e\u5b98\u65b9sdk\u6709\u5f88\u5927\u7684\u5acc\u7591\u662f\u4ecejava\u62f7\u8d1d\u8fc7\u6765\u7684\uff0c\u56e0\u6b64\uff0c\u91cd\u65b0\u8d77\u4e86\u8fd9\u4e2a\u9879\u76ee\n\n### Main functionalities\n\n* \u652f\u4ed8\u529f\u80fd\n* \u53e3\u7891\u529f\u80fd\n\n> \u7531\u4e8e\u6c99\u7bb1\u73af\u5883\u7f3a\u5c11\u53e3\u7891\u6743\u9650\u652f\u6301\uff0c\u4ec5\u5b9a\u4e49\u4e86\u63a5\u53e3\u529f\u80fd\uff0c\u672a\u8fdb\u884c\u5b8c\u6574\u7684\u5355\u5143\u6d4b\u8bd5\n\n\u66f4\u591a\u529f\u80fd\u6b63\u5728\u5f00\u53d1\u4e2d...\n\n### Requirements\n\npython >= 3.6\n\n### Install\n\n```\npip install alipay_sdk\n```\n\n### How to use\n\n\u9996\u5148\u8981\u5230[\u652f\u4ed8\u5b9d\u5f00\u653e\u5e73\u53f0](https://openhome.alipay.com/)\u6ce8\u518c\u4e00\u4e2a\u5f00\u53d1\u8005\u8d26\u53f7\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u5e94\u7528\u5e76\u83b7\u53d6\u5e94\u7528ID(AppID)\u3002\n\n\u901a\u77e5\u9700\u8981\u914d\u7f6e\u5e94\u7528\u5bc6\u94a5\u3001\u5546\u6237\u5bc6\u94a5\u548c\u652f\u4ed8\u5b9d\u516c\u94a5\uff0c\u8be6\u60c5\u53c2\u8003[\u5b98\u65b9\u6587\u6863](https://docs.open.alipay.com/291/105971/)\n\n\u5047\u8bbe\u6211\u4eec\u7684AppId\u662f12345\uff0c\u5546\u6237\u5bc6\u94a5\u6587\u4ef6\u662f1.txt\uff0c\u652f\u4ed8\u5b9d\u516c\u94a5\u662f2.txt\n\u90a3\u4e48\u6211\u4eec\u7684\u53ef\u4ee5\u8fd9\u4e48\u4f7f\u7528\uff1a\n\n```python\nwith open(\"1.txt\", \"r\") as f:\n    private_key = RSA.importKey(f.read())\nwith open(\"2.txt\", \"r\") as f:\n    publick_key = RSA.importKey(f.read())\nalipay = Alipay(\"12345\",private_key,private_key,\n    sign_type=\"rsa2\", ali_public_key=publick_key)\n```\n\n> 0.0.3 \u7248\u672c\u8d77\uff0c\u652f\u6301\u76f4\u63a5\u4f20\u5165\u5bc6\u94a5\u6587\u672c\n\n\u6ce8\u610f\uff1a\u652f\u4ed8\u5b9d\u516c\u94a5\u7b49\u53ef\u4ee5\u4f7f\u7528\u5b98\u65b9\u63d0\u4f9b\u7684\u5de5\u5177\u751f\u6210\uff0c\u4f46\u662f\u5bf9\u4e8e\u975ejava\u5e73\u53f0\u7684\u8bed\u8a00\uff0c\u9700\u8981\u8865\u9f50\u5bc6\u94a5\u683c\u5f0f\u4e2d\u7684\u683c\u5f0f\u5934\uff1a\n\n```txt\n-----BEGIN RSA PRIVATE KEY-----\n..........\n-----END RSA PRIVATE KEY-----\n```\n\n\u63a5\u4e0b\u6765\u5c31\u53ef\u4ee5\u4f7f\u7528sdk\u6765\u8c03\u7528\u63a5\u53e3\u4e86\uff0c\u4ee5\u7edf\u4e00\u4e0b\u5355\u63a5\u53e3\u4e3a\u4f8b\uff1a\n\n```python\nres = alipay.pay.trade_create(self.alipay.pay.trade_create(\n        \"5489763229687797\", 1.01, \"\u6d4b\u8bd5\u7edf\u4e00\u4e0b\u5355\", buyer_id=\"208810217951438X\"))\n```\n",
    "bugtrack_url": null,
    "license": "GNU",
    "summary": "AliPay Python SDK",
    "version": "2.0.0",
    "project_urls": {
        "Homepage": "https://github.com/block-cat/alipay_sdk"
    },
    "split_keywords": [
        "alipay",
        "sdk"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ddaa02761f1f0f4727ea1c936c00e53b6897b6e3ece25f8f7b67aca0db6df634",
                "md5": "cfbcc4e45f6e2174cb129a4f037ff4d2",
                "sha256": "6305541f0acc77139c4e444483fcd6bbee4ab17f9c22dd9c1215f2eee17dd612"
            },
            "downloads": -1,
            "filename": "alipay_sdk-2.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "cfbcc4e45f6e2174cb129a4f037ff4d2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 29830,
            "upload_time": "2025-08-10T09:26:13",
            "upload_time_iso_8601": "2025-08-10T09:26:13.066419Z",
            "url": "https://files.pythonhosted.org/packages/dd/aa/02761f1f0f4727ea1c936c00e53b6897b6e3ece25f8f7b67aca0db6df634/alipay_sdk-2.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-10 09:26:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "block-cat",
    "github_project": "alipay_sdk",
    "github_not_found": true,
    "lcname": "alipay-sdk"
}
        
Elapsed time: 1.67763s