mapType($whmcsType), description: $row['description'] ? substr($row['description'], 0, 500) : null, unitPrice: $amount, totalPrice: $amount, productId: $this->resolveProductId($whmcsType, (int) $row['relid']), ); } /** * Only 'Hosting' line items carry a resolvable product: relid -> tblhosting.id -> packageid -> products.legacy_id. * Domain/Addon relids point at tbldomains/tblhostingaddons, which don't map onto the products table. */ private function resolveProductId(string $whmcsType, int $relid): ?int { if ($whmcsType !== 'Hosting' || $relid <= 0) { return null; } $packageId = DB::connection('whmcs')->table('tblhosting')->where('id', $relid)->value('packageid'); return $packageId ? $this->products->resolve((int) $packageId) : null; } private function mapType(string $whmcsType): string { if ($whmcsType === 'Addon') { return 'addon'; } if (str_contains($whmcsType, 'Upgrade')) { return 'upgrade'; } return 'service'; } }