#lovitt_api

1 messages · Page 1 of 1 (latest)

distant rampartBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1253718160235040829

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

tall abyss
#

Hi 👋 can you share the requset ID showing how you've been approaching this? Offhand I'd expect you to be able to use discounts.coupon to provide the same Coupon to each phase where you want to use it. Is that what you described as option 1?

plain stream
#

thanks for getting back to me. here are the request IDs for the three things I've tried:

  1. Applying coupon to both current and next phase: req_hIWH9Pqt5ibjrs
  2. Applying coupon to current phase only: req_FtMIEIPysEK1Pl
  3. Applying coupon to next phase only: req_9uM29lGfK6pN4t

in these examples, I'm applying the discount ID to the SubscriptionSchedule.phases.discounts property

tall abyss
#

I think using an existing Discount object is the problem here. Can you provide the ID of your Coupon to discounts.coupon, which will create new Discounts, instead of trying to pass an existing Discount object's ID to discounts.discount?

plain stream
#

ah, interesting, let me try that

#

it worked!

#

req_2YdCZCoawRyTkw

#

thank you so much. in general, if I want to preserve any existing discounts on the subscription when creating a SubscriptionSchedule, it is safe to follow this approach? i.e., set the coupon ID on discounts.coupon field of both the current and new phase?

tall abyss
#

I think if you want to reuse an existing Discount object, it's fine to do so. The problem here is that you were trying to use a Discount that was only valid for a single phase across multiple phases, and that is expected to error and would require creating new Discounts to avoid that.

plain stream
#

I guess I'm still confused why my original #2 or #3 above would not have worked. my intent was not to make the "once" discount apply across multiple phases. I just wanted to retain it, such that it would continue to apply to the upcoming invoice only

#

but it sounds like referencing the coupon ID instead when creating a SubscriptionSchedule will work for perserving any discounts, so I will just change my code to do that. thank you again for your help!

tall abyss
#

Any time! The server is pretty busy right now, but I can come back and take a closer look at 2 and 3 that you shared if things slow down.

tall abyss
#

For 2, it looks to me to be expected that nothing happened. The Discount is being applied to the current phase, which the customer has already paid for because the Price being used bills at the beginning of a billing period. Then when the phase change happens, the Subscription Schedule doesn't persist the Discount to the next phase.

#

3 I can't explain as easily, I think I'd need to take a closer look at the output you received when previewing the upcoming invoice for that Subscription.

plain stream
#

fwiw, for #3, here is what the subscription page looks like after that subscription schedule has been created (sub_1PJGY101z6HWY8PkcBjKQDCF)

#

it is weird, because the 100%-off one-time coupon is referenced in the event details of the upcoming phase. but you can also see that the coupon is not applied to the upcoming invoice

distant rampartBOT
plain stream
#

this is not a big deal though, the new approach you suggested of referencing the coupon ID instead is working great. I am mainly just curious 🙂

tall abyss
#

Totally understand (I'm also a bit curious). My best guess, is that the UI is not taking the discount into account because it hasn't actually been applied yet, even though it will be next phase. I'd be curious if you ran that scenario through a Test Clock, if the Invoice would actually be discounted:
https://docs.stripe.com/billing/testing/test-clocks
If the new approach is working though, it may not be worth spending tooo much time looking at that.

Learn how to move Billing objects through time in test mode.

plain stream
#

fascinating, I will try that now