Capture a payment

For payment windows that support separate capture, the payment is completed in tow steps:



To capture payments, you can use
  1. 1. Automatic Capture :

    Payments are captured immediately after authorization. This is the defalut setting when you requested with transaction_type as PAYMENT or PAYMENT_PA.

  2. 2. Manual Capture :

    You can capture each payment by making a request to the Capture API when you requested with transaction_type as AUTHORIZE or AUTHORIZE_PA.

You can capture the payment later for example after the goods have been shipped. This lets you cancel the payment in case of any issues with the shipment.

Caputre API is available through a separate contract.

Request capture API

To request manually capture for authorized payment, you need the transaction_id. Request the API by adding the transaction_id as a Path parameter to the Capture API endpoint.

Request
                      
curl --request POST 'https://api-test.eximbay.com/v1/payments/{transaction_id}/capture' \
--header 'Authorization: Basic dGVzdF8xODQ5NzA1QzY0MkMyMTdFMEIyRDo=' \
--header 'Content-Type: application/json' \
--data '{
  "mid" : "1849705C64",
  "payment" : {
    "order_id" : "20220902101716",
    "currency" : "USD",
    "amount" : "1",
    "lang" : "EN"
  }
}'
                      
                    
                      
RestTemplate restTemplate = new RestTemplate();

HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json");
headers.add("Authorization", "Basic dGVzdF8xODQ5NzA1QzY0MkMyMTdFMEIyRDo=");

URI url = URI.create("https://api-test.eximbay.com/v1/payments/{transaction_id}/capture");

String body = "{\n" +
				      "\"mid\" : \"1849705C64\",\n" +
				      "\"payment\" : {\n" +
				      "\"order_id\" : \"20220902101716\",\n" +
				      "\"currency\" : \"USD\",\n" +
				      "\"amount\" : \"1\",\n" +
				      "\"lang\" : \"EN\"\n" +
				      " }\n" +
			        "}";

HttpEntity<String> entity = new HttpEntity<>(body, headers);
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);

System.out.println(response.getBody());
                      
                    
                      
<?php
$url = 'https://api-test.eximbay.com/v1/payments/{transaction_id}/capture';
$data = '{
  "mid" : "1849705C64",
  "payment" : {
    "order_id" : "20220902101716",
    "currency" : "USD",
    "amount" : "1",
    "lang" : "EN"
  }
}';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: Basic dGVzdF8xODQ5NzA1QzY0MkMyMTdFMEIyRDo='));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response  = curl_exec($ch);

echo $response;
curl_close($ch);
?>
                      
                    
                      
import requests
import json

url = "https://api-test.eximbay.com/v1/payments/{transaction_id}/capture"
headers = {
  "Authorization": "Basic dGVzdF8xODQ5NzA1QzY0MkMyMTdFMEIyRDo=",
  "Content-Type": "application/json"
}

request = {
  "mid" : "1849705C64",
  "payment" : {
    "order_id" : "20220902101716",
    "currency" : "USD",
    "amount" : "1",
    "lang" : "EN"
  }
}

response = requests.post(url, headers=headers, data=json.dumps(request))

print(response.text)
                      
                    
                      
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api-test.eximbay.com/v1/payments/{transaction_id}/capture',
  'headers': {
    'Authorization': 'Basic dGVzdF8xODQ5NzA1QzY0MkMyMTdFMEIyRDo=',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "mid": "1849705C64",
    "payment": {
      "order_id": "20220902101716",
      "currency": "USD",
      "amount": "1",
      "lang": "EN"
    }
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
                      
                    
                        
string uri = "https://api-test.eximbay.com/v1/payments/{transaction_id}/capture";
string body = "{\n" +
				      "\"mid\" : \"1849705C64\",\n" +
				      "\"payment\" : {\n" +
				      "\"order_id\" : \"20220902101716\",\n" +
				      "\"currency\" : \"USD\",\n" +
				      "\"amount\" : \"1\",\n" +
				      "\"lang\" : \"EN\"\n" +
				      " }\n" +
			        "}";

WebClient webClient = new WebClient();
webClient.Headers[HttpRequestHeader.ContentType] = "application/json";
webClient.Headers[HttpRequestHeader.Authorization] = "Basic dGVzdF8xODQ5NzA1QzY0MkMyMTdFMEIyRDo=";
webClient.Encoding = UTF8Encoding.UTF8;
string responseJSON = webClient.UploadString(uri, body);

Console.Write(responseJSON);
                        
                    
                        
val restTemplate =  RestTemplate()
val headers = HttpHeaders()
headers.add("Content-Type", "application/json")
headers.add("Authorization", "Basic dGVzdF8xODQ5NzA1QzY0MkMyMTdFMEIyRDo=")

var url = URI.create("https://api-test.eximbay.com/v1/payments/{transaction_id}/capture")

val body = "{\n" +
            "\"mid\" : \"1849705C64\",\n" +
            "\"payment\" : {\n" +
            "\"order_id\" : \"20220902101716\",\n" +
            "\"currency\" : \"USD\",\n" +
            "\"amount\" : \"1\",\n" +
            "\"lang\" : \"EN\"\n" +
            " }\n" +
            "}"

var entity = HttpEntity<String>(body, headers)
var response = restTemplate.exchange(url, HttpMethod.POST, entity, String::class.java)

println(response.body)
                        
                    

If request of capture is successful, it returns a resonse with resmsg as Success.

Response
                  
{
  "rescode": "0000",
  "resmsg": "Success.",
  "mid": "1849705C64",
  "payment": {
      "order_id": "20220922114007",
      "currency": "USD",
      "amount": "1",
      "transaction_id": "1849705C6420220922000016",
      "captured_date": "20220922114212",
      "partially_cancelable ": "Y"
  }
}