Add Woo Manager email notification milestones with shared mail templates.
Deploy Ladill Woo Manager / deploy (push) Successful in 2m11s
Deploy Ladill Woo Manager / deploy (push) Successful in 2m11s
New order, store connected, Pro expiry, and past-due alerts use the Ladill notification layout with woo branding; expiry reminders dedupe per threshold like hosting. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -11,7 +11,11 @@ use Illuminate\Support\Str;
|
||||
|
||||
class SubscriptionService
|
||||
{
|
||||
public function __construct(private readonly BillingClient $billing) {}
|
||||
public function __construct(
|
||||
private readonly BillingClient $billing,
|
||||
private readonly WooNotificationService $notifications,
|
||||
private readonly WooProExpiryAlertService $expiryAlerts,
|
||||
) {}
|
||||
|
||||
public function gatingActive(): bool
|
||||
{
|
||||
@@ -238,13 +242,18 @@ class SubscriptionService
|
||||
'last_reference' => $reference,
|
||||
'last_error' => null,
|
||||
])->save();
|
||||
$this->expiryAlerts->resetAlerts($sub->fresh());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$graceEnd = optional($sub->current_period_end)->addDays((int) config('woo.pro.grace_days', 3));
|
||||
if ($graceEnd && $graceEnd->isPast()) {
|
||||
$wasPastDue = $sub->status === ProSubscription::STATUS_PAST_DUE;
|
||||
$sub->forceFill(['status' => ProSubscription::STATUS_PAST_DUE, 'last_error' => $result['error']])->save();
|
||||
if (! $wasPastDue) {
|
||||
$this->notifications->proPastDue($sub->fresh());
|
||||
}
|
||||
} else {
|
||||
$sub->forceFill(['last_error' => $result['error']])->save();
|
||||
}
|
||||
@@ -282,9 +291,15 @@ class SubscriptionService
|
||||
'canceled_at' => null,
|
||||
'last_reference' => $reference,
|
||||
'last_error' => null,
|
||||
'metadata' => null,
|
||||
],
|
||||
);
|
||||
|
||||
$subscription = $this->subscriptionFor($user);
|
||||
if ($subscription) {
|
||||
$this->expiryAlerts->resetAlerts($subscription);
|
||||
}
|
||||
|
||||
return [true, $successMessage.' Your subscription is active.'];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user