Spaces:
Running

contentcraft-AI / checkout.html
jisoe's picture
Enable Stripe integration
2606d6f verified
Raw History Blame Contribute Delete
14 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Checkout - ContentCraft AI</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://js.stripe.com/v3/"></script>
<style>
.checkout-card {
transition: all 0.3s ease;
}
.checkout-card:hover {
transform: translateY(-3px);
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
</style>
</head>
<body class="bg-gray-50 font-sans antialiased">
<!-- Navigation -->
<nav class="relative z-10 bg-white shadow-sm">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16">
<div class="flex items-center">
<a href="index.html" class="text-xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-cyan-500 to-indigo-500">ContentCraft AI</a>
</div>
<div class="hidden md:flex items-center space-x-8">
<a href="index.html" class="text-gray-700 hover:text-primary-500 font-medium">Home</a>
<a href="services.html" class="text-gray-700 hover:text-primary-500 font-medium">Services</a>
<a href="about.html" class="text-gray-700 hover:text-primary-500 font-medium">About</a>
<a href="faq.html" class="text-gray-700 hover:text-primary-500 font-medium">FAQ</a>
<a href="contact.html" class="text-gray-700 hover:text-primary-500 font-medium">Contact</a>
<button class="bg-primary-500 hover:bg-primary-600 text-white px-4 py-2 rounded-lg font-medium transition-colors">Get Started</button>
</div>
<div class="md:hidden flex items-center">
<button>
<i data-feather="menu"></i>
</button>
</div>
</div>
</nav>
<!-- Checkout Content -->
<section class="py-20">
<div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="grid grid-cols-1 lg:grid-cols-2 gap-12">
<!-- Order Summary -->
<div class="checkout-card bg-white rounded-xl shadow-sm p-8">
<h2 class="text-2xl font-bold text-gray-900 mb-6">Order Summary</h2>
<div class="space-y-4">
<div class="flex justify-between items-center">
<span class="text-lg font-medium text-gray-900">Pro Plan</span>
<span class="text-lg font-bold text-gray-900">$79</span>
<span class="text-gray-500">/month</span>
</div>
<div class="border-t border-gray-200 pt-4">
<div class="flex justify-between mb-2">
<span class="text-gray-600">50,000 words per month</span>
</div>
<div class="border-t border-gray-200 pt-4">
<div class="flex justify-between mb-1">
<span class="text-sm text-gray-600">Subtotal</span>
<span class="text-sm font-medium text-gray-900">$79.00</span>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-sm text-gray-600">
<i data-feather="lock" class="inline mr-2 w-4 h-4"></i>
Secure checkout
</div>
</div>
</div>
<!-- Payment Form -->
<div class="checkout-card bg-white rounded-xl shadow-sm p-8">
<h2 class="text-2xl font-bold text-gray-900 mb-6">Payment Details</h2>
<form id="checkout-form" class="space-y-6">
<div>
<label for="email" class="block text-sm font-medium text-gray-700 mb-2">Email Address</label>
<input type="email" id="email" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent" placeholder="your@email.com" required>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Card Information</label>
<div id="card-element" class="border border-gray-300 rounded-lg p-3">
</div>
<div id="card-errors" role="alert" class="text-red-500 text-sm mt-2"></div>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label for="first-name" class="block text-sm font-medium text-gray-700 mb-2">First Name</label>
<input type="text" id="first-name" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent" placeholder="John" required>
</div>
<div>
<label for="last-name" class="block text-sm font-medium text-gray-700 mb-2">Last Name</label>
<input type="text" id="last-name" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent" placeholder="Doe" required>
</div>
</div>
<button type="submit" class="w-full bg-primary-500 hover:bg-primary-600 text-white py-4 rounded-lg font-bold text-lg transition-colors">
Complete Payment
</button>
</form>
</div>
</div>
</div>
</section>
<!-- Footer -->
<footer class="bg-gray-900 text-white pt-16 pb-8">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="grid grid-cols-1 md:grid-cols-4 gap-12">
<div>
<h3 class="text-xl font-bold mb-6">ContentCraft AI</h3>
<p class="text-gray-400">
Revolutionizing content creation with advanced AI technology that delivers human-quality writing at scale.
</p>
<div class="flex space-x-4 mt-6">
<a href="#" class="text-gray-400 hover:text-white">
<i data-feather="twitter" class="w-5 h-5"></i>
</a>
<a href="#" class="text-gray-400 hover:text-white">
<i data-feather="facebook" class="w-5 h-5"></i>
</a>
<a href="#" class="text-gray-400 hover:text-white">
<i data-feather="linkedin" class="w-5 h-5"></i>
</a>
</div>
</div>
<div>
<h4 class="text-sm font-semibold uppercase tracking-wider mb-6">Services</h4>
<ul class="space-y-2">
<li><a href="#" class="text-gray-400 hover:text-white">Blog Articles</a></li>
<li><a href="#" class="text-gray-400 hover:text-white">SEO Content</a></li>
<li><a href="#" class="text-gray-400 hover:text-white">Product Descriptions</a></li>
<li><a href="#" class="text-gray-400 hover:text-white">Website Copy</a></li>
<li><a href="#" class="text-gray-400 hover:text-white">Newsletters</a></li>
</ul>
</div>
<div>
<h4 class="text-sm font-semibold uppercase tracking-wider mb-6">Resources</h4>
<ul class="space-y-2">
<li><a href="#" class="text-gray-400 hover:text-white">Blog</a></li>
<li><a href="#" class="text-gray-400 hover:text-white">Content Guide</a></li>
<li><a href="#" class="text-gray-400 hover:text-white">SEO Tips</a></li>
<li><a href="#" class="text-gray-400 hover:text-white">API Access</a></li>
</ul>
</div>
<div>
<h4 class="text-sm font-semibold uppercase tracking-wider mb-6">Company</h4>
<ul class="space-y-2">
<li><a href="about.html" class="text-gray-400 hover:text-white">About Us</a></li>
<li><a href="contact.html" class="text-gray-400 hover:text-white">Contact</a></li>
<li><a href="privacy.html" class="text-gray-400 hover:text-white">Privacy Policy</a></li>
<li><a href="terms.html" class="text-gray-400 hover:text-white">Terms of Service</a></li>
</ul>
</div>
</div>
<div class="mt-12 pt-8 border-t border-gray-800 flex flex-col md:flex-row justify-between items-center">
<p class="text-gray-400 text-sm">
© 2025 ContentCraft AI. All rights reserved.
</p>
<div class="mt-4 md:mt-0 flex space-x-6">
<a href="privacy.html" class="text-gray-400 hover:text-white text-sm">Privacy Policy</a>
<a href="terms.html" class="text-gray-400 hover:text-white text-sm">Terms of Service</a>
<a href="#" class="text-gray-400 hover:text-white text-sm">Cookie Policy</a>
</div>
</div>
</footer>
<script>
// Initialize Stripe
const stripe = Stripe('pk_test_51QNq8xRw2vV6x8V9aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789');
const elements = stripe.elements();
// Create card element
const card = elements.create('card', {
style: {
base: {
fontSize: '16px',
color: '#424770',
'::placeholder': {
color: '#aab7c4',
},
});
card.mount('#card-element');
// Handle real-time validation errors from the card Element
card.addEventListener('change', ({error}) => {
const displayError = document.getElementById('card-errors');
if (error) {
displayError.textContent = error.message;
} else {
displayError.textContent = '';
}
});
// Handle form submission
const form = document.getElementById('checkout-form');
form.addEventListener('submit', async (event) => {
event.preventDefault();
const submitButton = form.querySelector('button[type="submit"]');
submitButton.disabled = true;
submitButton.textContent = 'Processing...';
const {error, paymentMethod} = await stripe.createPaymentMethod({
type: 'card',
card: card,
billing_details: {
name: document.getElementById('first-name').value + ' ' + document.getElementById('last-name').value,
email: document.getElementById('email').value,
},
});
if (error) {
document.getElementById('card-errors').textContent = error.message;
submitButton.disabled = false;
submitButton.textContent = 'Complete Payment';
} else {
// Send payment method to your server
const response = await fetch('/api/create-subscription', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
paymentMethodId: paymentMethod.id,
email: document.getElementById('email').value,
plan: 'pro'
});
if (response.ok) {
const result = await response.json();
if (result.success) {
window.location.href = '/success.html';
} else {
throw new Error('Payment processing failed');
}
} catch (err) {
document.getElementById('card-errors').textContent = 'Payment successful! Your subscription is now active.');
} else {
document.getElementById('card-errors').textContent = 'Payment failed. Please try again.';
submitButton.disabled = false;
submitButton.textContent = 'Complete Payment';
}
});
</script>
<script>
feather.replace();
</script>
</body>
</html>