Logo

dev-resources.site

for different kinds of informations.

Stripe Invoice.Upcoming changes: model switching from monthly to yearly

Published at
12/16/2024
Categories
stripe
Author
alexbtoast
Categories
1 categories in total
stripe
open
Author
10 person written this
alexbtoast
open
Stripe Invoice.Upcoming changes: model switching from monthly to yearly

How to use the Python SDK stripe.Invoice.upcoming call to preview a new invoice using a different quantity and plan?

There is a reference in the Stripe Invoice docs stating values can be passed when retrieving the upcoming invoice to model what-if scenarios

When fetching the preview, you can also model what the invoice would look like if you changed the subscription in one of these ways:

Swapping the underlying price.
Altering the quantity.
Applying a trial period.
Adding a coupon.
Enter fullscreen mode Exit fullscreen mode

There isn't enough information in the API or SDK changelogs to determine how to replace the deprecated params we use with new ones

Old:

return stripe.Invoice.upcoming(
        customer=customer_id,
        subscription=stripe_subscription_id,
        subscription_quantity=quantity_to_calculate_with, # if None, defaults to current
        subscription_proration_date=proration_date_as_unix_seconds,  
        subscription_plan=plan_to_calculate_with, # if None, defaults to current  
    )
Enter fullscreen mode Exit fullscreen mode

Attempted New:

subscription_details = dict(
proration_date=proration_date_as_unix_seconds, 
items=[
     {
     'quantity': quantity_to_calculate_with, 
     'plan': plan_to_calculate_with
     }
])

return stripe.Invoice.upcoming(
        customer=customer_id,
        subscription=stripe_subscription_id,
        subscription_details=subscription_details
)

Enter fullscreen mode Exit fullscreen mode

I can set the price to the plan id I was using before, the problem I have now is that I cannot model the new invoice price when switching from a monthly to a yearly plan. The error:

All prices on a subscription must have the same recurring.interval and recurring.interval_count. If you meant to update an existing subscription item instead of creating a new one, make sure to include the subscription item ID in your request. See examples at https://stripe.com/docs/billing/subscriptions/upgrade-downgrade#changing.

stripe Article's
30 articles in total
Favicon
Boost Your Shopify Sales in Australia, the US, and Beyond: Accept Various Payment Methods and Currencies with Stripe
Favicon
Boost Your Shopify Sales in Poland, Europe, and Beyond: Accept Various Payment Methods and Currencies with Stripe
Favicon
Is Stripe your only choice for payment gateway in Sharetribe?
Favicon
Stripe Invoice.Upcoming changes: model switching from monthly to yearly
Favicon
Replay failed stripe events via webhook
Favicon
Building a Payment System for Your Flutter App: A Journey with Stripe Connect and Firebase
Favicon
Understanding Laravel Cashier's Core Traits: A Deep Dive
Favicon
Creating Stripe Test Data in Python
Favicon
Simplifying Payments with Pay gem: A Guide to Using Stripe in Rails
Favicon
Comparison of the middleware implementation between Supabase Auth documentation and the nextjs-stripe-supabase.
Favicon
Building a Custom Shipping Calculator with Stripe and Netlify Functions for Multi-Currency (€/$), Quantity, and Location Support
Favicon
🌟Open-source SaaS Starter: React + Firebase + Stripe + i18n
Favicon
Creating a marketplace with Stripe Connect: The onboarding process
Favicon
Stripe Subscription Integration in Node.js [2024 Ultimate Guide]
Favicon
Clerk Update – November 12, 2024
Favicon
Integrating Stripe Payment Intent in NestJS with Webhook Handling
Favicon
How Mocking Against a Public API Endpoints within Blackbird Gets your API in Production Faster
Favicon
How to add Stripe to Astro
Favicon
Designing Idempotent APIs
Favicon
Building E-Commerce Platforms with Next.js and Stripe: A Step-by-Step Guide
Favicon
How to retrieve the Transactions from Stripe
Favicon
Integration with Stripe for Payment Processing on AWS
Favicon
Providing receipts for in-person transactions with Terminal
Favicon
Providing receipts for in-person transactions with Terminal
Favicon
Top 10 Payment Processors for Next.js Applications [2024]
Favicon
Fixing the Stripe API Key Error When Migrating Next.js from Vercel to Azure Static Web Apps
Favicon
Announcing the Release of my Stripe to SevDesk Integration
Favicon
Receive payments easily using Stripe and PHP
Favicon
Integrating Payment Gateways in Next.js 14
Favicon
Experimenting with pricing: Finding the right strategy for growth!

Featured ones: