Skip to content

Payments API

Record, list, retrieve, and update payments against invoices.

Authentication

All payment endpoints require a valid PASETO token:

http
Authorization: Bearer <token>

Endpoints

MethodPathDescription
POST/api/payment/:orgId/createRecord a new payment
GET/api/payment/:orgId/listList payments (paginated)
GET/api/payment/:orgId/by-code/:codeGet payment by code
GET/api/payment/:orgId/:paymentIdGet payment by ID
PUT/api/payment/:orgId/:paymentId/updateUpdate a payment

Common Path Parameters

ParameterTypeDescription
orgIdstringOrganisation ID
paymentIdstringPayment document ID
codestringHuman-readable payment code (e.g. PAY-0035)

POST /api/payment/:orgId/create

Record a new payment.

Request Body

json
{
  "invoiceId": "inv_pqr456",
  "invoiceCode": "INV-0078",
  "bookingId": "bk_xyz789",
  "guestId": "guest_abc123",
  "guestName": "Jane Smith",
  "amount": 5000,
  "method": "card",
  "cardLast4": "4242",
  "transactionId": "txn_abc123xyz",
  "paymentDate": "2026-03-18",
  "notes": "Partial payment at checkout",
  "receivedBy": "usr_789xyz"
}
FieldTypeRequiredDescription
invoiceIdstringYesInvoice being paid
invoiceCodestringNoInvoice code for reference
bookingIdstringNoAssociated booking ID
guestIdstringNoGuest ID
guestNamestringNoGuest name
amountnumberYesPayment amount
methodstringYesPayment method (cash, card, upi, bank_transfer, cheque, other)
cardLast4stringNoLast 4 digits of card (if card)
transactionIdstringNoExternal transaction reference
paymentDatestringYesDate of payment (YYYY-MM-DD)
notesstringNoAdditional notes
receivedBystringNoUser ID of staff who received

Response — 201 Created

json
{
  "success": true,
  "message": "Payment recorded successfully",
  "data": {
    "paymentId": "pay_lmn789",
    "code": "PAY-0035",
    "invoiceId": "inv_pqr456",
    "amount": 5000,
    "method": "card",
    "status": "completed",
    "paymentDate": "2026-03-18",
    "createdAt": "2026-03-18T14:00:00.000Z"
  }
}

Error — 400 Bad Request

json
{
  "success": false,
  "message": "Payment amount exceeds invoice balance due"
}

GET /api/payment/:orgId/list

List payments with pagination and optional filters.

Query Parameters

ParameterTypeDefaultDescription
pagenumber1Page number
limitnumber20Items per page
methodstringFilter by payment method
fromstringPayment date from (YYYY-MM-DD)
tostringPayment date to (YYYY-MM-DD)
invoiceIdstringFilter by invoice ID
searchstringSearch by guest name, code, or transaction ID

Response — 200 OK

json
{
  "success": true,
  "data": [
    {
      "paymentId": "pay_lmn789",
      "code": "PAY-0035",
      "invoiceId": "inv_pqr456",
      "invoiceCode": "INV-0078",
      "guestName": "Jane Smith",
      "amount": 5000,
      "method": "card",
      "status": "completed",
      "paymentDate": "2026-03-18"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 120,
    "totalPages": 6
  }
}

GET /api/payment/:orgId/by-code/:code

Retrieve a payment by its human-readable code.

Path Parameters

ParameterTypeDescription
codestringPayment code (e.g. PAY-0035)

Response — 200 OK

json
{
  "success": true,
  "data": {
    "paymentId": "pay_lmn789",
    "code": "PAY-0035",
    "invoiceId": "inv_pqr456",
    "invoiceCode": "INV-0078",
    "bookingId": "bk_xyz789",
    "guestId": "guest_abc123",
    "guestName": "Jane Smith",
    "amount": 5000,
    "method": "card",
    "cardLast4": "4242",
    "transactionId": "txn_abc123xyz",
    "status": "completed",
    "paymentDate": "2026-03-18",
    "notes": "Partial payment at checkout",
    "receivedBy": "usr_789xyz",
    "createdAt": "2026-03-18T14:00:00.000Z"
  }
}

Error — 404 Not Found

json
{
  "success": false,
  "message": "Payment not found"
}

GET /api/payment/:orgId/:paymentId

Retrieve full payment details by ID. Response format is identical to the by-code endpoint above.

Response — 200 OK

json
{
  "success": true,
  "data": {
    "paymentId": "pay_lmn789",
    "code": "PAY-0035",
    "invoiceId": "inv_pqr456",
    "invoiceCode": "INV-0078",
    "bookingId": "bk_xyz789",
    "guestName": "Jane Smith",
    "amount": 5000,
    "method": "card",
    "cardLast4": "4242",
    "transactionId": "txn_abc123xyz",
    "status": "completed",
    "paymentDate": "2026-03-18",
    "notes": "Partial payment at checkout",
    "receivedBy": "usr_789xyz",
    "createdAt": "2026-03-18T14:00:00.000Z",
    "updatedAt": "2026-03-18T14:00:00.000Z"
  }
}

PUT /api/payment/:orgId/:paymentId/update

Update an existing payment record.

Request Body

json
{
  "amount": 5500,
  "method": "upi",
  "transactionId": "upi_ref_987654",
  "notes": "Corrected amount — UPI payment",
  "paymentDate": "2026-03-18"
}
FieldTypeRequiredDescription
amountnumberNoUpdated amount
methodstringNoUpdated payment method
transactionIdstringNoUpdated transaction reference
notesstringNoUpdated notes
paymentDatestringNoUpdated payment date
cardLast4stringNoUpdated card last 4 digits

Response — 200 OK

json
{
  "success": true,
  "message": "Payment updated successfully",
  "data": {
    "paymentId": "pay_lmn789",
    "code": "PAY-0035",
    "amount": 5500,
    "method": "upi",
    "updatedAt": "2026-03-19T08:30:00.000Z"
  }
}

Error — 404 Not Found

json
{
  "success": false,
  "message": "Payment not found"
}

Released under the MIT License.