我正在以沙盒模式实现 Stripe 支付网关。我已经嵌入了结帐流程并创建了 token ,服务器使用它来调用 API 来创建费用。
使用的API版本是:stripe.api_version = '2017-06-05'
charge = stripe.Charge.create(
amount=1000,
currency="usd",
description="Example charge",
source=token,
)
当我调用这个 Charge create api 时,我收到以下错误:
用于在本地机器中创建费用的 strip API 是:
POST: https://api.stripe.com/v1/charges
我怎样才能让它在我的本地机器上工作?
但是当我将它部署到 AWS 时,它在那里工作。
最佳答案
您的本地 Python 解释器链接到不支持 TLS 1.2 的旧版 OpenSSL。您可以通过以下方式检查:
$ python -c "import ssl; print(ssl.OPENSSL_VERSION)"
您需要 OpenSSL 1.0.1 或更新版本才能使用 TLS 1.2。
如果您使用的是 OS X,解决此问题的最简单方法是使用 Homebrew 包管理器:
$ brew update && brew upgrade && brew install openssl && brew install python
如果您使用的是 Python 3,请将上面命令行末尾的
python
替换为 python3
。关于python - 从我的本地环境调用 strip 收费 API 时出现 TLS 问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47904852/