fix: map plan names to correct Stripe price IDs
- Add PLAN_NAME_TO_STRIPE_ID mapping helper - Maps: Chat IA → essential, Chat + Voz → profesional, Empresa IA → premium - Fixes bug where wrong plan IDs were sent to Stripe (e.g. 'chat ia' instead of 'essential') - Test calls verified for all 3 tiers across verticals
This commit is contained in:
+22
-1
@@ -11,6 +11,27 @@ type Language = "es" | "en";
|
|||||||
type Vertical = "real-estate" | "restaurant" | "clinic" | "home-services" | "car-rental";
|
type Vertical = "real-estate" | "restaurant" | "clinic" | "home-services" | "car-rental";
|
||||||
type Location = "generic" | "benalmadena";
|
type Location = "generic" | "benalmadena";
|
||||||
|
|
||||||
|
// Map internal plan names to Stripe price IDs
|
||||||
|
// Essential = Chat IA / AI Chat (€299)
|
||||||
|
// Profesional = Chat + Voz / Chat + Voice (€599)
|
||||||
|
// Premium = Empresa IA / AI Company (€1,499)
|
||||||
|
const PLAN_NAME_TO_STRIPE_ID: Record<string, string> = {
|
||||||
|
// Spanish
|
||||||
|
"chat ia": "essential",
|
||||||
|
"chat + voz": "profesional",
|
||||||
|
"empresa ia": "premium",
|
||||||
|
// English
|
||||||
|
"ai chat": "essential",
|
||||||
|
"chat + voice": "profesional",
|
||||||
|
"ai company": "premium",
|
||||||
|
};
|
||||||
|
|
||||||
|
function getStripePlanId(planName: string, vertical: string): string {
|
||||||
|
const normalizedName = planName.toLowerCase().trim();
|
||||||
|
const tier = PLAN_NAME_TO_STRIPE_ID[normalizedName] || "essential";
|
||||||
|
return `demo-${vertical}-${tier}`;
|
||||||
|
}
|
||||||
|
|
||||||
const contentByLang = {
|
const contentByLang = {
|
||||||
es: {
|
es: {
|
||||||
nav: { features: "Características", pricing: "Precios", contact: "Contacto", cta: "Pedir demo" },
|
nav: { features: "Características", pricing: "Precios", contact: "Contacto", cta: "Pedir demo" },
|
||||||
@@ -473,7 +494,7 @@ function DemosContent() {
|
|||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
<PaymentButton
|
<PaymentButton
|
||||||
planId={`demo-${selected}-${plan.name.toLowerCase().replace("starter", "starter").replace("site", "site").replace("growth", "growth")}`}
|
planId={getStripePlanId(plan.name, selected)}
|
||||||
planType="monthly"
|
planType="monthly"
|
||||||
label={lang === "es" ? "Elegir plan" : "Choose plan"}
|
label={lang === "es" ? "Elegir plan" : "Choose plan"}
|
||||||
variant={plan.popular ? "primary" : "secondary"}
|
variant={plan.popular ? "primary" : "secondary"}
|
||||||
|
|||||||
Reference in New Issue
Block a user