What You’ll Build
An Invoice button on your own order history page. Your server looks up the payment through GraphQL, reads itsinvoiceToken, and builds a link. When the customer clicks it, the invoice opens in the browser, already authorized, with a Download PDF button. No sign-in, no email verification.
There is no endpoint that returns the PDF file itself. The PDF is generated in the customer’s browser on the invoice page. If you need the file on your server, open the link in a headless browser, or point your customers to the page.
Prerequisites
- An API Key (Dashboard → API & Development). Use a test key while you build
- The Waffo Payment ID (
PAY_xxx) of the payment, or a way to find it: your own business number (orderMerchantExternalId), the buyer’s email, or the order ID - The payment must be succeeded. Pending and failed payments have no invoice
Step 1: Read the invoiceToken
Query payments (or payment by ID) and include invoiceToken. The field is visible to the merchant role only, so API Key and Dashboard sessions can read it; customer portal sessions cannot.
status: succeeded:
Step 2: Build the Link
Step 3: Keep It Current
The token is stable for the life of the payment, so you can store it next to your order record. Two convenient moments to fetch it:- On webhook:
order.completedandsubscription.payment_succeededcarry the Payment ID aseventId. Querypayment(id:)for theinvoiceTokenand save it with the order. See Webhooks - On demand: query
paymentsbybuyerEmailororderMerchantExternalIdwhen the customer opens their order history
What the Invoice Shows
Customers can also edit their invoice details (company name, address, tax ID) before downloading when they open the same invoice from the customer portal.
Alternatives
FAQ
Why is invoiceToken null?
Why is invoiceToken null?
The payment is not
succeeded yet. Pending and failed payments never get a token. Check status first. A 0.00 card-verification payment that starts a free trial is succeeded and does get one.Can I fetch the PDF from my server?
Can I fetch the PDF from my server?
Not through the API. The PDF is produced in the browser on the invoice page. Use the link as-is, or render the page in a headless browser if you must archive a copy.
Does the token expire or rotate?
Does the token expire or rotate?
No. It stays valid for the life of the payment, and refunds do not change it. The invoice page shows refunds that happen later.
Does this work in test mode?
Does this work in test mode?
Yes. Test payments get an
invoiceToken too, and the link opens the invoice with a test-mode banner.