Invoice statuses
After a billing period ends, Paygentic calculates the final amount before it issues the invoice. During this short time, the API can return
CLOSING, CLOSED, CALCULATING, or DRAFT. You don’t need to do anything with these statuses.
If Paygentic can’t prepare an invoice, its status is FAILED. Contact support@paygentic.io if you see this status.
If an invoice total is zero, Paygentic marks it PAID when it’s issued.
Pay an invoice
How the customer pays depends on the subscription’sautoCharge setting. See How invoices are paid.
While an invoice is unpaid, its paymentUrl field links to the invoice payment page. You can use this link in your own app or emails.
Record a payment collected outside Paygentic
If the customer paid you another way, such as by bank transfer, record the payment withPOST /v2/invoices/{id}/payment and method: "out_of_band". The invoice must be ISSUED or PAYMENT_FAILED. It changes to PAID immediately. reason is an optional note of up to 500 characters.
cURL
400 Bad Requestif the invoice total is zero (Paygentic marks thosePAIDitself) or the invoice nets to a credit owed to the customer.409 Conflictwhile a payment for the invoice is being processed, or when Paygentic can’t confirm that payment’s status with the payment provider. Wait, check the invoice’s status, and call again only if it is still unpaid.409 Conflicton a second call for the same invoice. Don’t retry it.
pending_payment. Paygentic activates it in the background, so the subscription can take a short time to change to active. In the sandbox, this is how you activate a subscription without a payment provider.
The same route with method: "hosted_link" creates a new payment link and emails it to the customer. See the API reference.
Track invoices
To list invoices, useGET /v2/invoices. You can filter by subscriptionId, customerId, or status. To get a single invoice, use GET /v2/invoices/{id}, and to download its PDF, use GET /v2/invoices/{id}/pdf.
invoice.issued.v0 webhook when an invoice is issued, and invoice.paid.v0 when it’s paid. It doesn’t send a webhook when an invoice changes to PAYMENT_FAILED, CANCELLED, or WRITTEN_OFF. To find those invoices, filter by status.
For event payloads and delivery details, see Webhooks.
API Reference: See the List Invoices and Get Invoice endpoints for all fields and filters.
See how a line was calculated
When Paygentic calculates an invoice, it saves a trace of how each line’s amount before tax was reached. To get it, addlineProvenance to the expand parameter. Each line then has a provenance field.
cURL
provenance looks like this:
Response
inputsare the values the calculation started from.selectoris the quantity a volume band is chosen on.- Each step changes one value (
on) fromintoout. A step starts where the previous step on the same value ended, so you can follow quantity, selector, price and amount through the trace. evaluateis the one step that turns quantity and price into an amount. Steps on quantity, selector and price come before it. Steps on the amount, such as a proration, a cap or a rounding, come after it.- Every
sourceis a key intosources. A source hasref, the ids that link to the resource, andasUsed, the values the calculation read. A price, plan or grant can change after the invoice is issued, butasUseddoes not. resultequals the line’s stored amount, quantity and unit price. Tax is not part of the trace.- Grant credit and percentage discount lines have their own trace. A
linesource in it names the line it reduces. statusisnotRecordedfor a line calculated before traces were saved. Show “Calculation not recorded” for it.statusispendingwhile the invoice is not yet calculated.
New ops, source types, price models and reasons can be added without a new
version. If your code does not know an op, show the step as “in → out, because source” and keep the rest of the trace.expand=lineProvenance also works on GET /v2/invoices/{id}/lineItems and GET /v2/invoices/lineItems. If you do not ask for it, the response does not change.