Files
HexaHost-GameCloud/integrations/whmcs/lib/ProductMapping.php
smueller 316679a913
Some checks failed
CI / Node — lint, typecheck, test, build (push) Failing after 9s
CI / Go — node-agent tests (push) Failing after 8s
CI / Go — edge-gateway build (push) Successful in 18s
Enhance WHMCS integration with mTLS support and product mapping features. Added mTLS configuration options, updated API endpoints for mTLS status and fingerprint registration, and implemented product validation API. Updated database schema and documentation accordingly.
2026-06-30 13:17:12 +02:00

76 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
use WHMCS\Database\Capsule;
final class HexaGameCloudProductMapping
{
public static function resolvePlanSlug(array $params, string $fallback = 'free'): string
{
$productId = (int) ($params['pid'] ?? 0);
if ($productId <= 0) {
return $params['configoption1'] ?: $fallback;
}
try {
$mapping = Capsule::table('mod_hexagamecloud_product_mappings')
->where('whmcs_product_id', $productId)
->where('is_active', 1)
->first();
if ($mapping && !empty($mapping->plan_slug)) {
return (string) $mapping->plan_slug;
}
} catch (Throwable) {
// Mapping table may not exist before addon activation
}
return $params['configoption1'] ?: $fallback;
}
public static function resolveSoftwareFamily(array $params, string $fallback = 'VANILLA'): string
{
$productId = (int) ($params['pid'] ?? 0);
if ($productId <= 0) {
return $params['configoption3'] ?: $fallback;
}
try {
$mapping = Capsule::table('mod_hexagamecloud_product_mappings')
->where('whmcs_product_id', $productId)
->where('is_active', 1)
->first();
if ($mapping && !empty($mapping->default_software)) {
return (string) $mapping->default_software;
}
} catch (Throwable) {
}
return $params['configoption3'] ?: $fallback;
}
public static function resolveMinecraftVersion(array $params, string $fallback = '1.21.1'): string
{
$productId = (int) ($params['pid'] ?? 0);
if ($productId <= 0) {
return $params['configoption2'] ?: $fallback;
}
try {
$mapping = Capsule::table('mod_hexagamecloud_product_mappings')
->where('whmcs_product_id', $productId)
->where('is_active', 1)
->first();
if ($mapping && !empty($mapping->default_version)) {
return (string) $mapping->default_version;
}
} catch (Throwable) {
}
return $params['configoption2'] ?: $fallback;
}
}