Skip to main content

API Endpoints

This section describes the available API endpoints for creating and managing sales through the zazpay API. Authentication is required for all endpoints as described in the auth.md documentation.

Create a Sale

POST /commerce/generate-sale

Creates a new sale transaction.

Input Parameters

ParameterTypeRequiredDescription
totalnumberYesTotal transaction amount
clientUsernamestringOne ofUsername of the client. Provide phone number or email
salesmanIdentifierstringOne ofSalesman reference. Provide either salesmanIdentifier or salesmanId
salesmanIdstringOne ofSalesman ID. Provide either salesmanId or salesmanIdentifier
storeIdstringYesStore ID (external or internal)
commentsstringNoOptional comments/description
folioExternalstringYesExternal reference for idempotency and sandbox behavior toggles

Notes:

  • Exactly one of clientUsername or clientId is required.
  • Exactly one of salesmanIdentifier or salesmanId is required.

Response (data)

{
"apiSaleId": "string",
"id": "string",
"folio": 12345,
"folioExternal": "EXT-001",
"status": "IN_PROGRESS",
"store": { "name": "Store name" }
}

Exceptions

Error CodeDescription
COMPANY-NOT-FOUNDCompany not found
STORE-NOT-FOUNDStore not found
STORE-NOT-BELONG-TO-COMPANYStore does not belong to your company
SALESMAN-NOT-FOUNDSalesman not found
CLIENT-NOT-FOUNDClient not found
SALE-CREATION-03Minimum amount not reached
SALE-CREATION-04Client credit line insufficient
TRANSACTION-NOT-FOUNDTransaction not found

Note: Some gateway-originated errors are passed through with their original statusCode and errorCode (e.g., C-PF-TRANSACTION-1001).

Retrieve Sale Status

POST /commerce/transaction-status

Retrieves the current status of a sale transaction by folio.

Input Parameters

ParameterTypeRequiredDescription
folionumberNoTransaction folio to look up
folioExternalstringNoTransaction folio external to look up

Response (data)

{
"folio": 12345,
"folioExternal": "string",
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-01-15T10:35:00.000Z",
"salesmanId": "string",
"storeId": "string",
"status": "APPROVED",
"total": 1500,
"clientId": "string",
"comments": "string"
}

Exceptions

Error CodeDescription
TRANSACTION-NOT-FOUNDTransaction not found

Cancel a sale

POST /commerce/cancel-transaction

Cancels a sale that hasn't been accepted yet.

Input Parameters

ParameterTypeRequiredDescription
folionumberNoThe transaction folio to cancel
folioExternalstringNoThe transaction external folio to cancel

Response (data)

{
"folio": 12345,
"status": "CANCELED",
"cancelledAt": "2024-01-15T10:40:00.000Z"
}

Exceptions

Error CodeDescription
SALE-CANCEL-01Sale not found
SALE-CANCEL-02Sale already cancelled
SALE-CANCEL-03Sale cannot be cancelled (already processed)

Parameter reference

  • folioExternal: External identifier supplied by your system. Used for idempotency and, in sandbox, to simulate outcomes.
  • ticket: Optional POS receipt/reference. Free-form string (recommended max 64 chars).

Sandbox behavior and test patterns

In the sandbox environment, the folioExternal field controls the outcome of a sale created via /commerce/generate-sale. Include one of the following keywords anywhere in the folioExternal string to trigger the desired scenario:

Keyword in folioExternalResulting statusDescription
(none)APPROVEDSale automatically transitions to APPROVED after ~5 seconds
REJECTEDREJECTEDSale automatically transitions to REJECTED after ~5 seconds
NO_CANCELIN_PROGRESSSale stays IN_PROGRESS indefinitely — no automatic transition. Useful for testing the manual cancellation flow via /commerce/cancel-transaction

Examples

folioExternal: "ORDER-001"              → APPROVED  (~5s)
folioExternal: "ORDER-001-REJECTED" → REJECTED (~5s)
folioExternal: "ORDER-001-NO_CANCEL" → IN_PROGRESS (no automatic transition)
tip

Combine these patterns with the predefined sandbox test clients to cover all integration scenarios.