Skip to main content
Version: 0.8

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

FieldNotes
StatusInvoiceStatusDraft, Open, Paid, Void, or Uncollectible
SubscriptionIDSet when the invoice originates from recurring billing
CustomerIDWhen available
NumberThe provider's human-readable invoice number, when assigned
Amount / AmountPaidMinor units; nil when the provider doesn't report them
HostedInvoiceURLStripe's hosted_invoice_url, Razorpay's short_url
PDFURLDownloadable PDF link (Stripe only); empty otherwise
DueDate / PaidAtZero 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.