Fix endcustomer package allocation and event create gating
This commit is contained in:
@@ -111,21 +111,26 @@ class CheckoutAssignmentService
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$tenantPackage = TenantPackage::updateOrCreate(
|
||||
[
|
||||
if ($purchase->wasRecentlyCreated) {
|
||||
$tenantPackage = TenantPackage::create([
|
||||
'tenant_id' => $tenant->id,
|
||||
'package_id' => $package->id,
|
||||
],
|
||||
[
|
||||
'price' => round($price, 2),
|
||||
'active' => true,
|
||||
'purchased_at' => now(),
|
||||
'expires_at' => $this->resolveExpiry($package, $tenant),
|
||||
]
|
||||
);
|
||||
]);
|
||||
} else {
|
||||
$tenantPackage = TenantPackage::query()
|
||||
->where('tenant_id', $tenant->id)
|
||||
->where('package_id', $package->id)
|
||||
->orderByDesc('purchased_at')
|
||||
->orderByDesc('id')
|
||||
->first();
|
||||
}
|
||||
}
|
||||
|
||||
if ($package->type !== 'reseller') {
|
||||
if ($package->type !== 'reseller' && $tenantPackage) {
|
||||
$tenant->forceFill([
|
||||
'subscription_status' => 'active',
|
||||
'subscription_expires_at' => $tenantPackage->expires_at,
|
||||
|
||||
Reference in New Issue
Block a user