0
votes

I am trying to take an application fee on a stripe invoice that I send on behalf of a connected stripe standard account. However, I cannot figure out how to create the invoice either A) on the stripe standard account, then take a fee from it B) create the invoice on my platform account and use the application fee to get paid.

The closest documentation I can find is https://stripe.com/docs/connect/subscriptions#invoices. My code below returns this error "No such invoice: in_1E3c6TIMPzVAHwIq4ndgMsBV".

$item=\Stripe\InvoiceItem::create([
    "customer" => "cus_ETsE8pqOpNnmdB",
    "amount" => 2500,
    "currency" => "usd",
    "description" => "One-time setup fee"
]);
$newInvoice=\Stripe\Invoice::create([
    "customer" => "cus_ETsE8pqOpNnmdB",
]);
$invoice = \Stripe\Invoice::retrieve(
    $newInvoice->id,
    ["stripe_account" => "acct_1AtpdCAO1KumKYA2"]
);
$invoice->application_fee = 100; // amount in cents
$invoice->save();

Expected results are sending an invoice branded that is branded to the connected standard account, and when it is paid, my platform account receives the fee.

1
Since you are using connect and creating Invoice on behalf of the Connected Account, you will need to make use of the Stripe Account header (["stripe_account" => "{CONNECTED_STRIPE_ACCOUNT_ID}"]) and use cus_xx in the connected account. In this case, you will be able to set the application_feewsw
@wsw That did it! If you add as an answer I'll accept it. For anyone looking, here is the code to make it work: $item=\Stripe\InvoiceItem::create([ "customer" => "cus_EWqTMbhPa537vV", "amount" => 2500],["stripe_account" => "acct_1AtpdCAO1KumKYA2"]); $newInvoice=\Stripe\Invoice::create([ "customer" => "cus_EWqTMbhPa537vV", ],["stripe_account" => "acct_1AtpdCAO1KumKYA2"]); $invoice = \Stripe\Invoice::retrieve( $newInvoice->id, ["stripe_account" => "acct_1AtpdCAO1KumKYA2"] ); $invoice->application_fee = 100; // amount in cents $invoice->save();Stein Christensen

1 Answers

1
votes

Thanks Stein,

For anyone looking, here is the code to make it work:

$item = \Stripe\InvoiceItem::create(["customer" => "cus_EWqTMbhPa537vV", "amount" => 2500], ["stripe_account" => "acct_1AtpdCAO1KumKYA2"]);
$newInvoice = \Stripe\Invoice::create(["customer" => "cus_EWqTMbhPa537vV"], ["stripe_account" => "acct_1AtpdCAO1KumKYA2"]);
$invoice = \Stripe\Invoice::retrieve($newInvoice->id, ["stripe_account" => "acct_1AtpdCAO1KumKYA2"]);
$invoice->application_fee = 100; // amount in cents 
$invoice->save();