我正在尝试使用Stripe API收取申请费。我确信我在请求中遗漏了一些东西。
条纹投诉它需要以下任一项:OAuth密钥,Stripe-Account标头或目标参数。
我正在传递Stripe-Account
标题。
请你指点我正确的方向吗?
这是我的卷曲请求:
curl https://api.stripe.com/v1/charges \
-u sk_test_<key>: \
-H "Stripe-Account: acct_<key>" \
-d amount=2000 -d currency=usd -d capture=true \
-d card=tok_<key> -d description="curl" -d application_fee=48
以下是我得到的回复:
{
"error": {
"type": "invalid_request_error",
"message": "Can only apply an application_fee when the request is made on behalf of another account (using an OAuth key, the Stripe-Account header, or the destination parameter).",
"param": "application_fee"
}
}
答案 0 :(得分:1)
要将我对此问题的体验添加到上述评论中 - 当您在请求中包含申请费时,Stripe预计您将代表关联帐户向客户收费。申请费用是您的平台帐户的金额,作为您提供的服务的费用。
如果Stripe认为正在支付的帐户是平台帐户,则会抛出此错误,因此向同一帐户处理单独的申请费是没有意义的。这种情况可能发生的方法包括在请求中传入您的平台帐号而不是连接的帐号,或者设置为null的目标参数。
解决方案是仔细检查您要付款的帐户是不是您的平台帐户,或者如果收费转到您的平台,则不包括申请费。我会在文档的相关部分添加一个链接,但我不知道这在任何地方都有。
答案 1 :(得分:1)
当我不小心将收件人的带区号设为nil
时,这发生在我身上。
解决方案是确保destination
是有效的条带帐户代码:例如"acct_1HtSHv7fgYVxT5fZ"
Stripe.api_key = 'sk_test_4eC39kjhkhgkhlhj1zdp7dc'
payment_intent = Stripe::PaymentIntent.create({
payment_method_types: ['card'],
amount: @amount_minor_unit,
currency: @currency,
application_fee_amount: 123,
transfer_data: {
destination: @stripe_account,
},
})
Stripe::InvalidRequestError (Can only apply an application_fee_amount when the
PaymentIntent is attempting a direct payment (using an OAuth key or Stripe-Account header)
or destination payment (using `transfer_data[destination]`).)
一旦我有了@stripe_account
(而不是nil
)的正确值,上面的代码就起作用了