*/}
diff --git a/frontend/src/components/OrderSummary.jsx b/frontend/src/components/OrderSummary.jsx
index b1ebf26..21a2e7a 100644
--- a/frontend/src/components/OrderSummary.jsx
+++ b/frontend/src/components/OrderSummary.jsx
@@ -65,6 +65,7 @@ const OrderSummary = ({ orderData, loading, order }) => {
{orderData.customer_email}
)}*/}
+ {order.shipping.method &&
@@ -72,7 +73,7 @@ const OrderSummary = ({ orderData, loading, order }) => {
{formatCurrency(order.shipping.total, orderData.currency)}
-
+ }
> }
Total Amount:
diff --git a/frontend/src/main.jsx b/frontend/src/main.jsx
index ab13ea0..f696279 100644
--- a/frontend/src/main.jsx
+++ b/frontend/src/main.jsx
@@ -1,13 +1,18 @@
import { Provider } from "@/components/ui/provider"
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
+import { ChakraProvider } from "@chakra-ui/react";
+import { system } from "./theme";
import './index.css'
import App from './App.jsx'
+import {ThemeProvider} from "next-themes";
createRoot(document.getElementById('root')).render(
-
-
-
+
+
+
+
+ ,
)
diff --git a/frontend/src/pages/Cancel.jsx b/frontend/src/pages/Cancel.jsx
index d6ecee3..9a4816a 100644
--- a/frontend/src/pages/Cancel.jsx
+++ b/frontend/src/pages/Cancel.jsx
@@ -16,20 +16,40 @@ const Cancel = () => {
const [searchParams] = useSearchParams();
const error = searchParams.get('error');
- const orderId = searchParams.get('order_id');
+ const orderId = searchParams.get('order_id') || searchParams.get('wc_order_id');
const paypalToken = searchParams.get('token');
-
+ const orderTotal = searchParams.get('total');
+ const currency = searchParams.get('currency') || 'USD';
+ const description = searchParams.get('description');
+ const customerEmail = searchParams.get('customer_email');
const cancelUrl = searchParams.get('cancel_url');
+ const returnUrl = searchParams.get('return_url');
+
+ const formatCurrency = (amount, curr = 'USD') => {
+ return new Intl.NumberFormat('en-US', {
+ style: 'currency',
+ currency: curr,
+ }).format(parseFloat(amount));
+ };
+
+ const getErrorMessage = () => {
+ if (error) {
+ return decodeURIComponent(error);
+ }
+ return 'Your payment was cancelled. You can try again or choose a different payment method.';
+ };
const handleRetryPayment = () => {
- // Build the payment URL with original parameters
const paymentUrl = new URL('/payment', window.location.origin);
- if (orderId) {
- paymentUrl.searchParams.set('wc_order_id', orderId);
- // You might want to fetch original order details here
- paymentUrl.searchParams.set('total', '25.99'); // This should come from order data
- }
+ // Preserve all original order parameters
+ if (orderId) paymentUrl.searchParams.set('wc_order_id', orderId);
+ if (orderTotal) paymentUrl.searchParams.set('total', orderTotal);
+ if (currency) paymentUrl.searchParams.set('currency', currency);
+ if (description) paymentUrl.searchParams.set('description', description);
+ if (customerEmail) paymentUrl.searchParams.set('customer_email', customerEmail);
+ if (returnUrl) paymentUrl.searchParams.set('return_url', returnUrl);
+ if (cancelUrl) paymentUrl.searchParams.set('cancel_url', cancelUrl);
window.location.href = paymentUrl.toString();
};
@@ -41,7 +61,7 @@ const Cancel = () => {
Payment Cancelled
- Your payment was cancelled. You can try again or choose a different payment method.
+ {getErrorMessage()}
@@ -63,6 +83,13 @@ const Cancel = () => {
Order ID:{orderId}
+ {orderTotal && (
+ <>
+ Order Total:
+ {formatCurrency(orderTotal, currency)}
+
+ >
+ )}
Your order is still pending. You can complete the payment to process your order.
@@ -121,7 +148,7 @@ const Cancel = () => {
- Text
+ Contact Support: Reach us anytime at {import.meta.env.VITE_REACT_APP_SUPPORT_EMAIL} or through live chat.
diff --git a/frontend/src/pages/Payment.jsx b/frontend/src/pages/Payment.jsx
index e475864..872c6b9 100644
--- a/frontend/src/pages/Payment.jsx
+++ b/frontend/src/pages/Payment.jsx
@@ -190,7 +190,7 @@ const Payment = () => {
diff --git a/frontend/src/theme.js b/frontend/src/theme.js
new file mode 100644
index 0000000..7019fe4
--- /dev/null
+++ b/frontend/src/theme.js
@@ -0,0 +1,8 @@
+import { createSystem, defaultConfig, defineConfig } from "@chakra-ui/react";
+
+const config = defineConfig({
+ // put tokens/recipes if you need; not required just to force light mode
+ theme: {},
+});
+
+export const system = createSystem(defaultConfig, config);
\ No newline at end of file