14

我正在尝试使用 Stripe API 收取申请费。我确定我在请求中遗漏了一些东西。

Stripe 抱怨它需要以下任何一种: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"
  }
}
4

2 回答 2

10

为了将我对这个问题的经验添加到上面的评论中——当您在请求中包含申请费时,Stripe 预计您将代表关联帐户向客户收费。申请费是应该转到您的平台帐户的金额,作为您提供的服务的费用。

如果 Stripe 认为被支付的账户是平台账户,则会抛出此错误,因此对同一账户单独处理申请费是没有意义的。发生这种情况的方式包括在请求中传入您的平台帐号而不是连接的帐号,或者将目标参数设置为 null。

解决方案是仔细检查您付款的账户是否不是您的平台账户,或者如果费用是通过您的平台收取的,则不包括申请费。我会添加一个指向文档相关部分的链接,但我不知道这在任何地方都有涉及。

于 2017-09-01T16:54:56.060 回答
3

当我不小心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,上面的代码就起作用了

于 2020-11-29T04:15:53.870 回答