Skip to content

Capture Payment

Note

Not all acquirers/payment brands support preauthorization and capture. Before implementing, check with your account manager if supported in your account.

Capturing a transaction must have a pre-authorization first.

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

POST/capture

Capture

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 captured.

Request Samples

curl
    -X POST "https://test-api.tlpe.io/capture" \
    -H "Content-Type: application/json" \
    -H "Authorization: {integratorToken}" \
    -d "{
        "transaction_id":"{transactionId}",
        "notify_user":"false",
        "reason":"Cancelled transaction"
    }"
public Dictionary<string, dynamic> Capture()
    {
        Dictionary<string, dynamic> responseData;
        string payload = "{\"transaction_id\":\"{transactionId}\",\"notify_user\":\"false\",\"reason\":\"Cancelled Transaction\"}";
        string url = "https://test-api.tlpe.io/capture";
        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 Capture() 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/capture"
    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', '/capture', 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/capture',
    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/capture",
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/capture',
    '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

422 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": "/capture",
    "data": {
        "transaction_id": "{transactionId}",
        "status_code": "OK.09.00",
        "status_description": "Full capture successful"
    }
}
{
    "timestamp": "2023-08-03T09:02:59.477+0000",
    "status": 422,
    "message": {
        "payment.currency": [
            "invalid currency"
        ]
    },
    "path": "/capture",
    "data": {
        "status_description": "Invalid client request due to invalid parameters",
        "status_code": "ER.02.30"
    }
}