item->service()->first(); $domainName = $this->item->server_name; if (! $service || ! $domainName) { Log::channel('Custom')->warning('ProvisionHostingAccountJob skipped: missing service or domain', [ 'order_item_id' => $this->item->id, ]); return; } $servicePlanId = $this->item->product?->service_plan_id; $servicePlan = $servicePlanId ? ServicePlan::with(['plesk', 'dnsServer'])->find($servicePlanId) : null; $hostingPlan = $servicePlan?->plesk?->plesk_plan_name; $server = $servicePlan?->dnsServer; Log::channel('Custom')->info('ProvisionHostingAccountJob resolved service plan', [ 'order_item_id' => $this->item->id, 'product_id' => $this->item->product_id, 'product_name' => $this->item->product?->name, 'service_plan_id' => $servicePlanId, 'plesk_plan_name' => $hostingPlan, 'dns_manager_server_id' => $server?->id, 'dns_manager_server_ip' => $server?->ip_address, ]); if (! $hostingPlan) { Log::channel('Custom')->error('ProvisionHostingAccountJob failed: no service_plan_plesk mapping for this product', [ 'order_item_id' => $this->item->id, 'product_id' => $this->item->product_id, 'service_plan_id' => $servicePlanId, ]); return; } if (! $server) { Log::channel('Custom')->error('ProvisionHostingAccountJob failed: service plan has no dns_manager_server_id configured', [ 'order_item_id' => $this->item->id, 'product_id' => $this->item->product_id, 'service_plan_id' => $servicePlanId, ]); return; } if (! $server->servesHosting()) { Log::channel('Custom')->error('ProvisionHostingAccountJob failed: configured server does not serve hosting', [ 'order_item_id' => $this->item->id, 'service_plan_id' => $servicePlanId, 'dns_manager_server_id' => $server->id, 'server_type' => $server->type, ]); return; } $result = $plesk->provision([ 'customer_id' => $this->item->order->customer_id, 'service_id' => $service->id, 'dns_manager_server_id' => $server->id, 'domain_name' => $domainName, 'hosting_plan' => $hostingPlan, 'invoice_id' => Invoice::where('order_id', $this->item->order_id)->where('invoice_type', 1)->orderBy('id')->value('id'), ]); if ($result['error']) { Log::channel('Custom')->error('ProvisionHostingAccountJob failed', [ 'order_item_id' => $this->item->id, 'hosting_plan' => $hostingPlan, 'message' => $result['message'] ?? 'Unknown error', ]); return; } $service->update(['status' => 'active']); } }