Postman collection
Payments Read

pixiPayGetInvoicesToCapture

Returns unpaid, shipped invoices of a payment method that are due for capture, with order, amount, customer address and card data.

Selects the invoices that a payment integration (for example a credit card provider) should capture next and returns them with all data needed for the capture.

An invoice is selected when all of the following apply:

  • Payment equals @PaymentCode.
  • Nothing has been paid yet (PayedSum = 0) and Total > 0.
  • The capture is not marked as done (CCPPaymentDone is N or NULL).
  • The invoice has been scanned out (ScanOutDate is set).
  • InvoiceKey is greater than @FromInvoiceId.
  • One of the retry conditions holds:
    • no capture attempt yet (CCPNumOfTries = 0), or
    • a recharge is requested (CCPRecharge = 'Y'), or
    • 1 to 3 failed attempts (ccpSetFailTries) and the last failure (ccpSetFailLastTime) is older than 10 minutes, or
    • @ShowAll = 1, which skips the retry conditions entirely.

At most @RowCount invoices are selected, ordered by InvoiceKey ascending. For each one the call returns invoice number, the comma-separated list of external order numbers, total, paid amount, amount to capture (Total - PayedSum), the sum of linked order lines in status ANG, currency code, shop (CustomerOf of the customer), the card and address data of the invoice address, and the capture status fields.

Paging: pass the InvoiceId of the last returned row as @FromInvoiceId to get the next block.

Notes

  • All reads use NOLOCK, so uncommitted changes may be visible.
  • The call does not change any data; marking invoices as captured or failed must be done separately.
  • @ShowAll = 1 only removes the retry/back-off condition; all other filters (payment code, unpaid, scanned out, not done) still apply. It also returns invoices with more than 3 failed attempts.
  • The TOP (@RowCount) limit is applied before joining currency, customer and address. Invoices without a matching row there are dropped, so fewer than @RowCount rows may be returned although more invoices exist.
  • Because only invoices with PayedSum = 0 are selected, TotalToCapture always equals Total.
  • Total_OrderCurr is a duplicate of Total; a code comment marks it for removal, so clients should not rely on it.
  • The result contains sensitive card data (number, expiry, CVC); handle and log it accordingly.

Tables used

Invoices · Read Invlines · Read Orderlines · Read Currency · Read Customers · Read Addresses · Read
SQL object:
dbo.pipiPayGetInvoicesToCapture
Updated at 2026-10-30