#hotwire_api

1 messages · Page 1 of 1 (latest)

brave stirrupBOT
#

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

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

sudden parrot
#

Are you able to share a bit more context here please?

tender breach
#

Let me double check the API version first so we're on the same page on that

sudden parrot
tender breach
#

Ah okay, just checked the code and we're using whatever it will default to.

When I make that call, depending on if I set the proration behaviour or not, I either get the full amount the new product quantities will invoice in the next billing cycle, or the amount the new items will add to your costs.

As we're billing for the prorated additional product immediately I'm looking for the invoice the person will be paying right then.

So say we're adding £400 to their billing at the next billing cycle, and they are buying somewhere in the middle of the month, I'm looking to tell them they are about to be billed £278.38 (or whatever the correct number is).

sudden parrot
#
tender breach
#

Let me run a new test with the code as it is right now and we can look at that request. It is possible I picked a poor choice of request to examine. One moment.

#

I realised I've picked a Live site request and my dev requests are going to be easier to debug this end

#

Okay this is better for us to look at :
req_WETGEfOZyFymhX

#

sorry, first time using Stripe support (product has been a dream so far)

#

This request is my starting point, at the moment shows the full amount billed next cycle. I want to alter this to get the prorated amount about to be billed

#

I've tried unsuccessfully to do this

sudden parrot
#

No worries, on there what did you expect to see vs. wwhat do you see?

tender breach
#

Right, so let me add those (how I've been doing it so far) and then show you the new request.

sudden parrot
#

The default value is create_prorations

tender breach
#

Am I using the right end points for a start

sudden parrot
#

yes, you're

tender breach
#

So I'm adding this: SubscriptionDetails = new InvoiceSubscriptionDetailsOptions { ProrationBehavior = "always_invoice"}

#

req_gLtZWQixH1yqqc

#

So what I get back now is the cost of the products I've added including Tax

#

What I'm looking for is what the user will be paying right now

sudden parrot
#

On that latest request, what amount did you expect to see and why?

tender breach
#

I expected to see a number less than £420, but more than £0, which would have been the prorated amount that we were about to charge the user, I can complete the flow this end to tell you exactly how much that will be if needed.

sudden parrot
#

You've already make multiple updates on that subscription. Can you simplify your subscription and share exact numbers please? You're saying that the proration does not calculate the amount correctly so having a concerete example with numbers will be help here.

tender breach
#

Okay give me a few minutes and I'll set up a fresh account and step through it and send you all the numbers.

sudden parrot
#

You do not need to set a fresh account if you're rereferring to a Stripe account. If you mean a new customer, that makese sense.

brave stirrupBOT
tender breach
#

apologies, ended up in a call... about the billing and prorated invoices!

#

Okay this is the default setup for the account:

#

I go and add licenses selecting to add 1 Advisor level license

#

I hit next and get this

#

Which is this request
req_pBtArHRnZD2Elq

orchid nymph
#

Hey there, stepping in for pgskc who needs to step away

#

taking a look at the request

tender breach
#

I press buy now and get this as the invoice amount ... which is correct (only a VERY short prorated amount of usage haha)

#

that 179.97 is what I would be expecting to have in the step before Buy Now

orchid nymph
tender breach
#

I'm 100% sure I'm doing something wrong in the code that fetches this stuff, I'm just not sure what.

orchid nymph
#

What is the request where you get that amount?

tender breach
#

var options = new InvoiceCreatePreviewOptions
{
Subscription = subscriptionId,
SubscriptionDetails = new InvoiceSubscriptionDetailsOptions { ProrationBehavior = "always_invoice"}
};

        if (items?.Count > 0)
        {
            options.InvoiceItems = items;
        }

        var service = new InvoiceService();
        return await service.CreatePreviewAsync(options);
#

using the C# wrapper for the API

orchid nymph
#

I mean the request ID that ends up with the 179.97 result

#

It sounds like you're making a change to the subscription that leads to a small proration

#

To get a preview invoice for changes to the subscription, you need to send those changes in the preview request

tender breach
#

So the 179 comes from actually creating the invoice
req_i4VguDTqwDkFfZ

#

So if I do the same request:
var updatedSubscription = await _stripe.UpdateSubscriptionCheckoutAsync(
id,
metadata,
items);

To CreatePreviewAsync (obviously with the model matching for a preview model) will that get me the result I'm looking for?

orchid nymph
#

Yea i would expect so -- the point of the preview with optional change details is to preview the next invoice that would get generated if you made the same changes to the subscription

tender breach
#

Okay the code base has this as two entirely seperate code paths this end for preview and updating subscription, I'll give it a go with calling the CreatePreview rather than update UpdateSubscriptionCheckout as an option in that method and see where I get to.

Thank you both for you help. Stripe continues to be excellent