Jaafarsa commited on
Commit
270a3da
·
verified ·
1 Parent(s): d22a69c

add proceed to check out with online payment

Browse files
Files changed (2) hide show
  1. cart.html +54 -10
  2. order-confirmation.html +116 -0
cart.html CHANGED
@@ -66,25 +66,34 @@
66
  <span id="total" class="text-lg font-bold gradient-text">$0.00</span>
67
  </div>
68
  </div>
69
-
70
  <button id="checkoutBtn"
71
  class="w-full bg-primary-500 hover:bg-primary-600 text-white font-bold py-3 px-4 rounded-lg transition disabled:opacity-50 disabled:cursor-not-allowed"
72
  disabled>
73
  Proceed to Checkout
74
  </button>
75
-
76
- <div class="mt-4 text-sm text-gray-400">
 
 
 
 
 
 
 
 
 
 
 
77
  <p>By completing your purchase, you agree to our <a href="#" class="text-primary-500 hover:text-primary-400">Terms of Service</a>.</p>
78
  </div>
79
  </div>
80
  </div>
81
  </div>
82
  </section>
83
-
84
  <script>
85
  feather.replace();
86
-
87
- // Load cart from localStorage
88
  let cart = JSON.parse(localStorage.getItem('cart')) || [];
89
 
90
  // Display cart items
@@ -178,13 +187,48 @@
178
  updateCartDisplay();
179
  updateCartCounter(); // Update counter in other pages
180
  });
181
-
182
  // Checkout button
183
  checkoutBtn.addEventListener('click', () => {
184
- alert('Proceeding to checkout - this would redirect to a payment page in a real application');
 
185
  });
186
-
187
- // Initialize cart display
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  updateCartDisplay();
189
 
190
  // Function to update cart counter (shared with other pages)
 
66
  <span id="total" class="text-lg font-bold gradient-text">$0.00</span>
67
  </div>
68
  </div>
 
69
  <button id="checkoutBtn"
70
  class="w-full bg-primary-500 hover:bg-primary-600 text-white font-bold py-3 px-4 rounded-lg transition disabled:opacity-50 disabled:cursor-not-allowed"
71
  disabled>
72
  Proceed to Checkout
73
  </button>
74
+ <div id="paymentMethods" class="mt-4 hidden">
75
+ <div class="flex gap-4 mb-4">
76
+ <button id="stripeBtn" class="flex-1 bg-white text-gray-800 font-bold py-2 px-4 rounded-lg border border-gray-300 flex items-center justify-center">
77
+ <img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/stripe/stripe-original.svg" class="w-6 h-6 mr-2" />
78
+ Pay with Stripe
79
+ </button>
80
+ <button id="paypalBtn" class="flex-1 bg-blue-600 text-white font-bold py-2 px-4 rounded-lg flex items-center justify-center">
81
+ <img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/paypal/paypal-original.svg" class="w-6 h-6 mr-2" />
82
+ Pay with PayPal
83
+ </button>
84
+ </div>
85
+ </div>
86
+ <div class="mt-4 text-sm text-gray-400">
87
  <p>By completing your purchase, you agree to our <a href="#" class="text-primary-500 hover:text-primary-400">Terms of Service</a>.</p>
88
  </div>
89
  </div>
90
  </div>
91
  </div>
92
  </section>
93
+ <script src="https://checkout.stripe.com/checkout.js"></script>
94
  <script>
95
  feather.replace();
96
+ // Load cart from localStorage
 
97
  let cart = JSON.parse(localStorage.getItem('cart')) || [];
98
 
99
  // Display cart items
 
187
  updateCartDisplay();
188
  updateCartCounter(); // Update counter in other pages
189
  });
 
190
  // Checkout button
191
  checkoutBtn.addEventListener('click', () => {
192
+ document.getElementById('paymentMethods').classList.remove('hidden');
193
+ checkoutBtn.disabled = true;
194
  });
195
+
196
+ // Stripe payment
197
+ document.getElementById('stripeBtn').addEventListener('click', () => {
198
+ const handler = StripeCheckout.configure({
199
+ key: 'pk_test_your_stripe_key',
200
+ image: 'https://yourhand.co/logo.png',
201
+ locale: 'auto',
202
+ currency: 'USD',
203
+ token: function(token) {
204
+ // In real app, send token to backend
205
+ console.log(token);
206
+ alert('Payment successful! Redirecting to order confirmation...');
207
+ localStorage.removeItem('cart');
208
+ window.location.href = 'order-confirmation.html';
209
+ }
210
+ });
211
+
212
+ const subtotal = cart.reduce((total, item) => total + (item.price * item.quantity), 0);
213
+
214
+ handler.open({
215
+ name: 'YourHand.co',
216
+ description: `${cart.length} items`,
217
+ amount: subtotal * 100
218
+ });
219
+ });
220
+
221
+ // PayPal payment
222
+ document.getElementById('paypalBtn').addEventListener('click', () => {
223
+ alert('Redirecting to PayPal...');
224
+ // In real app, this would integrate with PayPal SDK
225
+ // For demo, just clear cart and redirect to confirmation
226
+ setTimeout(() => {
227
+ localStorage.removeItem('cart');
228
+ window.location.href = 'order-confirmation.html';
229
+ }, 1000);
230
+ });
231
+ // Initialize cart display
232
  updateCartDisplay();
233
 
234
  // Function to update cart counter (shared with other pages)
order-confirmation.html ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en" class="dark">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Order Confirmation - YourHand.co</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
9
+ <style>
10
+ .gradient-text {
11
+ background: linear-gradient(90deg, #d946ef 0%, #a855f7 100%);
12
+ -webkit-background-clip: text;
13
+ background-clip: text;
14
+ color: transparent;
15
+ }
16
+ .checkmark {
17
+ width: 100px;
18
+ height: 100px;
19
+ border-radius: 50%;
20
+ display: block;
21
+ stroke-width: 5;
22
+ stroke: #a855f7;
23
+ stroke-miterlimit: 10;
24
+ margin: 0 auto;
25
+ animation: fill 0.4s ease-in-out 0.4s forwards, scale 0.3s ease-in-out 0.9s both;
26
+ }
27
+ @keyframes fill {
28
+ 100% {
29
+ box-shadow: inset 0px 0px 0px 50px rgba(168, 85, 247, 0.1);
30
+ }
31
+ }
32
+ @keyframes scale {
33
+ 0%, 100% {
34
+ transform: none;
35
+ }
36
+ 50% {
37
+ transform: scale3d(1.1, 1.1, 1);
38
+ }
39
+ }
40
+ </style>
41
+ </head>
42
+ <body class="bg-gray-900 text-gray-100 min-h-screen">
43
+ <nav class="bg-gray-800 border-b border-gray-700 px-4 py-3">
44
+ <div class="max-w-7xl mx-auto flex items-center justify-between">
45
+ <div class="flex items-center space-x-2">
46
+ <i data-feather="hand" class="text-primary-500 w-8 h-8"></i>
47
+ <span class="text-2xl font-bold gradient-text">YourHand.co</span>
48
+ </div>
49
+ <a href="index.html" class="text-primary-500 hover:text-primary-400 transition">
50
+ Continue Shopping
51
+ </a>
52
+ </div>
53
+ </nav>
54
+
55
+ <section class="max-w-4xl mx-auto py-16 px-4 text-center">
56
+ <svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">
57
+ <circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/>
58
+ <path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>
59
+ </svg>
60
+
61
+ <h1 class="text-4xl font-bold mt-8 mb-4">Order Confirmed!</h1>
62
+ <p class="text-xl text-gray-300 mb-8">Thank you for your purchase</p>
63
+
64
+ <div class="bg-gray-800 rounded-xl p-8 max-w-lg mx-auto mb-8 text-left">
65
+ <h2 class="text-2xl font-bold mb-6">Order Details</h2>
66
+
67
+ <div class="flex justify-between mb-2">
68
+ <span class="text-gray-400">Order Number</span>
69
+ <span class="font-mono">#ORD-${Math.floor(100000 + Math.random() * 900000)}</span>
70
+ </div>
71
+ <div class="flex justify-between mb-2">
72
+ <span class="text-gray-400">Date</span>
73
+ <span>${new Date().toLocaleDateString()}</span>
74
+ </div>
75
+ <div class="flex justify-between mb-2">
76
+ <span class="text-gray-400">Payment Method</span>
77
+ <span class="flex items-center">
78
+ <img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/stripe/stripe-original.svg" class="w-5 h-5 mr-2" />
79
+ Stripe
80
+ </span>
81
+ </div>
82
+ <div class="flex justify-between text-lg font-bold mt-4 pt-4 border-t border-gray-700">
83
+ <span>Total</span>
84
+ <span class="gradient-text">$${(Math.random() * 100 + 50).toFixed(2)}</span>
85
+ </div>
86
+ </div>
87
+
88
+ <div class="flex flex-col sm:flex-row gap-4 justify-center">
89
+ <a href="index.html" class="bg-primary-500 hover:bg-primary-600 text-white font-bold py-3 px-6 rounded-lg transition">
90
+ Continue Shopping
91
+ </a>
92
+ <a href="order-history.html" class="bg-gray-700 hover:bg-gray-600 text-white font-bold py-3 px-6 rounded-lg transition">
93
+ View Order History
94
+ </a>
95
+ </div>
96
+ </section>
97
+
98
+ <script>
99
+ feather.replace();
100
+
101
+ // Animate checkmark
102
+ document.addEventListener('DOMContentLoaded', () => {
103
+ const circle = document.querySelector('.checkmark__circle');
104
+ const check = document.querySelector('.checkmark__check');
105
+
106
+ circle.style.strokeDasharray = '166';
107
+ circle.style.strokeDashoffset = '166';
108
+ circle.style.animation = 'stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards';
109
+
110
+ check.style.strokeDasharray = '48';
111
+ check.style.strokeDashoffset = '48';
112
+ check.style.animation = 'stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards';
113
+ });
114
+ </script>
115
+ </body>
116
+ </html>