One-off invoice finalizes at $0 and is marked paid #33

Closed
opened 2026-10-06 18:19:09 -07:00 by westfarn · 0 comments
Owner

What happened

Creating a one-off invoice for $2040 produced a Stripe invoice at $0 that was already marked paid.

Why

create_one_off_invoice posts the line item as a pending invoice item, then creates the invoice without attaching that item.

Stripe's current Invoices API defaults pending_invoice_items_behavior to exclude, so the new invoice is an empty draft. Finalizing an invoice whose amount due is $0 automatically transitions it to paid. The webhook and the finalize response then copy that status onto the local invoice.

Expected

The Stripe invoice total matches the amount entered (for example $2040.00) and the status stays open until the customer pays.

Fix

Create the draft invoice first, attach the invoice item to that invoice id, then finalize. Reject and void the Stripe invoice if the finalized total does not match amount_cents, and do not store paid when Stripe reports a $0 total on a non-zero local invoice.

## What happened Creating a one-off invoice for $2040 produced a Stripe invoice at $0 that was already marked paid. ## Why `create_one_off_invoice` posts the line item as a pending invoice item, then creates the invoice without attaching that item. Stripe's current Invoices API defaults `pending_invoice_items_behavior` to `exclude`, so the new invoice is an empty draft. Finalizing an invoice whose amount due is $0 automatically transitions it to `paid`. The webhook and the finalize response then copy that status onto the local invoice. ## Expected The Stripe invoice total matches the amount entered (for example $2040.00) and the status stays `open` until the customer pays. ## Fix Create the draft invoice first, attach the invoice item to that invoice id, then finalize. Reject and void the Stripe invoice if the finalized total does not match `amount_cents`, and do not store `paid` when Stripe reports a $0 total on a non-zero local invoice.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ai_ml_operations/company_site#33