Developers
V1
V2

Redirect method

Process the payment result in a typical mobile environment using page redirection.

The following sample code processes the response to a payment request in a typical mobile environment where the payment window is redirected to a new page to process the payment result.

client-side
IMP.request_pay( { /* ...Omitted... */ m_redirect_url: "{redirect URL}", } /* callback */, ); // callback is not called

If m_redirect_url is specified as the request_pay function parameter as above, the payment result is sent to the URL address in the form of a query string after payment is completed.

What is a query string?

This is the simplest way to pass data by attaching it to the end of a URL, and it is mainly used when sending data in the GET method.

GET https://merchant domain address/complete

Sets the endpoint url to receive the payment result via m_redirect_url.

You can receive the following parameters through the specified URL as a query string.

Parameters

Query

imp_uid*

iโ€™mport payment ID

merchant_uid*

Merchant order ID

imp_success*
error_code

Error code (upon payment failure only)

error_msg

Error message (upon payment failure only)

The following is an example of a redirecting URL based on the query string.

curl https://myservice.com/payments/complete?imp_uid=unique_iamport_paymentID&merchant_uid=unique_merchant_orderID&imp_success=true

If the payment window is redirected to a new page, you cannot receive the payment result via callback.

The final payment result logic processing must be handled stably by using a webhook. If you donโ€™t set up a webhook, you may fail to receive the payment result.

What does completion of the payment process mean?

The payment process is complete when:

  1. Payment is successful (Status: paid, imp_success: true)

  2. Payment fails (Status: failed, imp_success: false)

  3. Payment window fails to open due to PG module setting error

  4. User terminates the payment process by clicking the X or Cancel button

  5. Payment is suspended due to invalid card information, limit exceeded, insufficient balance, etc.

  6. Virtual account is issued (status: ready, imp_success: true)

Note - imp_success parameter

The imp_success parameter indicates whether or not the payment process completed successfully. However, since the payment page is opened by calling a JavaScript function from the client-side, the payment amount can be forged by a malicious user. Hence, this value should not be used to determine the success of the payment. Depending on the value of imp_success, determine the payment success as follows:

  • imp_success = true: First send payment information (imp_uid, merchant_uid) to the server to verify the payment amount, and then finalize payment success.
  • imp_success = false: Alert the user that the payment failed.

* Note that some PGs return a success parameter instead of imp_success, or return neither. (Example: KG INICIS - instant bank transfer)