I am using the below code to add products to Stripe:
const baseProduct = await stripe.products.create({
name: 'Basetest4',
description: 'Basetest4 subscription plan',
});
await stripe.prices.create({
product: baseProduct.id,
unit_amount: 800, // $8 in cents
currency: 'usd',
recurring: {
interval: 'month',
trial_period_days: 0, // Ensure no trial period is set
},
});
This adds the product to Stripe. However, when I get that product on the frontend using the code:
const basePlan = products.find((product) => product.id === 'prod_R7C*********Zvw');
console.log('Base plan:', basePlan);
// const plusPlan = products.find((product) => product.name === 'Plusv2');
// console.log('Plus plan:', plusPlan);
const basePrice = prices.find((price) => price.productId === basePlan?.id);
// const plusPrice = prices.find((price) => price.productId === plusPlan?.id);
return (
<main className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
<div className="grid md:grid-cols-2 gap-8 max-w-xl mx-auto">
<PricingCard
name={basePlan?.name || 'Base'}
price={basePrice?.unitAmount || 800}
interval={basePrice?.interval || 'month'}
trialDays={basePrice?.trialPeriodDays || 7}
features={['Basic Access', 'Standard Support', 'Core Features']}
priceId={basePrice?.id}
/>
</div>
</main>
);
The code has *
which is changed during running (hidden for security purposes). When I run on the frontend and click on the checkout URL,
I see this: https://imgur.com/a/NQTMpSX.
Now see there is a 14 days free trial. I don’t want to give a trial and want to start the billing from the instant the payment is made. How can I make these changes? Please let me know if you need any other code blocks.
tried adding
trial_period_days = 0