createPortalSession($customerId, $baseUrl . '/billing.php'); $url = (string)($session['url'] ?? ''); if ($url === '') { dbnToolsError('Stripe did not return a portal URL.', 502, 'stripe_no_url'); } dbnToolsRespond(['ok' => true, 'url' => $url]); } catch (Throwable $e) { error_log('[stripe-portal] ' . $e->getMessage()); dbnToolsError('Could not open billing portal: ' . $e->getMessage(), 500, 'stripe_failed'); }