diff --git a/app/api/create-checkout-session/route.ts b/app/api/create-checkout-session/route.ts index 108423d..faca94a 100644 --- a/app/api/create-checkout-session/route.ts +++ b/app/api/create-checkout-session/route.ts @@ -5,14 +5,41 @@ const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, { apiVersion: "2024-12-18.acacia", }) +const CCG_TICKET_PRICE_ID = "price_1SbokZ8IwXvKSVJpRvkTqePT" +const CCG_ACCOMMODATION_PRICE_ID = "price_1Sboq08IwXvKSVJpf8RRSoCy" +const CCG_FOOD_PRICE_ID = "price_1Sboq18IwXvKSVJpY7NJWaYd" + export async function POST(request: NextRequest) { try { const formData = await request.formData() const paymentMethod = formData.get("paymentMethod") as string const registrationDataStr = formData.get("registrationData") as string + const packagesStr = formData.get("packages") as string // Parse registration data const registrationData = registrationDataStr ? JSON.parse(registrationDataStr) : null + const packages = packagesStr ? JSON.parse(packagesStr) : { accommodation: false, food: false } + + const lineItems: Stripe.Checkout.SessionCreateParams.LineItem[] = [ + { + price: CCG_TICKET_PRICE_ID, + quantity: 1, + }, + ] + + if (packages.accommodation) { + lineItems.push({ + price: CCG_ACCOMMODATION_PRICE_ID, + quantity: 1, + }) + } + + if (packages.food) { + lineItems.push({ + price: CCG_FOOD_PRICE_ID, + quantity: 1, + }) + } // Configure payment method types based on selection let paymentMethodTypes: Stripe.Checkout.SessionCreateParams.PaymentMethodType[] = ["card"] @@ -25,25 +52,7 @@ export async function POST(request: NextRequest) { const session = await stripe.checkout.sessions.create({ payment_method_types: paymentMethodTypes, - line_items: [ - { - price_data: { - currency: "eur", - product_data: { - name: "Crypto Commons Gathering 2026", - description: "Full event access including all sessions and infrastructure", - images: ["https://ccg2025.vercel.app/og-image.png"], - }, - unit_amount: 20000, // €200 - }, - quantity: 1, - adjustable_quantity: { - enabled: true, - minimum: 1, - maximum: 5, - }, - }, - ], + line_items: lineItems, mode: "payment", success_url: `${request.nextUrl.origin}/success?session_id={CHECKOUT_SESSION_ID}`, cancel_url: `${request.nextUrl.origin}/register`, @@ -51,13 +60,15 @@ export async function POST(request: NextRequest) { ? { name: registrationData.name, contact: registrationData.contact, - contributions: registrationData.contributions.substring(0, 500), // Stripe has length limits + contributions: registrationData.contributions.substring(0, 500), expectations: registrationData.expectations.substring(0, 500), howHeard: registrationData.howHeard || "", dietary: registrationData.dietary.join(", ") + (registrationData.dietaryOther ? `, ${registrationData.dietaryOther}` : ""), crewConsent: registrationData.crewConsent, + includesAccommodation: packages.accommodation ? "yes" : "no", + includesFood: packages.food ? "yes" : "no", } : {}, // For stablecoin payments diff --git a/app/register/page.tsx b/app/register/page.tsx index 24c8556..4e148bf 100644 --- a/app/register/page.tsx +++ b/app/register/page.tsx @@ -24,6 +24,20 @@ export default function RegisterPage() { dietaryOther: "", crewConsent: "", }) + const [packages, setPackages] = useState({ + accommodation: false, + food: false, + }) + + const baseTicketPrice = 200 + const accommodationPrice = 227.4 + const foodPrice = 135 + const calculateTotal = () => { + let total = baseTicketPrice + if (packages.accommodation) total += accommodationPrice + if (packages.food) total += foodPrice + return total + } const handleSubmit = (e: React.FormEvent) => { e.preventDefault() @@ -63,63 +77,89 @@ export default function RegisterPage() {

Complete Your Registration

-

Choose your payment method

+

Select packages and payment method

- Event Cost Breakdown - Full 6-day event costs (August 16-22, 2026) + Select Your Packages + Ticket is required. Add accommodation and food as needed. -
-
-
-
Ticket Price
-
Venue rental & infrastructure
+
+ {/* Ticket (required) */} +
+
+ +
+
CCG 2026 Ticket (Required)
+
Venue rental & infrastructure
+
- €200 + €200.00
-
-
-
Accommodation
-
6 nights dorm (€37.90/night)
+ + {/* Accommodation */} +
+
+ setPackages({ ...packages, accommodation: checked as boolean })} + className="mt-1" + /> +
€227.40
-
-
-
Food
-
6 days meals (€22.50/day avg)
+ + {/* Food */} +
+
+ setPackages({ ...packages, food: checked as boolean })} + className="mt-1" + /> +
- €135 + €135.00
+ + {/* Total */}
-
Total Estimated Cost
-
Pay ticket now, accommodation & food at venue
+
Total Amount
+
+ {packages.accommodation || packages.food + ? "All selected items will be charged now" + : "Ticket only"} +
- €562.40 + €{calculateTotal().toFixed(2)}
-

- You're only paying the ticket price (€200) now. Accommodation and food will be arranged and paid - separately at the Commons Hub. -

- {/* */} {/* Payment Methods */}
Payment Options - Ticket Price: €200 per person + Choose your preferred payment method
+