URL-PATH

 

voidPayment
1

# Request

  • PHP
<?php

    $curl = curl_init();

    //key order must be same order generate signature dataString
    $requestBody = [
        "merchantId" => "xxxxxxx",
        "type" => "VOID",
        "transactionId" => "1234",
        "note" => "transaction reversal."
    ];

    curl_setopt_array($curl, array(
        CURLOPT_URL => "https://dev.directpay.lk/v1/mpg/api/external/transaction/voidPayment",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POSTFIELDS => json_encode($requestBody),
        CURLOPT_HTTPHEADER => array(
            "Signature: j+02o+Q5cH+pXV",
            "x-api-key: dnfo8743ythbf9n7cr8yh473n",
            "Content-Type: application/json"
        ),
    ));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Field Type Description
Content-Type String application/json
Signature String Signature generated for the data
x-api-key String Merchant api key

# Parameter

Field Type Description Allowed values
merchantId String Merchant ID
transactionId String Transaction id you want to void.
type String API request type VOID
note String Transaction void note

# Response

SuccessResponse

{
    "status": 200,
    "type": "VOID_TRN",
    "data": {
        "voidTrnId": 14148,
        "description": "APPROVED"
    }
}
1
2
3
4
5
6
7
8

ErrorResponse

{
    "status": 400,
    "data": {
        "code": "TRANSACTION_EXCEPTION",
        "message": "Value '14147' is invalid. Target transaction has already successfully been voided."
    }
},
{
    "status": 400,
    "data": {
        "error": "ValidationException",
        "message": "Invalid Signature.",
        "title": "Message"
    }
}

 {
    "status": 400,
    "data": {
        "code": "VALIDATION_EXCEPTION",
        "message": "Transaction not found."
    }
}

 {
    "status": 400,
    "data": {
        "error": "ValidationException",
        "message": "Invalid Merchant."
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31