申请费错误 - 条纹

Application Fee Error - Stripe

当我尝试使用以下代码在 stripe 中收取申请费时

$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)
);

我收到以下错误

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).
)

之前在stripe工作过,上次没有出现这个问题。我的捐赠表格(用于收取我正在使用条纹的捐赠)和我正在执行条纹操作的页面位于同一站点中。我目前只是在测试。

您可能使用的是 Stripe's PHP library that does not support the Stripe-Account header 的旧版本。理想情况下,您应该使用最新版本(此时为 4.4.0)。

如果这不是问题所在,则可能是 $stripe_connected_user_id 变量的值为空。确保变量包含有效的帐户 ID ("acct_...")。