Search code examples
stripe-payments

Upgrading Stripe Subscription from Free to Paid


My application automatically creates a Stripe Subscription with a Free price for all users, without collecting payment details.

When the user upgrades to the Paid plan, I update the Subscription as described in https://docs.stripe.com/billing/subscriptions/upgrade-downgrade , but since the customer has no payment info, the API call fails.

stripe_client.subscriptions.update(
    subscription_id,
    {
        "expand": ["latest_invoice.payment_intent"],
        "items": [
            {
                "id": subscription_item_id,
                "price": price,
                "quantity": quantity,
            }
        ],
    },
)

This customer has no attached payment source or default payment method. Please consider adding a default payment method. For more information, visit https://stripe.com/docs/billing/subscriptions/payment-methods-setting#payment-method-priority.

I'm not using the embedded page but a custom flow. How should I collect the payment details in this flow? My goal is to collect the payment details when the user attempts to subscribe to the Paid plan and then charge them for the subscription fee (by upgrading their subscription).

I understand I could create a Payment Intent (or Setup Intent?) manually, but how do I associate it with the Subscription?


Solution

  • If you use a SetupIntent to collect the payment method then you can set the payment method as default on the subscription when you update it - https://docs.stripe.com/api/subscriptions/update#update_subscription-default_payment_method

    The other option here to use Customer Portal to collect the payment method - https://docs.stripe.com/billing/subscriptions/trials#use-the-customer-portal-to-collect-payment