Closed khabzox closed 1 month ago
I fix it, look this pages inside my repo inside api: https://github.com/khabzox/aceyourscore/tree/main/app/api/payments
inside components: https://github.com/khabzox/aceyourscore/tree/main/components/dashboard/UsersInfo
I have a web application with payment system integration, and I am facing an issue where the payment data is not updating in the dashboard in the production environment, although it works fine in development.
see diagramme: https://excalidraw.com/#json=uwcITb3OzG_H2KBvCcWSJ,-Epm-_UIdZgrTsVRfJQ2nA
if you dont want to see diagramme:
Client:
PayPage: Handles the payment process. Dashboard: Displays the payment data, which includes Status, Exam, Full Name, and Email. Server:
Webhook: Receives payment data from the payment provider. API: Fetches payment data from the database. Database:
Stores payment data.
Flow:
PayPage: User completes a payment. Webhook: Receives payment data and updates the database. Dashboard: Fetches payment data from the API and displays it.
Problem:
Development: Data is saved in the database and updates correctly on the dashboard.
Production: Data is saved in the database, but it does not update on the dashboard.
`import { getUsersPaymentsData } from "./FetchUsersPaymentsData"; import { currentUser } from "@clerk/nextjs/server";
export default async function UsersInfo() { try { // get data of user const data = await getUsersPaymentsData();
// that for catch error and return it } catch (error) { console.log("Error loading user payment info: ", error); return (
Status: Error loading data
} }
`
`import config from "@/config";
export const getUsersPaymentsData = async () => { try { const res = await fetch(
${config.domainNameProduction}/api/payments
, { cache: "no-store", });} catch (error) { console.log("Error loading topics: ", error); } };`
this api/payments/route.js
`import clientPromise from "@/utils/mongodb"; import { NextResponse } from "next/server";
export async function GET() { try { const client = await clientPromise; const db = client.db(process.env.MONGODB_DB);
} catch (error) { console.log(error); return NextResponse.json({ message: "Error", error }, { status: 500 }); } } `
I search and I found, when I went to Data Cache > Purge Cache > Purge Everything and remove it the data on app is updated and show it on dashboard. But its not for long time. anther way, You must do this for every update that occurs relative to the DataBase