Skip to content

Commit

Permalink
Fix paypal upgrade broken
Browse files Browse the repository at this point in the history
  • Loading branch information
ilestis committed Oct 24, 2024
1 parent 7e5a922 commit 6ef3493
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Settings/SubscriptionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function change(Request $request, Tier $tier)
$period = $request->get('period') === 'yearly' ? PricingPeriod::Yearly : PricingPeriod::Monthly;

// If the user has a cancelled sub still ending
if ($user->subscribed('kanka') && $user->subscription('kanka')->onGracePeriod()) {
if ($user->subscribed('kanka') && $user->subscription('kanka')->onGracePeriod() && !$user->hasPayPal()) {
return view('settings.subscription.change_blocked')
->with('user', $user);
}
Expand Down
4 changes: 2 additions & 2 deletions app/Services/PayPalService.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public function process(): mixed
$oldPrice = $tier->yearly;
}
// @phpstan-ignore-next-line
$price = (floatval($price) - ($oldPrice)) * ($this->user->subscriptions()->first()->ends_at->diffInDays(Carbon::now()) / 365);
$price = number_format($price, 2);
$price = round(($price - ($oldPrice)) * ($this->user->subscriptions()->first()->ends_at->diffInDays(Carbon::now(), true) / 365), 2);
}
$price = max(0, $price);

$provider = new PayPal();
$provider->setApiCredentials(config('paypal'));
Expand Down

0 comments on commit 6ef3493

Please sign in to comment.