Spaces:
Running

arbatinukas / index.html
Dextrer's picture
Create a checkout form:** Design a form on your website where users can enter their payment details, such as credit card information - Initial Deployment
16bfe79 verified
Raw History Blame Contribute Delete
20.7 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Secure Checkout</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.card-type-icon {
position: absolute;
right: 10px;
top: 50%;
transform: translateY(-50%);
font-size: 1.5rem;
color: #666;
}
.input-with-icon {
position: relative;
}
.input-with-icon input {
padding-right: 40px;
}
.payment-method {
transition: all 0.3s ease;
}
.payment-method:hover {
transform: translateY(-3px);
box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}
.payment-method.selected {
border-color: #4f46e5;
background-color: #f5f3ff;
}
.flip-card {
perspective: 1000px;
}
.flip-card-inner {
transition: transform 0.6s;
transform-style: preserve-3d;
}
.flip-card:hover .flip-card-inner {
transform: rotateY(10deg);
}
</style>
</head>
<body class="bg-gray-50 min-h-screen">
<div class="container mx-auto px-4 py-12 max-w-4xl">
<div class="flex flex-col md:flex-row gap-8">
<!-- Order Summary -->
<div class="w-full md:w-2/5">
<div class="bg-white rounded-xl shadow-md p-6 sticky top-6">
<h2 class="text-xl font-bold text-gray-800 mb-6">Order Summary</h2>
<div class="space-y-4 mb-6">
<div class="flex justify-between">
<span class="text-gray-600">Subtotal</span>
<span class="font-medium">$129.99</span>
</div>
<div class="flex justify-between">
<span class="text-gray-600">Shipping</span>
<span class="font-medium">$5.99</span>
</div>
<div class="flex justify-between">
<span class="text-gray-600">Tax</span>
<span class="font-medium">$9.75</span>
</div>
</div>
<div class="border-t pt-4">
<div class="flex justify-between text-lg font-bold">
<span>Total</span>
<span>$145.73</span>
</div>
</div>
<div class="mt-6">
<h3 class="font-semibold mb-2">Items (3)</h3>
<div class="space-y-3">
<div class="flex gap-3">
<div class="w-16 h-16 bg-gray-200 rounded-lg overflow-hidden">
<img src="https://via.placeholder.com/80" alt="Product" class="w-full h-full object-cover">
</div>
<div>
<p class="font-medium">Wireless Headphones</p>
<p class="text-sm text-gray-500">1 × $79.99</p>
</div>
</div>
<div class="flex gap-3">
<div class="w-16 h-16 bg-gray-200 rounded-lg overflow-hidden">
<img src="https://via.placeholder.com/80" alt="Product" class="w-full h-full object-cover">
</div>
<div>
<p class="font-medium">Phone Case</p>
<p class="text-sm text-gray-500">2 × $25.00</p>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Checkout Form -->
<div class="w-full md:w-3/5">
<div class="bg-white rounded-xl shadow-md overflow-hidden">
<div class="p-6 border-b">
<h1 class="text-2xl font-bold text-gray-800">Checkout</h1>
<p class="text-gray-600 mt-1">Complete your purchase securely</p>
</div>
<div class="p-6">
<!-- Payment Method Selection -->
<div class="mb-8">
<h2 class="text-lg font-semibold mb-4">Payment Method</h2>
<div class="grid grid-cols-2 gap-3">
<label class="payment-method cursor-pointer">
<input type="radio" name="payment-method" class="hidden" checked>
<div class="border rounded-lg p-4 flex items-center justify-center h-full">
<div class="text-center">
<i class="fab fa-cc-visa text-3xl text-blue-800 mb-2"></i>
<p class="text-sm">Credit Card</p>
</div>
</div>
</label>
<label class="payment-method cursor-pointer">
<input type="radio" name="payment-method" class="hidden">
<div class="border rounded-lg p-4 flex items-center justify-center h-full">
<div class="text-center">
<i class="fab fa-paypal text-3xl text-blue-600 mb-2"></i>
<p class="text-sm">PayPal</p>
</div>
</div>
</label>
</div>
</div>
<!-- Credit Card Form -->
<div id="credit-card-form">
<div class="mb-8 flip-card">
<div class="flip-card-inner">
<div class="bg-gradient-to-r from-indigo-500 to-purple-600 rounded-xl p-6 text-white shadow-lg">
<div class="flex justify-between items-start mb-8">
<div>
<p class="text-sm opacity-80">Card Number</p>
<p class="text-xl font-mono tracking-wider">•••• •••• •••• ••••</p>
</div>
<i class="fab fa-cc-visa text-3xl"></i>
</div>
<div class="flex justify-between items-end">
<div>
<p class="text-sm opacity-80">Card Holder</p>
<p class="font-medium">YOUR NAME</p>
</div>
<div>
<p class="text-sm opacity-80">Expires</p>
<p class="font-medium">••/••</p>
</div>
</div>
</div>
</div>
</div>
<form id="checkout-form">
<div class="space-y-4">
<div>
<label for="card-number" class="block text-sm font-medium text-gray-700 mb-1">Card Number</label>
<div class="input-with-icon">
<input type="text" id="card-number" placeholder="1234 5678 9012 3456"
class="w-full px-4 py-3 border rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
<div class="card-type-icon">
<i class="far fa-credit-card"></i>
</div>
</div>
</div>
<div>
<label for="card-name" class="block text-sm font-medium text-gray-700 mb-1">Name on Card</label>
<input type="text" id="card-name" placeholder="John Smith"
class="w-full px-4 py-3 border rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label for="expiry-date" class="block text-sm font-medium text-gray-700 mb-1">Expiry Date</label>
<input type="text" id="expiry-date" placeholder="MM/YY"
class="w-full px-4 py-3 border rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
</div>
<div>
<label for="cvv" class="block text-sm font-medium text-gray-700 mb-1">CVV</label>
<div class="input-with-icon">
<input type="text" id="cvv" placeholder="•••"
class="w-full px-4 py-3 border rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
<div class="card-type-icon">
<i class="fas fa-question-circle" title="3-digit code on back of card"></i>
</div>
</div>
</div>
</div>
</div>
<div class="mt-8">
<h2 class="text-lg font-semibold mb-4">Billing Address</h2>
<div class="space-y-4">
<div>
<label for="address" class="block text-sm font-medium text-gray-700 mb-1">Street Address</label>
<input type="text" id="address" placeholder="123 Main St"
class="w-full px-4 py-3 border rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label for="city" class="block text-sm font-medium text-gray-700 mb-1">City</label>
<input type="text" id="city" placeholder="New York"
class="w-full px-4 py-3 border rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
</div>
<div>
<label for="zip" class="block text-sm font-medium text-gray-700 mb-1">ZIP Code</label>
<input type="text" id="zip" placeholder="10001"
class="w-full px-4 py-3 border rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
</div>
</div>
<div>
<label for="country" class="block text-sm font-medium text-gray-700 mb-1">Country</label>
<select id="country" class="w-full px-4 py-3 border rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
<option>United States</option>
<option>Canada</option>
<option>United Kingdom</option>
<option>Australia</option>
<option>Other</option>
</select>
</div>
</div>
</div>
<div class="mt-8 flex items-center">
<input type="checkbox" id="save-info" class="w-4 h-4 text-indigo-600 rounded focus:ring-indigo-500">
<label for="save-info" class="ml-2 text-sm text-gray-700">Save this information for next time</label>
</div>
<div class="mt-8">
<button type="submit" class="w-full bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-3 px-4 rounded-lg transition duration-200 flex items-center justify-center">
<span>Pay $145.73</span>
<i class="fas fa-lock ml-2"></i>
</button>
<p class="text-xs text-gray-500 mt-2 text-center">
<i class="fas fa-shield-alt mr-1"></i> Your payment is securely encrypted
</p>
</div>
</form>
</div>
<!-- PayPal Form (Hidden by default) -->
<div id="paypal-form" class="hidden">
<div class="text-center py-8">
<i class="fab fa-paypal text-5xl text-blue-600 mb-4"></i>
<p class="mb-6">You'll be redirected to PayPal to complete your purchase securely.</p>
<button class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-4 rounded-lg transition duration-200">
Continue with PayPal
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Payment method selection
const paymentMethods = document.querySelectorAll('.payment-method');
const creditCardForm = document.getElementById('credit-card-form');
const paypalForm = document.getElementById('paypal-form');
paymentMethods.forEach(method => {
method.addEventListener('click', function() {
// Remove selected class from all methods
paymentMethods.forEach(m => {
m.querySelector('div').classList.remove('selected');
});
// Add selected class to clicked method
this.querySelector('div').classList.add('selected');
// Show corresponding form
if (this.querySelector('input').nextElementSibling.querySelector('i').classList.contains('fa-cc-visa')) {
creditCardForm.classList.remove('hidden');
paypalForm.classList.add('hidden');
} else {
creditCardForm.classList.add('hidden');
paypalForm.classList.remove('hidden');
}
});
});
// Format card number input
const cardNumberInput = document.getElementById('card-number');
cardNumberInput.addEventListener('input', function(e) {
let value = this.value.replace(/\s+/g, '').replace(/[^0-9]/gi, '');
let matches = value.match(/\d{4,16}/g);
let match = matches && matches[0] || '';
let parts = [];
for (let i=0, len=match.length; i<len; i+=4) {
parts.push(match.substring(i, i+4));
}
if (parts.length) {
this.value = parts.join(' ');
}
// Detect card type and change icon
const cardTypeIcon = document.querySelector('.card-type-icon i');
if (/^4/.test(value)) {
cardTypeIcon.className = 'fab fa-cc-visa';
cardTypeIcon.style.color = '#1a1f71';
} else if (/^5[1-5]/.test(value)) {
cardTypeIcon.className = 'fab fa-cc-mastercard';
cardTypeIcon.style.color = '#eb001b';
} else if (/^3[47]/.test(value)) {
cardTypeIcon.className = 'fab fa-cc-amex';
cardTypeIcon.style.color = '#016fd0';
} else if (/^6(?:011|5)/.test(value)) {
cardTypeIcon.className = 'fab fa-cc-discover';
cardTypeIcon.style.color = '#ff6000';
} else {
cardTypeIcon.className = 'far fa-credit-card';
cardTypeIcon.style.color = '#666';
}
});
// Format expiry date input
const expiryDateInput = document.getElementById('expiry-date');
expiryDateInput.addEventListener('input', function(e) {
let value = this.value.replace(/\s+/g, '').replace(/[^0-9]/gi, '');
if (value.length > 2) {
this.value = value.substring(0, 2) + '/' + value.substring(2, 4);
}
});
// Form submission
const checkoutForm = document.getElementById('checkout-form');
checkoutForm.addEventListener('submit', function(e) {
e.preventDefault();
// Here you would normally process the payment
alert('Payment processed successfully!');
});
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Dextrer/arbatinukas" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>