diff --git a/src/routes/discord-bot/+page.server.ts b/src/routes/discord-bot/+page.server.ts
index 0967b570..51d7d146 100644
--- a/src/routes/discord-bot/+page.server.ts
+++ b/src/routes/discord-bot/+page.server.ts
@@ -2,32 +2,7 @@ import { error, fail, redirect } from "@sveltejs/kit";
import { validateData } from "$lib/utils";
import { loginUserSchema, registerUserSchema } from "$lib/schemas";
-/*
-export const load = async () => {
- const apiKey = import.meta.env.VITE_LEMON_SQUEEZY_API_KEY;
-
- const getLTDCount = async () => {
- // make the POST request to the endpoint
- const response = await fetch('https://api.lemonsqueezy.com/v1/order-items?page[size]=100', {
- headers: {
- 'Accept': 'application/vnd.api+json',
- 'Content-Type': 'application/vnd.api+json',
- 'Authorization': `Bearer ${apiKey}`
- }
- });
- const output = await response.json();
- const filteredData = output?.data?.filter(item => item?.attributes?.product_name === 'Pro Subscription (Life Time Access)');
- const count = filteredData?.length || 0;
-
- return count;
- };
-
- return {
- getLTDCount: await getLTDCount(),
- };
- };
-*/
export const actions = {
login: async ({ request, locals }) => {
diff --git a/src/routes/discord-bot/+page.svelte b/src/routes/discord-bot/+page.svelte
index ce7da768..dedc3b45 100644
--- a/src/routes/discord-bot/+page.svelte
+++ b/src/routes/discord-bot/+page.svelte
@@ -24,22 +24,14 @@
}
});
- async function purchasePlan(subscriptionType: string = "") {
+ async function purchasePlan() {
if (data?.user) {
let subId = "";
- if (subscriptionType === "lifeTime") {
- subId = import.meta.env.VITE_LEMON_SQUEEZY_LIFE_TIME_ACCESS_ID;
- } else if (mode && subscriptionType === "plus") {
- subId = import.meta.env.VITE_LEMON_SQUEEZY_ANNUAL_ID_PLUS;
- } else if (!mode && subscriptionType === "plus") {
- subId = import.meta.env.VITE_LEMON_SQUEEZY_MONTHLY_ID_PLUS;
- } else if (mode && subscriptionType === "pro") {
- subId = import.meta.env.VITE_LEMON_SQUEEZY_ANNUAL_ID_PRO;
- } else if (!mode && subscriptionType === "pro") {
- subId = import.meta.env.VITE_LEMON_SQUEEZY_MONTHLY_ID_PRO;
+ if (mode) {
+ subId = import.meta.env.VITE_LEMON_SQUEEZY_DISCORD_ANNUAL_ID;
} else {
- subId = import.meta.env.VITE_LEMON_SQUEEZY_ANNUAL_ID_PRO;
+ subId = import.meta.env.VITE_LEMON_SQUEEZY_DISCORD_MONTHLY_ID;
}
try {
} catch (e) {
@@ -66,8 +58,8 @@
@@ -259,12 +251,13 @@
-
+
@@ -299,7 +292,7 @@
class="relative overflow-hidden mt-4 card card-side mt-10 mb-10 bg-[#18181B] to-black rounded-lg p-5 flex flex-col lg:flex-row items-center justify-between"
>
-
+
See Our Discord Bots In Action!
Join Discord
-
+
![]()
{
+ try {
+ const bodyText = await request.text();
+
+ // Retrieve the signature header; return early if missing.
+ const signatureHeader = request.headers.get("x-Signature");
+ if (!signatureHeader) {
+ console.error("Missing x-Signature header.");
+ return new Response(
+ JSON.stringify({ error: "Missing signature header" }),
+ {
+ status: 403,
+ headers: { "Content-Type": "application/json" },
+ }
+ );
+ }
+
+ if (!isValidSignature(bodyText, signatureHeader)) {
+ console.error("Signature verification failed.");
+ return new Response(
+ JSON.stringify({ error: "Invalid signature" }),
+ {
+ status: 403,
+ headers: { "Content-Type": "application/json" },
+ }
+ );
+ }
+
+ // Parse the JSON payload
+ const payload = JSON.parse(bodyText);
+ const userId = payload?.meta?.custom_data?.userId;
+ const { status, refunded } = payload?.data?.attributes || {};
+
+
+ if (!userId || status === undefined) {
+ console.error("Missing userId or status in payload:", payload);
+ return new Response(
+ JSON.stringify({ error: "Invalid payload structure" }),
+ {
+ status: 400,
+ headers: { "Content-Type": "application/json" },
+ }
+ );
+ }
+
+
+ try {
+
+
+ const paymentData = { user: userId, data: payload };
+ await locals.pb.collection("discordPayments").create(paymentData);
+ } catch (dbError) {
+ console.error("Database error:", dbError);
+
+ return new Response(
+ JSON.stringify({ error: "Pocketbase error" }),
+ {
+ status: 500,
+ headers: { "Content-Type": "application/json" },
+ }
+
+ );
+
+
+ }
+
+ return new Response(
+ JSON.stringify({ message: "Payment data received successfully" }),
+ {
+ status: 200,
+ headers: { "Content-Type": "application/json" },
+ }
+ );
+ } catch (error) {
+ console.error("Error processing request:", error);
+ return new Response(
+ JSON.stringify({ error: "Internal server error" }),
+ {
+ status: 500,
+ headers: { "Content-Type": "application/json" },
+ }
+ );
+ }
+};