Overview
This reference documents all shared data types used across both HTTP and WebSocket Terminal Gateway APIs.PaymentRequest
The payment request object used to initiate payments.Unique transaction identifier in UUIDv7 format. Use this to track and reconcile payments. Auto-generated if not provided.Example:
"01945f3d-a8c9-7000-8d45-6f8234ab9012"Payment amount. Can be a string (recommended for precision) or number.Example:
"99.99" or 99.99ISO 4217 currency code.Example:
"USD", "EUR", "PHP"Payment method type.Values:
CARD, CASH, MOBILE, OTHERArray of products in the transaction.
Customer information for the transaction.
Custom key-value pairs for your use. This data is stored with the transaction and returned in responses.Example:
Example
PaymentResponse
The payment response object returned when a payment completes.Transaction identifier matching your original request.
Payment status.Values:
SUCCESS, FAILED, PENDING, CANCELLEDPayment amount.
Currency code.
Payment method used.
Authorization code from payment processor. Present on successful payments.Example:
"AUTH123456"Error code if status is
FAILED.Example: "INSUFFICIENT_FUNDS"Human-readable error message if status is
FAILED.Example: "Card declined due to insufficient funds"Opaque receipt data from terminal. Format depends on the terminal’s payment processor.
ISO 8601 timestamp of when the payment was processed.
Your custom metadata returned from the original request.
Successful Payment Example
Failed Payment Example
Product
Product item in a payment request.Product identifier.Example:
"PROD-001"Product name.Example:
"Widget"Unit price.Example:
"29.99"Quantity purchased.Example:
2Product category.Example:
"Electronics"Stock keeping unit.Example:
"WDG-001-BLK"Brand name.Example:
"Acme Corp"Tax amount for this item.Example:
2.99Discount amount for this item.Example:
5.00Example
CustomerInfo
Customer information for a payment.Customer identifier in your system.Example:
"CUST-123"Customer email address.Example:
"customer@example.com"Customer phone number.Example:
"+1-555-123-4567"Example
TerminalInfo
Terminal information returned when listing or querying terminals.Unique connection identifier. Changes when terminal reconnects.
Primary identifier. Uses
deviceId if available, otherwise connectionId.Stable device identifier. Configured via
X-Device-Id header on terminal connection. Persists across reconnections.ISO 8601 timestamp of when the terminal connected.
ISO 8601 timestamp of the terminal’s last activity.
Terminal status.Values:
online, offline, reconnectingCustom terminal metadata.
Example
TransactionRecord
Transaction record returned when querying transaction status (HTTP API).Unique transaction identifier.
Transaction status.Values:
PENDING, COMPLETED, FAILED, CANCELLED, AWAITING_RECONNECT, VOIDEDOriginal payment request.
Payment response (if completed).
ISO 8601 timestamp of creation.
ISO 8601 timestamp of last update.
ISO 8601 timestamp of completion (if applicable).
Stable terminal device identifier (if available).
ISO 8601 timestamp when payment was voided (if applicable).
Reason for voiding the payment (if voided).
ISO 8601 timestamp of this response.
Example
VoidResult
The result returned when a void operation is performed.Whether the void operation succeeded.
The transaction that was voided.
Reason for the void.Example:
"Terminal reconnected after grace period"ISO 8601 timestamp of when the payment was voided.Example:
"2024-01-15T10:38:30.000Z"Error message if the void operation failed.Example:
"Transaction already voided"Example
Metadata Field
Themetadata field allows you to attach custom data to payments. This data is stored with the transaction and returned in responses.
Use Cases
| Use Case | Example |
|---|---|
| Order tracking | Link payments to your order management system |
| Staff attribution | Track which employee processed the transaction |
| Custom reporting | Add fields needed for your business reporting |
| Integration IDs | Store references to external systems |
The
metadata field accepts any valid JSON object. Keys and values should be strings, numbers, or booleans for best compatibility.Payment Status Definitions
Transaction Status
| Status | Description |
|---|---|
PENDING | Transaction created, awaiting terminal response |
COMPLETED | Transaction completed successfully |
FAILED | Transaction failed (see error details) |
CANCELLED | Transaction was cancelled |
AWAITING_RECONNECT | Terminal disconnected mid-payment, waiting for reconnection (60-second grace period) |
VOIDED | Payment was voided (e.g., terminal reconnected after grace period with successful payment) |
Payment Response Status
| Status | Description |
|---|---|
SUCCESS | Payment was successfully processed and approved. The authorizationCode will be present. |
FAILED | Payment was declined or encountered an error. Check errorCode and errorMessage for details. |
PENDING | Payment is still being processed. This may occur with network issues or terminal communication delays. |
CANCELLED | Payment was cancelled by the user or terminal operator before completion. |
HTTP Error Reference
Error Response Format
All HTTP API errors follow this format:Error Codes
| Code | HTTP Status | Description | Recommended Action |
|---|---|---|---|
INVALID_REQUEST | 400 | Request body is malformed or missing required fields | Check request format and required fields |
INVALID_AMOUNT | 400 | Amount is invalid or doesn’t match products total | Verify amount calculation |
UNAUTHORIZED | 401 | Missing or invalid API key | Check API key configuration |
INVALID_SIGNATURE | 401 | HMAC signature verification failed | Verify signature computation |
TIMESTAMP_EXPIRED | 401 | Request timestamp outside 5-minute window | Ensure system clock is synchronized |
GROUP_MISMATCH | 403 | Resource belongs to a different group | Verify you’re using the correct API key |
TERMINAL_NOT_FOUND | 404 | Specified terminal does not exist | Refresh terminal list |
TRANSACTION_NOT_FOUND | 404 | Specified transaction does not exist | Verify transaction ID |
PAYMENT_IN_PROGRESS | 409 | Another payment is being processed | Wait for current payment to complete |
RATE_LIMITED | 429 | Too many requests | Reduce request frequency |
TERMINAL_CONNECTION_ERROR | 502 | Failed to communicate with terminal | Terminal may have disconnected; retry |
TERMINAL_OFFLINE | 503 | Terminal is offline or unresponsive | Check terminal connectivity |
TIMEOUT | 504 | Terminal did not respond within 90 seconds | Check transaction status endpoint |
INTERNAL_ERROR | 500 | Unexpected server error | Contact support if persistent |
WebSocket Error Reference
Error Message Format
WebSocket errors follow this format:Common Errors
| Error | Message | Cause |
|---|---|---|
| Bad Request | Invalid JSON in message body | Malformed JSON in request |
| Bad Request | terminalId is required | Missing required field |
| Bad Request | paymentRequest is required | Missing payment data |
| Not Found | Connection not found | Invalid connection ID |
| Not Found | Terminal connection not found | Terminal not connected |
| Forbidden | Only desktop devices can request terminal list | Wrong device type |
| Forbidden | Cannot send message to connection in different group | Group mismatch |
| Internal Server Error | Failed to process message | Server-side error |
forceDisconnect Reasons
| Reason | Description |
|---|---|
api_key_used_elsewhere | Another device connected with the same API key |
stale_connection_timeout | Connection was inactive for too long |
admin_action | Connection terminated by administrator |
server_restarting | Server is restarting for maintenance or deployment |
other | Other system-initiated disconnect |
Currency Codes
The API uses ISO 4217 three-letter currency codes:| Code | Currency |
|---|---|
USD | US Dollar |
EUR | Euro |
GBP | British Pound |
PHP | Philippine Peso |
JPY | Japanese Yen |
CAD | Canadian Dollar |
AUD | Australian Dollar |
Contact support@moduluslabs.io for the complete list of supported currencies for your integration.
System Constants
Important timeouts and limits to consider when integrating with Terminal Gateway.| Constant | Value | Description |
|---|---|---|
| Reconnect grace period | 60 seconds | Time allowed for a terminal to reconnect during a mid-payment disconnect |
| Long poll timeout | 90 seconds | Maximum wait time for HTTP API payment requests |
| Transaction retention (WebSocket) | 7 days | How long WebSocket transactions are retained |
| Transaction retention (HTTP) | 30 days | How long HTTP transactions are retained |
If a terminal disconnects mid-payment, the system waits up to 60 seconds for reconnection. If the terminal reconnects with a successful payment after this grace period, the payment is automatically voided.
WebhookEndpoint
Configuration object for a webhook endpoint.Unique identifier for the webhook endpoint.Example:
"wh_01HQ3K4M5N6P7R8S9T0UVWXYZ"The HTTPS URL where webhook payloads are delivered.Example:
"https://api.yourcompany.com/webhooks/payments"Event types this endpoint is subscribed to.Values:
payment.completed, payment.failed, payment.cancelled, payment.timeoutHuman-readable description for this endpoint.Example:
"Production payment notifications"Webhook signing secret for verifying payloads. Only returned on endpoint creation.Example:
"whsec_abc123xyz789..."Endpoint status.Values:
active, disabledCustom key-value pairs associated with this endpoint.
ISO 8601 timestamp of when the endpoint was created.
ISO 8601 timestamp of the last update.
Example
WebhookPayload
Payload delivered to your webhook endpoint when a payment event occurs.The type of event that triggered this webhook.Values:
payment.completed, payment.failed, payment.cancelled, payment.timeoutUnique identifier for this event. Use for idempotency checks.Example:
"evt_01HQ3K4M5N6P7R8S9T0UVWXYZ"ISO 8601 timestamp of when the event occurred.
Event-specific payload data containing the payment result.
Example
WebhookEventType
Event types that can trigger webhook notifications.| Event Type | Description | Trigger |
|---|---|---|
payment.completed | Payment succeeded | Terminal returns SUCCESS status |
payment.failed | Payment declined or error | Terminal returns FAILED status |
payment.cancelled | User cancelled payment | Terminal returns CANCELLED status |
payment.timeout | Terminal didn’t respond | 90-second timeout reached |
Payment Methods
Supported payment method values:| Method | Description |
|---|---|
CARD | Credit or debit card payment |
CASH | Cash payment |
MOBILE | Mobile payment (e.g., Apple Pay, Google Pay) |
OTHER | Other payment method |