Create an invoice

Generate one-off invoices for custom charges, or understand how subscription invoices are created automatically.

View as Markdown

One-off invoices

Create a standalone invoice for a customer that is not tied to a subscription. Use one-off invoices for custom charges, consulting fees, setup fees, or any non-recurring billing.

  1. Go to Billing > Invoices in the sidebar
  2. Click Create Invoice
  3. Select a customer
  4. Set the currency and issued date
  5. Add line items with descriptions, quantities, and amounts
  6. Click Create

The invoice is created in Draft state. Finalize it to begin collection.

Line item fields

FieldDescription
nameDisplay name for the line item
descriptionDescription displayed on the invoice
quantityNumber of units (default: 1)
unit_amountPrice per unit
amountTotal amount for this line item (alternative to unit_amount * quantity)
price_idLink to an existing price in your product catalog
metadataFree-form metadata for the item

Use price_id to reference a catalog price, or provide amount/unit_amount for ad-hoc charges.

Subscription invoices

Subscription invoices are generated automatically by the billing lifecycle. You do not need to create them manually.

PaymentKit generates invoices at these points:

EventBilling reason
Subscription createdsubscription_create
Billing period renewssubscription_cycle
Subscription items changed (with always_invoice proration)subscription_update

Each invoice contains line items built from the subscription’s active items at the time of generation.

Invoice lifecycle

Every invoice follows this state flow:

StateDescription
DraftInvoice is being prepared. Items and amounts can still be modified.
OpenFinalized and ready for payment. Amounts are locked.
PaidPayment collected in full.
Partially paidSome payment received, balance remaining.
Past duePayment deadline has passed. Dunning retries are active.
VoidInvoice cancelled. No payment expected.
UncollectibleAll collection attempts exhausted.

Transitions

FromToTrigger
DraftOpenInvoice finalized
DraftVoidInvoice voided before finalizing
OpenPaidPayment succeeds in full
OpenPartially paidPartial payment received
OpenPast duePayment deadline passes
OpenVoidInvoice voided
OpenUncollectibleDunning exhausted
Partially paidPaidRemaining balance paid
Partially paidPast duePayment deadline passes
Partially paidVoidInvoice voided
Past duePaidPayment recovered
Past duePartially paidPartial payment received
Past dueUncollectibleDunning exhausted
UncollectibleVoidInvoice voided

Finalize an invoice

Finalizing moves a draft invoice to Open state, locks all amounts, and optionally triggers PDF generation and email delivery.

$curl -X POST https://api.paymentkit.com/api/{account_id}/invoices/{invoice_id}/finalize \
>-H "Authorization: Bearer sk_live_..."

Collect payment

Attempt to collect payment on an open invoice:

$curl -X POST https://api.paymentkit.com/api/{account_id}/invoices/{invoice_id}/collect \
>-H "Authorization: Bearer sk_live_..."

The response includes the payment outcome:

1{
2 "invoice_id": "in_abc123",
3 "invoice_status": "paid",
4 "subscription_id": null,
5 "payment_status": "paid",
6 "error_message": null
7}

If the invoice is still in Draft state, the collect endpoint finalizes it before attempting payment.

For subscription invoices, payment collection is handled automatically by the lifecycle engine. Use the collect endpoint for manual invoices or to retry a failed payment.

Webhook events

EventTrigger
invoice.createdInvoice created
invoice.finalizedDraft finalized to Open
invoice.paidPayment collected in full
invoice.payment_succeededA payment attempt succeeded
invoice.payment_failedA payment attempt failed
invoice.overdueInvoice became past due
invoice.voidedInvoice voided
invoice.marked_uncollectibleInvoice marked uncollectible