Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stripe API error when passing application_fee

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: OAuth key, the Stripe-Account header, or the destination parameter.

I am passing in the Stripe-Account header.

Here is my curl request:

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

Here is the response I get:

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

What can I try next?

like image 968
Moon Avatar asked Aug 09 '15 22:08

Moon


People also ask

What does Stripe payment error mean?

The customer must use another card or method of payment. processing_error. An error occurred while processing the card. The payment needs to be attempted again. If it still can't be processed, try again later.

What does errors Code Card_decline_rate_limit_exceeded mean?

card_decline_rate_limit_exceeded. This card has been declined too many times. You can try to charge this card again after 24 hours. We suggest reaching out to your customer to make sure they have entered all of their information correctly and that there are no issues with their card.

Why did Stripe charge me an application fee?

If you're using free pricingIf a donor leaves a tip, this will appear as an “application fee” on the transaction in your Stripe dashboard.

Can't connect to Stripe Please retry?

This looks like an issue either with your server config or with network issues that prevent it from connecting to Stripe. Brief googling suggests you try to restart Apache\Nginx and PHP on your server. If that isn't helping, try to update openssl library.


2 Answers

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.

like image 195
LA24 Avatar answered Oct 24 '22 18:10

LA24


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

like image 3
stevec Avatar answered Oct 24 '22 18:10

stevec