Skip to content

Refund Payment

Note

Not all acquirers/payment brands support refund and certain refund type. Before implementing, check with your account manager if refund is supported in your account.


An endpoint to request a refund for a transaction.

To initiate transaction refund, send the request header and body parameters via POST.

POST/refund

Refund has two types, the FULL and PARTIAL refund.

Full Refund

HEADER PARAMETERS

Content-Type optional
string
Default content type of the API.

Authorization required
string
Unique identifier of the integrator.

REQUEST BODY SCHEMA: application/json

transaction_id required
string
Payment transaction reference ID.

notify_user required
string
True or false value. Directs function whether to notify the customer via email.

reason required
string
Note or remark why the transaction is being refunded.

Request Samples

curl
    -X POST "https://test-api.tlpe.io/refund" \
    -H "Content-Type: application/json" \
    -H "Authorization: {integratorToken}" \
    -d "{
        "transaction_id":"{transactionId}",
        "notify_user":"false",
        "reason":"Cancelled transaction"
    }"
public Dictionary<string, dynamic> Refund()
    {
        Dictionary<string, dynamic> responseData;
        string payload = "{\"transaction_id\":\"{transactionId}\",\"notify_user\":\"false\",\"reason\":\"Cancelled Transaction\"}";
        string url = "https://test-api.tlpe.io/refund";
        byte[] buffer = Encoding.ASCII.GetBytes(payload);
        HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
        request.Method = "POST";
        request.Headers["Authorization"] = "{integratorToken}";
        request.ContentType = "application/json";
        Stream PostData = request.GetRequestStream();
        PostData.Write(buffer, 0, buffer.Length);
        PostData.Close();
      using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
        {
            Stream responseStream = response.GetResponseStream();
            StreamReader reader = new StreamReader(responseStream);
            StringReader sr = new StringReader(reader.ReadToEnd());

            JsonReader jreader = new JsonTextReader(sr);
            JsonSerializer jss = new JsonSerializer();
            responseData = jss.Deserialize<Dictionary<string, dynamic>>(jreader);
            reader.Close();
            responseStream.Close();
        }

      return responseData;

    }
Public Function Refund() As Dictionary(Of String, Object)
    Dim payload As String = "{""transaction_id"":""{transactionId}"",""notify_user"":false,""reason"":""Cancelled Transaction""}"
    Dim url As String = "https://test-api.tlpe.io/refund"
    Dim request As WebRequest = WebRequest.Create(url)
    request.Method = "POST"
    request.Headers.Add("Authorization", "{ingtegratorToken}")
    request.ContentType = "application/json"
    Dim byteArray As Byte() = Encoding.UTF8.GetBytes(payload)
    request.ContentLength = byteArray.Length
    Dim dataStream As Stream = request.GetRequestStream()
    dataStream.Write(byteArray, 0, byteArray.Length)
    dataStream.Close()

    Dim response As WebResponse = request.GetResponse()
    Dim responseStream = response.GetResponseStream()
    Dim reader As New StreamReader(responseStream)
    Dim responseReader As StringReader = New StringReader(reader.ReadToEnd())
    Dim jreader As JsonReader = New JsonTextReader(responseReader)
    reader.Close()
    responseStream.Close()
    response.Close()
    Dim jss As New JsonSerializer()
    Dim responseData As Dictionary(Of String, Object) = jss.Deserialize(Of Dictionary(Of String, Object))(jreader)

    Return responseData
End Function
import http.client
import json

conn = http.client.HTTPSConnection('test-api.tlpe.io')
payload = json.dumps({'transaction_id': '{transactionId}',
                    'notify_user': 'false',
                    'reason': 'Cancelled transaction'})
headers = {'Content-Type': 'application/json',
        'Authorization': '{integratorToken}'}
conn.request('POST', '/refund', payload, headers)
res = conn.getresponse()
data = res.read()
print data.decode('utf-8'))
<?php
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://test-api.tlpe.io/refund',
    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 => '{
            "transaction_id":"{transactionId}",
            "notify_user":"false",
            "reason":"Cancelled transaction"
            }',
    CURLOPT_HTTPHEADER => array(
        'Content-Type: application/json',
        'Authorization: {integratorToken}'
    ) ,
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
require 'rest-client'
require 'json'

response = RestClient::Request.execute(
method:  :post, 
url:     "https://test-api.tlpe.io/refund",
payload: '{
    "transaction_id":"{transactionId}",
    "notify_user":"false",
    "reason":"Cancelled transaction"
}',
headers: { authorization: '{integratorToken}', content_type: 'application/json', accept: 'application/json'}
)

responseJson = JSON.parse(response)

puts JSON.pretty_generate(responseJson)
var request = require('request');
var options = {
    'method': 'POST',
    'url': 'https://test-api.tlpe.io/refund',
    'headers': {
        'Content-Type': 'application/json',
        'Authorization': '{integratorToken}'
    },
    body: JSON.stringify({
        "transaction_id": "{transactionId}",
        "notify_user": "false",
        "reason": "Cancelled transaction"
    })
};
request(options, function(error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});

Download Postman request here

200 Successful Response

RESPONSE SCHEMA: application/json

timestamp
string
Transaction timestamp

status
string
HTTP status code

message
string
HTTP status code message/description

path
string
Endpoint path used for the transaction

data
object
Contains transaction-related response

transaction_id
string
Payment reference number of the transaction

status_code
string
API status code

status_description
string
API status code message/description

200 Erroneous Response

RESPONSE SCHEMA: application/json

timestamp
string
Transaction timestamp

status
string
HTTP status code

message
string
HTTP status code message/description

path
string
Endpoint path used for the transaction

data
object
Contains transaction-related response

status_code
string
API status code

status_description
string
API status code message/description

Response Samples

{
    "timestamp": "2020-07-14T08:08:04.815+0000",
    "status": 200,
    "message": "Request processed successfully",
    "path": "/refund",
    "data": {
        "transaction_id": "{transactionId}",
        "status_code": "OK.02.00",
        "status_description": "Full refund successful"
    }
}
{
    "timestamp": "2023-08-03T09:02:59.477+0000",
    "status": 404,
    "message": "Not found",
    "path": "/report/123456ABC",
    "data": {
        "status_description": "Invalid client request due to invalid parameters",
        "status_code": "ER.02.30"
    }
}

Partial Refund

HEADER PARAMETERS

Content-Type optional
string
Default content type of the API.

Authorization required
string
Unique identifier of the integrator.

REQUEST BODY SCHEMA: application/json

transaction_id required
string
Payment transaction reference ID.

notify_user required
string
True or false value. Directs function whether to notify the customer via email.

reason required
string
Note or remark why the transaction is being refunded.

amount required
string
Amount to be refunded. Must not exceed available refundable amount.

Request Samples

curl
    -X POST "https://test-api.tlpe.io/refund" \
    -H "Content-Type: application/json" \
    -H "Authorization: {integratorToken}" \
    -d "{
        "transaction_id":"{transactionId}",
        "notify_user":"false",
        "reason":"Cancelled transaction",
        "amount": 1.00
    }"
200 Successful Response

RESPONSE SCHEMA: application/json

timestamp
string
Transaction timestamp

status
string
HTTP status code

message
string
HTTP status code message/description

path
string
Endpoint path used for the transaction

data
object
Contains transaction-related response

transaction_id
string
Payment reference number of the transaction

status_code
string
API status code

status_description
string
API status code message/description

200 Erroneous Response

RESPONSE SCHEMA: application/json

timestamp
string
Transaction timestamp

status
string
HTTP status code

message
string
HTTP status code message/description

path
string
Endpoint path used for the transaction

data
object
Contains transaction-related response

status_code
string
API status code

status_description
string
API status code message/description

{
    "timestamp":"2020-07-14T09:29:03.806+0000",
    "status":200,
    "message":"Request processed successfully",
    "path":"/refund",
    "data":{
        "transaction_id":"{transactionId}",
        "status_code":"OK.04.00",
        "status_description":"Partial refund successful"
    }
}
{
    "timestamp":"2020-07-14T09:29:49.843+0000",
    "status":200,
    "message":"Request processed successfully",
    "path":"/refund",
    "data":{
        "status_code":"ER.20.20",
        "status_description":"Unable to process client request due to 'Transaction is already refunded'"
    }
}