Mexico example. This walkthrough uses the Mexican CFDI flow. For another
issuing country, start with shared fields and country rules.
1. Issue the PPD invoice
Start withdraft-body.json from the invoice recipe. The direct
income endpoint issues immediately; there is no separate draft review step in this call.
200, data.status: "valid", payment_method: "PPD",
payment_form: "99", and total 1160. Keep the UUID from this response.
2. Record the first payment
The customer paid MXN 580: half the subtotal (500) plus IVA (80). The API derives
the payment total from its items; the example uses the same currency as the invoice.
201, a payment ID, and total 580.
ppd_invoice_id is the income invoice’s SAT UUID, despite the field’s name.
It requests complement handling for that existing invoice. The handler enables that
automation even with automation_type: "none"; it does not issue a second income invoice.
Do not also call POST /invoices/payment for the same payment.3. Verify the complement and balance
Automation is asynchronous. A successful payment registration alone does not prove that the complement finished stamping. Fetch the payment and parent invoice:payment_complements: 580, last_balance: 580, and installments: 2.
Here installments points to the next installment number; it does not mean two
payments have already happened.
For a second payment, use a new payment key and no more than the remaining balance.
Read the current balance again before registering it. Multi-currency payments require
additional exchange-rate handling; see the payment reference.
If the complement remains absent, investigate the automation result before submitting
another payment. Troubleshooting explains how to reconcile ambiguous writes.