Skip to content
This repository was archived by the owner on Dec 14, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
API_URL=https://system-api.firehosting.com.br
NEXT_PUBLIC_API_URL=https://system-api.firehosting.com.br
API_URL=https://api-dev.firehosting.com.br
NEXT_PUBLIC_API_URL=https://api-dev.firehosting.com.br
NEXT_PUBLIC_SOCKET_URL=https://firehosting-socket.squareweb.app
NEXT_PUBLIC_CENTRAL_URL=https://central.firehosting.com.br
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"api": {
"baseUrl": "https://system-api.firehosting.com.br",
"baseUrl": "https://api-dev.firehosting.com.br",
"authKey": "CjYYooDNiVgzWBJPNlYyIUfoxJRtLozDFiTAoHdQuPAnxFEAuK"
}
}
Binary file added public/images/Franklin_Clinton.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/default-minecraft-server.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/michael.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 61 additions & 12 deletions src/app/checkout/[service]/[plan]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,13 @@ const CheckoutPageComponent = () => {
const rawPlanName = params?.plan || '';

const planName = decodeURIComponent(rawPlanName);
// Create a clean version without the "+" for API use
const cleanPlanName = planName.replace(/\+/g, "");

const isMinecraft = service.toLowerCase() === "minecraft";
const isVPS = service.toLowerCase() === "vps";
const isMTA = service.toLowerCase() === "mta";
const isSAMP = service.toLowerCase() === "samp";

useEffect(() => {
const billingFromUrl = searchParams?.get('billing');
Expand All @@ -188,6 +193,15 @@ const CheckoutPageComponent = () => {
router.push(`/login?redirect=${encodeURIComponent(returnUrl)}`);
}
}, [authContext, router, service, planName, searchParams]);

// Set default values for MTA and SAMP services
useEffect(() => {
if (isMTA || isSAMP) {
// Set default server name and egg ID for MTA and SAMP
setServerName(isMTA ? "MTA Server" : "SAMP Server");
setEggId(isMTA ? "13" : "14"); // Assuming these are the correct egg IDs
}
}, [isMTA, isSAMP]);

useEffect(() => {
if (!service || !planName) {
Expand All @@ -201,8 +215,9 @@ const CheckoutPageComponent = () => {
setError(null);
try {
const apiUrl = config.api.baseUrl || "http://localhost:4000";

const response = await fetch(
`${apiUrl}/v1/public/plans/${service}/${encodeURIComponent(planName)}`,
`${apiUrl}/v1/public/plans/${service}/${encodeURIComponent(cleanPlanName)}`,
);
if (!response.ok) {
throw new Error("Plano não encontrado.");
Expand Down Expand Up @@ -336,7 +351,7 @@ const CheckoutPageComponent = () => {
return;
}

if (isMinecraft && (!eggId || !serverName)) {
if (isMinecraft && !isMTA && !isSAMP && (!eggId || !serverName)) {
alert("Preencha o nome do servidor e selecione um sistema.");
return;
} else if (isVPS && !osId) {
Expand All @@ -363,27 +378,49 @@ const CheckoutPageComponent = () => {
return;
}

const customfields = isMinecraft
? { server_name: serverName, egg_id: eggId }
: { OS: osId };

const body: any = {
// Create request body based on service type
let body: any = {
pid: plan.id,
billingcycle: selectedCycle,
customfields,
};

// Only add customfields if it's NOT MTA or SAMP
if (!isMTA && !isSAMP) {
if (isMinecraft) {
body.customfields = { server_name: serverName, egg_id: eggId };
} else {
body.customfields = { OS: osId };
}
}
// For MTA and SAMP, no customfields at all

if (appliedCoupon) {
body.promocode = appliedCoupon.code;
}

const response = await fetch(`${apiUrl}/v1/users/payment/create`, {
// Use specific API endpoints for MTA and SAMP services
const endpoint = isMTA ? `/v1/users/payment/create` :
isSAMP ? `/v1/users/payment/create` :
`/v1/users/payment/create`;

// For plan-specific endpoints like MTA/SAMP, make sure we're passing the clean plan name
// without any "+" characters
if (isMTA || isSAMP) {
// Add the clean plan name to the body
body.plan = cleanPlanName;
}

// Make sure we're only sending what's necessary
const requestBody = JSON.stringify(body);
console.log(`Sending request to ${endpoint}:`, requestBody);

const response = await fetch(`${apiUrl}${endpoint}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${accessKey}`,
},
body: JSON.stringify(body),
body: requestBody,
});
const data = await response.json();

Expand Down Expand Up @@ -547,8 +584,20 @@ const CheckoutPageComponent = () => {
</div>
<h2 className="text-2xl font-bold">1. Configure seu Servidor</h2>
</div>
{isMinecraft && renderMinecraftFields()}
{isVPS && renderVPSFields()}
{isMinecraft && !isMTA && !isSAMP && renderMinecraftFields()}
{isVPS && !isMTA && !isSAMP && renderVPSFields()}
{(isMTA || isSAMP) && (
<motion.div variants={fadeIn} className="mb-6">
<div className="p-4 bg-green-500/10 border border-green-500/30 rounded-lg">
<p className="text-green-400 font-medium">
Servidor {isMTA ? "MTA" : "SA-MP"} pronto para usar!
</p>
<p className="text-light/70 mt-2">
Este servidor já vem pré-configurado com as configurações otimizadas. Não é necessário selecionar sistema operacional ou definir nome.
</p>
</div>
</motion.div>
)}
<motion.div variants={fadeIn} className="my-8">
<label className="block text-light/90 mb-3 font-medium">Ciclo de Pagamento</label>
<div className="grid grid-cols-2 sm:grid-cols-4 gap-3">
Expand Down
Loading