đźď¸Redirect method
Process the payment result in a typical mobile environment using page redirection.
đާWhat is 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.
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.
Sets the endpoint url to receive the payment result via m_redirect_url.
GET
https://merchant domain address/complete
You can receive the following parameters through the specified URL as a query string.
Query Parameters
Name | Type | Description |
---|---|---|
imp_uid* | String | i'mport payment ID |
merchant_uid* | String | Merchant order ID |
imp_success* | String | |
error_code | String | Error code (upon payment failure only) |
error_msg | String | Error message (upon payment failure only) |
The following is an example of a redirecting URL based on the query string.
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:
Payment is successful (Status:
paid
, imp_success:true
)Payment fails (Status:
failed
, imp_success:false
)Payment window fails to open due to PG module setting error
User terminates the payment process by clicking the X or Cancel button
Payment is suspended due to invalid card information, limit exceeded, insufficient balance, etc.
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)
Last updated