---
title: Refund Transaction - API E-Wallet (Direct Debit) SNAP
slug: nicepay-api-snap-refund-transaction-e-wallet-direct-debit
description: Informasi tentang Refund Transaction - API E-Wallet (Direct Debit) SNAP yang terdapat pada sistem NICEPAY
image: https://archbee-image-uploads.s3.amazonaws.com/ZHvSjR5ZrsoxwKbJa3xmo/oPwsfTMjOurlfnQAu-iAL_microsoftteams-image.png
icon: {"faIcon":"fa-solid fa-book"}
docTags: 
createdAt: 2023-02-17T09:49:29.000Z
---

# Tentang Refund Transaction - API E-Wallet (Direct Debit) SNAP

***

API ini digunakan untuk mengajukan proses *refund&#x20;*&#x64;ari transaksi yang dilakukan dengan metode pembayaran E-Wallet dengan Fitur Direct Debit Host to Host yang sesuai standar SNAP.



# Refund Transaction - API E-Wallet (Direct Debit) SNAP

***

:::hint{type="warning"}
Silakan mengajukan akses token terlebih dahulu untuk melakukan autentikasi melalui bagian [Request Access Token API - SNAP](docId\:GcGqBIYXG1Etcd0Ji9cHX).
:::

| **Service Code** | `58`                                                                                |
| ---------------- | ----------------------------------------------------------------------------------- |
| **API Endpoint** | [`/api/v1.0/debit/refund`](https://dev.nicepay.co.id/nicepay/api/v1.0/debit/refund) |
| **HTTP Method**  | **POST**                                                                            |
| **Description**  | Request refund transaction for authentication &#xD;                                 |
| **Content-type** | `application/json`                                                                  |



## Request Header Parameter for Refund Transaction - API E-Wallet (Direct Debit) SNAP

***

| **Parameter**   | **Tipe** | **Ukuran** | **Kebutuhan** | **Deskripsi**                                                                                                                                                                     | **Contoh**   |
| --------------- | -------- | ---------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ |
| `Content-Type`  | String   | 127        | Mandatory     | `Application/Json`                                                                                                                                                                |              |
| `Authorization` | String   | Variable   | Mandatory     | Bearer “`accessToken`”                                                                                                                                                            |              |
| `X-TIMESTAMP`   | String   | 25         | 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   | Variable   | 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   | 20         | Mandatory     | Unique Channel Merchant Credential ID Number.<br />Client ID + "01" =  Channel ID <br />`"IONPAYTEST" + "01" = "IONPAYTEST01"`                                                    | IONPAYTEST01 |



## Request Body Parameter for Refund Transaction - API E-Wallet (Direct Debit) SNAP

***

| **Parameter**                | **Tipe**             | **Ukuran** | **Kebutuhan** | **Deskripsi**                                                                                                                      |
| ---------------------------- | -------------------- | ---------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `merchantId`                 | String               | 10         | Mandatory     | Merchant identifier that is unique per each Merchant                                                                               |
| `subMerchantId`              | String               | 32         | Optional      | Sub Merchant ID                                                                                                                    |
| `originalReferenceNo`        | String               | 40         | Mandatory     | Original transaction identifier on service provider system                                                                         |
| `originalPartnerReferenceNo` | String               | 40         | Mandatory     | Original transaction identifier on consumer system                                                                                 |
| `partnerRefundNo`            | String               | 40         | Mandatory     | Reference number from Merchant for the refund                                                                                      |
| `refundAmount`               | Array of JSON Object | Variable   | Mandatory     | Amount of refund<br />`"refundAmount": {`<br />`         "value": "10000.00", `<br />`         "currency": "IDR" `<br />`    }` |
| `value`                      | String               | 12         | Mandatory     | Value                                                                                                                              |
| `currency`                   | String               | 3          | Mandatory     | Currency                                                                                                                           |
| `externalStoreId`            | String               | 32         | Optional      | Unique identifier of Shop ID in Client system                                                                                      |
| `reason`                     | String               | 256        | Optional      | Refund reason                                                                                                                      |
| `additionalInfo`             | JSON Object          | Variable   | Optional      | Additional information<br />`"additionalInfo": {`<br />`         "refundType": "1" `<br />`    }`                                |
| `refundType`                 | String               | 2          | Mandatory     | Refund Type:<br />`1`: Full Refund<br />`2`: Partial Refund                                                                        |



## Response Parameter for Refund Transaction - API E-Wallet (Direct Debit) SNAP

***

| **Parameter**                | **Tipe**             | **Ukuran** | **Kebutuhan** | **Deskripsi**                                                                                                                      |
| ---------------------------- | -------------------- | ---------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `responseCode`               | String               | 7          | Mandatory     | Refer to [General Response Code and Message - API SNAP](docId\:lKqJXSl5CMKdXYXxHYYSs) list                                         |
| `responseMessage`            | String               | 150        | Mandatory     | Refer to [General Response Code and Message - API SNAP](docId\:lKqJXSl5CMKdXYXxHYYSs) list                                         |
| `originalReferenceNo`        | String               | 40         | Mandatory     | Original transaction identifier on service provider system                                                                         |
| `originalPartnerReferenceNo` | String               | 40         | Mandatory     | Original transaction identifier on service provider system<br />Must be filled upon successful transaction                         |
| `refundNo`                   | String               | 40         | Mandatory     | Refund number identifier on service provider system reference Number                                                               |
| `partnerRefundNo`            | String               | 40         | Mandatory     | Reference number from Merchant for the refund                                                                                      |
| `refundAmount`               | Array of JSON Object | Variable   | Mandatory     | Amount of refund<br />`"refundAmount": {`<br />`         "value": "10000.00", `<br />`         "currency": "IDR" `<br />`    }` |
| `value`                      | String               | 12         | Mandatory     | Value                                                                                                                              |
| `currency`                   | String               | 3          | Mandatory     | Currency                                                                                                                           |
| `refundTime`                 | String               | 25         | Mandatory     | Refund time ISO-8601, in format `YYYYMMDDTHH:mm:ss+07:00`<br />Time must be in GMT+7 (Jakarta time)                                |
| `additionalInfo`             | JSON Object          | Variable   | Optional      | Additional Information<br />`"additionalInfo": {`<br />`         "refundType": "1" `<br />`    }`                                |
| `refundType`                 | String               | 2          | Mandatory     | Refund Type:<br />`1`: Full Refund<br />`2`: Partial Refund                                                                        |



## Sample Parameter for Refund Transaction API E-Wallet (Direct Debit) SNAP

***

### Request Parameter

:::CodeblockTabs
cURL

```curl
curl -X POST \
  'https://dev.nicepay.co.id/nicepay/api/v1.0/debit/refund' \
  -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: TNICEEW051' \
  -H 'X-EXTERNAL-ID: tXid202402111402271707638101' \
  -H 'CHANNEL-ID: TNICEEW05101' \
  -d '{"merchantId":"00007100010926","subMerchantId":"310928924949487","originalPartnerReferenceNo":"2020102900000000000001","originalReferenceNo":"TNICEEW05105202210141451109841","partnerRefundNo":"239850918204981205970","refundAmount":{"value":"10000.00","currency":"IDR"},"externalStoreId":"124928924949487","reason":"Customer complain","additionalInfo":{"refundType":"1"}}'
```

Node.js

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

let parameterRefund = {
  body: {
    merchantId: "00007100010926",
    subMerchantId: "310928924949487",
    originalPartnerReferenceNo: "2020102900000000000001",
    originalReferenceNo: "TNICEEW05105202210141451109841",
    partnerRefundNo: "239850918204981205970",
    refundAmount: {
      value: "10000.00",
      currency: "IDR",
    },
    externalStoreId: "124928924949487",
    reason: "Customer complain",
    additionalInfo: {
      refundType: "1",
    },
  },
  headers: {
    X_TIMESTAMP: "2024-12-31T10:11:40+07:00",
    X_PARTNER_ID: "TNICEEW051",
    X_EXTERNAL_ID: "tXid202402111402271707638101",
    CHANNEL_ID: "TNICEEW05101",
  },
};

let endPoint = `/api/v1.0/debit/refund`; // Refund endpoint
let snap = new Snap(config);

let response = snap
  .requestSnapTransaction(
    parameterRefund, 
    endPoint, 
    "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJJT05QQVlURVNUIiwiaXNzIjoiTklDRVBBWSIsIm5hbWUiOiJCUklOIiwiZXhwIjoiMjAyNC0wMi0xMVQwODowOTozNVoifQ==.aIybLX36dYwfFvW7dcoenXkOe2EAwIYq84ZtPuIf3K8=", // ACCESS_TOKEN
    "POST" 
  );
```

```java
String accessToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJJT05QQVlURVNUIiwiaXNzIjoiTklDRVBBWSIsIm5hbWUiOiJCUklOIiwiZXhwIjoiMjAyNC0wMi0xMVQwODowOTozNVoifQ==.aIybLX36dYwfFvW7dcoenXkOe2EAwIYq84ZtPuIf3K8=";

// Step 1: Initialize the NICEPay Configuration
config = NICEPay.builder()
    .isProduction(false)
    .clientSecret("YOUR_CLIENT_SECRET")
    .partnerId("TNICEEW051")
    .externalID("tXid202402111402271707638101")
    .timestamp("2024-12-31T10:11:40+07:00")
    .privateKey("YOUR_PRIVATE_KEY")
    .build();

// Step 2: Define the Debit Refund Request Body
Cancel requestData = Cancel.builder()
    .merchantId("00007100010926")
    .subMerchantId("310928924949487")
    .originalPartnerReferenceNo("2020102900000000000001")
    .originalReferenceNo("TNICEEW05105202210141451109841")
    .partnerRefundNo("239850918204981205970")
    .refundAmount("10000.00", "IDR")
    .externalStoreId("124928924949487")
    .reason("Customer complain")
    .refundType("1")
    .build();

// Step 3: Execute the Refund 
NICEPayResponse Result =
    SnapCancelService.callServiceEwalletCancel(requestData, accessToken, config);
```

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

bodyDirectDebitRefund = (
    builderDirectDebit.BuildDirectDebitRefund()
    .setPartnerRefundNo("239850918204981205970")
    .setMerchantId("TNICEEW051")
    .setSubMerchantId("310928924949487")
    .setOriginalPartnerReferenceNo("2020102900000000000001")
    .setOriginalReferenceNo("TNICEEW05105202210141451109841")
    .setExternalStoreId("124928924949487")
    .setReason("Customer complain")
    .setRefundAmount({
        "value": "10000.00",
        "currency": "IDR"
    })
    .setAdditionalInfo({
        "refundType": "1"
    })
    .build()
)

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

result = SnapService.serviceTransaction(bodyCreateToken.jsonAccessToken(),
                                        bodyDirectDebitRefund.jsonDirectDebitRefund(),
                                        ConstantsEndpoints.refundDirectDebit(),
                                        environment)
```

C#

```csharp
TestingConstant config = new TestingConstant();
string privateKey = config.PrivateKey;
string clientSecret = config.ClientSecret;

// Variables used multiple times for configuration/header generation
const string CLIENT_ID = "TNICEEW051";
const string CHANNEL_ID = "TNICEEW05101";
const string X_TIMESTAMP = "2024-12-31T10:11:40+07:00";
const string ACCESS_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJJT05QQVlURVNUIiwiaXNzIjoiTklDRVBBWSIsIm5hbWUiOiJCUklOIiwiZXhwIjoiMjAyNC0wMi0xMVQwODowOTozNVoifQ==.aIybLX36dYwfFvW7dcoenXkOe2EAwIYq84ZtPuIf3K8=";


string clientId = CLIENT_ID;
string timestamp = X_TIMESTAMP;
string channelId = CHANNEL_ID;
bool isProduction = false;
bool isCloudServer = false;

if (string.IsNullOrEmpty(clientId) || string.IsNullOrEmpty(clientSecret))
{
    Console.WriteLine("clientId or clientSecret cannot be empty.");
    Assert.Fail("clientId or clientSecret cannot be empty.");
    return;
}
// Generate signature
string signature = SignatureGeneratorUtils.GenerateSignature(privateKey, clientId, timestamp);

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

// Create Ewallet service
ApiEndpoints apiEndpoints = new ApiEndpoints();
APIService ewalletService = new APIService(apiEndpoints, clientSecret, clientId, channelId, isProduction, isCloudServer);
SnapEwalletServices snapEwalletServices = new SnapEwalletServices(clientId);
 
string createRequestBody = snapEwalletServices.GenerateRefundEwalletRequest(
    merchantId: "00007100010926",
    subMerchantId: "310928924949487",
    originalPartnerReferenceNo: "2020102900000000000001",
    originalReferenceNo: "TNICEEW05105202210141451109841",
    partnerRefundNo: "239850918204981205970",
    externalStoreId: "124928924949487",
    refundAmountValue: "10000.00",
    currency: "IDR",
    reason : "Customer complain",
    refundType : "1"
);
Console.WriteLine("Refund Ewallet Request: " + createRequestBody);

string createResponse = await ewalletService.SendPostRequest(
    apiEndpoints.RefundEwallet, 
    accessToken, 
    timestamp, 
    createRequestBody, 
    "tXid202402111402271707638101" 
);

Console.WriteLine("Refund Ewallet Response: " + createResponse);
```

Laravel

```php
string ACCESS_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJJT05QQVlURVNUIiwiaXNzIjoiTklDRVBBWSIsIm5hbWUiOiJCUklOIiwiZXhwIjoiMjAyNC0wMi0xMVQwODowOTozNVoifQ==.aIybLX36dYwfFvW7dcoenXkOe2EAwIYq84ZtPuIf3K8=";
string X_TIMESTAMP = "2024-12-31T10:11:40+07:00";
string X_EXTERNAL_ID = "tXid202402111402271707638101";
string CHANNEL_ID = "TNICEEW05101";

protected $useProd = false;
protected $useCloud = false;
protected $refund_ewallet_endpoint = "/api/v1.0/debit/refund";

// Credential
protected $client_id = "TNICEEW051"; 
PROTECTED $key = "_PRIVATE_KEY_MERCHANT";
PROTECTED $client_secret = "_CLIENT_SECRET_MERCHANT";
PROTECTED $access_token = ACCESS_TOKEN;
PROTECTED $store_id = "124928924949487";

$url = HttpUtil::getNicepayDomain($this->useProd, $this->useCloud) . $this->refund_ewallet_endpoint;
$helper = new Helpers();

$http_method = "POST";
$x_time_stamp = X_TIMESTAMP;
$partner_id = $this->client_id;
$client_secret = $this->client_secret;
$access_token = $this->access_token;
$store_id = $this->store_id;

$external_id = X_EXTERNAL_ID;
$partner_refund_no = "239850918204981205970"; 

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

$additionalInfo = [
    "refundType" => "1"
];

$body = [
    "merchantId" => "00007100010926",
    "subMerchantId" => "310928924949487",
    "originalReferenceNo" => "TNICEEW05105202210141451109841",
    "originalPartnerReferenceNo" => "2020102900000000000001",
    "partnerRefundNo" => $partner_refund_no,
    "refundAmount" => $refundAmount,
    "externalStoreId" => $store_id,
    "reason" => "Customer complain",
    "additionalInfo" => $additionalInfo
];

$string_to_sign = $helper->generateStringToSign(
    $http_method,
    $this->refund_ewallet_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,
    CHANNEL_ID
);

try {
    $response = HttpUtil::postJsonRequestWithHeader($url, $body, $header);
} catch (Exception $e) {
    // Handle exception
}
```

PHP Native

```php
$config = NICEPay::builder()
    ->setIsProduction(false)
    ->setClientSecret(TestConst::$CLIENT_SECRET)
    ->setPartnerId("TNICEEW051")
    ->setExternalID("tXid202402111402271707638101")
    ->setTimestamp("2024-12-31T10:11:40+07:00")
    ->setPrivateKey(TestConst::$PRIVATE_KEY)
    ->build();

$requestBody = Cancel::builder()
    ->setMerchantId("00007100010926")
    ->setSubMerchantId("310928924949487")
    ->setOriginalPartnerReferenceNo("2020102900000000000001")
    ->setOriginalReferenceNo("TNICEEW05105202210141451109841")
    ->setPartnerRefundNo("239850918204981205970")
    ->setRefundAmount("10000.00", "IDR")
    ->setExternalStoreId("124928924949487")
    ->setReason("Customer complain")
    ->setRefundType("1")
    ->build();

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

$snapEwalletService = new SnapEwalletService($config);

try {
    $response = $snapEwalletService->refund($requestBody, $accessToken);
} catch (\Exception $e) {
    // Handle exception
}
```

```kotlin
const val ACCESS_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJJT05QQVlURVNUIiwiaXNzIjoiTklDRVBBWSIsIm5hbWUiOiJCUklOIiwiZXhwIjoiMjAyNC0wMi0xMVQwODowOTozNVoifQ==.aIybLX36dYwfFvW7dcoenXkOe2EAwIYq84ZtPuIf3K8="

// Step 1: Initialize the NICEPay Configuration
var config: NICEPay = NICEPay.Builder()
    .isProduction(false)
    .clientSecret("YOUR_CLIENT_SECRET")
    .partnerId("TNICEEW051")
    .externalID("tXid202402111402271707638101")
    .timestamp("2024-12-31T10:11:40+07:00")
    .privateKey("YOUR_PRIVATE_KEY")
    .build()

// Step 2: Define the Static Debit Refund Request Body
val refundEwallet: SnapCancel = SnapCancel.Builder()
    .merchantId("00007100010926")
    .subMerchantId("310928924949487")
    .originalPartnerReferenceNo("2020102900000000000001")
    .originalReferenceNo("TNICEEW05105202210141451109841")
    .partnerRefundNo("239850918204981205970")
    .externalStoreId("124928924949487")
    .refundAmount("10000.00", "IDR")
    .refundType("1")
    .reason("Customer complain")
    .build()

// Step 3: Execute the Refund
val response: NICEPayResponse? = snapEwalletService.refund(refundEwallet, ACCESS_TOKEN, config)
```

CodeIgniter

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

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

$requestBody = RefundEwallet::builder()
    ->setMerchantId("00007100010926")
    ->setSubMerchantId("310928924949487")
    ->setOriginalPartnerReferenceNo("2020102900000000000001")
    ->setOriginalReferenceNO("TNICEEW05105202210141451109841")
    ->setPartnerRefundNo("239850918204981205970")
    ->setRefundAmount("10000.00", "IDR")
    ->setExternalStoreId("124928924949487")
    ->setReason("Customer complain")
    ->setAdditionalInfo(["refundType" => "1"])
    ->build();

$snapEwalletService = new SnapEwalletService();

try {
    $response = $snapEwalletService->refundEwallet($requestBody, $accessToken, $config);
} catch (\Exception $e) {
    // Handle exception
}
```
:::

### Response Parameter

:::CodeblockTabs
Sample Response

```json
{
    "responseCode": "2005800",
    "responseMessage": "Successful",
    "originalPartnerReferenceNo": "2020102900000000000001",
    "originalReferenceNo": "TNICEEW05105202210141451109841",
    "refundNo": "REF993883",
    "partnerRefundNo": "239850918204981205970",
    "refundAmount": {
        "value": "10000.00",
        "currency": "IDR"
    },
    "refundTime": "2020-12-21T17:21:41+07:00",
    "additionalInfo": {
        "refundType": "1"
    }
}
```
:::

