Merge branch 'hemant' of http://git.wdipl.com/CityCards/CityCards-Website into arya-branch

This commit is contained in:
aryabenade
2026-04-23 20:12:44 +05:30
2 changed files with 22 additions and 9 deletions

View File

@@ -51,10 +51,9 @@ export const cardsApi = createApi({
}),
confirmCardPayment: builder.mutation({
query: (id) => ({
url: `/website/passes/${id}/confirm-payment`,
query: (payload: { id: string; checkoutSessionId: string }) => ({
url: `/website/passes/${payload.id}/${payload.checkoutSessionId}/confirm-payment/`,
method: "POST",
// body: id,
}),
}),

View File

@@ -39,18 +39,22 @@ export function PaymentSuccessPage({
useEffect(() => {
const confirm = async () => {
// Try all possible sources
// 1. Retrieve bookingId from storage (cookie, localStorage, sessionStorage, or query param)
let bookingId = getCookie('pendingBookingId');
if (!bookingId) bookingId = localStorage.getItem('pendingBookingId');
if (!bookingId) bookingId = sessionStorage.getItem('pendingBookingId');
if (!bookingId) bookingId = searchParams.get('bookingId');
console.log('Retrieved bookingId from sources:', {
// 2. Get checkoutSessionId from URL query parameter
const checkoutSessionId = searchParams.get('session_id');
console.log('Retrieved data:', {
bookingId: bookingId,
checkoutSessionId: checkoutSessionId,
cookie: getCookie('pendingBookingId'),
localStorage: localStorage.getItem('pendingBookingId'),
sessionStorage: sessionStorage.getItem('pendingBookingId'),
queryParam: searchParams.get('bookingId'),
final: bookingId,
queryBookingId: searchParams.get('bookingId'),
});
if (!bookingId) {
@@ -62,10 +66,20 @@ export function PaymentSuccessPage({
return;
}
if (!checkoutSessionId) {
setStatus('error');
setErrorMsg(
'Missing session ID. Please contact support with your order details.'
);
return;
}
try {
await confirmPayment(bookingId).unwrap();
// Call API with both id and checkoutSessionId
await confirmPayment({ id: bookingId, checkoutSessionId }).unwrap();
setStatus('success');
toast.success('Payment confirmed! Your order is complete.');
// Clean up all storage
document.cookie = 'pendingBookingId=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
localStorage.removeItem('pendingBookingId');