---
title: Cancel - API Virtual Account SNAP
slug: en/nicepay-api-snap-cancel-virtual-account
description: Information about Cancel - API Virtual Account SNAP available on the NICEPAY system
image: https://archbee-image-uploads.s3.amazonaws.com/ZHvSjR5ZrsoxwKbJa3xmo/jTjkiAJF_J4G6gaOHjVd__rdrx9d8diazpgm07xfz2test.png
icon: {"faIcon":"fa-solid fa-book"}
docTags: 
createdAt: 2023-11-20T10:07:04.974Z
---

# About Cancel - API Virtual Account SNAP

***

This API with SNAP standards uses to request transaction cancellation process on Virtual Account payment method.



# Merchant Cancel - API Virtual Account SNAP

***

:::hint{type="warning"}
Please request the access token firsthand before doing the authentication through the [Request Access Token API - SNAP](docId:92feymrQs_iebHXrfgXUq) section.
:::

| **Service Code** | `31`                                                |
| ---------------- | --------------------------------------------------- |
| **API Endpoint** | `/api/v1.0/transfer-va/delete-va`                   |
| **HTTP Method**  | **DELETE**                                          |
| **Description**  | To request VA transaction cancellation process&#xD; |
| **Content-Type** | `application/json`                                  |



## Request Header Parameter for Cancel - API Virtual Account SNAP

| **Parameter**   | **Type** | **Length** | **Required** | **Description**                                                                                                                                                                   | **Example**  |
| --------------- | -------- | ---------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ |
| `Content-Type`  | String   |            | Mandatory    | `Application / JSON`                                                                                                                                                              |              |
| `Authorization` | String   |            | Mandatory    | Bearer “`access_token`”                                                                                                                                                           |              |
| `X-TIMESTAMP`   | String   |            | Mandatory    | Using ISO 8601 as timestamp format.<br />Transaction date time, in format `YYYYMMDDTHH:mm:ss+07:00`.<br />Time must be in GMT+7 (Jakarta time).<br />`2022-03-21T10:11:40+07:00`. |              |
| `X-SIGNATURE`   | String   |            | Mandatory    | Signature will be generated by Merchant.<br />[Panduan X-Signature - Symmetric](docId\:UZex33ReLyENKOgbJJnYp)                                                                     |              |
| `X-PARTNER-ID`  | String   | 20         | Mandatory    | `X-PARTNER-ID` = `CLIENT_ID`                                                                                                                                                      |              |
| `X-EXTERNAL-ID` | String   | 40         | Mandatory    | Unique Reference Number<br />(`41807553358950093184`)                                                                                                                             |              |
| `CHANNEL-ID`    | String   |            | Mandatory    | Unique Channel Merchant Credential ID Number.<br />Client ID + "01" =  Channel ID <br />`"IONPAYTEST" + "01" = "IONPAYTEST01"`                                                    | IONPAYTEST01 |



## Request Body Parameter for Cancel - API Virtual Account SNAP

| **Parameter**       | **Type**     | **Length** | **Required** | **Description**                                                                                                         |
| ------------------- | ------------ | ---------- | ------------ | ----------------------------------------------------------------------------------------------------------------------- |
| `partnerServiceId`  | String       | 20         | Mandatory    | Partner Service ID / Prefix                                                                                             |
| `customerNo`        | String       | 40         | Mandatory    | Customer Number <br />(Mandatory for Fix type)                                                                          |
| `virtualAccountNo`  | String       | 25         | Mandatory    | Virtual Account Number                                                                                                  |
| `trxId`             | String<br /> | 40         | Mandatory    | Transaction ID<br />(Reference Number from Merchant)                                                                    |
| `additionalInfo`    |  Object      |            |  Mandatory   | `"additionalInfo": {`<br />`     "totalAmount": { `<br />`       ... `<br />`     }, `<br />`     ... `<br />`  }` |
| `totalAmount`       | Object       |            | Mandatory    | `"totalAmount": {`<br />`       ... `<br />`    }`                                                                    |
| `value`             | String       | 12         | Mandatory    | Transaction Amount                                                                                                      |
| `currency`          | String       | 3          | Mandatory    | Currency                                                                                                                |
| `tXidVA`            | String       | 40         | Mandatory    | Transaction ID                                                                                                          |
| `cancelMessage`     | String       | 255        | Mandatory    | Cancel Message                                                                                                          |



## &#x20;Response Parameter for Cancel - API Virtual Account SNAP

| **Parameter**        | **Type**     | **Length** | **Required** | **Description**                                                                                                                       |
| -------------------- | ------------ | ---------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------- |
| `responseCode`       | String       |            | Mandatory    | [General Response Code and Message - API SNAP](docId\:bJr4kjAmZCKnlN-5zRnvW)                                                          |
| `responseMessage`    | String       |            | Mandatory    | [General Response Code and Message - API SNAP](docId\:bJr4kjAmZCKnlN-5zRnvW)                                                          |
| `virtualAccountData` | Object       |            | Mandatory    | `"virtualAccountData": {`<br />`    ... `<br />` }`                                                                                 |
| `partnerServiceId`   | String       | 20         | Mandatory    | Partner Service ID / Prefix                                                                                                           |
| `customerNo`         | String       | 40         | Mandatory    | Customer Number <br />(Mandatory for Fix type)                                                                                        |
| `virtualAccountNo`   | String       | 40         | Mandatory    | Virtual Account Number                                                                                                                |
| `trxId`              | String<br /> | 40         | Mandatory    | Transaction ID<br />(Reference Number from Merchant)                                                                                  |
| `additionalInfo`     | Object       |            | Mandatory    | `"additionalInfo": {`<br />`             ...,  `<br />`"totalAmount": {`<br />`                ... `<br />`            }`<br />`}` |
| `tXidVA`             | String       |     40     | Mandatory    | Transaction ID                                                                                                                        |
| `cancelMessage`      | String       |    200     | Mandatory    | Cancel Message                                                                                                                        |
| `cancelVATime`       | String       |      8     | Mandatory    | Cancel Virtual Account Time                                                                                                           |
| `totalAmount`        | Object       |            |  Mandatory   | `"totalAmount": {`<br />`                ... `<br />`            }`                                                                 |
| `value`              | String       | 12         | Mandatory    | Transaction Amount                                                                                                                    |
| `currency`           | String       | 3          | Mandatory    | Currency                                                                                                                              |



# Sample Parameter for Cancel - API Virtual Account SNAP

***

## Request Parameter

:::CodeblockTabs
cURL

```curl
curl -X DELETE "https://www.nicepay.co.id/nicepay/api/v1.0/transfer-va/delete-va" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJJT05QQVlURVNUIiwiaXNzIjoiTklDRVBBWSIsIm5hbWUiOiJCUklOIiwiZXhwIjoiMjAyNC0wMi0xMVQwODowOTozNVoifQ==.aIybLX36dYwfFvW7dcoenXkOe2EAwIYq84ZtPuIf3K8=" \
-H "X-TIMESTAMP: 2024-12-31T10:11:40+07:00" \
-H "X-SIGNATURE: ufBw7R8RhW79IOiV/Hlv607M60qzAYBv8uZmbSrYb6/Thlo/FhQVP4xRyelUehoSS9o+QS6vWTKb/ygtucC+tQ==" \
-H "X-PARTNER-ID: NORMALTEST" \
-H "X-EXTERNAL-ID: tXid202402111402271707638095" \
-H "CHANNEL-ID: NORMALTEST" \
-d '{
  "partnerServiceId": "99123040",
  "customerNo": "00007307",
  "virtualAccountNo": "9912304000007307",
  "trxId": "2024123000000000000001",
  "additionalInfo": {
    "totalAmount": {
      "value": "10000.00",
      "currency": "IDR"
    },
    "tXidVA": "NORMALTEST02202401181001033629",
    "cancelMessage": "Cancel Virtual Account"
  }
}'

```

Node.js

```nodejs
const config = {
  isProduction: false,
  privateKey: cons.privateKey,
  clientSecret: cons.clientSecret,
  clientId: cons.clientId,
  isCloudServer: false,
};

let parameterDelete = {
  body: {
    partnerServiceId: "99123040",
    customerNo: "00007307",
    virtualAccountNo: "9912304000007307",
    trxId: "2024123000000000000001",
    additionalInfo: {
      totalAmount: {
        value: "10000.00",
        currency: "IDR",
      },
      tXidVA: "NORMALTEST02202401181001033629",
      cancelMessage: "Cancel Virtual Account",
    },
  },
  headers: {
    X_EXTERNAL_ID: "tXid202402111402271707638095",
    CHANNEL_ID: cons.clientId,
  },
};

let endPoint = `/api/v1.0/transfer-va/delete-va`;
let snap = new Snap(config);

let response = snap.requestSnapTransaction(parameterDelete, endPoint, accessToken, "DELETE");

```

```java
config = NICEPay.builder()
        .isProduction(false)
        .clientSecret(CLIENT_SECRET)
        .partnerId(I_MID)
        .externalID("tXid202402111402271707638095")
        .timestamp("2024-12-31T10:11:40+07:00")
        .privateKey(PRIVATE_KEY)
        .build();

var accessToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJJT05QQVlURVNUIiwiaXNzIjoiTklDRVBBWSIsIm5hbWUiOiJCUklOIiwiZXhwIjoiMjAyNC0wMi0xMVQwODowOTozNVoifQ==.aIybLX36dYwfFvW7dcoenXkOe2EAwIYq84ZtPuIf3K8=";

Cancel requestData = Cancel.builder()
        .partnerServiceId("99123040")
        .customerNo("00007307")
        .virtualAccountNo("9912304000007307")
        .totalAmount("10000.00", "IDR")
        .trxId("2024123000000000000001")
        .tXidVA("NORMALTEST02202401181001033629")
        .cancelMessage("Cancel Virtual Account")
        .build();

NICEPayResponse result = SnapCancelService.callServiceVACancel(requestData, accessToken, config);

```

```python
bodyCreateToken = (
    builderAccessToken.BuildAccessToken()
    .setGrantType("client_credentials")
    .setAdditionalInfo("")
    .build()
)

totalAmount = {
    "value": "10000.00",
    "currency": "IDR"
}

additionalInfo = {
    "tXidVA": "NORMALTEST02202401181001033629",
    "totalAmount": totalAmount,
    "cancelMessage": "Cancel Virtual Account"
}

bodyCancelVA = (
    builderVirtualAccount.BuildCancelVA()
    .setPartnerServiceId("99123040")
    .setCustomerNo("00007307")
    .setVirtualAccountNo("9912304000007307")
    .setTrxId("2024123000000000000001")
    .setAdditionalInfo(additionalInfo)
    .build()
)

environment = (
    builderEnvironment.BuildEnvironment()
    .isCloud(False)
    .isProduction(False)
    .build()
)

result = SnapService.serviceTransaction(
    bodyCreateToken.jsonAccessToken(),
    bodyCancelVA.jsonVACancel(),
    ConstantsEndpoints.cancelVA(),
    environment,
    "DELETE"
)

```

C#

```csharp
TestingConstant config = new TestingConstant();
string clientId = config.ClientId;
string privateKey = config.PrivateKey;
string timestamp = "2024-12-31T10:11:40+07:00"; 
string clientSecret = config.ClientSecret;
string channelId = "NORMALTEST"; 
bool isProduction = false;
bool isCloudServer = false;

string signature = SignatureGeneratorUtils.GenerateSignature(privateKey, clientId, timestamp);

// Get access token
var tokenRequester = new AccessTokenRequester();
string accessTokenResponse = await tokenRequester.GetAccessTokenAsync(clientId, signature, timestamp, isProduction, isCloudServer);
dynamic accessTokenObject = JObject.Parse(accessTokenResponse);
string accessToken = accessTokenObject.accessToken;

// Setup Nicepay API service
ApiEndpoints apiEndpoints = new ApiEndpoints();
APIService vaService = new APIService(apiEndpoints, clientSecret, clientId, channelId, isProduction, isCloudServer);

string VA_NO = "9912304000007307";
string trxID = "2024123000000000000001";
string Amount = "10000.00";
string currency = "IDR";
string txidVa = "NORMALTEST02202401181001033629";
string cancelMessage = "Cancel Virtual Account";

var bodyBuilder = new CancelBuilder()
    .SetCancelVASnap(
        partnerServiceId: "99123040",
        virtualAccountNo: VA_NO,
        trxId: trxID,
        amountValue: Amount,
        currency: currency,
        tXidVA: txidVa,
        customerNo: "00007307",
        cancelMessage: cancelMessage
    )
    .Build();

string jsonPayload = Newtonsoft.Json.JsonConvert.SerializeObject(bodyBuilder);
Console.WriteLine("Delete VA Request: " + jsonPayload);

// Process Delete VA (POST request)
string externalId = "tXid202402111402271707638095"; 
string deleteResponse = await vaService.SendDeleteRequest(apiEndpoints.DeleteVA, accessToken, timestamp, bodyBuilder, externalId);

```

Laravel

```php
$url = HttpUtil::getNicepayDomain($this->useProd, $this->useCloud) . "nicepay/" . $this->delete_va_endpoint;
$helper = new Helpers();
$http_method = "DELETE";
$date = Carbon::now();
$x_time_stamp = $date->toIso8601String();
$time_stamp = $date->format("YmdHis");
$partner_id = $this->client_id;
$client_secret = $this->client_secret;
$access_token = $this->access_token;
$external_id = "tXid202402111402271707638095";

$totalAmount = [
    "value" => "10000.00",
    "currency" => "IDR"
];

$additionalInfo = [
    "totalAmount" => $totalAmount,
    "tXidVA" => "NORMALTEST02202401181001033629",
    "cancelMessage" => "Cancel Virtual Account"
];

$body = [
    "partnerServiceId" => "99123040",
    "customerNo" => "00007307",
    "virtualAccountNo" => "9912304000007307",
    "trxId" => "2024123000000000000001",
    "additionalInfo" => $additionalInfo,
];

$string_to_sign = $helper->generateStringToSign(
    $http_method,
    $this->delete_va_endpoint,
    $access_token,
    $body,
    $x_time_stamp
);

$signature = $helper->hmacSHA512Encoded(
    $string_to_sign,
    $client_secret,
    OPENSSL_ALGO_SHA512
);

$header = $helper->generateHeader(
    $access_token,
    $x_time_stamp,
    $signature,
    $partner_id,
    $external_id,
    $partner_id . "02"
);

try {
    $response = HttpUtil::deleteJsonRequestWithHeader($url, $body, $header);
} catch (\Exception $e) {
    echo "Error deleting VA: " . $e->getMessage();
}

```

PHP Native

```php
$config = NICEPay::builder()
    ->setIsProduction(false)
    ->setClientSecret(TestConst::$CLIENT_SECRET_NT)
    ->setPartnerId($this->iMid)
    ->setExternalID("ExtIdCancel" . $this->timestamp)
    ->setTimestamp($this->timestamp)
    ->setPrivateKey(TestConst::$KEY_OLD_FORMAT)
    ->build();

$accessToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJJT05QQVlURVNUIiwiaXNzIjoiTklDRVBBWSIsIm5hbWUiOiJCUklOIiwiZXhwIjoiMjAyNC0wMi0xMVQwODowOTozNVoifQ==.aIybLX36dYwfFvW7dcoenXkOe2EAwIYq84ZtPuIf3K8=";

$vacctNo = "9912304000007307";
$reffNo = "2024123000000000000001";
$txId = "NORMALTEST02202401181001033629";
$amount = "10000.00";

$requestData = Cancel::builder()
    ->setPartnerServiceId("99123040")
    ->setCustomerNo("00007307")
    ->setVirtualAccountNo($vacctNo)
    ->setTotalAmount($amount, "IDR")
    ->setTrxId($reffNo)
    ->settxIdVA($txId)
    ->setCancelMessage("Cancel Virtual Account")
    ->build();

try {
    $snapVAService = new SnapVAService($config);
    $response = $snapVAService->cancel($requestData, $accessToken);
} catch (Exception $e) {
    echo "Error cancelling VA: " . $e->getMessage();
}

```

```kotlin
val config: NICEPay = NICEPay.Builder()
    .isProduction(false)
    .clientSecret(TestingConstants.NORMALTEST_CLIENT_SECRET)
    .partnerId(I_MID_NORMALTEST)
    .externalID("tXid202402111402271707638095")
    .timestamp("2024-12-31T10:11:40+07:00")
    .privateKey(TestingConstants.PRIVATE_KEY)
    .build()

val accessToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJJT05QQVlURVNUIiwiaXNzIjoiTklDRVBBWSIsIm5hbWUiOiJCUklOIiwiZXhwIjoiMjAyNC0wMi0xMVQwODowOTozNVoifQ==.aIybLX36dYwfFvW7dcoenXkOe2EAwIYq84ZtPuIf3K8="

val reqDeleteVA: SnapCancel = SnapCancel.Builder()
    .partnerServiceId("99123040")
    .customerNo("00007307")
    .virtualAccountNo("9912304000007307")
    .cancelMessage("Cancel Virtual Account")
    .totalAmount("10000.00", "IDR")
    .trxId("2024123000000000000001")
    .tXidVA("NORMALTEST02202401181001033629")
    .build()

val snapVirtualAccountService: SnapVirtualAccountService = SnapVirtualAccountServiceImpl()
val response: NICEPayResponse? = snapVirtualAccountService.deleteVA(reqDeleteVA, accessToken, config)

```

CodeIgniter

```php
$timestamp = Helper::getFormattedDate();

$config = NICEPay::builder()
    ->setIsProduction(false)
    ->setIsCloudServer(true)
    ->setPrivateKey($this->oldKeyFormat)
    ->setClientSecret($this->clientSecret)
    ->setPartnerId($this->iMidTest)
    ->setExternalID("tXid202402111402271707638095")
    ->setTimestamp("2024-12-31T10:11:40+07:00")
    ->build();

$deleteVirtualAccountBuilder = DeleteVirtualAccount::builder();
$parameter = $deleteVirtualAccountBuilder
    ->setPartnerServiceId("99123040")
    ->setCustomerNo("00007307")
    ->setVirtualAccountNo("9912304000007307")
    ->setTrxId("2024123000000000000001")
    ->setTotalAmount("10000.00", "IDR")
    ->setTxIdVA("NORMALTEST02202401181001033629")
    ->setCancelMessage("Cancel Virtual Account")
    ->build();

$accessToken = self::getAccessToken($config);
$snapVAService = new SnapVAService();

try {
    $response = $snapVAService->deleteVA($parameter, $accessToken, $config);
} catch (\Exception $e) {
    echo "Error deleting VA: " . $e->getMessage();
}

```
:::

## Response Parameter

:::CodeblockTabs
Sample Response

```json
{
    "responseCode": "2003100",
    "responseMessage": "Success",
    "virtualAccountData": {
        "partnerServiceId": "99123040",
        "customerNo": "00007307",
        "virtualAccountNo": "9912304000007307",
        "trxId": "2024123000000000000001",
        "additionalInfo": {
            "tXidVA": "NORMALTEST02202401181001033629",
            "cancelMessage": "Cancel Virtual Account",
            "cancelVATime": "2024-12-31T10:11:40+07:00",
            "totalAmount": {
                "value": "10000.00",
                "currency": "IDR"
            }
        }
    }
}
```
:::

