Invoices
InvoiceProvider adds read access to invoices — the billing documents a
provider generates for each recurring subscription charge. It's an optional,
read-only capability: creating, voiding, or paying invoices is out of
scope. Implemented by Stripe and Razorpay; PayPal has no invoice concept
in its Orders API and returns payment.ErrUnsupported.
inv, err := client.GetInvoice(ctx, invoiceID)
if err != nil {
log.Fatal(err)
}
if inv.IsPaid() {
fmt.Println(inv.HostedInvoiceURL) // customer-facing, viewable + payable
}
An empty invoiceID returns payment.ErrNotFound without a network call.
Invoice fields
| Field | Notes |
|---|---|
Status | InvoiceStatusDraft, Open, Paid, Void, or Uncollectible |
SubscriptionID | Set when the invoice originates from recurring billing |
CustomerID | When available |
Number | The provider's human-readable invoice number, when assigned |
Amount / AmountPaid | Minor units; nil when the provider doesn't report them |
HostedInvoiceURL | Stripe's hosted_invoice_url, Razorpay's short_url |
PDFURL | Downloadable PDF link (Stripe only); empty otherwise |
DueDate / PaidAt | Zero value when not set/reported |
inv.IsPaid() is shorthand for Status == InvoiceStatusPaid.
Where invoices come from
Invoices are generated by a provider's own recurring billing engine each
time a Subscription bills — there is no
CreateInvoice. Fetch the ID from the InvoiceID on a
WebhookInvoicePaymentSucceeded / WebhookInvoicePaymentFailed webhook
event, or from the provider's own subscription/invoice list in their
dashboard.