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
To add my experience of this issue to the comments above – when you include an application fee in the request, Stripe expects that you will be charging a customer on behalf of a connected account. The application fee is the amount that should go to your platform account, as your fee for the service you provide.
Stripe throws this error if it believes that the account being paid is the platform account, and therefore it makes no sense to process a separate application fee to the same account. Ways this can happen include passing in your platform account number instead of a connected account number in the request, or a destination parameter that is set to null.
The solution is to double check the account you are making payment to is not your platform account, or not include the application fee if the charge is going to your platform. I would add a link to the relevant part of the documentation, but I'm not aware of this being covered anywhere.
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