【问题标题】:Stripe API error when passing application_fee传递 application_fee 时出现条带 API 错误
【发布时间】:2015-11-01 18:20:52
【问题描述】:

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

需要以下任何一项的条带投诉:OAuth 密钥、Stripe-Account 标头或目标参数。

我正在传递Stripe-Account 标头。

能否请您指出正确的方向?

这是我的 curl 请求:

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"
  }
}

【问题讨论】:

  • 您是否在此处传递自己的帐户 ID 作为平台?如果是这样,您可以尝试将新帐户连接到平台吗?
  • 99% 的情况下,当您尝试向自己的平台收费并在 Stripe-Account 标头中传递平台的帐户 ID acct_XXX 时,就会发生该错误。
  • @koopajah 这也是我的问题的原因。我在 Stripe 上创建了一个新帐户(使用新的电子邮件地址),然后就没事了。
  • 这是一个常见的测试环境问题,绝对应该在 Stripe 文档中解释...
  • 我也遇到了这个问题,是我和平台和客户使用同一个账号造成的。

标签: stripe-payments stripe-connect


【解决方案1】:

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

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

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

【讨论】:

  • 我的目的地为空!先生,你救了我。
【解决方案2】:

当我不小心为收件人的条带帐号设置了 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),上面的代码就可以工作了

【讨论】:

    猜你喜欢
    • 2018-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-14
    • 2022-07-02
    • 2019-03-04
    • 2014-09-17
    • 2018-12-28
    相关资源
    最近更新 更多