jai
jai

Reputation: 451

Application Fee Error - Stripe

When I try to charge an application fee in stripe using the following code

$charge = \Stripe\Charge::create(array(
    'amount' => $amtincents,
    'currency' => 'usd',
    'source' => $stripetoken,
    'application_fee' => $appfee,
    'description' => 'Campaign Donation',
    'metadata' => array("Campaign Id" => $id)
    ), array('stripe_account' => $stripe_connected_user_id)
);

I get the following error

Array
(
    [error] => 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).
)

I have worked in stripe before and last time I did not have this problem. My donation form (for charging the donations I am using stripe) and the page I am performing the stripe operations are in the same site. I am only testing at the moment.

Upvotes: 1

Views: 1391

Answers (1)

Ywain
Ywain

Reputation: 17505

You might be using an older version of Stripe's PHP library that does not support the Stripe-Account header. Ideally, you should be using the latest version (4.4.0 at this time).

If that's not the issue, then it's likely that the $stripe_connected_user_id variable has an empty value. Make sure that the variable contains valid account ID ("acct_...").

Upvotes: 1

Related Questions