This commit is contained in:
Iliyan Angelov
2025-11-20 02:18:52 +02:00
parent 34b4c969d4
commit 44e11520c5
55 changed files with 4741 additions and 876 deletions

View File

@@ -365,6 +365,30 @@ export const capturePayPalPayment = async (
};
};
/**
* Cancel PayPal payment (when user cancels on PayPal page)
* POST /api/payments/paypal/cancel
*/
export const cancelPayPalPayment = async (
bookingId: number
): Promise<{
success: boolean;
message?: string;
}> => {
const response = await apiClient.post(
'/payments/paypal/cancel',
{
booking_id: bookingId,
}
);
// Map backend response format (status: "success") to frontend format (success: true)
const data = response.data;
return {
success: data.status === "success" || data.success === true,
message: data.message,
};
};
export default {
createPayment,
getPayments,
@@ -378,4 +402,5 @@ export default {
confirmStripePayment,
createPayPalOrder,
capturePayPalPayment,
cancelPayPalPayment,
};