Stripe API error when passing application_fee

前端 未结 2 900
遥遥无期
遥遥无期 2021-01-11 11:47

I am trying to collect an application fee using the Stripe API. I am sure I am missing something in the request.

Stripe complaints that it needs either of these: OA

2条回答
  •  情话喂你
    2021-01-11 12:28

    This happened to me when I accidentally had a nil value for the recipient's stripe account number.

    The solution was to make sure destination was a valid stripe account code: e.g. "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]`).)
    
    

    Once I had the correct value for @stripe_account (instead of nil), the above code worked

提交回复
热议问题