Postman collection
Payments Write

pixiPaySetInvoiceCapture

Records the result of a payment capture for an invoice, books it as paid or resets it to unpaid, logs it in CCPTranLog and can set open orderlines to HAL.

Processes the outcome of a payment capture reported by an external payment provider ("pixi Apps Payment Provider") for the invoice InvoiceNr.

First the invoice is looked up together with its customer and currency (customer's CustomerOf shop, CustRef, AddrRef, currency code). All changes then run in one transaction (or a savepoint if the caller already has an open transaction).

Success = 1 (capture succeeded)

  1. Calls the internal procedure pixi_SetInvoicePaid with paid = 1, EventID and PaidSum = CaptureSum, which inserts a manual booking event in the customer account and matches it with the invoice. EventID must be a manual, positive customer-account event, otherwise the booking is not created.
  2. If SetRemainingOrdersToHAL = 1, all orderlines with status ANG that belong to an order (same OrderNr) having at least one orderline on this invoice are set to status HAL.
  3. Inserts a row into CCPTranLog with transaction type CA and error code CAPTURED, the note Message, total amount CaptureSum and the invoice currency.
  4. Returns Status = Success with the message Successfully created CA manual booking event for InvoiceNr ….

Success = 0 (capture failed)

  1. Updates the invoice: increments ccpSetFailTries, sets CCPNumOfTries, ccpSetFailLastTime, resets PayedSum to 0 and Payed to NULL, sets CCPPaymentDone and CCPReCharge to N.
  2. Always sets the remaining ANG orderlines of the affected orders to HAL (independent of SetRemainingOrdersToHAL).
  3. Inserts a row into CCPTranLog with transaction type ER and error code CAPTURED FAILED.
  4. Returns Status = Success with the message Reset payment data to unpaid for InvoiceNr ….

If an error occurs, the transaction is rolled back and a row with Status = Error and the SQL error message is returned.

Notes

  • Errors inside pixi_SetInvoicePaid (e.g. invoice does not exist, invoice already paid, EventID missing or not a manual positive event) are caught and only written to the error log (log.InsertError). The call still returns Status = Success and writes the CCPTranLog entry, so a Success row does not guarantee that the payment was booked.
  • In the attached pixi_SetInvoicePaid the booked amount is the open amount of the invoice in the customer account; CaptureSum is not used as booking amount there, only stored in CCPTranLog.
  • PayID and PayCode are required but not used by the code.
  • Any value of Success other than 1 (including NULL) takes the failure branch.
  • CCPNumOfTries is set from ccpSetFailTries + 1, not from its own previous value.
  • If the invoice (or its customer/currency join) is not found, no invoice or orderline is updated, but a log entry with empty references is attempted.
  • Orderline updates use UpdateEmp = API Call PaySetAuth; invoice updates use CCP Process. Lookups use NOLOCK.

Tables used

Invoices · Write Customers · Read Currency · Read Orderlines · Write Invlines · Read CCPTranLog · Write
SQL object:
dbo.pipiPaySetInvoiceCapture
Updated at 2026-10-30