#idemoov-lo_api

1 messages ยท Page 1 of 1 (latest)

cerulean havenBOT
#

๐Ÿ‘‹ 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/1413502414497120328

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

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.

willow kite
#
[Nest] 18    - 09/05/2025, 2:28:48 PM   ERROR  No charge found for payment inpay_1S3ykx5EyZyp1Ds5DUREfpwH

id=inpay_1S3ykx5EyZyp1Ds5DUREfpwH object=invoice_payment amount_paid=999 amount_requested=999 created=1757075323 currency=eur invoice=in_1S3ykx5EyZyp1Ds5k0dTslpH is_default=true livemode=false payment={"payment_intent":"pi_3S3ykx5EyZyp1Ds50E2n6Wz6","type":"payment_intent"} status=paid status_transitions={"canceled_at":null,"paid_at":1757075324}
quasi hull
#

๐Ÿ‘‹ happy to help

willow kite
#

code for context

payments = stripe.invoicePayments.list({ invoice: invoice.id }, { stripeAccount: accountId });
for (const payment of payments) {
        const charge =
          typeof payment.payment.charge === 'string'
            ? await this.stripeService
                .getInstance()
                .charges.retrieve(payment.payment.charge, { stripeAccount: accountId })
            : payment.payment.charge;

        if (!charge) {
          this.logger.error(`No charge found for payment ${payment.id}`);
          this.logger.debug(JSON.stringify(payment));
        }

        const balanceTransaction =
          typeof charge.balance_transaction === 'string'
            ? await this.stripeService
                .getInstance()
                .balanceTransactions.retrieve(charge.balance_transaction, {
                  stripeAccount: accountId,
                })
            : charge.balance_transaction;

        application_fee += charge.application_fee_amount ?? 0;
        stripe_fee += (balanceTransaction?.fee ?? 0) - (charge.application_fee_amount ?? 0);
        net_amount += balanceTransaction?.net ?? 0;
      }
}
willow kite
#

ah yes my code trigger when webhook event invoice.paid

quasi hull
#

please read through the changelog to understand more about the context

willow kite
#

So charge should exist on payment no ?

#

I saw that charge was removed from invoice it's why I get the payments of the invoice

quasi hull
willow kite
#

In my case why I don't have payment.payment.charge defined ?

willow kite
#

I already did that here

#
          if (typeof payment.payment.payment_intent === 'string') {
            paymentIntent = await this.stripeService.getPaymentIntent(
              payment.payment.payment_intent,
              accountId,
            );
          } else {
            paymentIntent = payment.payment.payment_intent;
          }
quasi hull
#

instead of that you can see the type property as suggested in the doc I sent you

willow kite
#

there's the charge object on paymentIntent ?

quasi hull
#

yes the latest_charge

willow kite
#
        const balanceTransaction =
          typeof charge.balance_transaction === 'string'
            ? await this.stripeService
                .getInstance()
                .balanceTransactions.retrieve(charge.balance_transaction, {
                  stripeAccount: accountId,
                })
            : charge.balance_transaction;

        application_fee += charge.application_fee_amount ?? 0;
        stripe_fee += (balanceTransaction?.fee ?? 0) - (charge.application_fee_amount ?? 0);
        net_amount += balanceTransaction?.net ?? 0;
quasi hull
willow kite
#

ha my bad I saw it in the doc I am a little dumb

#

So i should use type charge to get the charge directly ?

quasi hull
#

it depends whether the payment has the charge or not

#

you either get the PaymentIntent or the Charge

#

you need to think that in most cases you'll get the PaymentIntent

willow kite
#

Ah yes I never saw a payment of type charge for now

quasi hull
#

you should still handle both cases

willow kite
#

ok so in one case there is payment.payment.charge and in the other case payement.payment.payment_intent

#

It help me a lot thank you very much

quasi hull
#

payment.payment.payment_intent.latest_charge

willow kite
#

I understood that there's this prop on payment intent

quasi hull
#

I mean what you can do is get the charge ID from either case and then retrieve the balance transaction

willow kite
#

I understand but in this case id=inpay_1S3ykx5EyZyp1Ds5DUREfpwH object=invoice_payment amount_paid=999 amount_requested=999 created=1757075323 currency=eur invoice=in_1S3ykx5EyZyp1Ds5k0dTslpH is_default=true livemode=false payment={"payment_intent":"pi_3S3ykx5EyZyp1Ds50E2n6Wz6","type":"payment_intent"} status=paid status_transitions={"canceled_at":null,"paid_at":1757075324}
I don't have it so I need to add expand ?

quasi hull
#

oh yes you do need to retrieve the paymentIntent to get the latest_charge

willow kite
#

ok everything good for me thank you for your help