# Close transaction

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /api/payment-gateway/v1/payments/close-transaction:
    post:
      summary: Close transaction
      deprecated: false
      description: >-
        If your business involves transactions that may need cancellation—such
        as flash sales, hotel bookings, or ticket sales—you can use the **Close
        Transaction API** to cancel a transaction. Once a transaction is closed,
        its payment status is updated to **CANCELLED**. This means the payment
        will either be rejected or reversed, and no payment notification
        (callback) will be sent to the merchant.
      tags:
        - Ecommerce Checkout
      parameters:
        - name: Content-Type
          in: header
          description: ''
          required: true
          example: application/json
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                req_time:
                  type: string
                  title: ''
                  description: Request date and time in UTC format as YYYYMMDDHHmmss.
                merchant_id:
                  type: string
                  description: A unique merchant key which provided by ABA Bank.
                  title: ''
                  maxLength: 20
                tran_id:
                  type: string
                  description: >-
                    Original purchase transaction id that you want to
                    close/cancel.
                  title: ''
                  maxLength: 20
                hash:
                  type: string
                  title: ''
                  description: >-
                    A Base64-encoded HMAC SHA-512 hash generated by
                    concatenating `req_time`, `merchant_id`, and `tran_id` ,
                    encrypted using your `public_key`.


                    **PHP Sample Code**


                    ```php

                    // public key provided by ABA Bank

                    $api_key = "API KEY PROVIDED BY ABA BANK";

                    // Prepare the data to be hashed

                    $b4hash = $req_time . $merchant_id . $tran_id;

                    // Generate the HMAC hash using SHA-512 and encode it in
                    Base64 

                    $hash = base64_encode(hash_hmac('sha512', $b4hash, $api_key,
                    true));

                    ```
              required:
                - req_time
                - merchant_id
                - tran_id
                - hash
              x-apidog-orders:
                - req_time
                - merchant_id
                - tran_id
                - hash
            example:
              req_time: '20241022053608'
              merchant_id: lavacafe
              tran_id: '1729573626'
              hash: ln9Td4JiGPc...R6y2tmUoF2NERNaQ==
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: object
                    properties:
                      code:
                        type: string
                        title: ''
                        description: |-
                          Response code of the reqeust.
                          - `00` : Success
                          - `1` : Wrong Hash
                          - `5` : Transaction not found
                          - `26` : Invalid merchant profile
                      message:
                        type: string
                        title: ''
                        description: >-
                          Please see the property reponse `code` for the
                          details.
                      tran_id:
                        type: string
                        title: ''
                        description: Purchase transaction id that has been cancelled.
                    required:
                      - code
                      - message
                      - tran_id
                    x-apidog-orders:
                      - code
                      - message
                      - tran_id
                required:
                  - status
                x-apidog-orders:
                  - status
          headers: {}
          x-apidog-name: OK
      security: []
      x-apidog-folder: Ecommerce Checkout
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/831852/apis/api-14530822-run
components:
  schemas: {}
  securitySchemes: {}
servers:
  - url: https://checkout-sandbox.payway.com.kh/
    description: StillZeroBug
security: []

```
