> ## Documentation Index
> Fetch the complete documentation index at: https://docs.commercecash.my/llms.txt
> Use this file to discover all available pages before exploring further.

# Confirm Payment

> Confirms a previously initiated payment transaction.

`POST /api/payments/confirm`

Confirms a payment transaction that was previously initiated. You must supply the `transactionId` from the [Initiate Payment](/api-reference/payments/initiate) response. An optional `confirmationCode` (e.g., OTP) may be required depending on the product.

***

## Request Body

<ParamField body="transactionId" type="string" required>
  Transaction ID obtained from the [Initiate Payment](/api-reference/payments/initiate) response.

  **Example:** `TXN-20240616143022-A7F9E2`
</ParamField>

<ParamField body="referenceNo" type="string" required>
  Merchant reference number associated with the transaction.

  **Example:** `MER-20240616-001`
</ParamField>

<ParamField body="confirmationCode" type="string">
  OTP or additional verification code required by some payment products.
</ParamField>

<ParamField body="extraProperties" type="string (JSON)">
  Additional confirmation data serialised as a JSON string.

  **Example:** `"{}"`
</ParamField>

***

## Response

### 200 — Payment Confirmed

<ResponseField name="isSuccess" type="boolean">
  `true`
</ResponseField>

<ResponseField name="errorCode" type="null">
  `null` on success.
</ResponseField>

<ResponseField name="message" type="string | null">
  Optional informational message.
</ResponseField>

<ResponseField name="data" type="object">
  <Expandable title="PaymentConfirmResponse">
    <ResponseField name="transactionId" type="string">
      Unique transaction ID.
    </ResponseField>

    <ResponseField name="referenceNo" type="string">
      Merchant reference number.
    </ResponseField>

    <ResponseField name="status" type="string">
      Final payment status after confirmation.

      **Common values:** `CONFIRMED`, `SUCCESSFUL`, `FAILED`
    </ResponseField>

    <ResponseField name="amount" type="number (decimal)">
      Payment amount as a decimal value (e.g., `150.00`).
    </ResponseField>

    <ResponseField name="providerReference" type="string | null">
      Transaction reference returned by the downstream payment provider.
    </ResponseField>

    <ResponseField name="confirmedAt" type="string (ISO 8601)">
      UTC timestamp of when the confirmation was processed.

      **Example:** `2024-06-16T14:35:10Z`
    </ResponseField>

    <ResponseField name="errorMessage" type="string | null">
      Error detail populated if confirmation resulted in a `FAILED` status.
    </ResponseField>

    <ResponseField name="extraProperties" type="string | null">
      Additional confirmation response data, serialised as a JSON string.
    </ResponseField>
  </Expandable>
</ResponseField>

### 400 — Bad Request

Validation failed or the transaction cannot be confirmed (e.g., already confirmed or expired).

### 500 — Internal Server Error

***

## Examples

<CodeGroup>
  ```json Request theme={null}
  {
    "transactionId": "TXN-20240616143022-A7F9E2",
    "referenceNo": "MER-20240616-001",
    "confirmationCode": "123456",
    "extraProperties": "{}"
  }
  ```

  ```json 200 Response theme={null}
  {
    "isSuccess": true,
    "errorCode": null,
    "message": null,
    "data": {
      "transactionId": "TXN-20240616143022-A7F9E2",
      "referenceNo": "MER-20240616-001",
      "status": "SUCCESSFUL",
      "amount": 150,
      "providerReference": "TNB-TXN-987654321",
      "confirmedAt": "2024-06-16T14:35:10Z",
      "errorMessage": null,
      "extraProperties": null
    }
  }
  ```

  ```json 400 Response theme={null}
  {
    "isSuccess": false,
    "errorCode": "TRANSACTION_NOT_FOUND",
    "message": "No transaction was found for the provided ID.",
    "data": null
  }
  ```

  ```json 500 Response theme={null}
  {
    "isSuccess": false,
    "errorCode": "INTERNAL_ERROR",
    "message": "An unexpected error occurred. Please try again.",
    "data": null
  }
  ```
</CodeGroup>
