#mohiodin

1 messages · Page 1 of 1 (latest)

stoic spindleBOT
zinc topaz
#

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

primal osprey
#

Could you elaborate your question? And pinpoint on which part of your code is having issue?

zinc topaz
#

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

primal osprey
zinc topaz
#

can you please provide me a code snippet

primal osprey
#

No, you would need to write it yourself. We are happy to help if you face any error

zinc topaz
#

how can i update price recurring interval and interval count