Skip to content

Commit

Permalink
Merge pull request maartenpaauw#5 from maartenpaauw/feat/optional-col…
Browse files Browse the repository at this point in the history
…lect-tax-ids

Optional collect tax ids
  • Loading branch information
maartenpaauw authored Feb 1, 2024
2 parents e9afb8c + f5d7fa2 commit d60efd4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Add plans to your `cashier.php` config file:
'basic' => [
'price_id' => ENV('CASHIER_STRIPE_SUBSCRIPTION_BASIC_PRICE_ID'),
'trial_days' => 14, // Optional
'collect_tax_ids' => false, // Optional
],
],
```
Expand Down
3 changes: 2 additions & 1 deletion src/Stripe/RedirectIfUserNotSubscribed.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ public function handle(Request $request, Closure $next, string $plan): Response

$priceId = $this->repository->get("cashier.plans.$plan.price_id");
$trialDays = $this->repository->get("cashier.plans.$plan.trial_days", false);
$collectTaxIds = $this->repository->get("cashier.plans.$plan.collect_tax_ids", false);

return $tenant->newSubscription($plan, $priceId)
->allowPromotionCodes()
->when($trialDays, static fn (SubscriptionBuilder $subscription) => $subscription->trialDays($trialDays))
->collectTaxIds()
->when($collectTaxIds, static fn (SubscriptionBuilder $subscription) => $subscription->collectTaxIds())
->checkout([
'success_url' => Dashboard::getUrl(),
'cancel_url' => Dashboard::getUrl(),
Expand Down

0 comments on commit d60efd4

Please sign in to comment.