Skip to content

Commit

Permalink
Add calculateTaxes to HandleTaxes
Browse files Browse the repository at this point in the history
  • Loading branch information
victoralbino committed Oct 25, 2023
1 parent 852e26d commit 35ed6ce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/CheckoutBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ public function create($items, array $sessionOptions = [], array $customerOption

return $item;
})->values()->all(),
'tax_id_collection' => [
'enabled' => Cashier::$calculatesTaxes ?: $this->collectTaxIds,
],
'tax_id_collection' => $this->calculateTaxes()
]);

return Checkout::create($this->owner, array_merge($payload, $sessionOptions), $customerOptions);
Expand Down
15 changes: 15 additions & 0 deletions src/Concerns/HandlesTaxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@ protected function automaticTaxPayload()
]);
}

/**
* Get the payload for Stripe tax calculation.
*
* @return array
*/
protected function calculateTaxes()
{
if (Cashier::$calculatesTaxes ?: $this->collectTaxIds){
return array_filter([
"tax_id_collection" => ["enabled" => true]
]);
}
return [];
}

/**
* Determine if automatic tax is enabled.
*
Expand Down

0 comments on commit 35ed6ce

Please sign in to comment.