Refund a payment

If you want to refund the accepted or cancelled transaction by using Refund API. You can partially or fully refund any successful payment.

Request refund API

If you want to refund the accpeted transaction, you need transaction_id that issued as a result of the payment authorization is required.
Request the API by adding the transaction_id as a Path parameter to Refund API endpoint.

Request
                      
curl --request POST 'https://api-test.eximbay.com/v1/payments/{transaction_id}/cancel' \
--header 'Authorization: Basic dGVzdF8xODQ5NzA1QzY0MkMyMTdFMEIyRDo=' \
--header 'Content-Type: application/json' \
--data '{
  "mid" : "1849705C64",
  "refund" : {
    "refund_type" : "F",
    "refund_amount" : "1",
    "refund_id" : "1849705C64",
    "reason" : "단순변심"
  },
  "payment" : {
    "order_id" : "20220829170258",
    "currency" : "USD",
    "amount" : "1",
    "balance" : "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}/cancel");

String body = "{\n" +
              "\"mid\" : \"1849705C64\",\n" +
              "\"refund\" : {\n" +
              "\"refund_type\" : \"F\",\n" +
              "\"refund_amount\" : \"1\",\n" +
              "\"refund_id\" : \"1849705C64\",\n" +
              "\"reason\" : \"단순변심\"\n" +
              "},\n" +
              "\"payment\" : {\n" +
              "\"order_id\" : \"20220829170258\",\n" +
              "\"currency\" : \"USD\",\n" +
              "\"amount\" : \"1\",\n" +
              "\"balance\" : \"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}/cancel';
$data = '{
  "mid" : "1849705C64",
  "refund" : {
    "refund_type" : "F",
    "refund_amount" : "1",
    "refund_id" : "1849705C64",
    "reason" : "단순변심"
  },
  "payment" : {
    "order_id" : "20220829170258",
    "currency" : "USD",
    "amount" : "1",
    "balance" : "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.eximbay//v1/payments/{transaction_id}/cancel"
headers = {
  "Authorization": "Basic dGVzdF8xODQ5NzA1QzY0MkMyMTdFMEIyRDo=",
  "Content-Type": "application/json"
}

request = {
  "mid" : "1849705C64",
  "refund" : {
    "refund_type" : "F",
    "refund_amount" : "1",
    "refund_id" : "1849705C64",
    "reason" : "단순변심"
  },
  "payment" : {
    "order_id" : "20220829170258",
    "currency" : "USD",
    "amount" : "1",
    "balance" : "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}/cancel',
  'headers': {
    'Authorization': 'Basic dGVzdF8xODQ5NzA1QzY0MkMyMTdFMEIyRDo=',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "mid": "1849705C64",
    "refund": {
      "refund_type": "F",
      "refund_amount": "1",
      "refund_id": "1849705C64",
      "reason": "단순변심"
    },
    "payment": {
      "order_id": "20220829170258",
      "currency": "USD",
      "amount": "1",
      "balance": "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}/cancel";
string body = "{\n" +
              "\"mid\" : \"1849705C64\",\n" +
              "\"refund\" : {\n" +
              "\"refund_type\" : \"F\",\n" +
              "\"refund_amount\" : \"1\",\n" +
              "\"refund_id\" : \"1849705C64\",\n" +
              "\"reason\" : \"단순변심\"\n" +
              "},\n" +
              "\"payment\" : {\n" +
              "\"oreder_id\" : \"20220829170258\",\n" +
              "\"currency\" : \"USD\",\n" +
              "\"amount\" : \"1\",\n" +
              "\"balance\" : \"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}/cancel")

val body = "{\n" +
            "\"mid\" : \"1849705C64\",\n" +
            "\"refund\" : {\n" +
            "\"refund_type\" : \"F\",\n" +
            "\"refund_amount\" : \"1\",\n" +
            "\"refund_id\" : \"1849705C64\",\n" +
            "\"reason\" : \"단순변심\"\n" +
            "},\n" +
            "\"payment\" : {\n" +
            "\"oreder_id\" : \"20220829170258\",\n" +
            "\"currency\" : \"USD\",\n" +
            "\"amount\" : \"1\",\n" +
            "\"balance\" : \"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)
                        
                    

When you receive the Refund API response, you can find the refund information in refund object.

Response
                  
{
  "rescode": "0000",
  "resmsg": "Success.",
  "mid": "1849705C64",
  "refund": {
      "refund_amount": "1.00",
      "refund_id": "1849705C64",
      "refund_date": "20220922113927",
      "refund_transaction_id": "1849705C6420220922000014"
  },
  "payment": {
      "order_id": "20220922113330",
      "currency": "USD",
      "amount": "1.00",
      "transaction_id": "1849705C6420220922000013",
      "balance": "0.00",
      "base_amount": "1.00",
      "base_rate": "1.000000",
      "dcc_rate": "1.000000",
      "payment_method" : "P101"
  },
  "foreign": {
      "foregin_currency": "USD",
      "foregin_amount": "1.00",
      "foregin_rate": "0"
  }
}
                  
                

Reqeust partially refund

You can refund a part of the authorization amount. Put P in refund_type by making a request to the Refund API.

Request
                      
curl --request POST 'https://api-test.eximbay.com/v1/payments/{transaction_id}/cancel' \
--header 'Authorization: Basic dGVzdF8xODQ5NzA1QzY0MkMyMTdFMEIyRDo=' \
--header 'Content-Type: application/json' \
--data '{
"mid" : "1849705C64",
"refund" : {
"refund_type" : "P",
"refund_amount" : "0.5",
"refund_id" : "1849705C64",
"reason" : "단순변심"
},
"payment" : {
"order_id" : "20220829170258",
"currency" : "USD",
"amount" : "1",
"balance" : "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}/cancel");

String body = "{\n" +
  "\"mid\" : \"1849705C64\",\n" +
  "\"refund\" : {\n" +
  "\"refund_type\" : \"P\",\n" +
  "\"refund_amount\" : \"0.5\",\n" +
  "\"refund_id\" : \"1849705C64\",\n" +
  "\"reason\" : \"단순변심\"\n" +
  "},\n" +
  "\"payment\" : {\n" +
  "\"oreder_id\" : \"20220829170258\",\n" +
  "\"currency\" : \"USD\",\n" +
  "\"amount\" : \"1\",\n" +
  "\"balance\" : \"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}/cancel';
$data = '{
"mid" : "1849705C64",
"refund" : {
"refund_type" : "P",
"refund_amount" : "0.5",
"refund_id" : "1849705C64",
"reason" : "단순변심"
},
"payment" : {
"order_id" : "20220829170258",
"currency" : "USD",
"amount" : "1",
"balance" : "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.eximbay//v1/payments/{transaction_id}/cancel"
headers = {
"Authorization": "Basic dGVzdF8xODQ5NzA1QzY0MkMyMTdFMEIyRDo=",
"Content-Type": "application/json"
}

request = {
"mid" : "1849705C64",
"refund" : {
"refund_type" : "P",
"refund_amount" : "0.5",
"refund_id" : "1849705C64",
"reason" : "단순변심"
},
"payment" : {
"order_id" : "20220829170258",
"currency" : "USD",
"amount" : "1",
"balance" : "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}/cancel',
'headers': {
'Authorization': 'Basic dGVzdF8xODQ5NzA1QzY0MkMyMTdFMEIyRDo=',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"mid": "1849705C64",
"refund": {
"refund_type": "P",
"refund_amount": "0.5",
"refund_id": "1849705C64",
"reason": "단순변심"
},
"payment": {
"order_id": "20220829170258",
"currency": "USD",
"amount": "1",
"balance": "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}/cancel";
string body = "{\n" +
  "\"mid\" : \"1849705C64\",\n" +
  "\"refund\" : {\n" +
  "\"refund_type\" : \"P\",\n" +
  "\"refund_amount\" : \"0.5\",\n" +
  "\"refund_id\" : \"1849705C64\",\n" +
  "\"reason\" : \"단순변심\"\n" +
  "},\n" +
  "\"payment\" : {\n" +
  "\"oreder_id\" : \"20220829170258\",\n" +
  "\"currency\" : \"USD\",\n" +
  "\"amount\" : \"1\",\n" +
  "\"balance\" : \"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}/cancel")

val body = "{\n" +
"\"mid\" : \"1849705C64\",\n" +
"\"refund\" : {\n" +
"\"refund_type\" : \"P\",\n" +
"\"refund_amount\" : \"0.5\",\n" +
"\"refund_id\" : \"1849705C64\",\n" +
"\"reason\" : \"단순변심\"\n" +
"},\n" +
"\"payment\" : {\n" +
"\"oreder_id\" : \"20220829170258\",\n" +
"\"currency\" : \"USD\",\n" +
"\"amount\" : \"1\",\n" +
"\"balance\" : \"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)