# 4. Process Payment

Upon completing the 3DS authentication process, the user is redirected to the endpoint specified in the Acs\_CallbackUrl parameter of the InitiatePay request. The merchant receives a response containing a form object at this endpoint. The merchant must verify that <mark style="color:blue;">**form.result**</mark> equals "SUCCESS" and <mark style="color:blue;">**form.response.gatewayRecommendation**</mark> equals "PROCEED" to determine whether to proceed with the payment process. If both conditions are satisfied, the merchant should call the ProcessPayment API with the specified parameters.

#### API Edpoints

{% tabs %}
{% tab title="Production Endpoint" %}

```
https://kwpaypg.casheer.com/COFWAY/ProcessPayment
```

{% endtab %}

{% tab title="Sandbox Endpoint" %}

```
https://kwpaypgsb.casheer.com/COFWAY/ProcessPayment   
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Sample Request" %}

<pre class="language-html"><code class="lang-html"> {
    "ReferenceId": "xxxxxxxxxxxx",  // 15-digit reference id used in the validate request
    "MerchantId": "KW23821",        // Merchant code
     "Result": "success",             // result received in the form.result object
    "GatewayRecommendation": "PROCEED" // Gateway recommendation received in the form.result.gatewayrecommandation
<strong>}
</strong></code></pre>

{% endtab %}

{% tab title="Sample Response" %}

```

  "errorCode": 0,
  "errorMessgae": "SUCCESS",
  "result": {
    "error": null,
    "gatewayEntryPoint": "WEB_SERVICES_API",
    "merchant": "",
    "order": {
      "amount": 10,
      "certainty": null,
      "creationTime": "2025-04-23T10:27:26.416Z",
      "currency": "USD",
      "id": "543839849919125",
      "status": "CAPTURED",
      "totalAuthorizedAmount": 10,
      "totalCapturedAmount": 10,
      "totalRefundedAmount": 0,
      "authenticationStatus": "AUTHENTICATION_SUCCESSFUL",
      "lastUpdatedTime": "2025-04-23T10:27:41.733+00:00",
      "merchantCategoryCode": "5399",
      "valueTransfer": null
    },
    "response": {
      "the3DSecure": null,
      "acquirerCode": "00",
      "acquirerMessage": "Approved",
      "gatewayCode": "APPROVED",
      "gatewayRecommendation": "NO_ACTION"
    },
    "result": "SUCCESS",
    "sourceOfFunds": {
      "provided": {
        "card": {
          "brand": "MASTERCARD",
          "number": "512345xxxxxx0008",
          "securityCode": null,
          "expiry": {
            "month": "1",
            "year": "39"
          }
        }
      },
      "type": "CARD"
    },
    "timeOfRecord": "2025-04-23T13:27:41.529+03:00",
    "transaction": {
      "acquirer": {
        "batch": 20250423,
        "date": "0423",
        "id": "NBK_S2I",
        "merchantId": "900459840",
        "settlementDate": "2025-04-23T00:00:00",
        "timeZone": "+0300",
        "tra": "..."
      }
    }
  }
}
```

{% endtab %}
{% endtabs %}

Upon receiving the response from the ProcessPayment API, the merchant must verify the errorCode to determine the next steps. If the errorCode is 0, indicating a successful API call, the merchant should parse the result object and verify that result.result equals "SUCCESS" and result.response.acquirerMessage equals "APPROVED". These conditions confirm a successful payment transaction.
