#qualleadmin

1 messages · Page 1 of 1 (latest)

sharp nebulaBOT
river bane
#

can you share the Invoice ID in_xxx where that happened?

frosty turtle
#

in_1Nq0twFAWKEWQzfqzvWPZRMp

#

we are having several customers being unnecessarily charged and refunded

river bane
frosty turtle
#

that invoice is in production where the issue originally occurred

#

this should be one with the flag

#

in_1NqAoFFAWKEWQzfqywTWAOsA

river bane
#

that worked fine and produced an Invoice that was 'draft' with no items

sharp nebulaBOT
river bane
frosty turtle
#
          await stripe.invoiceItems.create({
            customer: agency_customer_id || customer_id,
            amount: formatAmountForStripe(amount, 'USD'),
            currency: 'usd',
            description: 'One-time setup fee',
            metadata: {
              container: container,
              turn: turn_id,
              serviceFee: amountBreakup?.serviceFee || null,
              salesTax: amountBreakup?.salesTax || null,
              baseFee: amountBreakup?.baseFee || null,
            },
          });

          const invoice = await stripe.invoices.create({
            customer: agency_customer_id || customer_id,
            description: 'transaction',
            default_payment_method: defaultPaymentMethodId,
            metadata: {
              container: container,
              turn: turn_id,
              serviceFee: amountBreakup?.serviceFee || null,
              salesTax: amountBreakup?.salesTax || null,
              baseFee: amountBreakup?.baseFee || null,
            },
          });
          await stripe.invoices.finalizeInvoice(invoice.id);
          const paidInvoice = await stripe.invoices.pay(invoice.id);
#

we create the item, the invoice, finalize it, and pay it

#

should charge 31.32

#

but apparantly adding the pending_invoice_items_behavior: 'exclude', set its to 0

river bane
#

yes

#

that's exactly what it does and what it's documented to do, it creates the Invoice without including the existing pending items.

#

if you're using that parameter you should do the code in a different order

#

e..g create the Invoice with that param, it's a draft invoice with $0
now create the Invoice Item and pass the ID of the Invoice so the item is attached to it
then finalize the Invoice