URL-PATH

 

refundPayment
1

# Request

  • PHP
<?php

$curl = curl_init();

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

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://dev.directpay.lk/v1/mpg/api/external/transaction/refundPayment",
    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
34
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 refund.
type String API request type REFUND
note String Transaction void note
amount Decimal Transaction amount.

# Response

SuccessResponse

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

ErrorResponse

{
    "status": 400,
    "type": "REFUND_TRN",
    "paymentCategory": "REFUND_TRANSACTION",
    "data": {
        "code": "TRANSACTION_EXCEPTION",
        "message": "Value 'REFUND' is invalid. Missing merchant privilege 'Excessive Refund'."
    }
}, 

{
    "status": 400,
    "type": "REFUND_TRN",
    "paymentCategory": "REFUND_TRANSACTION",
    "data": {
        "error": "ValidationException",
        "message": "Invalid Signature.",
        "title": "Message"
    }
}

 {
    "status": 400,
    "type": "REFUND_TRN",
    "paymentCategory": "REFUND_TRANSACTION",
    "data": {
        "code": "VALIDATION_EXCEPTION",
        "message": "Transaction not found."
    }
}

 {
    "status": 400,
    "type": "REFUND_TRN",
    "paymentCategory": "REFUND_TRANSACTION",
    "data": {
        "error": "ValidationException",
        "message": "Invalid Merchant."
    }
}

 {
    "status": 400,
    "type": "REFUND_TRN",
    "paymentCategory": "REFUND_TRANSACTION",
    "data": {
        "error": "ValidationException",
        "message": "Today transactions total less than refund amount."
    }
}
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50