Skip to main content

Settle a pending payment from credit (InvoicePaid)

POST 

/orders/:id/settle

Attempts to pay the WHMCS invoice of a pending (pending_payment / payment_failed) order from the reseller balance. Triggered when the customer pays the invoice in the reseller's WHMCS (InvoicePaid hook). If the balance was insufficient at order time, the charge is collected here after the reseller tops up the balance → VPS setup is queued (pending_provision).

Idempotent: For an order that is already paid (payment_applied=true), WHMCS is not touched at all; the current state is returned with already_applied=true. The Idempotency-Key header is optional; if sent, the same key returns the same response.

Concurrent settlement: If another settlement for the same order is in progress, 409 settle_in_progress (Retry-After 5) is returned. A record whose ApplyCredit result is uncertain (transport error) is resolved after 5 minutes using the WHMCS invoice status: if Paid it is treated as paid, if Unpaid it is retried.

Result states (status):

  • pending_provision — credit applied, VPS setup pending
  • pending_payment — balance still insufficient (notice=insufficient_credit), can be retried immediately
  • payment_failed — temporary WHMCS error (5xx); retry after 5 minutes
  • unknown_state / provision_failed — no charge is made, already_applied=false

Isolation: Another reseller's order id returns 404 order_not_found.

Request​

Responses​

Result of the settlement attempt (success, insufficient, or already paid)