perf: memoize parseImageIds, fix checkLimit OR query, loading skeletons, dashboard cache, compound indexes, sidebar active state, matches notified fix, padding fixes, match criteria in property detail
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import { verifyPayTRCallback } from "@/lib/payments/paytr";
|
||||
import { activatePlanInDb } from "@/lib/appwrite/subscription-actions";
|
||||
import type { TenantPlan, PlanPeriod } from "@/lib/appwrite/schema";
|
||||
|
||||
export async function POST(req: Request): Promise<Response> {
|
||||
const rawBody = await req.text();
|
||||
const params = new URLSearchParams(rawBody);
|
||||
|
||||
const merchantOid = params.get("merchant_oid") ?? "";
|
||||
const status = params.get("status") ?? "";
|
||||
const totalAmount = params.get("total_amount") ?? "";
|
||||
const hash = params.get("hash") ?? "";
|
||||
|
||||
if (!verifyPayTRCallback({ merchantOid, status, totalAmount, hash })) {
|
||||
return new Response("FAILED", { status: 400 });
|
||||
}
|
||||
|
||||
if (status === "success") {
|
||||
// merchant_oid: {tenantId}T{timestamp}{random}P{plan}X{period}
|
||||
const tenantId = merchantOid.split("T")[0];
|
||||
const planPart = merchantOid.split("P")[1]; // "{plan}X{period}"
|
||||
const plan = (planPart?.split("X")[0] ?? "pro") as TenantPlan;
|
||||
const period = (planPart?.split("X")[1] ?? "monthly") as PlanPeriod;
|
||||
|
||||
if (!tenantId) {
|
||||
return new Response("FAILED", { status: 400 });
|
||||
}
|
||||
try {
|
||||
await activatePlanInDb(tenantId, plan, "paytr", period);
|
||||
} catch (e) {
|
||||
console.error("[paytr-callback]", e);
|
||||
return new Response("FAILED", { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
// PayTR düz metin "OK" bekliyor — BOM veya whitespace olmayacak
|
||||
return new Response("OK", {
|
||||
status: 200,
|
||||
headers: { "Content-Type": "text/plain" },
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user