Skip to content

Latest commit

 

History

History
93 lines (85 loc) · 2.76 KB

File metadata and controls

93 lines (85 loc) · 2.76 KB
title description
6. Complete payment
Complete the payment process by returning the result (success/failure) to the user.

import Tab from "/components/gitbook/tabs/Tab.astro"; import Tabs from "/components/gitbook/tabs/Tabs.astro"; import Hint from "~/components/Hint.astro";

In a typical PC-environment payment processed using an iframe, the payment response can be received via a callback function. When the result processing is completed on the merchant server, the result message is returned depending on the success of the payment as shown in the following example.

```ts title="client-side" IMP.request_pay( { /* ...Omitted... */ }, function (rsp) { // callback if (rsp.success) { // payment successful: payment accepted or virtual account issued // jQuery HTTP request jQuery .ajax({ /* ...Omitted... */ }) .done(function (data) { // response processing switch (data.status) { case "vbankIssued": // Virtual account issued break; case "success": // Payment successful break; } }); } else { alert("Payment failed. Error message: " + rsp.error_msg); } }, ); ``` ```ts title="client-side" IMP.request_pay( { /* ...Omitted... */ }, (rsp) => { // callback if (rsp.success) { // payment successful: payment accepted or virtual account issued // axios HTTP request axios({ /* ...Omitted... */ }).then((data) => { // Response processing switch (data.status) { case "vbankIssued": // Virtual account issued break; case "success": // Payment successful
            break;
        }
      });
    } else {
      alert(`Payment failed. Error message: ${rsp.error_msg}`);
    }
  },
);
```

In a typical mobile environment payment processed by redirecting to a new page, process the payment complete message from the merchant endpoint URL set in the m_redirect_url parameter.

**error\_msg and error\_code definitions**

These parameters are returned as a response when the payment fails and they contains the same values returned from the PG without additional processing. Note that we don't yet provide definitions for the error codes and error messages that have accumulated in our system.