PayFacto API - v1.0 - POST /v1/closeBatch

PayFacto API - v1.0 - POST /v1/closeBatch

PayFacto API - v1.0 - POST /v1/closeBatch

Closes the current open batch on a Semi-Integrated terminal, triggering settlement of all transactions accumulated in that batch with the banking acquirer. No new transactions can be submitted to the terminal while a batch closing is in progress.

1

Prerequisites

πŸ”‘

API Key

Generate your API key from the Payments Manager: Administrator Client β†’ API Key β†’ Add New Key. Pass it as auth-api-key in every request.

πŸͺ

Company & Merchant Numbers

Your CompanyNumber (5-digit) and MerchantNumber (8-digit) are issued by PayFacto during onboarding. Both are required on every Close Batch request.

🌐

Environment Base URL

Test: https://test.api.payfacto.cloud/v1   |   Production: Provided by the PayFacto Integration team upon certification.

πŸ“¦

Request Format β€” Base64-Encoded Payload

Requests use HTTP POST with an application/x-www-form-urlencoded body. Assemble all parameters as a cleartext query string, Base64-encode it, then send: auth-api-key={key}&payload={base64}.

πŸ–₯️

Semi-Integrated Terminal Only

Close Batch is exclusively a terminal administrative operation. The terminal identified by MerchantTerminalNumber must be online and available. Blank spaces are not accepted for this field.

⚠️

Transaction Lockout During Batch Close

No transaction can be submitted to the terminal while a batch closing is in progress. Attempting to do so will return return code 9115. Wait for the batch close to complete before resuming normal transaction processing. The batch number is generated by the terminal and returned in every transaction response as batchNumber.

2

Request

ℹ️

All parameters are passed inside the Base64-encoded payload form field. Raw body format: auth-api-key=<key>&payload=<base64>. MerchantTerminalNumber must be the assigned terminal number β€” blank spaces are not accepted. This endpoint has no optional fields.

Required fields

FieldTypeDescription
CompanyNumberNumeric(5)Identifies the merchant on PayFacto's network. Provided by PayFacto during onboarding. Example: 12345
MerchantNumberNumeric(8)Identifies the merchant to PayFacto's network. Provided by the integration team. Example: 53400000
MerchantTerminalNumberNumeric(5)Identifies the Semi-Integrated terminal on PayFacto's network whose batch is to be closed. Must be the assigned terminal number β€” blank spaces are not accepted. Example: 12345
BatchNumberNumeric(4)The batch number identifying the batch to be closed. This value is returned as batchNumber in the response of every transaction processed on this terminal. The batch number must be unique and must identify an open batch. Example: 0001
OperatorIDAlphanumeric(8)Identifies the cashier or system that initiated the batch close. Useful for identifying the employee who generated the transaction on PayFacto's network. Example: USER0001
3

Request β€” Code Example

⚠️

The example below uses the test endpoint and a sandbox API key. Replace credentials and base URL before going live.

cURL
# Close Batch β€” POST /v1/closeBatch
# Step 1: Build the cleartext payload

PAYLOAD="CompanyNumber=12345&MerchantNumber=53400000&MerchantTerminalNumber=12345&BatchNumber=0001&OperatorID=USER0001"

# Step 2: Base64-encode the payload
ENCODED=$(echo -n "$PAYLOAD" | base64)

# Step 3: Submit the request
curl -X POST "https://test.api.payfacto.cloud/v1/closeBatch" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "auth-api-key=YOUR_TEST_API_KEY&payload=$ENCODED"
4

Response

Always returned

FieldTypeDescription
returnCodeAlphanumeric(4)Identifies the exact status of the result. 00 = batch closed successfully. All other values indicate a failure. Refer to Section 6 for endpoint-specific codes.
batchNumberNumeric(4)The batch number that was closed, as used by the terminal when processing the transactions in the batch. Example: 0001
transactionNumberNumeric(12)Unique PayFacto gateway transaction identifier for the batch close operation. Example: 000111222333
companyNumberNumeric(5)Echo of the request CompanyNumber.
merchantNumberNumeric(8)Echo of the request MerchantNumber.
operatorIdAlphanumeric(8)Echo of the request OperatorID.
serverNumberAlphanumeric(4)Identifies the PayFacto Network server that processed the batch close.
terminalNumberNumeric(5)Identifies the terminal in the PayFacto Network whose batch was closed.
timeStampAlphanumeric(17)Date and time the batch close was processed on the payment server. Format: YYYYMMDD-HHMMSSCC. Example: 20240515-23000100
receiptDispAlphanumeric(32)PayFacto-generated message for the batch close. Can be used to produce a receipt. Example: APPROVED-THANK-YOU
terminalDispAlphanumeric(24)Message displayed on the terminal following the batch close. Example: APPROVED

Conditionally returned

FieldTypeDescription
demoModeAlphanumeric(4)Only returned when the terminal is in demo mode. Value will be true.
errorDescriptionAlphanumeric(50)Only returned when the batch close is not successful. Human-readable description of the failure reason.
5

Response β€” Code Example

JSON β€” 200 Batch Closed Successfully
{
"returnCode": "00",
"batchNumber": "0001",
"transactionNumber": "000111222333",
"companyNumber": "12345",
"merchantNumber": "53400000",
"operatorId": "USER0001",
"serverNumber": "0001",
"terminalNumber": "12345",
"timeStamp": "20240515-23000100",
"receiptDisp": "APPROVED-THANK-YOU ",
"terminalDisp": "APPROVED "
}
JSON β€” Error
{
"returnCode": "9221",
"errorDescription": "BATCH NOT OPEN",
"terminalDisp": "DECLINED ",
"receiptDisp": "DECLINED ",
"transactionNumber": "000111222334",
"timeStamp": "20240515-23000200"
}
6

Error / Return Codes

The following codes are most relevant to this endpoint. For the complete catalogue see the Return Code Index.

Return CodeMeaningWhen it occursRecommended Action
00Transaction approvedThe batch was closed and settlement with the banking acquirer was triggered successfully.No further action required. Normal transaction processing can resume.
9004"Null" value: company numberCompanyNumber is null or blank in the payload.Check your application. The field must correspond to the specification in the documentation.
9005 / 9006Invalid / rejected: company numberCompanyNumber does not match the required 5-digit length or is not configured in the payment solution.Make sure the application uses the correct company number provided by PayFacto. If it does, contact PayFacto customer service.
9007"Null" value: merchant numberMerchantNumber is null or blank in the payload.Check your application. The field must correspond to the specification in the documentation.
9008 / 9009Invalid / rejected: merchant numberMerchantNumber does not match the required 8-digit length or is not configured in the payment solution.Make sure the application uses the merchant number provided by PayFacto. If it does, contact PayFacto customer service.
9031"Null" value: POS terminal numberMerchantTerminalNumber is null or blank. A valid terminal number is required for this endpoint.Check your application. The field must correspond to the specification in the documentation.
9032 / 9033Invalid / rejected: POS terminal numberMerchantTerminalNumber does not follow the specification, or the merchant is not configured as a POS terminal merchant.Check your application. The field must correspond to the specification in the documentation. If the problem persists, contact PayFacto customer service.
9040 / 9041 / 9042Null / invalid / rejected: operator IDOperatorID is null, exceeds 8 characters, or does not follow the specification.Check your application. The field must correspond to the specification in the documentation.
9106Batch not ready to closeThe batch is not in a state that allows closing at this time.Wait a moment and retry. If the problem persists, contact PayFacto customer service.
9115Administrative transaction in progressA batch closing process is already in progress for this merchant. No transaction can be performed while a batch close is underway.Wait a few moments for the current batch close to complete, then retry.
9219 / 9220Rejected / invalid: batch numberBatchNumber was rejected because it does not follow the specification, or does not match the required 4-digit length.Check your application. The batch number must match the specification stated in the documentation.
9221Batch not openThe batch identified by BatchNumber is not currently open and cannot be closed.Verify the batch number. Use the batch number returned in the most recent transaction response for the target terminal.
9222Batch not found or not closableThe batch identified by BatchNumber was not found or is in a state that prevents it from being closed.Verify the batch number. If the problem persists, contact PayFacto customer service.
9223Batch total not foundThe selected batch does not exist or is empty. A batch must contain at least one transaction before it can be closed.Use a different batch number that contains transactions. If the problem persists, contact PayFacto customer service.
3666One or more terminals are busyAll of the merchant's terminals are currently processing transactions.Wait and retry. If the problem persists, contact PayFacto customer service.
3667Semi-integrated terminal is busyThe target terminal is currently processing another transaction or a recovery is in progress.Wait 15 seconds and retry. If the problem persists, contact PayFacto customer service.
3668Waiting for a recoveryAn error occurred with the semi-integrated terminal. A recovery must be completed before another operation can be processed.Make sure everything is plugged in correctly. If needed, restart the driver and unplug then replug the terminal power. Wait 35 seconds and retry. If the problem persists, contact PayFacto customer service.
3777Inexistent terminal and/or merchantThe merchant or terminal has not been configured in the Dispatcher module.If the problem persists, contact PayFacto customer service.
MBBatch already closedA request was made to close a batch file that has already been closed.No further action is needed β€” the batch was already closed successfully. Verify the batch number before retrying.
M0Batch closing requiredThe transaction log has reached its maximum capacity or the maximum number of transactions per batch has been reached. PayFacto will automatically initiate a batch close upon receiving this code.Wait a few moments and retry the transaction. If the problem persists, contact PayFacto customer service.
9051Time outProcessing timed out. Often caused by an inactive Dispatcher module.Retry the operation. If the problem persists, contact PayFacto customer service.
9049 / 9050Fatal errorA critical error occurred while processing the batch close.Retry the operation. If the problem persists, contact PayFacto customer service.