---
title: Registration - API E-Wallet (Direct Debit) SNAP
slug: nicepay-api-snap-registration-e-wallet-direct-debit
description: Informasi tentang Registration - API E-Wallet (Direct Debit) SNAP yang terdapat pada sistem NICEPAY
image: https://archbee-image-uploads.s3.amazonaws.com/ZHvSjR5ZrsoxwKbJa3xmo/2E6o0S-kzj7bIJIb8ADLC_microsoftteams-image-12.png
icon: {"faIcon":"fa-solid fa-book"}
docTags: 
createdAt: 2023-02-17T09:48:06.000Z
---

# Tentang Registration - API E-Wallet (Direct Debit) SNAP

***

API ini digunakan untuk mengajukan pendaftaran transaksi melakukan pembayaran menggunakan metode pembayaran E-Wallet dengan Fitur Direct Debit Host to Host yang sesuai standar SNAP.

&#x20;

# Registration - 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** | `54`                                                                                                                    |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------- |
| **API Endpoint** | [`/nicepay/api/v1.0/debit/payment-host-to-host`](https://dev.nicepay.co.id/nicepay/api/v1.0/debit/payment-host-to-host) |
| **HTTP Method**  | `POST`                                                                                                                  |
| **Description**  | Request Direct Debit transaction for authentication payment                                                             |
| **Content-type** | `application/json`                                                                                                      |



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

***

| **Parameter**   | **Tipe** | **Ukuran** | **Kebutuhan** | **Deskripsi**                                                                                                                                                                     | **Contoh**   |
| --------------- | -------- | ---------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ |
| `Content-Type`  | String   | 127        | Mandatory     | Content type, value always `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     | Unique Partner ID, Partner ID = Client ID                                                                                                                                         |              |
| `X-EXTERNAL-ID` | String   | 40         | Mandatory     | Unique messaging Reference ID generated by Merchant. Numeric String. Reference number that should be unique in every transaction.                                                 |              |
| `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 Registration - API E-Wallet (Direct Debit) SNAP

***

| **Parameter**        | **Tipe**             | **Kebutuhan** | **Ukuran** | **Deskripsi atau Contoh**                                                                                                                                                  |
| -------------------- | -------------------- | ------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `partnerReferenceNo` | String               | Mandatory     | 40         | Transaction ID from Merchant                                                                                                                                               |
| `merchantId`         | String               | Mandatory     | 10         | Merchant Identifier that is unique per each Merchant                                                                                                                       |
| `subMerchantId`      | String               | Optional      | 32         | Sub-Merchant Identifier                                                                                                                                                    |
| `externalStoreId`    | String               | Optional      | 32         | Unique Identifier of Shop ID in Client system                                                                                                                              |
| `amount`             | Array of JSON Object | Mandatory     | Variable   | Amount Information                                                                                                                                                         |
| `value`              | String               | Mandatory     | 12         | Transaction amount, including thecents                                                                                                                                     |
| `currency`           | String               | Mandatory     | 3          | Currency code based on ISO                                                                                                                                                 |
| `urlParams`          | Array of JSON Object | Mandatory     | Variable   | Notify URL that Merchant must send the payment<br />notification.<br /><br />`"urlParams":[`<br />`    {...}, {...} `<br />` ]`                                          |
| `url`                | String               | Mandatory     | 512        | Indicates the URL of the Client’s app to redirect back to once payment has been completed in Merchant.<br /><br />Merchant accepts HTTP links and URL scheme<br />formats. |
| `type`               | String               | Mandatory     | 32         | Indicates the type of the sent URL. Only accepts<br />‘`PAY_RETURN`” and ‘`PAY_NOTIFY`” value.                                                                             |
| `isDeeplink`         | String               | Mandatory     | 1          | Indicates whether the URL is a deep link or not, only<br />accepts ‘Y’ value                                                                                               |
| `validUpTo`          | String               | Optional      | 25         | The time when the payment will be automatic only expired. ISO 8601, in `YYYY-MMDDTHH` format.<br />`mm:ss+07:00`. Time must be in GMT+7 (Jakarta time).                    |
| `pointOfInitiation`  | String               | Optional      | 20         | Used for getting more info regarding source of<br />request of the ser                                                                                                     |
| `additionalInfo`     | Array of JSON Object | Optional      | Variable   | Additional information<br />`"additionalInfo":{...}`                                                                                                                       |
| `mitraCd`            | String               | Mandatory     | 4          | [Mitra Code - API SNAP](docId\:mebNfCDEq1GFUs9oE_MOF)<br />Example:<br />ShopeePay: `ESHP`<br />OVO: `OVOE`<br />LinkAja: `LINK`<br />DANA: `DANA`<br />AstraPay: `ASTR`   |
| `goodsNm`            | String               | Mandatory     | 200        | Goods Name                                                                                                                                                                 |
| `billingNm`          | String               | Mandatory     | 100        | Buyer Name                                                                                                                                                                 |
| `billingPhone`       | String               | Mandatory     | 20         | Buyer Phone Number                                                                                                                                                         |
| `billingEmail`       | String               | Optional      | 40         | Buyer E-mail                                                                                                                                                               |
| `callBackUrl`        | String               | Mandatory     | 500        | Payment result forward URL (on browser)                                                                                                                                    |
| `dbProcessUrl`       | String               | Mandatory     | 500        | Payment Notification URL (Async Notification)                                                                                                                              |
| `cartData`           | String               | Mandatory     | 4000       | `{Format_``JSON_String}`<br /><br />`{`<br />`  "count": "2",`<br />`  "item": [`<br />`    {...},`<br />`    {...}`<br />`  ]`<br />`}`                                   |
| `msId`               | String               | Optional      | 20         | Merchant Seller ID                                                                                                                                                         |
| `msFee`              | String               | Optional      | 7          | Merchant Seller Fee                                                                                                                                                        |
| `msFeeType`          | String               | Optional      | 2          | Merchant Seller Fee Type                                                                                                                                                   |
| `mbFee`              | String               | Optional      | 7          | Merchant Balance Fee                                                                                                                                                       |
| `mbFeeType`          | String               | Optional      | 2          | Merchant Balance Fee Type                                                                                                                                                  |



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

***

| **Parameter**          | **Tipe** | **Kebutuhan** | **Ukuran** | **Deskripsi atau Contoh**                                                                                                                   |
| ---------------------- | -------- | ------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `responseCode`         | String   | Mandatory     | 7          | Refer to [General Response Code and Message - API SNAP](docId\:lKqJXSl5CMKdXYXxHYYSs) list                                                  |
| `responseMessage`      | String   | Mandatory     | 150        | Refer to [General Response Code and Message - API SNAP](docId\:lKqJXSl5CMKdXYXxHYYSs) list                                                  |
| `partnerReferenceNo`   | String   | Mandatory     | 40         | Merchant transaction identifier                                                                                                             |
| `referenceNo`          | String   | Mandatory     | 40         | Original transaction identifier on service<br />provider system                                                                             |
| `appRedirectUrl`<br /> | String   | Optional      | 2048       | Returns an URL scheme to payment page<br />in native app<br /><font color="#eb144c">**For ShopeePay, this value will be deprecated**</font> |
| `webRedirectUrl`       | String   | Optional      | 2048       | Partner checkout URL                                                                                                                        |
| `additionalInfo`       | String   | Optional      | Variable   | Additional information<br />`"additionalInfo": {...}`                                                                                      |
| `redirectToken`        | String   | Optional      | 255        | Partner checkout token                                                                                                                      |



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

***

### Request Parameter

:::CodeblockTabs
cURL

```curl
curl -X POST \
  'https://dev.nicepay.co.id/nicepay/api/v1.0/debit/payment-host-to-host' \
  -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: tXid202402111402271707638099' \
  -H 'CHANNEL-ID: TNICEEW051' \
  -d '{"partnerReferenceNo":"2020102900000000000001","merchantId":"TNICEEW05","subMerchantId":"310928924949487","amount":{"value":"12345678.00","currency":"IDR"},"urlParams":[{"url":"https://test1.bi.go.id/v1/test","type":"PAY_NOTIFY","isDeeplink":"Y"},{"url":"https://test2.bi.go.id/v1/test","type":"PAY_RETURN","isDeeplink":"Y"}],"externalStoreId":"239840198240795109","validUpTo":"2020-12-23T07:44:11+07:00","pointOfInitiation":"Mobile App","additionalInfo":{"mitraCd":"DANA","goodsNm":"Merchant Goods 1","billingNm":"Buyer Name","billingPhone":"02112345678","billingEmail":"jhondoe@gmail.com","callBackUrl":"http://www.merchant.com/callback","dbProcessUrl":"http://www.merchant.com/notification","cartData":"{\"count\":\"2\",\"item\":[{\"img_url\":\"http://img.aaa.com/ima1.jpg\",\"goods_name\":\"Item 1 Name\",\"goods_detail\":\"Item 1 Detail\",\"goods_amt\":\"0.00\",\"goods_quantity\":\"1\"},{\"img_url\":\"http://img.aaa.com/ima2.jpg\",\"goods_name\":\"Item 2 Name\",\"goods_detail\":\"Item 2 Detail\",\"goods_amt\":\"12345678.00\",\"goods_quantity\":\"1\"}]}","msId":"","msFee":"","msFeeType":"","mbFee":"","mbFeeType":""}}'
```

Node.js

```nodejs
const PARTNER_ID = "TNICEEW051";
const X_EXTERNAL_ID = "tXid202402111402271707638099";
const X_TIMESTAMP = "2024-12-31T10:11:40+07:00";
const CHANNEL_ID = "TNICEEW051";

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

const ACCESS_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJJT05QQVlURVNUIiwiaXNzIjoiTklDRVBBWSIsIm5hbWUiOiJCUklOIiwiZXhwIjoiMjAyNC0wMi0xMVQwODowOTozNVoifQ==.aIybLX36dYwfFvW7dcoenXkOe2EAwIYq84ZtPuIf3K8=";

const parameter = {
  body: {
    partnerReferenceNo: "2020102900000000000001",
    merchantId: PARTNER_ID,
    subMerchantId: "310928924949487",
    amount: {
      value: "12345678.00",
      currency: "IDR"
    },
    urlParams: [
      {
        url: "https://test1.bi.go.id/v1/test",
        type: "PAY_NOTIFY",
        isDeeplink: "Y"
      },
      {
        url: "https://test2.bi.go.id/v1/test",
        type: "PAY_RETURN",
        isDeeplink: "Y"
      }
    ],
    externalStoreId: "239840198240795109",
    validUpTo: "2020-12-23T07:44:11+07:00",
    pointOfInitiation: "Mobile App",
    additionalInfo: {
      mitraCd: "DANA",
      goodsNm: "Merchant Goods 1",
      billingNm: "Buyer Name",
      billingPhone: "02112345678",
      billingEmail: "jhondoe@gmail.com",
      callBackUrl: "http://www.merchant.com/callback",
      dbProcessUrl: "http://www.merchant.com/notification",
      cartData: "{\"count\":\"2\",\"item\":[{\"img_url\":\"http://img.aaa.com/ima1.jpg\",\"goods_name\":\"Item 1 Name\",\"goods_detail\":\"Item 1 Detail\",\"goods_amt\":\"0.00\",\"goods_quantity\":\"1\"},{\"img_url\":\"http://img.aaa.com/ima2.jpg\",\"goods_name\":\"Item 2 Name\",\"goods_detail\":\"Item 2 Detail\",\"goods_amt\":\"12345678.00\",\"goods_quantity\":\"1\"}]}",
      msId: "",
      msFee: "",
      msFeeType: "",
      mbFee: "",
      mbFeeType: ""
    }
  },
  headers: {
    X_TIMESTAMP: X_TIMESTAMP,
    X_PARTNER_ID: PARTNER_ID,
    X_EXTERNAL_ID: X_EXTERNAL_ID,
    CHANNEL_ID: CHANNEL_ID,
  },
};

let snap = new Snap(config);
let endPoint = `/api/v1.0/debit/payment-host-to-host`; // Updated Endpoint
let response = snap
  .requestSnapTransaction(parameter, endPoint, ACCESS_TOKEN, "POST");
```

```java
final String PARTNER_ID = "TNICEEW051"; // Adjusted from TNICEEW05
final String EXTERNAL_ID = "tXid202402111402271707638099";
final String TIMESTAMP = "2024-12-31T10:11:40+07:00";
final String ACCESS_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJJT05QQVlURVNUIiwiaXNzIjoiTklDRVBBWSIsIm5hbWUiOiJCUklOIiwiZXhwIjoiMjAyNC0wMi0xMVQwODowOTozNVoifQ==.aIybLX36dYwfFvW7dcoenXkOe2EAwIYq84ZtPuIf3K8=";

// Step 1: Configuration (using hardcoded values)
config = NICEPay.builder()
    .isProduction(false)
    .isCloudServer(false)
    .clientSecret("YOUR_CLIENT_SECRET")
    .partnerId(PARTNER_ID)
    .externalID(EXTERNAL_ID)
    .timestamp(TIMESTAMP)
    .privateKey("YOUR_PRIVATE_KEY")
    .build();

// Step 2: Define the Request Body (Ewallet model repurposed for Debit H2H)
Ewallet ewallet = Ewallet.builder()
    .partnerReferenceNo("2020102900000000000001")
    .merchantId(PARTNER_ID)
    .subMerchantId("310928924949487")
    .externalStoreId("239840198240795109")
    .validUpTo("2020-12-23T07:44:11+07:00")
    .pointOfInitiation("Mobile App")
    .amount("12345678.00", "IDR")
    .additionalInfo( new HashMap<String, Object>() {{
        put("mitraCd", "DANA");
        put("goodsNm", "Merchant Goods 1");
        put("billingNm", "Buyer Name");
        put("billingPhone", "02112345678");
        put("billingEmail", "jhondoe@gmail.com");
        put("callBackUrl", "https://test1.bi.go.id/v1/test");
        put("dbProcessUrl", "https://test1.bi.go.id/v1/test");
        put("cartData", "{\"count\":\"2\",\"item\":[{\"img_url\":\"http://img.aaa.com/ima1.jpg\",\"goods_name\":\"Item 1 Name\",\"goods_detail\":\"Item 1 Detail\",\"goods_amt\":\"0.00\",\"goods_quantity\":\"1\"},{\"img_url\":\"http://img.aaa.com/ima2.jpg\",\"goods_name\":\"Item 2 Name\",\"goods_detail\":\"Item 2 Detail\",\"goods_amt\":\"12345678.00\",\"goods_quantity\":\"1\"}]}");
        put("msId", "");
        put("msFee", "");
        put("msFeeType", "");
        put("mbFee", "");
        put("mbFeeType", "");
    }})
    .urlParams(new String[][]{
        {"https://test1.bi.go.id/v1/test", "PAY_NOTIFY", "Y"},
        {"https://test2.bi.go.id/v1/test", "PAY_RETURN", "Y"}
    })
    .build();

// Step 3: Execute the Request (Removed dynamic token fetching)
NICEPayResponse response = SnapEwalletService.callServiceEwalletPayment(ewallet, ACCESS_TOKEN, config);
```

```python

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

amount = {
    "value": "12345678.00",
    "currency": "IDR"
}

urlParams = [
    {
        "url": "https://test1.bi.go.id/v1/test",
        "type": "PAY_NOTIFY",
        "isDeeplink": "Y"
    },
    {
        "url": "https://test2.bi.go.id/v1/test",
        "type": "PAY_RETURN",
        "isDeeplink": "Y"
    }
]

additionalInfo = {
    "mitraCd": "DANA",
    "goodsNm": "Merchant Goods 1",
    "billingNm": "Buyer Name",
    "billingPhone": "02112345678",
    "billingEmail": "jhondoe@gmail.com",
    "callBackUrl": "http://www.merchant.com/callback",
    "dbProcessUrl": "http://www.merchant.com/notification",
    "cartData": '{"count":"2","item":[{"img_url":"http://img.aaa.com/ima1.jpg","goods_name":"Item 1 Name","goods_detail":"Item 1 Detail","goods_amt":"0.00","goods_quantity":"1"},{"img_url":"http://img.aaa.com/ima2.jpg","goods_name":"Item 2 Name","goods_detail":"Item 2 Detail","goods_amt":"12345678.00","goods_quantity":"1"}]}',
    "msId": "",
    "msFee": "",
    "msFeeType": "",
    "mbFee": "",
    "mbFeeType": ""
}

bodyDirectDebit = (
    builderDirectDebit.BuildDirectDebit()
    .setPartnerReferenceNo("2020102900000000000001")
    .setMerchantId("TNICEEW051")
    .setSubMerchantId("310928924949487")
    .setExternalStoreId("239840198240795109")
    .setValidUpTo("2020-12-23T07:44:11+07:00")
    .setPointOfInitiation("Mobile App")
    .setAmount(amount) 
    .setUrlParams(urlParams) 
    .setAdditionalInfo(additionalInfo)
    .build()
)

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

result = SnapService.serviceTransaction(bodyCreateToken.jsonAccessToken(),
                                        bodyDirectDebit.jsonDirectDebit(),
                                        ConstantsEndpoints.directDebit(),
                                        environment)
```

C#

```csharp
// --- C# Host-to-Host Debit Payment Snippet (TNICEEW051) ---

// Hardcoded Access Token
const string ACCESS_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJJT05QQVlURVNUIiwiaXNzIjoiTklDRVBBWSIsIm5hbWUiOiJCUklOIiwiZXhwIjoiMjAyNC0wMi0xMVQwODowOTozNVoifQ==.aIybLX36dYwfFvW7dcoenXkOe2EAwIYq84ZtPuIf3K8=";

// Assuming privateKey, clientId, timestamp, isProduction, isCloudServer are defined/loaded elsewhere.

// Define urlParams in a variable as requested
var urlParams = new List<Dictionary<string, object>>
{
    new Dictionary<string, object>
    {
        { "url", "https://test1.bi.go.id/v1/test" },
        { "type", "PAY_NOTIFY" },
        { "isDeeplink", "Y" }
    },
    new Dictionary<string, object>
    {
        { "url", "https://test2.bi.go.id/v1/test" },
        { "type", "PAY_RETURN" },
        { "isDeeplink", "Y" }
    }
};

string signature = SignatureGeneratorUtils.GenerateSignature(privateKey, "TNICEEW051", "2024-12-31T10:11:40+07:00");

// Create Ewallet service (using updated parameters)
ApiEndpoints apiEndpoints = new ApiEndpoints();
APIService ewalletService = new APIService(apiEndpoints, clientSecret, "TNICEEW051", "TNICEEW051", isProduction, isCloudServer);

var bodyBuilder = new EwalletBuilder()
    .SetEwalletSnap(
        partnerReferenceNo: "2020102900000000000001",
        merchantId: "TNICEEW051",
        externalStoreId: "239840198240795109",
        value: "12345678.00",
        currency: "IDR",
        subMerchantId: "310928924949487",
        validUpTo: "2020-12-23T07:44:11+07:00",
        mitraCd: "DANA",
        goodsNm: "Merchant Goods 1",
        billingNm: "Buyer Name",
        billingPhone: "02112345678",
        urlParams: urlParams, // Used the variable here
        cartData: "{\"count\":\"2\",\"item\":[{\"img_url\":\"http://img.aaa.com/ima1.jpg\",\"goods_name\":\"Item 1 Name\",\"goods_detail\":\"Item 1 Detail\",\"goods_amt\":\"0.00\",\"goods_quantity\":\"1\"},{\"img_url\":\"http://img.aaa.com/ima2.jpg\",\"goods_name\":\"Item 2 Name\",\"goods_detail\":\"Item 2 Detail\",\"goods_amt\":\"12345678.00\",\"goods_quantity\":\"1\"}]}",
        dbProcessUrl: "http://www.merchant.com/notification",
        callBackUrl: "http://www.merchant.com/callback",
        msId: "",
        msFee: "",
        msFeeType: "",
        mbFee: "",
        mbFeeType: "",
        pointOfInitiation: "Mobile App"
    ).Build();

string jsonPayload = JsonConvert.SerializeObject(bodyBuilder);

string createResponse = await ewalletService.SendPostRequest(apiEndpoints.PaymentEwallet, ACCESS_TOKEN, "2024-12-31T10:11:40+07:00", bodyBuilder, "tXid202402111402271707638099");
```

Laravel

```php
protected $useProd = false;
protected $useCloud = false;
protected $payment_host_to_host_endpoint = "/api/v1.0/debit/payment-host-to-host";

protected $client_id = "TNICEEW051";
PROTECTED $key = "_PRIVATE_KEY_MERCHANT";
PROTECTED $client_secret = "_CLIENT_SECRET_MERCHANT";
PROTECTED $access_token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJJT05QQVlURVNUIiwiaXNzIjoiTklDRVBBWSIsIm5hbWUiOiJCUklOIiwiZXhwIjoiMjAyNC0wMi0xMVQwODowOTozNVoifQ==.aIybLX36dYwfFvW7dcoenXkOe2EAwIYq84ZtPuIf3K8=";
PROTECTED $store_id = "239840198240795109";

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

$http_method = "POST";
$x_time_stamp = "2024-12-31T10:11:40+07:00";
$partner_id = "TNICEEW051"; 
$client_secret = $this->client_secret;
$access_token = $this->access_token;
$store_id = $this->store_id;

$external_id = "tXid202402111402271707638099";
$channel_id = "TNICEEW051"; 

$body = [
    "partnerReferenceNo" => "2020102900000000000001",
    "merchantId" => $partner_id,
    "subMerchantId" => "310928924949487",
    "amount" => [
        "value" => "12345678.00",
        "currency" => "IDR"
    ],
    "urlParams" => [
        [
            "url" => "https://test1.bi.go.id/v1/test",
            "type" => "PAY_NOTIFY",
            "isDeeplink" => "Y"
        ],
        [
            "url" => "https://test2.bi.go.id/v1/test",
            "type" => "PAY_RETURN",
            "isDeeplink" => "Y"
        ]
    ],
    "externalStoreId" => $store_id,
    "validUpTo" => "2020-12-23T07:44:11+07:00",
    "pointOfInitiation" => "Mobile App",
    "additionalInfo" => [
        "mitraCd" => "DANA",
        "goodsNm" => "Merchant Goods 1",
        "billingNm" => "Buyer Name",
        "billingPhone" => "02112345678",
        "billingEmail" => "jhondoe@gmail.com",
        "callBackUrl" => "http://www.merchant.com/callback",
        "dbProcessUrl" => "http://www.merchant.com/notification",
        "cartData" => '{"count":"2","item":[{"img_url":"http://img.aaa.com/ima1.jpg","goods_name":"Item 1 Name","goods_detail":"Item 1 Detail","goods_amt":"0.00","goods_quantity":"1"},{"img_url":"http://img.aaa.com/ima2.jpg","goods_name":"Item 2 Name","goods_detail":"Item 2 Detail","goods_amt":"12345678.00","goods_quantity":"1"}]}',
        "msId" => "",
        "msFee" => "",
        "msFeeType" => "",
        "mbFee" => "",
        "mbFeeType" => ""
    ]
];

$string_to_sign = $helper->generateStringToSign(
    $http_method,
    $this->payment_host_to_host_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
$this->configSnap = NICEPay::builder()
    ->setIsProduction(false)
    ->setClientSecret("_YOUR_CLIENT_SECRET_")
    ->setPartnerId("TNICEEW051")
    ->setExternalID("tXid202402111402271707638099")
    ->setTimestamp("2024-12-31T10:11:40+07:00")
    ->setPrivateKey("_YOUR_PRIVATE_KEY_")
    ->build();


$requestBody = Ewallet::builder()
    ->partnerReferenceNo("2020102900000000000001")
    ->merchantId("TNICEEW051")
    ->subMerchantId("310928924949487")
    ->externalStoreId("239840198240795109")
    ->validUpTo("2020-12-23T07:44:11+07:00")
    ->pointOfInitiation("Mobile App")
    ->amount("12345678.00", "IDR")
    ->additionalInfo(
        [
            "mitraCd" => "DANA",
            "goodsNm" => "Merchant Goods 1",
            "billingNm" => "Buyer Name",
            "billingPhone" => "02112345678",
            "billingEmail" => "jhondoe@gmail.com",
            "callBackUrl" => "http://www.merchant.com/callback",
            "dbProcessUrl" => "http://www.merchant.com/notification",
            "cartData" => '{"count":"2","item":[{"img_url":"http://img.aaa.com/ima1.jpg","goods_name":"Item 1 Name","goods_detail":"Item 1 Detail","goods_amt":"0.00","goods_quantity":"1"},{"img_url":"http://img.aaa.com/ima2.jpg","goods_name":"Item 2 Name","goods_detail":"Item 2 Detail","goods_amt":"12345678.00","goods_quantity":"1"}]}',
            "msId" => "",
            "msFee" => "",
            "msFeeType" => "",
            "mbFee" => "",
            "mbFeeType" => ""
        ]
    )
    ->urlParams([
        ["https://test1.bi.go.id/v1/test", "PAY_NOTIFY", "Y"],
        ["https://test2.bi.go.id/v1/test", "PAY_RETURN", "Y"]
    ])
    ->build();

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

$ewalletService = new SnapEwalletService($this->configSnap);

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

```kotlin
// Hardcoded Access Token
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("TNICEEW05")
    .externalID("tXid202402111402271707638099")
    .timestamp("2024-12-31T10:11:40+07:00")
    .privateKey("YOUR_PRIVATE_KEY")
    .build()

// Step 2: Define the Static Request Body
val ewallet = SnapEwallet.Builder()
    .partnerReferenceNo("2020102900000000000001")
    .merchantId("TNICEEW05")
    .subMerchantId("310928924949487")
    .externalStoreId("239840198240795109")
    .validUpTo("2020-12-23T07:44:11+07:00")
    .pointOfInitiation("Mobile App")
    .amount("12345678.00", "IDR")
    .additionalInfo(
        mapOf(
            "mitraCd" to "DANA",
            "goodsNm" to "Merchant Goods 1",
            "billingNm" to "Buyer Name",
            "billingPhone" to "02112345678",
            "billingEmail" to "jhondoe@gmail.com",
            "callBackUrl" to "http://www.merchant.com/callback",
            "dbProcessUrl" to "http://www.merchant.com/notification",
            "cartData" to "{\"count\":\"2\",\"item\":[{\"img_url\":\"http://img.aaa.com/ima1.jpg\",\"goods_name\":\"Item 1 Name\",\"goods_detail\":\"Item 1 Detail\",\"goods_amt\":\"0.00\",\"goods_quantity\":\"1\"},{\"img_url\":\"http://img.aaa.com/ima2.jpg\",\"goods_name\":\"Item 2 Name\",\"goods_detail\":\"Item 2 Detail\",\"goods_amt\":\"12345678.00\",\"goods_quantity\":\"1\"}]}",
            "msId" to "",
            "msFee" to "",
            "msFeeType" to "",
            "mbFee" to "",
            "mbFeeType" to ""
        )
    )
    .urlParams(
        arrayOf(
            arrayOf("https://test1.bi.go.id/v1/test", "PAY_NOTIFY", "Y"),
            arrayOf("https://test2.bi.go.id/v1/test", "PAY_RETURN", "Y")
        )
    )
    .build()

// Step 3: Execute the Request
val response = snapEwalletService.paymentHostToHost(ewallet, ACCESS_TOKEN, config)
```

CodeIgniter

```php
const string ACCESS_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJJT05QQVlURVNUIiwiaXNzIjoiTklDRVBBWSIsIm5hbWUiOiJCUklOIiwiZXhwIjoiMjAyNC0wMi0xMVQwODowOTozNVoifQ==.aIybLX36dYwfFvW7dcoenXkOe2EAwIYq84ZtPuIf3K8=";

$config = NICEPay::builder()
    ->setIsProduction(false)
    ->setIsCloudServer(isCloudServer: true)
    ->setPrivateKey("_YOUR_PRIVATE_KEY_")
    ->setClientSecret("_YOUR_CLIENT_SECRET_")
    ->setPartnerId("TNICEEW051")
    ->setExternalID("tXid202402111402271707638099")
    ->setTimestamp("2024-12-31T10:11:40+07:00")
    ->build();

$urlParams = [
    ["https://test1.bi.go.id/v1/test", "PAY_NOTIFY", "Y"],
    ["https://test2.bi.go.id/v1/test", "PAY_RETURN", "Y"]
];

$requestBody = Ewallet::builder()
    ->setPartnerReferenceNo("2020102900000000000001")
    ->setMerchantId("TNICEEW051")
    ->setSubMerchantId("310928924949487")
    ->setExternalStoreId("239840198240795109")
    ->setValidUpTo("2020-12-23T07:44:11+07:00")
    ->setPointOfInitiation("Mobile App")
    ->setAmount("12345678.00", "IDR")
    ->setAdditionalInfo(
        [
            "mitraCd" => "DANA",
            "goodsNm" => "Merchant Goods 1",
            "billingNm" => "Buyer Name",
            "billingPhone" => "02112345678",
            "billingEmail" => "jhondoe@gmail.com",
            "callBackUrl" => "http://www.merchant.com/callback",
            "dbProcessUrl" => "http://www.merchant.com/notification",
            "cartData" => '{"count":"2","item":[{"img_url":"http://img.aaa.com/ima1.jpg","goods_name":"Item 1 Name","goods_detail":"Item 1 Detail","goods_amt":"0.00","goods_quantity":"1"},{"img_url":"http://img.aaa.com/ima2.jpg","goods_name":"Item 2 Name","goods_detail":"Item 2 Detail","goods_amt":"12345678.00","goods_quantity":"1"}]}',
            "msId" => "",
            "msFee" => "",
            "msFeeType" => "",
            "mbFee" => "",
            "mbFeeType" => ""
        ]
    )
    ->setUrlParams($urlParams)
    ->build();

$snapEwalletService = new SnapEwalletService();

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

### Response Parameter

:::CodeblockTabs
Sample Response

```json
{
  "responseCode": "2005400",
  "responseMessage": "Successful",
  "partnerReferenceNo": "2020102900000000000001",
  "referenceNo": "TNICEEW05105202210141451109841",
  "webRedirectUrl": "https://pjsp.com/universal?bizNo=REF993883&...",
  "additionalInfo": {
    "redirectToken": " df548fff93e82aad9174c657820a85aa5d10042535157c7e89f52499"
  }
}
```
:::

