# 6. Complete payment

In a typical PC-environment payment processed using an i**frame**, 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.

{% tabs %}
{% tab title="JavaScript" %}
{% code title="client-side" %}

```javascript
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);
    }
  });
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript (ES Next)" %}
{% code title="client-side" %}

```javascript
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}\`);
    }
  });
```

{% endcode %}
{% endtab %}
{% endtabs %}

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.

{% hint style="info" %}
**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.
{% endhint %}
