Skip to content

MQ-Pay API Reference

Complete API reference for MQ-Pay payment integration.

Base URL

Production: https://api.your-domain.com/api/mq-pay
Development: http://localhost:3000/api/mq-pay

Payment Endpoints

Create Payment

http
POST /payments/checkout
Content-Type: application/json

{
  "source": {
    "type": "Order",
    "id": "order-uuid-123",
    "uid": "ORD-2024-001"
  },
  "payment": {
    "provider": "VNPAY_QR_MMS",
    "method": "100_QR_CODE",
    "total": 100000,
    "currency": "VND"
  },
  "expiration": {
    "mode": "duration",
    "milliseconds": 300000
  }
}

Response (200 OK)

json
{
  "transaction": {
    "id": "txn-uuid-001",
    "number": "TXN001",
    "status": "100_NEW",
    "total": "100000.0000",
    "paid": "0.0000"
  },
  "attempt": {
    "id": "att-uuid-001",
    "code": "ATT001",
    "status": "204_SENT",
    "provider": "VNPAY_QR_MMS",
    "method": "100_QR_CODE"
  },
  "payment": {
    "qrCode": "00020101021238...",
    "qrUrl": "https://...",
    "expiresAt": "2024-01-15T10:35:00Z"
  }
}

Confirm System Payment

http
POST /payments/system/ipn
Content-Type: application/json

{
  "attempt": { "id": "att-uuid-001" },
  "tendered": 100000,
  "note": "Cash payment"
}

Response (200 OK)

json
{
  "transaction": {
    "id": "txn-uuid-001",
    "status": "304_SETTLED",
    "paid": "100000.0000"
  },
  "attempt": {
    "id": "att-uuid-001",
    "status": "302_SUCCESS",
    "tendered": "100000.0000"
  },
  "change": "0.0000"
}

Cancel Payment Attempt

http
POST /payments/cancel
Content-Type: application/json

{
  "attemptId": "att-uuid-001",
  "reason": "Customer changed payment method"
}

Response (200 OK)

json
{
  "transaction": {
    "id": "txn-uuid-001",
    "status": "100_NEW"
  },
  "cancelledAttempts": [
    {
      "id": "cancel-att-uuid",
      "type": "200_CANCEL_PAYMENT",
      "status": "302_SUCCESS",
      "parentId": "att-uuid-001"
    }
  ]
}

NOTE

You can also cancel all attempts for a transaction by sending { "transactionId": "txn-uuid-001" } instead of attemptId.

Verify Payment Attempt

http
POST /payments/verify
Content-Type: application/json

{
  "attemptId": "att-uuid-001"
}

Response (200 OK)

json
{
  "attempt": {
    "id": "att-uuid-001",
    "status": "302_SUCCESS",
    "provider": "VNPAY_QR_MMS"
  },
  "providerStatus": {
    "responseCode": "00",
    "message": "Success"
  }
}

Refund Payment

http
POST /payments/refund
Content-Type: application/json

{
  "attemptId": "att-uuid-001",
  "amount": 50000,
  "reason": "Partial refund for returned item"
}

Response (200 OK)

json
{
  "refundAttempt": {
    "id": "refund-att-uuid",
    "type": "300_REFUND_PAYMENT",
    "status": "302_SUCCESS",
    "amount": "50000.0000",
    "parentId": "att-uuid-001"
  }
}

IMPORTANT

Refund amount cannot exceed originalAmount - alreadyRefundedAmount. The original attempt must be in 302_SUCCESS status.

Transaction Endpoints (CRUD)

Auto-generated via ControllerFactory at base path /transactions.

MethodPathDescription
GET/transactionsList transactions (supports filter, pagination, sorting)
GET/transactions/:idGet transaction by ID
GET/transactions/countCount transactions matching filter
POST/transactionsCreate transaction
PATCH/transactions/:idUpdate transaction
DELETE/transactions/:idSoft-delete transaction

Filter Example:

http
GET /transactions?filter={"where":{"sourceType":"Order","sourceId":"order-uuid"}}

Payment Attempt Endpoints (CRUD)

Auto-generated via ControllerFactory at base path /payment-attempts.

MethodPathDescription
GET/payment-attemptsList payment attempts
GET/payment-attempts/:idGet attempt by ID
GET/payment-attempts/countCount attempts matching filter
POST/payment-attemptsCreate attempt
PATCH/payment-attempts/:idUpdate attempt
DELETE/payment-attempts/:idSoft-delete attempt

Payment Result Endpoints (CRUD)

Auto-generated via ControllerFactory at base path /payment-results.

MethodPathDescription
GET/payment-resultsList payment results
GET/payment-results/:idGet result by ID
GET/payment-results/countCount results matching filter
POST/payment-resultsCreate result
PATCH/payment-results/:idUpdate result
DELETE/payment-results/:idSoft-delete result

Transaction Item Endpoints (CRUD)

Auto-generated via ControllerFactory at base path /transaction-items.

MethodPathDescription
GET/transaction-itemsList transaction items
GET/transaction-items/:idGet item by ID
GET/transaction-items/countCount items matching filter
POST/transaction-itemsCreate item
PATCH/transaction-items/:idUpdate item
DELETE/transaction-items/:idSoft-delete item

Status Codes

Transaction Statuses

StatusCodeDescription
NEW100_NEWCreated, no payment
PARTIAL300_PARTIALPartially paid
SETTLED304_SETTLEDFully paid
CANCELLED505_CANCELLEDAll attempts cancelled
BLOCKED403_BLOCKEDTemporarily blocked
CLOSED404_CLOSEDPermanently closed

Attempt Statuses

StatusCodeDescription
NEW100_NEWCreated, not sent
SENT204_SENTSent to provider
SUCCESS302_SUCCESSPayment confirmed
FAIL500_FAILProvider error
EXPIRED501_EXPIREDTimed out

Error Responses

json
{
  "error": {
    "code": "INVALID_TRANSACTION_STATUS",
    "message": "Cannot add payment to completed transaction"
  }
}

Common Error Codes

CodeDescription
INVALID_TRANSACTION_STATUSWrong transaction state
PAYMENT_ATTEMPT_NOT_FOUNDAttempt ID not found
PROVIDER_NOT_CONFIGUREDProvider not enabled
SIGNATURE_MISMATCHIPN verification failed
REFUND_EXCEEDS_REMAININGRefund amount > remaining refundable
ATTEMPT_NOT_SUCCESSCannot refund non-success attempt

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.