gpt4 book ai didi

python - 属性错误: 'NoneType' object has no attribute 'wrap_socket' in GAE using Braintree

转载 作者:太空宇宙 更新时间:2023-11-03 18:10:33 25 4
gpt4 key购买 nike

我正在 Google App Engine 中测试一个嵌入 Braintree 平台的应用。我正在使用他们的代码进行此测试来处理虚构的交易。在我的 html 中,我有一个表单,提交后它将其信息路由到下面的“/create_transaction”。服务器代码是:

@app.route("/create_transaction", methods=["POST"])
def create_transaction():
result = braintree.Transaction.sale({
"amount": "1000.00",
"credit_card": {
"number": request.form["number"],
"cvv": request.form["cvv"],
"expiration_month": request.form["month"],
"expiration_year": request.form["year"]
},
"options": {
"submit_for_settlement": True
}
})
if result.is_success:
return "<h1>Success! Transaction ID: {0}</h1>".format(result.transaction.id)
else:
return "<h1>Error: {0}</h1>".format(result.message)

浏览器不会返回结果,而是呈现内部服务器错误 500。回溯如下:

ERROR    2014-09-26 03:08:13,852 app.py:1423] Exception on /create_transaction [POST]
Traceback (most recent call last):
File "/home/manuel/Google/braintree_app/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/home/manuel/Google/braintree_app/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/manuel/Google/braintree_app/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/manuel/Google/braintree_app/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/home/manuel/Google/braintree_app/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/manuel/Google/braintree_app/app.py", line 40, in create_transaction
"submit_for_settlement": True
File "/home/manuel/Google/braintree_app/braintree/transaction.py", line 302, in sale
return Transaction.create(params)
File "/home/manuel/Google/braintree_app/braintree/transaction.py", line 397, in create
return Configuration.gateway().transaction.create(params)
File "/home/manuel/Google/braintree_app/braintree/transaction_gateway.py", line 33, in create
return self._post("/transactions", {"transaction": params})
File "/home/manuel/Google/braintree_app/braintree/transaction_gateway.py", line 137, in _post
response = self.config.http().post(url, params)
File "/home/manuel/Google/braintree_app/braintree/util/http.py", line 49, in post
return self.__http_do("POST", path, params)
File "/home/manuel/Google/braintree_app/braintree/util/http.py", line 71, in __http_do
raise e
AttributeError: 'NoneType' object has no attribute 'wrap_socket'

为什么 GAE 会抛出此异常?

最佳答案

我在布伦特里工作。如果您需要更多帮助,您可以随时get in touch with our support team .

这似乎是 problem with certain versions of urllib3 / requests (a Braintree dependency) on GAE .

尝试将其添加到您的 app.yaml 文件中:

libraries:
- name: ssl
version: latest

并确保您已为应用程序启用计费功能。

如果这不能解决问题,您可以查看上面链接的 github 问题以获取更多信息。

关于python - 属性错误: 'NoneType' object has no attribute 'wrap_socket' in GAE using Braintree,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26051462/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com