在家庭服务器上处理 Stripe 付款时出现禁止 (403) 错误



我是一名 iOS 开发者,希望将 Stripe 支付添加到我的一个应用程序中。我在我的SSL网站上创建了一个页面,该页面托管了以下链接中建议的代码:

https://stripe.com/docs/charges

当我尝试处理付款时,我收到"禁止 (403)"错误。谁能告诉我我可能做错了什么?我的 Ruby 文件中的所有代码如下:

stripe.api_key = "MySecretKeyGoesHere"
token = request.POST['stripeToken']
try:
  charge = stripe.Charge.create(
    amount=1000, # amount in cents, again
    currency="gbp",
    source=token,
    description="Example charge"
  )
except stripe.error.CardError, e:
 # The card has been declined
 pass

在许多主要语言中都有这方面的示例,我很高兴使用其中任何一个,但目前正在尝试Ruby和Python版本。

int amount = 10000;//$100.00int 申请费用 = int(金额 * 0.3);30% 份额

Map<String, Object> chargeParams = new HashMap<String, Object>();
chargeParams.put("amount", amount);
chargeParams.put("currency", "usd");
chargeParams.put("description", "Example charge");
chargeParams.put("customer", customerId); // customerId is the ID of the customer object for the paying person    
chargeParams.put("destination", accountId); // accountId is the ID of the account object for the vendor that should be paid
chargeParams.put("application_fee", applicationFee);
Charge.create(chargeParams);
  1. 还请验证您是否在服务器端设置中使用了正确的实时密钥实时可发布密钥

  2. 检查帐户日志以验证您在 https://dashboard.stripe.com/logs?method=not_get 处理付款时面临的确切问题是什么

  3. 在 Stripe 上验证您的已连接账户

    帐户详细信息:https://dashboard.stripe.com/account/details
    身份验证:https://stripe.com/docs/connect/identity-verification

  4. 文档链接:-
    [1] https://stripe.com/docs/api#create_charge
    [2] https://stripe.com/docs/api#create_transfer
    [3] https://stripe.com/docs/api#create_refund
    [4] https://stripe.com/docs/api#balance_object
    [5] https://stripe.com/docs/connect/payments-fees#charging-directly
    [6] https://stripe.com/docs/connect/authentication#authentication-via-the-stripe-account-header
    [7] https://stripe.com/docs/connect/payments-fees#charging-through-the-platform

我的情况问题与您略有不同,但由于它有 Stripes 文档,我想我会分享我的问题。

这是 Stripe 拥有的 python:

@app.route('/create-payment-intent', methods=['POST'])
def create_payment():
    try:
        data = json.loads(request.data)
        # Create a PaymentIntent with the order amount and currency
        intent = stripe.PaymentIntent.create(
            amount=calculate_order_amount(data['items']),
            currency='eur',
            automatic_payment_methods={
                'enabled': True,
            },
        )
        return jsonify({
            'clientSecret': intent['client_secret']
        })
    except Exception as e:
        return jsonify(error=str(e)), 403

除了他们之外,他们传递了一个 403 错误,而我没有意识到这一点。 所以对我来说,我只是删除了那个异常并通过了 500 错误,直到我更好地理解这个系统!

最新更新