#qualleadmin
1 messages · Page 1 of 1 (latest)
can you share the Invoice ID in_xxx where that happened?
in_1Nq0twFAWKEWQzfqzvWPZRMp
we are having several customers being unnecessarily charged and refunded
https://dashboard.stripe.com/logs/req_5lJDm1XjIHKOSi. I don't see where you used pending_invoice_items_behavior: 'exclude' on that request.
that invoice is in production where the issue originally occurred
this should be one with the flag
in_1NqAoFFAWKEWQzfqywTWAOsA
that worked fine and produced an Invoice that was 'draft' with no items
you however then finalized the Invoice a second later , telling us you were finished and ready to charge, so we did(and the charge was $0 because no items were added).
You can see all the logs for this on https://dashboard.stripe.com/test/invoices/in_1NqAoFFAWKEWQzfqywTWAOsA
is that different from what you expected to happen?
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
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
that's the flow documented exactly on https://stripe.com/docs/invoicing/integration#create-invoice-code .