I am using Stripe Connect for my platform. My platform is responsible to ensure the appropriate amount of tax is charged, collected and paid out to the relevant tax authority. My problem is Stripe calculates the tax correctly, charges it to the customer correctly…but instead of transferring the collected tax to the Platform Account with the Application Fee, it transfers the collected tax to the Connected Account.
Here is my code to set up a Checkout Session
require APPPATH .'third_party/stripe-php/init.php'; // Include the Stripe PHP bindings library
\Stripe\Stripe::setApiKey($this->CI->config->item('stripe_api_key')); // Set API key
$reg_id = $this->input->post('reg_id');
$stripe_price_id = $this->input->post('stripe_price_id'); //this gets connected account number 'inst' is creator id value hidden in button
$stripeAccount = $this->Profiles_model->fetch_stripe_account_by_id($reg_id);
$email = $this->session->userdata('email');
$stripeCustomerID = $this->Profiles_model->fetch_stripe_customerID($email);
$session = \Stripe\Checkout\Session::create([
'customer' => $stripeCustomerID,
'customer_update' => [
'address' => 'auto',
],
'payment_method_types' => ['card'],
'mode' => 'subscription',
'metadata' => ['creator_id' => $reg_id],
"line_items" => [
['price' => $stripe_price_id,
'quantity' => 1,
],
],
'automatic_tax' => [
'enabled' => true,
],
'subscription_data' => [
// 'application_fee_percent' => 25,
'transfer_data' => [
'destination' => $stripeAccount,
'amount_percent' => 75,
],
],
'success_url' => 'https://example.com/purchasesuccess',
'cancel_url' => 'https://example.com/privatemember',
]);
Stripe suggests I just increase my Application Fee to cover the tax amount, but how do I do that when the amount of tax charged varies based on customer location? I thought maybe I could get around it using something like:
'application_fee_amount' => ($fee+'line_items.data.amount_total'-'line_items.data.amount_subtotal'),
OR
'application_fee_amount' => ($fee+'amount_total'-'amount_subtotal'),
OR using
'amount_percent' => 75,
The Docs say the "amount_percent" is based on the Sub-Total, but it transfers 75% of the total (ie base price + tax).
Ideas?