fix: use dynamic Stripe pricing instead of pre-created price IDs
This commit is contained in:
parent
25d77b6d7f
commit
13bddc06ef
|
|
@ -5,41 +5,32 @@ 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"
|
||||
// Dynamic pricing configuration (in EUR cents)
|
||||
const TICKET_PRICE_CENTS = 8000 // €80 early bird
|
||||
|
||||
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
|
||||
|
||||
const registrationData = registrationDataStr ? JSON.parse(registrationDataStr) : null
|
||||
const packages = packagesStr ? JSON.parse(packagesStr) : { accommodation: false, food: false }
|
||||
|
||||
// Use price_data for dynamic pricing (no pre-created prices needed)
|
||||
const lineItems: Stripe.Checkout.SessionCreateParams.LineItem[] = [
|
||||
{
|
||||
price: CCG_TICKET_PRICE_ID,
|
||||
price_data: {
|
||||
currency: "eur",
|
||||
product_data: {
|
||||
name: "CCG 2026 Ticket",
|
||||
description: "Crypto Commons Gathering 2026 - August 16-22, Austria",
|
||||
},
|
||||
unit_amount: TICKET_PRICE_CENTS,
|
||||
},
|
||||
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,
|
||||
})
|
||||
}
|
||||
|
||||
let paymentMethodTypes: Stripe.Checkout.SessionCreateParams.PaymentMethodType[] = ["card"]
|
||||
|
||||
if (paymentMethod === "sepa_debit") {
|
||||
|
|
@ -65,8 +56,6 @@ export async function POST(request: NextRequest) {
|
|||
registrationData.dietary.join(", ") +
|
||||
(registrationData.dietaryOther ? `, ${registrationData.dietaryOther}` : ""),
|
||||
crewConsent: registrationData.crewConsent,
|
||||
includesAccommodation: packages.accommodation ? "yes" : "no",
|
||||
includesFood: packages.food ? "yes" : "no",
|
||||
}
|
||||
: {},
|
||||
...(paymentMethod === "crypto" && {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue