Logo
API ReferencePayments

Retrieve Payment

Retrieves the details of an existing payment by its ID.

Endpoint

GET /api/v1/payments/{payment_id}

Authentication

This endpoint requires HMAC Integration Authentication.

Path Parameters

ParameterTypeRequiredDescription
payment_idstringYesThe UUID of the payment to retrieve

Example Request

import crypto from 'crypto';

const API_KEY = process.env.PAYMENT_API_KEY!;
const API_SECRET = process.env.PAYMENT_API_SECRET!;

async function getPayment(paymentId: string) {
  const method = 'GET';
  const path = `/api/v1/payments/${paymentId}`;
  const body = '';
  const timestamp = Date.now().toString();

  const message = `${timestamp}.${body}`;
  const signature = crypto
    .createHmac('sha256', API_SECRET)
    .update(message)
    .digest('hex');

  const response = await fetch(`https://api.example.com${path}`, {
    method,
    headers: {
      'X-API-Key': API_KEY,
      'X-Timestamp': timestamp,
      'X-Signature': `sha256=${signature}`,
    },
  });

  const result = await response.json();

  if (result.success) {
    console.log('Payment status:', result.data.status);
    console.log('Payment amount:', result.data.amount);
    return result.data;
  } else {
    console.error('Error:', result.error);
    throw new Error(result.error.message);
  }
}

// Get payment
const payment = await getPayment('550e8400-e29b-41d4-a716-446655440000');

Response

Success Response (200 OK)

{
  "success": true,
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "amount": "1000.00",
    "currency": "THB",
    "status": "succeeded",
    "paymentMethod": "promptpay",
    "referenceId": "order-12345",
    "description": "Payment for order #12345",
    "metadata": {
      "order_id": "12345"
    },
    "clientSecret": null,
    "nextAction": null,
    "confirmedAt": "2024-01-01T00:05:00.000Z",
    "capturedAt": "2024-01-01T00:05:00.000Z",
    "canceledAt": null,
    "expiresAt": "2024-01-01T01:00:00.000Z",
    "createdAt": "2024-01-01T00:00:00.000Z",
    "updatedAt": "2024-01-01T00:05:00.000Z"
  }
}

Error Response (404 Not Found)

{
  "success": false,
  "error": {
    "code": "RESOURCE_NOT_FOUND",
    "message": "Payment not found"
  }
}

Payment Status

Payments can be in one of the following statuses:

StatusDescription
requires_payment_methodPayment method needs to be attached
requires_confirmationPayment needs to be confirmed (two-step payment flow)
requires_actionAdditional action required from customer (e.g., 3D Secure)
processingPayment is being processed
requires_capturePayment is authorized and waiting to be captured
succeededPayment was completed successfully
canceledPayment was cancelled by merchant or customer
expiredPayment expired before completion
payment_failedPayment failed (e.g., insufficient funds, card declined)

Payment Status Flow

Status Transitions

  1. Initial Status: Payments typically start as processing or requires_payment_method
  2. Processing: Payment is being processed by the payment provider
  3. Final Status:
    • succeeded - Payment completed successfully
    • canceled - Payment was cancelled
    • expired - Payment expired
    • payment_failed - Payment failed

Status Values

Some status values like requires_confirmation and requires_capture may appear in responses but are not currently actionable via API endpoints. Payments typically transition automatically through these statuses during processing.

Response Fields

FieldTypeDescription
idstringPayment UUID
amountstringAmount as decimal string
currencystringCurrency code (THB)
statusstringCurrent payment status
paymentMethodstringPayment method used (or null)
referenceIdstringYour reference ID
descriptionstringPayment description (or null)
metadataobjectAdditional metadata (or null)
clientSecretstringClient secret for payment processing (or null)
nextActionobjectNext action required (or null)
confirmedAtstringISO timestamp when payment was confirmed (or null)
capturedAtstringISO timestamp when payment was captured (or null)
canceledAtstringISO timestamp when payment was canceled (or null)
expiresAtstringISO timestamp when payment expires (or null)
createdAtstringISO timestamp when payment was created
updatedAtstringISO timestamp when payment was last updated

On this page