Refund API

Base URL: https://checkout-sandbox.payway.com.kh/Copy to clipboard
POST

You can use the Refund API to issue full or partial refunds within 30 days after the transaction was created. ABA PAY and KHQR refunds is immediate, while Card, WeChat, and Alipay refunds follow your agreement with PayWay. This API works both for instore transaction and online transaction.

  • Eligible Transactions: Only transactions with a status of COMPLETED can be refunded.
  • Time Frame: Refunds must be requested within 30 days of the payment created date.
  • Pending Settlements: Refunds can be issued even if the settlement is still pending (Alipay, WeChat, Card).
  • Partial Refunds: Multiple partial refunds can be issued until the total amount paid is refunded.
  • Rate limit: Request limit 500 reqeusts/second.
  • Refund Enablement: The outlet/terminal must have the refund feature enabled to allow refunds.

Request

Header Params
stringrequired

Example: application/json

Body Params application/json

stringrequired

Request date and time in UTC format as YYYYMMDDHHmmss.

stringrequired

A unique merchant key which provided by ABA Bank.

<= 20 characters
stringrequired

The JSON-encoded object containing mc_id, tran_id, and refund_amount using RSA public key encryption in chunks. The encrypted data is then concatenated and encoded in Base64 format.


mc_id string mandatory
A unique merchant key which provided by ABA Bank. Same value as merchant_id


tran_id string mandatory
Purcahse transaction id to refund.


refund_amount decimal mandatory
Amount to refund back to payer.


PHP Sample Code

// Prepare data to be encrypted
$data_object = json_encode([
    'mc_id' => $merchant_id, // same value as merchant_id
    'tran_id' => $tran_id,
    'refund_amount' => $amount
]);
// RSA public key provided by the bank
$rsa_public_key = "RSA PUBLIC KEY PROVIDED BY ABA BANK";
// Maximum length for encryption chunks
$maxlength = 117;
// Initialize output for encrypted data
$encrypted_output = '';
// Encrypt data in chunks
while ($data_object !== '') {
    // Extract a substring of the allowed maximum length
    $chunk = substr($data_object, 0, $maxlength);
    $data_object = substr($data_object, $maxlength);
// Encrypt the chunk using the public key
if (openssl_public_encrypt($chunk, $encrypted_chunk, $rsa_public_key)) {
        $encrypted_output .= $encrypted_chunk;
    } else {
        // Handle encryption failure (optional: log the error or throw an exception)
        throw new Exception('Encryption failed for a data chunk.');
    }
}
// Encode the concatenated encrypted output in Base64
$merchant_auth = base64_encode($encrypted_output);
stringrequired

Base64 encode of hash hmac sha512 encryption of concatenates values request_time, merchant_id and merchant_auth with public_key.

PHP Sample Code

// public key provided by ABA Bank
$api_key = "API KEY PROVIDED BY ABA BANK";
// Prepare the data to be hashed
$b4hash = $request_time . $merchant_id . $merchant_auth;
// Generate the HMAC hash using SHA-512 and encode it in Base64
$hash = base64_encode(hash_hmac('sha512', $b4hash, $api_key, true));

Example

{
  "request_time": "",
  "merchant_id": "",
  "merchant_auth": "",
  "hash": ""
}
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R

Responses