Polar generates PDF invoices on demand for each order. Laravel Polar surfaces this through two methods on theDocumentation Index
Fetch the complete documentation index at: https://danestvesllc-2b77d201.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Order model:
receiptUrl()— returns the PDF URL as a string, useful for embedding a link in a Blade view.downloadInvoice()— returns aRedirectResponsethat sends the customer’s browser directly to the PDF.
Invoice URLs are generated fresh on each request via the Polar API. They are not stored locally. The result is memoized on the
Order instance (per request) so multiple calls within a single request won’t hit the API more than once.Getting the invoice URL
CallreceiptUrl() on any Order instance to get the URL of the generated PDF:
null when the order has no polar_id or no associated customer. Otherwise it:
- Authenticates with Polar on behalf of the customer.
- Calls Polar’s generate-invoice endpoint.
- Extracts and returns the URL from the response.
Memoization
The result is cached on theOrder instance for the lifetime of the request. Calling receiptUrl() twice on the same object only makes one API call:
receiptUrl() in a loop over a list of orders within a single request, but each distinct Order instance will make its own API call.
The invoice URL is fetched fresh on each request (once per
Order instance). If you need to persist it, save the string returned by receiptUrl() to your own database column.Embedding the link in a Blade view
UsereceiptUrl() in a Blade view to conditionally render a download link:
$order->receiptUrl() twice in the same template does not trigger a second API request.
Redirecting to the invoice from a controller
UsedownloadInvoice() to redirect the customer’s browser directly to the PDF. The method returns an Illuminate\Http\RedirectResponse:
downloadInvoice() calls receiptUrl() internally and throws a RuntimeException if no URL is available (for example, when the order has not yet been synced from Polar).