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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"http-proxy-middleware": "^3.0.5",
"isomorphic-dompurify": "^2.25.0",
"js-cookie": "^3.0.5",
"lucide-react": "^0.544.0",
"next": "^15.3.5",
"next-themes": "^0.2.1",
"react": "^18.2.0",
Expand Down
91 changes: 91 additions & 0 deletions public/images/bg-cartoon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 2 additions & 18 deletions src/app/checkout/[service]/[plan]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ 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";
Expand All @@ -180,10 +179,8 @@ const CheckoutPageComponent = () => {
setSelectedCycle(billingFromUrl);
}

// Verificar se existe um código de afiliado no cookie
const utmCode = getCookie('utm_code');
if (utmCode) {
console.log(`Checkout detectou código de afiliado: ${utmCode}`);
}
}, [searchParams]);

Expand All @@ -201,12 +198,10 @@ const CheckoutPageComponent = () => {
}
}, [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
setEggId(isMTA ? "13" : "14");
}
}, [isMTA, isSAMP]);

Expand Down Expand Up @@ -385,48 +380,37 @@ const CheckoutPageComponent = () => {
return;
}

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

// 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;
}

// Verificar se existe utm_code no cookie e adicionar ao body
const utmCode = getCookie('utm_code');
if (utmCode) {
body.utm_code = utmCode;
console.log(`Código de afiliado detectado: ${utmCode}`);
}

// 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",
Expand Down
Loading
Loading