Generate an Invoice
This recipe covers generating an invoice for a completed order, downloading the PDF, and -- for Brazilian operations -- triggering NFSe (tax invoice) issuance via ISSNet.
Prerequisites
- WordPress admin access.
- A WooCommerce order with status
completedorprocessing. - For NFSe: the Organization's billing entity must be MIDDAG BR, and the ISSNet integration must be configured in plugin settings.
Steps
Part A: Verify the Stripe invoice
Step 1. Go to MIDDAG Account > Invoices in the admin sidebar.
Step 2. Search by the Organization name or order number.
Step 3. The invoice should already exist. Invoices in MIDDAG Account are synced automatically from Stripe via webhooks -- the system does not generate invoices independently.
Step 4. Open the invoice and verify:
- Status is
paid. - Amount matches the order total.
- Stripe Account shows the correct entity (
middag_brormiddag_global). - Organization is correct.
Step 5. If the invoice does not appear:
- Check the Stripe dashboard for the invoice under the correct account (BR or GLOBAL).
- Go to MIDDAG Account > Logs and search for webhook events. Look for
invoice.createdorinvoice.paidevents. - If the webhook failed, you can trigger a re-sync from the Stripe dashboard by re-sending the event, or wait for the reconciliation cron (runs every 15 minutes).
Part B: Download the invoice PDF
Step 6. On the invoice detail page, click Download PDF.
Step 7. The system redirects to the Stripe-hosted invoice PDF. If the Stripe PDF is unavailable, the system generates a custom PDF and stores it in Cloudflare R2.
Step 8. The customer can also download the PDF from the portal under Invoices. Both Stripe invoices and NFSe are shown in a unified list with a visual indicator for each type.
Part C: Issue NFSe (Brazilian operations only)
This section applies only when the billing entity is MIDDAG BR. International (GLOBAL) transactions do not require NFSe.
Step 9. Go to MIDDAG Account > Tax Invoices in the admin sidebar.
Step 10. Check if an NFSe was already created automatically. When a BR payment is confirmed, the system attempts automatic NFSe issuance:
- It extracts service details and amounts from the order.
- It reads the customer's tax information (CNPJ, address) from the Organization.
- It submits an XML request to the ISSNet web service (Brasilia/DF).
- The NFSe is recorded as
pendingorissued.
Step 11. If the NFSe status is pending:
- A cron job checks ISSNet every 5 minutes for status updates.
- Once approved, the status transitions to
issuedwith the official NFSe number and verification code. - If pending for more than 24 hours, an admin notification is triggered.
Step 12. If automatic issuance failed or the NFSe was not created:
- Click Issue NFSe Manually on the order or invoice detail page.
- Review and adjust the pre-filled data: service description, municipal tax code (CNAE), amount, customer tax information.
- Click Submit to ISSNet.
- The system sends the request and records the result.
Step 13. Verify the NFSe:
- Status should be
issued. - NFSe Number and Verification Code are filled in (assigned by the municipal authority).
- The customer can see and download the NFSe (XML and PDF) from the portal under Invoices.
Part D: Customer experience
Step 14. The customer sees both Stripe invoices and NFSe in a unified list in the portal under Invoices. Each entry has a visual label:
- Commercial Invoice -- from Stripe.
- Tax Invoice (NFSe) -- from ISSNet (BR only).
Step 15. The customer can filter by type, status, date range, and download PDFs or XML directly.
Expected result
- A Stripe invoice with status
paidexists and is linked to the order and Organization. - The customer can download the invoice PDF from the portal.
- For MIDDAG BR transactions: an NFSe was issued via ISSNet with an official number and verification code. The customer can download both XML and PDF.
Further reading
- Billing and Finance -- how financial data flows through the system.
- Multi-Entity Operations -- how entity routing affects invoicing.