refactor(support): replace mock data with real costs and simplify stats
Updated support page to use real data instead of mock values, including monthly costs
This commit is contained in:
1 parent
01e97eb078
commit
00501e6699
8 files changed
+235
-150
No files matched your search
+69
-4
@@ -19,10 +19,13 @@ interface BillingResponse {
|
||||
id: string;
|
||||
amount: number;
|
||||
status: "PENDING" | "PAID" | "EXPIRED" | "CANCELLED";
|
||||
pixCode: string;
|
||||
pixQrCode: string;
|
||||
expiresAt: string;
|
||||
pixCode?: string;
|
||||
pixQrCode?: string;
|
||||
qrCode?: string;
|
||||
expiresAt?: string;
|
||||
createdAt: string;
|
||||
url?: string; // URL para redirecionamento
|
||||
paymentUrl?: string; // URL alternativa de pagamento
|
||||
}
|
||||
|
||||
class AbacatePayClient {
|
||||
@@ -61,6 +64,56 @@ class AbacatePayClient {
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async createDonationBilling(params: {
|
||||
amount: number;
|
||||
donorEmail?: string;
|
||||
donorName?: string;
|
||||
message?: string;
|
||||
}): Promise<BillingResponse> {
|
||||
const requestBody = {
|
||||
products: [
|
||||
{
|
||||
external_id: `donation-${Date.now()}`,
|
||||
name: "Doação - Tibia Trade Pagodera",
|
||||
quantity: 1,
|
||||
price: Math.round(params.amount * 100), // R$ para centavos
|
||||
},
|
||||
],
|
||||
return_url: `${process.env.NEXT_PUBLIC_BASE_URL}/apoiar/obrigado`,
|
||||
completion_url: `${process.env.NEXT_PUBLIC_BASE_URL}/api/donations/verify`,
|
||||
};
|
||||
|
||||
console.log("🔍 AbacatePay Request URL:", `${this.config.baseUrl}/billing`);
|
||||
console.log(
|
||||
"🔍 AbacatePay Request Body:",
|
||||
JSON.stringify(requestBody, null, 2)
|
||||
);
|
||||
|
||||
const response = await fetch(`${this.config.baseUrl}/billing`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${this.config.apiKey}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(requestBody),
|
||||
});
|
||||
|
||||
console.log("🔍 AbacatePay Response Status:", response.status);
|
||||
console.log("🔍 AbacatePay Response OK:", response.ok);
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => ({}));
|
||||
console.error("🔍 AbacatePay Error Response:", errorData);
|
||||
throw new Error(
|
||||
`Failed to create billing: ${errorData.message || response.statusText}`
|
||||
);
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
console.log("🔍 AbacatePay Success Response:", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
async getBillingStatus(billingId: string): Promise<BillingResponse> {
|
||||
const response = await fetch(
|
||||
`${this.config.baseUrl}/billing/${billingId}`,
|
||||
@@ -92,8 +145,20 @@ class AbacatePayClient {
|
||||
}
|
||||
|
||||
// Instância do cliente (será configurada com variáveis de ambiente)
|
||||
const isProduction = process.env.NODE_ENV === "production";
|
||||
const apiKey = isProduction
|
||||
? process.env.ABACATE_APIKEY || "demo_key"
|
||||
: process.env.ABACATE_TEST_APIKEY || "demo_key";
|
||||
|
||||
// Log para debug (apenas em desenvolvimento)
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
console.log(
|
||||
`🔧 AbacatePay: Using ${isProduction ? "PRODUCTION" : "TEST"} environment`
|
||||
);
|
||||
}
|
||||
|
||||
export const abacatePay = new AbacatePayClient({
|
||||
apiKey: process.env.ABACATEPAY_API_KEY || "demo_key",
|
||||
apiKey,
|
||||
accountId: process.env.ABACATEPAY_ACCOUNT_ID || "demo_account",
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user