【问题标题】:Python Django, Stripe charge, APIConnectionErrorPython Django、Stripe 收费、APIConnectionError
【发布时间】:2019-01-12 17:26:43
【问题描述】:

我正在尝试在我的网站上实现 Stripe 卡支付,我对他们的 API 相当陌生,查看了他们的示例,我更喜欢为卡号、到期日和 cvc 设置单独的字段,所以我没有使用卡片对象。以下是我的代码:

Javascript:以下是 checkout.html 页面上的最终按钮点击事件,其中生成令牌并设置隐藏输入字段中的各种值,然后提交到 charge.html 页面。

 $("#cardPayBtn").click(function() {
    var options = {
    };
    stripe.createToken(cardNumber, options).then(function(result) {
        if (result.error) {
            var errorElement = document.getElementById('cardErrors');
            errorElement.textContent = result.error.message;
            //alert(errorElement);
        }
        else {
            $("#chargeAmount").val(parseInt($("#totalFee").val())*100);
            $("#chargeCurrency").val("gbp");
            $("#tokenSource").val(JSON.stringify(result.token));
            $("#cardPaymentForm").submit();
        }
    });
});

在chargeView.py文件中,post方法用于处理checkout.html页面的form-post动作,并创建如下费用;

def post(self, request):

    token = request.POST["tokenSource"]
    chargeAmount = request.POST['chargeAmount']
    chargeCurrency = request.POST['chargeCurrency']


    charge = stripe.Charge.create(
        amount=chargeAmount,
        currency=chargeCurrency,
        description='Example charge',
        source=json.loads(token),
    )

    return render(request, self.template)

我查了,有金额、货币和来源的值;但是,收费并没有通过以下错误;

APIConnectionError at /photos/charge/
Unexpected error communicating with Stripe.  If this problem persists,
let us know at support@stripe.com.

(Network error: SSLError: ("bad handshake: SysCallError(-1, 'Unexpected EOF')",))

经过几个小时的搜索,我有点无能为力,感谢任何帮助或建议,谢谢!

吉姆

【问题讨论】:

    标签: python django stripe-payments


    【解决方案1】:

    我自己找到了答案,这是由于公司的OpenSSL认证过时,如果你的openSSL版本低于1.0.xx你需要更新它,我使用的是MAC OS,所以可以通过以下方式更新brew,然后安装新版本的Python并将SSL链接到新的Python,requirement.txt下的所有依赖都需要重新安装。

    【讨论】:

      猜你喜欢
      • 2017-04-04
      • 1970-01-01
      • 2015-07-23
      • 1970-01-01
      • 1970-01-01
      • 2018-06-22
      • 2015-11-08
      • 2012-04-19
      • 2018-06-21
      相关资源
      最近更新 更多