---
title: Cancel - API GPN
slug: en/nicepay-api-non-snap-cancel-api-gpn
description: Information about Non-SNAP Payment API - Cancel - GPN API available on NICEPAY system
image: https://archbee-image-uploads.s3.amazonaws.com/ZHvSjR5ZrsoxwKbJa3xmo/iDaoL5lz84j-dEsZM8vdw_nicepay-docs-logo.png
icon: {"faIcon":"fa-solid fa-book"}
docTags: 
createdAt: 2022-12-01T07:53:10.000Z
---

# About API GPN Cancel

***

This API uses to cancel the paid transaction. If the transaction cancels before the settlement process is done, then that transaction will consider void, and that fund transaction will return to Your Customer.



# API GPN Cancel

***

The GPN API uses to cancel system for payments via GPN.

| **API Endpoint**   | `/nicepay/direct/v2/cancel`                           |
| ------------------ | ----------------------------------------------------- |
| **Request Method** | <font color="#3b9f0f">**POST**</font>****             |
| **Header**         | `Content-Type: application/json`                      |
| **Merchant Token** | SHA256(`timeStamp`+`iMid`+`tXid`+`amt`+`merchantKey`) |



# Payment Methods Available for Cancel

***

**Code              PayMethod**

***

`01`               Credit Card

***

`02`               Virtual Account&#x20;

***

`03`               Convenience Store&#x20;

***

`04`               Direct Debit&#x20;

***

`05`               E-Wallet&#x20;

***

`06`               Paylater&#x20;

***

`08`               QRIS&#x20;

***

`09`               <font color="#2166ae">**GPN**</font>****

***



## Request Parameters for GPN Cancel

***

The following is a list of parameters for requesting integration of the cancel payment process on the GPN payment method. These parameters use via the API testing platform. &#x20;

| **Parameter**                                                     | **Type** | **Size** | **Description**             | **Example / Notes**                                              |
| ----------------------------------------------------------------- | -------- | -------- | --------------------------- | ---------------------------------------------------------------- |
| `timeStamp`<br /><font color="#2166ae">Required</font>           | N        | 14       | API Request Timestamp       | 20180123100505                                                   |
| `tXid`<br /><font color="#2166ae">Required</font>                | AN       | 30       | Transaction ID              | IONPAYTEST01202103311759347262                                   |
| `iMid`<br /><font color="#2166ae">Required</font>                | AN       | 10       | Merchant ID                 | IONPAYTEST                                                       |
| `payMethod`<br /><font color="#2166ae">Required</font>           | N        | 2        | Payment Method              | 09                                                               |
| `cancelType`<br /><font color="#2166ae">Required</font>          | N        | 2        | Cancel Type                 | 1                                                                |
| `merchantToken`<br /><font color="#2166ae">Required</font>       | AN       | 255      | Merchant Token              | 66141d60572e570045c4f3e9965f3452d511496841981e8a2af6a24a7038a119 |
| `amt`<br /><font color="#2166ae">Required</font>                 | N        | 12       | Payment Amount              | 10000                                                            |
| `cancelMsg`                                                       | AN       | 255      | Cancel Message&#xD;         | Request Cancel&#xD;                                              |
| `preauthToken`                                                    | AN       | 100      | Pre-Auth Token&#xD;         |                                                                  |
| `referenceNo`<br /><font color="#2166ae">(Optional For CC)</font> | ANS      | 40       | Merchant Cancel Number&#xD; | CancelNo20160525000-52104&#xD;                                   |
| `cancelServerIp`                                                  | AN       | 15       | Server IP&#xD;              | 127.0.0.1                                                        |
| `cancelUserId`                                                    | AN       | 30       | User ID&#xD;                | admin                                                            |
| `cancelUserIp`                                                    | AN       | 15       | User IP&#xD;                | 127.0.0.1&#xD;                                                   |
| `cancelUserInfo`                                                  | AN       | 100      | User Information&#xD;       | Test Cancel&#xD;                                                 |
| `cancelRetryCnt`	&#xD;                                            | N        | 2        | Retry Count&#xD;            | 3                                                                |
| `worker`                                                          | AN       | 10       | Worker                      |                                                                  |



## Response Parameter for GPN Cancel

***

Following are the response parameters from the results of the request parameters for integration of the GPN to cancel.

| **Parameter**                                                           | **Type** | **Size** | **Description**                                                                                                              | **Example / Notes**                 |
| ----------------------------------------------------------------------- | -------- | -------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------------------------------- |
| `resultCd`                                                              | N        | 4        | [Result Code](docId:9eC3yH9CQqpb6cRWauWWO) [&#xD;](https://app.archbee.com/docs/36sM2OxRIwwbi9iNlqMTP/wpcEMaZro_Xvnxz-1ZAiB) | 0000                                |
| `resultMsg`                                                             | AN       | 255      | Result Message: [Error Code](docId\:FsX1GESJKxOp0T9rvUHp_)&#xD;                                                              | SUCCESS                             |
| `tXid`                                                                  | AN       | 30       | Transaction ID&#xD;                                                                                                          | IONPAYTEST01202103311759347262&#xD; |
| `referenceNo`                                                           | ANS      | 40       | Merchant Order Number&#xD;                                                                                                   | ord20210331170394&#xD;              |
| `transDt`                                                               | N        | 8        | Transaction Date&#xD;                                                                                                        | 20210331                            |
| `transTm`                                                               | N        | 6        | Transaction Time                                                                                                             | 175934&#xD;                         |
| `amt`                                                                   | N        | 12       | Amount                                                                                                                       | 10000                               |
| `cancelReferenceNo`<br /><font color="#2166ae">(Optional For CC)</font> | AN       | 40       | Merchant Cancel Number &#xD;                                                                                                 | CancelNo20160525000-52104&#xD;      |



## Sample JSON for GPN Cancel

***

:::CodeblockTabs
JSON Request

```json
{
    "timeStamp":"20180123100505",
    "tXid":"IONPAYTEST01202103311759347262",
    "iMid":"IONPAYTEST",
    "payMethod":"09",
    "cancelType":"1",
    "cancelMsg":"Request Cancel",
    "merchantToken":"66141d60572e570045c4f3e9965f3452d511496841981e8a2af6a24a7038a119",
    "preauthToken":"",
    "amt":"10000",
    "cancelServerIp":"127.0.0.1",
    "cancelUserId":"admin",
    "cancelUserIp":"127.0.0.1",
    "cancelUserInfo":"Test Cancel",
    "cancelRetryCnt":"3",
    "referenceNo": "CancelNo20160525000-52104",
    "worker":""
}
```

JSON Response

```json
{
    "tXid": "IONPAYTEST01202103311759347262",
    "referenceNo": "ord20210331170394",
    "resultCd": "0000",
    "resultMsg": "SUCCESS",
    "transDt": "20210331",
    "transTm": "175934",
    "amt": "10000",
    "cancelReferenceNo": "CancelNo20160525000-52104"
}
```

Java Request

```json
//Cancel Registration//
nicePay.setTimeStamp("20221114114338");
nicePay.setiMid("IONPAYTEST");
nicePay.setAmt("10000");
nicePay.setReferenceNo("ordNo20221202141217");
nicePay.setMerchantToken(nicePay.makeToken(nicePay.getMerchantToken());
nicePay.settXid("IONPAYTEST01202103311759347262");
nicePay.setPayMethod("09");
nicePay.setCancelType("1");
nicePay.setCancelMsg("Request Cancel");
nicePay.setCancelServerIp("127.0.0.1");


// Request Cancel
nicePay.cancel();

// Response String //
System.out.println("Final Response String : " + nicePay.getResponseString());

String resultCd = nicePay.Get("resultCd");
String resultMsg = nicePay.Get("resultMsg");
String tXid = nicePay.Get("tXid");
String referenceNo = nicePay.Get("referenceNo");
String amt = nicePay.Get("amt");
String cancelReferenceNo = nicePay.Get("cancelReferenceNo");
```
:::

