Skip to content

Commit

Permalink
Do encryption/decryption with
Browse files Browse the repository at this point in the history
  • Loading branch information
fzlee committed Mar 16, 2018
1 parent 6a30b8a commit 842ea1a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 26 deletions.
22 changes: 8 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,15 @@ Or you may just follow this manual if not.
## GUIDE
#### Installation

```bash
# for users upgraded from 1.3.0, uninstall pycrypto first
pip uninstall pycrypto

```
# installation
pip install python-alipay-sdk --upgrade
```

#### cert generation
```bash
openssl
OpenSSL> genrsa -out app_private_key.pem 2048 # the private key file
# openssl
OpenSSL> genrsa -out app_private_key.pem 2048 # the private key file
OpenSSL> rsa -in app_private_key.pem -pubout -out app_public_key.pem # export public key
OpenSSL> exit
```
Expand Down Expand Up @@ -129,7 +126,7 @@ def api_alipay_xxx(self, out_trade, total_amount, **kwargs):
# Pay via WAP, open this url in your browser: https://openapi.alipay.com/gateway.do? + order_string
order_string = alipay.api_alipay_trade_wap_pay(
out_trade_no="20161112",
total_amount="0.01",
total_amount=0.01,
subject=subject,
return_url="https://example.com",
notify_url="https://example.com/notify" # this is optional
Expand All @@ -141,7 +138,7 @@ def api_alipay_xxx(self, out_trade, total_amount, **kwargs):
# Pay via App,just pass order_string to your Android or iOS client
order_string = alipay.api_alipay_trade_app_pay(
out_trade_no="20161112",
total_amount="0.01",
total_amount=0.01,
subject=subject,
notify_url="https://example.com/notify" # this is optional
)
Expand Down Expand Up @@ -343,14 +340,11 @@ Or you may do test manually in this way, `debug=True` will direct your request t
alipay = AliPay(..., debug=True)
```

## Thanks to
* John60676
* EveryIsNormal
* varwey
* Macuilxochitl

## Changelog

#### 2018-03-16(version 1.7)
* Do encryption/decryption with `pycryptodomex`,which is not conflict with Pycrypto (many thanks to fakepoet)

#### 2018-01-23(version 1.6)
* initialize Alipay instance with key string

Expand Down
17 changes: 6 additions & 11 deletions README.zh-hans.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
#### 安装

```bash
# 从 1.3.0升级上来的用户, 请先卸载pycrypto:
pip uninstall pycrypto
# 安装python-alipay-sdk
pip install python-alipay-sdk --upgrade
```
Expand All @@ -42,7 +40,7 @@ OpenSSL> rsa -in app_private_key.pem -pubout -out app_public_key.pem # 导出公
OpenSSL> exit
```

在支付宝上下载的公钥是一个字符串,你需要在文本的首尾添加标记位(-----BEGIN PUBLIC KEY-----和-----END PUBLIC KEY-----) 才能正常使用
在支付宝上下载的公钥是一个字符串,你需要在文本的首尾添加标记位 (-----BEGIN PUBLIC KEY-----和-----END PUBLIC KEY-----) 才能正常使用
证书的格式你可以参考[这里](https://github.com/fzlee/alipay/blob/master/tests/certs/ali/ali_public_key.pem)

#### 初始化
Expand Down Expand Up @@ -139,7 +137,7 @@ alipay.api_alipay_trade_page_pay(
# 手机网站支付,需要跳转到https://openapi.alipay.com/gateway.do? + order_string
order_string = alipay.api_alipay_trade_wap_pay(
out_trade_no="20161112",
total_amount="0.01",
total_amount=0.01,
subject=subject,
return_url="https://example.com",
notify_url="https://example.com/notify" # 可选, 不填则使用默认notify url
Expand All @@ -151,7 +149,7 @@ alipay.api_alipay_trade_page_pay(
# App支付,将order_string返回给app即可
order_string = alipay.api_alipay_trade_app_pay(
out_trade_no="20161112",
total_amount="0.01",
total_amount=0.01,
subject=subject,
notify_url="https://example.com/notify" # 可选, 不填则使用默认notify url
)
Expand Down Expand Up @@ -351,14 +349,11 @@ python -m unittest discover
alipay = AliPay(..., debug=True)
```

## 感谢(排名不分先后)
* John60676
* EveryIsNormal
* varwey
* Macuilxochitl

## Changelog

#### 2018-03-16(version 1.7)
* 使用`pycryptodomex`进行底层加解密运算,避免和旧的加密库冲突(感谢fakepoet)

#### 2018-01-23(version 1.6)
* 支持传入密钥字符串初始化Alipay对象

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def alipay_test_suite():

setup(
name="python-alipay-sdk",
version="1.6.0",
version="1.7.0",
author="fzlee",
author_email="[email protected]",
description="Python SDK for AliPay, RSA is the only sign method we support",
Expand Down

0 comments on commit 842ea1a

Please sign in to comment.