#n10000k

1 messages · Page 1 of 1 (latest)

balmy hareBOT
winter rain
#

Manage to replicate in the Stripe dashboard also

#

Steps to replicate:

  • Subscription in a incompleted status
  • Add new pricing option to subscription + remove old pricing option
  • Update subscription
#

Use case:

  • Customer wants to change subscription pricing plan
  • Don't have to recreate subscriptions each time
raven moss
#

Yes you can only update the attributes mentioned in the error message if the Subscription is in an incomplete status.

#

Don't have to recreate subscriptions each time
You need to create the Susbcription only at the latest step of the checkout flow.

winter rain
#

We create the subscription at the payment intent stage

#
  • Create customer
  • Create subscription
  • Return payment intent on last invoice
#

e.g

// create subscription with Stripe
      return await this.stripe.subscriptions
        .create({
          customer: subscription.providerCustomerId,
          items: [
            {
              price: plan.stripePriceId,
            },
          ],
          payment_behavior: 'default_incomplete',
          payment_settings: {
            save_default_payment_method: 'on_subscription',
            payment_method_types: [
              'card',
            ],
          },
          expand: [
            'latest_invoice.payment_intent',
          ],
          metadata: {
            subscriptionId: subscription.id,
          },
        })
        .then(async (stripeSubscription) => {
          // eslint-disable-next-line @typescript-eslint/ban-ts-comment
          // @ts-ignore
          return stripeSubscription.latest_invoice.payment_intent.client_secret;
        })
#

I'm fairly sure this behaviour was working a few weeks ago, as it's a possible flow in the dashboard and returns a backend api error, there's no validation around this either on the frontend side?

raven moss
#

I'l nt sure of the exact timeline of this validation, but for now and for sure, you can't update those fields if the Subscription is in an incomplete status. You can either cancel and create a new Subscription or complete that Subscription and update it later using prorations.