#raf7703_api

1 messages ¡ Page 1 of 1 (latest)

regal copperBOT
#

👋 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/1215397092894187581

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

swift pivotBOT
#

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

opaque iris
#

You can opt in to this, but some scenarios require it to happen

#

What issues are you having with the upcoming invoice API?

drowsy nexus
#

State 1 -> I create a customer and purchase 2 licences at $50 each. I immediately pay $100. My next bill shows $100 -GOOD

State 2 -> I manually add 50% off discount code. My previous payment still shows $100. My next bill now shows $50 - GOOD

State 3 -> I add an additional licence to the subscription. I expect to pay an immediate prorated charge around $25 dollars ($50/2) and i expect my next monthly bill to be $75. However this is not the case. I see no immediate charge and the next monthly bill is showing up as $50.01. the math works out as follows 3*$50 = $150 apply the %50 off brings it to $75, then a credit of -$24.99 is applied to the bill. I can kind of theorize where this credit is coming from. However This crediting system makes it difficult for me to determine if there will be an immediate charge to the customers account and what there next monthly bill will be. I can not determine a simple way to determine these amounts using the invoices.retrieveUpcoming endpoint. These are the two things i need before updating the subscription. 1. what value if any will the customer be charged immediately if they add an additional licence now 2. What will there next recurring bill payment be

#

When i call invoices.retrieveUpcoming here is my code

 const items = [
      {
        id: subscription.items.data[0].id,
        price: subscription.items.data[0].price.id,
        quantity: dto.quantity + 1,
      },
    ];

const invoiceProration = await this.stripe.invoices.retrieveUpcoming({
      customer: stripeCustomer.customerID,
      subscription: subscription.id,
      subscription_items: items,
      subscription_proration_date: proration_date,
      subscription_proration_behavior: 'always_invoice',
    });
opaque iris
#

So, I think I'd recommend you look at using test clocks to account for time in these tests

#

the $0.01 amount suggests you're crediting for the additional license added soon after the other changes

#

Do you want immediate payment when licenses are added?

#

The default would be adding a prorated amount for the remainder of the current period to the next invoice

#

You can optionally imvoice immediately, and you can also optionally disable prorations

drowsy nexus
#

Yes I want immediate payment when licenses are added. Therefore, I have proration_behavior set to always_invoice when i call stripe to update the subscription.

    let updatedSubscription = await this.stripe.subscriptions.update(
      subscription.id,
      {
        items: [
          {
            id: subscription.items.data[0].id,
            price: subscription.items.data[0].price.id,
            quantity: quantity,
          },
        ],
              //Should be adding proration date but fine for now
        proration_behavior: 'always_invoice',
      },
    );

#

Is it possible to prevent this crediting on the next month bill. When adding the licence? I think it has something to do with adding the 50% off coupon after the subscription was already purchased at full price.

#

Maybe there is a way to only have the coupon start at the start of the next billing cycling?

opaque iris
#

Yes, its prorating the current period remainder when you add the coupon

#

You can add the coupon while using proration_behavior=none during that update so the discount only applies to the renewal, not the current period

#

But again you should explore the behaviour here with lots of testing