#mohiodin
1 messages · Page 1 of 1 (latest)
const newIntervalType = "day"; // replace with the new interval type
const newIntervalCount = plan.days_difference; // replace with the new interval count
// Get the subscription object from Stripe
const subscription = await stripe.subscriptions.retrieve(
subscription_id
);
console.log("subscription", subscription);
// Get the ID of the current recurring price plan for the subscription
const currentPriceId = subscription.items.data[0].price.id;
console.log("currentPriceId", currentPriceId.stripe_product_id);
// Update the recurring price plan with the new interval and interval count
const updatedPrice = await stripe.prices.update(
currentPriceId.stripe_product_id,
{
recurring: {
interval: newIntervalType,
interval_count: newIntervalCount,
},
}
);
console.log("updatedPrice", updatedPrice);
// Update the subscription with the new recurring price plan
const updatedSubscription = await stripe.subscriptions.update(
subscription_id,
{
cancel_at_period_end: true,
items: [
{
id: subscription.items.data[0].id,
price: updatedPrice.id,
}
],
}
);
i am updating in ythis way
waiting for reply
Could you elaborate your question? And pinpoint on which part of your code is having issue?
i want to update subscription with new interval type and interval count
i want to update interval count in price as 30 and interval type as days
Here is the paramters: https://stripe.com/docs/api/subscriptions/update#update_subscription-items-price_data-recurring-interval
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
can you please provide me a code snippet
No, you would need to write it yourself. We are happy to help if you face any error
how can i update price recurring interval and interval count