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.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What happened
Creating a one-off invoice for $2040 produced a Stripe invoice at $0 that was already marked paid.
Why
create_one_off_invoiceposts 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_behaviortoexclude, so the new invoice is an empty draft. Finalizing an invoice whose amount due is $0 automatically transitions it topaid. 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
openuntil 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 storepaidwhen Stripe reports a $0 total on a non-zero local invoice.