💸Payment cancellation (refund)

Learn how to cancel a payment using the i'mport payment cancel API.

STEP 01. Request cancellation

Request a refund to the server with the required refund information. In the case of virtual account refund, you need to specify additional parameters for the refund deposit account information. The following example requests a refund with the required refund information.

client-side
<button onclick="cancelPay()">Request Refund</button>
<script
  src="https://code.jquery.com/jquery-3.3.1.min.js"
  integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
  crossorigin="anonymous"></script><!-- jQuery CDN --->
<script>
  function cancelPay() {
    jQuery.ajax({
      "url": "{URL to receive refund request}", // Example: http://www.myservice.com/payments/cancel
      "type": "POST",
      "contentType": "application/json",
      "data": JSON.stringify({
        "merchant_uid": "{Order ID}", // Example: ORD20180131-0000011
            "cancel_request_amount": 2000, // Refund amount
            "reason": "Testing payment refund" // Reason for the refund
            "refund_holder": "Jone Doe", // [required for virtual account refund] refund account holder's name
            "refund_bank": "88" // [required for virtual account refund] refund account bank code (e.g. Shinhan Bank is 88 for KG Inicis)
            "refund_account": "56211105948400" // [required for virtual account refund] refund account number
      }),
      "dataType": "json"
    });
  }
</script>

Sample refund button

STEP 02. Get payment information

Assume that there is a Payments table that stores payment information as follows:

Query the payment information of the order from the Payments table using the order ID (merchant_uid) received from the client.

STEP 03. Request refund to i'mport server

To request a refund, you must first get a REST API access token. Use the access token to call the i'mport cancel API to request a refund.

Note - Refunding mobile micropayments

  • If a refund is requested on a different month from when the payment is made, a full refund is not allowed. For example, a payment made on January 31st is not refundable on February 1st.

Setting parameters for refund request:

Refund unique key

Set imp_uid or merchant_uid as the unique key that identifies the transaction to be refunded. The value of imp_uid takes precedence, and if an invalid imp_uid value is entered, the refund request will fail regardless of the merchant_uid value.

Refund amount (amount)

Enter the refund amount. If amount is not specified, the full amount will be refunded.

Refundable amount (checksum)

Enter the refundable amount. For example, the checksum of a product that costs 10,000 won is 10,000. If this payment has been partially refunded for 1,000 won in the past, the checksum is 9000 for the subsequent refund request. The checksum is used to check whether the refundable amount is the same between the merchant server and the i'mport server. If they do not match, the refund request will fail. If the checksum is not specified, the verification is not performed.

The following example requests a refund.

STEP 04. Save refund result

After the refund process is completed, save the result in the database as follows:

STEP 04. Handle response for refund request

Add the client-side logic to handle the response from the server as follows:

Last updated