簡體   English   中英

傳遞 application_fee 時出現 Stripe API 錯誤

[英]Stripe API error when passing application_fee

我正在嘗試使用 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"
  }
}

將我對此問題的經驗添加到上述評論中 - 當您在請求中包含申請費時,Stripe 預計您將代表已連接的帳戶向客戶收費。 申請費是應進入您的平台賬戶的金額,作為您提供服務的費用。

如果 Stripe 認為支付的賬戶是平台賬戶,則拋出此錯誤,因此對同一賬戶處理單獨的申請費是沒有意義的。 發生這種情況的方式包括在請求中傳遞您的平台帳號而不是連接的帳號,或者將目標參數設置為 null。

解決方案是仔細檢查您付款的帳戶是否不是您的平台帳戶,或者如果費用將轉到您的平台,則不包括申請費。 我會添加指向文檔相關部分的鏈接,但我不知道這在任何地方都有涉及。

當我不小心將收件人的條帶帳號的值設為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 ),上面的代碼就起作用了

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM