#_nerder

1 messages ยท Page 1 of 1 (latest)

rigid pantherBOT
strange pond
#

Hello! There's a few diferent cases this could happen - one example if if you pass in customer to retrieve the upcoming invoice but the customer has not subscriptions or invoice items that need to be invoiced

frank vapor
#

ok, so for instance if the customer has no subscription and i'm trying to fetch the upcoming invoice it will be null?

#

let me try that out real quick

strange pond
#

Yeah if they have no subscription and no invoice items then yes, you should get back a 404 error because there's no upcoming invoice

frank vapor
#

If i share with you some ids can you help me figure it out or is best to ask support?

strange pond
#

If it's a technical question I'm happy to help

#

What's the issue?

frank vapor
#

I have this log, right before the crash:

Fetching upcoming invoice for subscription [sub_1N9NxDEs7Z8AGDaVnkfvkE0Z] when old item is [si_NvEQ36DSk5V9tR] and new price will be [price_1LXkGeEs7Z8AGDaVA58BASWS]

For the following account: acct_1LLp6TEs7Z8AGDaV

The code that is returning the empty invoice is the following (substituting the value from the log) :

    const invoice = await this.stripe.invoices.retrieveUpcoming(
      {
        subscription: 'sub_1N9NxDEs7Z8AGDaVnkfvkE0Z',
        subscription_items: [
          {
            id: 'si_NvEQ36DSk5V9tR',
            price: 'price_1LXkGeEs7Z8AGDaVA58BASWS',
          },
        ],
        subscription_proration_behavior: 'always_invoice',
        subscription_proration_date: Math.floor(Date.now() / 1000),
      },
      { stripeAccount: gym.accountId.value },
    );
#

in this scenario why is this giving back an empty invoice?

#

in this customer I can see an active subscription (actually 2)

strange pond
#

Can you give me the full response you're getting back from the API when you're making that request?

frank vapor
#

umm this I don't really have, my code i breaking right after when i try to access invoice since is a null pointer

#

but I have the exact time in which this has happened

#

so maybe in some event log I can find it?

strange pond
#

If you're logging it on your end you'll be able to find it, but we don't store the responses from GET requests on our end, which is why I asked if you had the full response

#

Is this something you've been able to reproduce at all? Like if you try this request right now, what do you get?

frank vapor
frank vapor
strange pond
#

The request would be made on the connected account so I'd assume itd be in your connected account logs, but it entirely depends on how you're storing these logs on your end (and again, we don't keep track of the full response from these upcoming invoice requests on our end, so you wouldn't find it in the dashboard)

#

Do you maybe have the request ID? Or the exact timestamp?

frank vapor
#

I have the exact timestamp of the log, let me search for the request ID one-sec

strange pond
#

๐Ÿ‘ feel free to share both when you have them

frank vapor
#

I can't find it for some reason

#

the timestamp of the log is this one 2023-07-16 09:47:24.853 CEST

strange pond
#

๐Ÿ‘ let me see what I can find with just the timestamp

frank vapor
#

If i try to filter for v1/invoices/upcoming i don't see anything

strange pond
#

Is this in the dashboard? Do you have GET requests enabled?

frank vapor
#

yes, and no

strange pond
#

Based on the timestamp I'm guessing it's this request: req_NmxofIUWKQlDea

frank vapor
#

wow nice catch!

#

how did you find it?

strange pond
#

We have tools on our end to look at account requests

frank vapor
#

that's great

strange pond
#

Based on what I'm seeing in the logs this should have returned a full Invoice - after you retrieve the upcoming invoice what is your code doing with invoice?

frank vapor
#

i'm just building an object like this:

    return Invoice.of({
      amountUnused: invoice.lines.data[0]?.amount,
      amountRemaining: invoice.lines.data[1]?.amount,
      currency: invoice.currency,
      total: invoice.total,
      id: invoice.from_invoice.invoice as string,
    });
strange pond
#

Are you 100% sure the invoice is null, or is it possible that just one of these specific atributes isn't being populated as you expect? The reason I ask is because the id: invoice.from_invoice.invoice as string, line if the above code is one that would probably fail/break for upcoming invoices because invoice.from_invoice is only populated for Invoice revisions

#

If you want the ID of the Invoice you can just do invoice.id

frank vapor
#

oh ok, i'm trying to find a better log to confirm this but the error i'm seeing in js is the following:

TypeError: Cannot read properties of null (reading 'invoice')

#

so it seems like it

strange pond
#

Yeah since invoice.from_invoice is null, it can't read invoice from invoice.from_invoice

frank vapor
#

Oh i see!

#

Ok than

#

but seems like that upcoming invoice doesn't provide the id tho, look at this type spec:

type UpcomingInvoice = Omit<Stripe.Invoice, 'id'>;
strange pond
#

Ahhh I forgot about that

frank vapor
#

I guess this is why I was using the from_invoice mistakenly

strange pond
#

Is there a reason you need the upcoming invoice ID?

#

The Invoice isn't actually created at that point, which is why we don't actualyl return it

frank vapor
#

not really actually, is just because my domain object expect it

#

ok then, let me refactor my code to avoid this then

strange pond
#

๐Ÿ‘ yup that's what i'd suggest

frank vapor
#

thank you so much for this!

#

was indeed a very strange use-case that was driving me mad eheh

strange pond
#

happy to help!

frank vapor
#

Great then!

#

since we are here, I just have an unrelated question.

strange pond
#

go ahead!

frank vapor
#

Why is not possible to enable iDeal for recurring payments for all the connected account but they need to do thay by themselves?

#

And, this will be actually possible to do if we move to Connect Express?

strange pond
#

Let me start with your second question - what matters more here is what kind of funds flow you have. Typically with Express accounts you have destination charges, which look at the payment method settings on the Platform in order to determine which payment method types can be used

#

And so yes, if you're currently using direct charges, then moving to destination charges would allow you to use the settings on your platform

#

Now going back to your question about ideal/ that recurring settting

#

I'm not sure why we didn't also didn't ship the ability to manage this for connected accounts - it would have definitely been nice

frank vapor
frank vapor
#

we have iDeal active in all our connected account by default, but we need to ask them to activate the recurring option if they want to use it for subscriptions (practially 100% of them wants it in The Netherland)

strange pond
#

Yeah I agree it's not great

#

I can definitely flag it as feedback

frank vapor
#

It will be cool yes ๐Ÿ™‚

#

I've open couple of those feedback, there is a way to "track" them on my side?

#

So that I remember to check them from time to time

strange pond
#

If you need a way to track them you have to write in to support (https://support.stripe.com/contact) - that way they can keep a record of who requested what feature

frank vapor
#

Ok, good to know i'll do that from next time

#

cool, thank you so much @strange pond super helpful as always

strange pond
#

๐Ÿ™‚