Purchase to pay
Create purchase orders and supplier bills, then record payment with a complete payables trail.
Purchase to pay
A purchase-to-pay integration connects procurement activity to accounts payable and the final cash movement.
Workflow
| Step | Endpoint | Result |
|---|---|---|
| 1. Resolve the supplier | Contacts | Supplier contact ID |
| 2. Create the order | Create purchase order | Purchase order ID |
| 3. Create the payable | Convert purchase order to bill | Draft bill ID |
| 4. Record settlement | Create payment | Payment allocated to the bill |
| 5. Verify | Retrieve bill | Current balance and status |
Create a purchase order
curl --request POST "https://api.wafeq.com/v1/purchase-orders/" \
--header "Authorization: Api-Key <API_KEY>" \
--header "Content-Type: application/json" \
--header "X-Wafeq-Idempotency-Key: po-<SOURCE_ID>" \
--data '{
"contact": "<SUPPLIER_CONTACT_ID>",
"currency": "AED",
"purchase_order_date": "2026-08-29",
"purchase_order_number": "PO-701",
"reference": "PROC-701",
"external_id": "proc_701",
"line_items": [
{
"description": "Office equipment",
"account": "<ASSET_OR_EXPENSE_ACCOUNT_ID>",
"quantity": 2,
"unit_amount": 1800,
"tax_rate": "<TAX_RATE_ID>",
"cost_center": "<COST_CENTER_ID>"
}
]
}'Line items can also be managed with the Purchase order line items endpoints.
Convert the order to a bill
When the supplier invoice is accepted:
curl --request POST "https://api.wafeq.com/v1/purchase-orders/<PURCHASE_ORDER_ID>/bill/" \
--header "Authorization: Api-Key <API_KEY>" \
--header "Content-Type: application/json"Store the returned bill ID. The purchase order remains the procurement record; the bill becomes the accounts-payable document.
If your workflow has no purchase order, create the payable directly with Create bill.
Record supplier payment
curl --request POST "https://api.wafeq.com/v1/payments/" \
--header "Authorization: Api-Key <API_KEY>" \
--header "Content-Type: application/json" \
--header "X-Wafeq-Idempotency-Key: supplier-payment-<PAYMENT_ID>" \
--data '{
"amount": 3780,
"currency": "AED",
"date": "2026-09-15",
"paid_through_account": "<BANK_ACCOUNT_ID>",
"contact": "<SUPPLIER_CONTACT_ID>",
"external_id": "supplier_pay_701",
"bill_payments": [
{
"bill": "<BILL_ID>",
"amount": 3780,
"amount_to_pcy": 3780
}
]
}'Handle exceptions explicitly
- Use a debit note for supplier-side reductions or returns rather than rewriting the original bill.
- Keep partial payments as separate payment records or allocations.
- For foreign currency, follow the payment schema and preserve the exchange-rate context.
- Keep the supplier, currency, project, branch, cost center, and custom-field values consistent from order to bill.
For card purchases and operational spend that should not enter accounts payable, see Record expenses and receipts.
Updated about 1 hour ago
Did this page help you?