#williamrobertson_best-practices

1 messages · Page 1 of 1 (latest)

livid jackalBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1234716193219285024

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

novel bobcat
#

Hello! To add more context on potential solutions, I was more or less thinking about https://stackoverflow.com/a/58832126 where I'd create a new subscription for the upgraded/downgraded plan and then cancel the old subscription + start the new subscription in Stripe if the payment goes through successfully. That seems kind of complicated/tricky from an invoicing perspective though 😅

#

Also this is what I read which stated that you can't delete subscription items with the pending updates feature - #1166797161686630490 message

hollow sonnet
#

Thanks for waiting! Discord is busy now and will take time to reply

#
  • You can't delete subscription items (i.e., we have a plan with 1 line item and another plan with 4 line items)
    What is the use case here? If it's just to delete an item, pending_update is not necessary since there's likely no payment is required.
  • You can't specify a default payment method
    Why is pending update required for default_payment_method change?
  • You can't update the metadata (not a deal breaker, but I'm setting the planID in metadata so we can reference what plan the user upgraded to in our webhooks)
    Metadata change doesn't create a proration. Pending update is not required.

--

Pending update will only take effect if there is a proration, i.e. subscription will only be updated after the payment is made successfully

novel bobcat
# hollow sonnet > - You can't delete subscription items (i.e., we have a plan with 1 line item...

Thanks for the quick response! Let me try to address these:

  1. Say I'm on a "Pro" plan with 3 line items (base product, overage product #1, overage product #2), and I want to downgrade to "Basic" which has 2 line items (base product, overage product #1). I can't update the subscription using the pending updates feature because there's no way to delete subscription items as stated in #1166797161686630490 message

My understanding was that a downgrade could cause a proration to occur hence the need to use pending_updates for both the upgrade + downgrade scenario.

  1. We want users to be able to select which payment method they'd like to use to upgrade/downgrade plans. In doing so, it looked like we'd need to specify the default_payment_method parameter with the ID of the payment method we'd like to use for the subscription update.

3). I want to update the subscription line items (which cause a proration if upgrading from a cheaper plan -> more expensive plan), and at the same time I want to be able to update the metadata for the subscription

Just clarifying again - I'd like to do this all in one API call or see what the "best" way to do this without pending updates would be 🙂

hollow sonnet
#

Thanks for sharing the details.

  1. Say I'm on a "Pro" plan with 3 line items (base product, overage product #1, overage product #2), and I want to downgrade to "Basic" which has 2 line items (base product, overage product #1). I can't update the subscription using the pending updates feature because there's no way to delete subscription items as stated in ⁠unknown
    For downgrade case, payment is usually not required for customer. You likely don't need pending update for this scenario. I'd recommend giving it a try in test mode.
  1. We want users to be able to select which payment method they'd like to use to upgrade/downgrade plans. In doing so, it looked like we'd need to specify the default_payment_method parameter with the ID of the payment method we'd like to use for the subscription update.
    This will require two separate update call - one to update the default_payment_method only and the other to upgrade/downgrade the subscription

3). I want to update the subscription line items (which cause a proration if upgrading from a cheaper plan -> more expensive plan), and at the same time I want to be able to update the metadata for the subscription
Do you only want to update the metadata only when the payment is succeeded?

novel bobcat
# hollow sonnet Thanks for sharing the details. > 1) Say I'm on a "Pro" plan with 3 line items...

True, I'll test out scenario #1 and get back! For (3), yes only when the payment succeeds. The use case there was user updates subscription -> set plan ID metadata -> in subscription.updated webhook, update the plan in my subscriptions database table based on the plan ID metadata. I could probably work around this requirement by attaching the plan ID metadata to the price IDs and using that instead.

For (2) and (3), I'm worried about getting into inconsistent states by using multiple update calls (maybe this isn't super likely). Say I update the payment method for the subscription, but then the upgrade fails. Now the user's payment method has been switched without them being aware of it. I was debating if it would just be worth it to not use pending updates, but I'm a little unsure of how to best handle this logic manually

hollow sonnet
#

If the customer chooses another payment method as default, doesn't it mean that the customer agrees to use the new selected one moving forward? There shouldn't be a need to revert to the previous payment method.

For metadata, another alternative is to only update the metadata after the payment is succeeded

novel bobcat
#

The UX flow I was imagining here was "Before a user confirms a subscription upgrade/downgrade, let them select which payment method they'd like to use moving forward for the transition." If I updated the payment method for the subscription -> attempted the upgrade/downgrade -> the upgrade/downgrade fails (e.g. maybe network failure), wouldn't that mean the existing subscription is now stuck with a payment method that doesn't work?

#

Thank you for the help so far btw, much appreciated