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)
- Calls the internal procedure
pixi_SetInvoicePaidwithpaid = 1,EventIDandPaidSum = CaptureSum, which inserts a manual booking event in the customer account and matches it with the invoice.EventIDmust be a manual, positive customer-account event, otherwise the booking is not created. - If
SetRemainingOrdersToHAL= 1, all orderlines with statusANGthat belong to an order (sameOrderNr) having at least one orderline on this invoice are set to statusHAL. - Inserts a row into
CCPTranLogwith transaction typeCAand error codeCAPTURED, the noteMessage, total amountCaptureSumand the invoice currency. - Returns
Status=Successwith the message Successfully created CA manual booking event for InvoiceNr ….
Success = 0 (capture failed)
- Updates the invoice: increments
ccpSetFailTries, setsCCPNumOfTries,ccpSetFailLastTime, resetsPayedSumto 0 andPayedto NULL, setsCCPPaymentDoneandCCPReChargetoN. - Always sets the remaining
ANGorderlines of the affected orders toHAL(independent ofSetRemainingOrdersToHAL). - Inserts a row into
CCPTranLogwith transaction typeERand error codeCAPTURED FAILED. - Returns
Status=Successwith 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,EventIDmissing or not a manual positive event) are caught and only written to the error log (log.InsertError). The call still returnsStatus=Successand writes theCCPTranLogentry, so aSuccessrow does not guarantee that the payment was booked. - In the attached
pixi_SetInvoicePaidthe booked amount is the open amount of the invoice in the customer account;CaptureSumis not used as booking amount there, only stored inCCPTranLog. PayIDandPayCodeare required but not used by the code.- Any value of
Successother than 1 (including NULL) takes the failure branch. CCPNumOfTriesis set fromccpSetFailTries+ 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 useCCP Process. Lookups useNOLOCK.
Tables used
| Parameter | Type | Default | Description |
|---|---|---|---|
InvoiceNr
Required
|
varchar(20) string |
– |
Number of the invoice whose capture result is reported. Example: |
Success
Required
|
bit boolean |
– |
Result of the capture at the payment provider. Allowed values
Example: |
PayID
Required
|
varchar(50) string |
– |
Payment ID of the provider. Required but not used by the code. Example: |
PayCode
Required
|
varchar(50) string |
– |
Payment code of the provider. Required but not used by the code. Example: |
Message
Required
|
varchar(200) string |
– |
Free text stored as note ( Example: |
CaptureSum
Required
|
money decimal |
– |
Captured amount; stored as total amount in the CCP log and passed as Example: |
EventID
|
varchar(3) string |
NULL |
Customer account event used for the manual payment booking when Example: |
SetRemainingOrdersToHAL
Required
|
bit boolean |
– |
Only for Allowed values
Example: |
Result set 1 · Always, one row (success message for either branch, or error row if an exception occurred).
Status row of the call.
| Column | Type | Description |
|---|---|---|
Status
|
varchar(7) string |
|
Message
Nullable |
nvarchar(4000) string |
Success text containing the invoice number, or the SQL error message. NULL if |
Response example
<SqlRowSet1>
<row>
<Status>Success</Status>
<Message>Successfully created CA manual booking event for InvoiceNr RE1000123</Message>
</row>
</SqlRowSet1>
| Status | Message | Cause |
|---|---|---|
| Error | {ERROR_MESSAGE()} | Any SQL error during the invoice/orderline update or the `CCPTranLog` insert (e.g. constraint violations). The transaction is rolled back. Errors inside `pixi_SetInvoicePaid` are not returned here but only logged. |
POST https://apigateway.descartes.com/tms/pixi/
Content-Type: text/xml; charset=utf-8
Authorization: Basic BASE64(USERNAME:PASSWORD)
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://apigateway.descartes.com/tms/pixi/">
<SOAP-ENV:Body>
<ns1:pixiPaySetInvoiceCapture>
<InvoiceNr>RE1000123</InvoiceNr>
<Success>1</Success>
<PayID>pay_8f3a21c9</PayID>
<PayCode>CAPTURE_OK</PayCode>
<Message>Capture confirmed by provider</Message>
<CaptureSum>119.90</CaptureSum>
<!-- <EventID>ZE</EventID> -->
<SetRemainingOrdersToHAL>0</SetRemainingOrdersToHAL>
</ns1:pixiPaySetInvoiceCapture>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
curl -X POST 'https://apigateway.descartes.com/tms/pixi/' \
--user 'USERNAME:PASSWORD' \
--header 'Content-Type: text/xml; charset=utf-8' \
--data-binary @- <<'XML'
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://apigateway.descartes.com/tms/pixi/">
<SOAP-ENV:Body>
<ns1:pixiPaySetInvoiceCapture>
<InvoiceNr>RE1000123</InvoiceNr>
<Success>1</Success>
<PayID>pay_8f3a21c9</PayID>
<PayCode>CAPTURE_OK</PayCode>
<Message>Capture confirmed by provider</Message>
<CaptureSum>119.90</CaptureSum>
<!-- <EventID>ZE</EventID> -->
<SetRemainingOrdersToHAL>0</SetRemainingOrdersToHAL>
</ns1:pixiPaySetInvoiceCapture>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
XML
<?php
$soapClient = new SoapClient(null, [
'login' => 'USERNAME',
'password' => 'PASSWORD',
'location' => 'https://apigateway.descartes.com/tms/pixi/',
'uri' => 'https://apigateway.descartes.com/tms/pixi/',
]);
$arguments = [
'InvoiceNr' => 'RE1000123',
'Success' => '1',
'PayID' => 'pay_8f3a21c9',
'PayCode' => 'CAPTURE_OK',
'Message' => 'Capture confirmed by provider',
'CaptureSum' => '119.90',
// 'EventID' => 'ZE',
'SetRemainingOrdersToHAL' => '0',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiPaySetInvoiceCapture', $soapArguments);
- SQL object:
- dbo.pipiPaySetInvoiceCapture