On this pagePrerequisitesCreate a Payment OrderResponseWhat's Next?

Quick Start ​

Create your first payment order in minutes.

Prerequisites ​

  • A HashNut merchant account with Access Key ID and Secret Key
  • A deployed Splitter Address (split wallet contract)

Create a Payment Order ​

go
package main

import (
    "fmt"
    "log"

    hashnut "github.com/hashnut/hashnut-go-sdk"
    "github.com/hashnut/hashnut-go-sdk/model"
)

func main() {
    client := hashnut.NewClient("your-secret-key", true) // true = testnet

    order, err := client.CreateOrder(&model.CreateOrderRequest{
        AccessKeyID:     "your-access-key-id",
        MerchantOrderID: "ORDER-001",
        ChainCode:       "polygon-erc20",
        CoinCode:        "usdt",
        Amount:          "10.00",
        SplitterAddress: "0xYourSplitWalletAddress",
        Subject:         "Test Product",
        ExpireDuration:  600,
    })
    if err != nil {
        log.Fatal(err)
    }

    fmt.Printf("Order ID:        %s\n", order.PayOrderID)
    fmt.Printf("Receipt Address: %s\n", order.ReceiptAddress)
    fmt.Printf("Payment Page:    %s\n", order.PayURL)
}
java
import java.net.URI;
import java.net.http.*;
import java.time.Instant;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.util.Base64;
import java.util.UUID;

public class CreateOrder {
    static final String SECRET_KEY = "your-secret-key";
    static final String BASE_URL = "https://testnet.hashnut.io/api/v4.0.0";

    public static void main(String[] args) throws Exception {
        String uuid = UUID.randomUUID().toString();
        String timestamp = String.valueOf(Instant.now().toEpochMilli());
        String body = """
            {
              "accessKeyId": "your-access-key-id",
              "merchantOrderId": "ORDER-001",
              "chainCode": "polygon-erc20",
              "coinCode": "usdt",
              "amount": "10.00",
              "splitterAddress": "0xYourSplitWalletAddress",
              "subject": "Test Product",
              "expireDuration": 600
            }""";

        // HMAC-SHA256 signing
        String message = uuid + timestamp + body;
        Mac mac = Mac.getInstance("HmacSHA256");
        mac.init(new SecretKeySpec(SECRET_KEY.getBytes(), "HmacSHA256"));
        String sign = Base64.getEncoder().encodeToString(mac.doFinal(message.getBytes()));

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create(BASE_URL + "/pay/orders/api"))
            .header("Content-Type", "application/json")
            .header("hashnut-request-uuid", uuid)
            .header("hashnut-request-timestamp", timestamp)
            .header("hashnut-request-sign", sign)
            .POST(HttpRequest.BodyPublishers.ofString(body))
            .build();

        HttpResponse<String> response = HttpClient.newHttpClient()
            .send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
python
import hmac, hashlib, base64, json, time, uuid
import requests

SECRET_KEY = "your-secret-key"
BASE_URL = "https://testnet.hashnut.io/api/v4.0.0"

body = json.dumps({
    "accessKeyId": "your-access-key-id",
    "merchantOrderId": "ORDER-001",
    "chainCode": "polygon-erc20",
    "coinCode": "usdt",
    "amount": "10.00",
    "splitterAddress": "0xYourSplitWalletAddress",
    "subject": "Test Product",
    "expireDuration": 600,
}, separators=(",", ":"))

# HMAC-SHA256 signing
req_uuid = str(uuid.uuid4())
timestamp = str(int(time.time() * 1000))
message = req_uuid + timestamp + body
signature = base64.b64encode(
    hmac.new(SECRET_KEY.encode(), message.encode(), hashlib.sha256).digest()
).decode()

resp = requests.post(
    f"{BASE_URL}/pay/orders/api",
    headers={
        "Content-Type": "application/json",
        "hashnut-request-uuid": req_uuid,
        "hashnut-request-timestamp": timestamp,
        "hashnut-request-sign": signature,
    },
    data=body,
)

order = resp.json()["data"]
print(f"Order ID:        {order['payOrderId']}")
print(f"Receipt Address: {order['receiptAddress']}")
javascript
const crypto = require("crypto");

const SECRET_KEY = "your-secret-key";
const BASE_URL = "https://testnet.hashnut.io/api/v4.0.0";

const body = JSON.stringify({
  accessKeyId: "your-access-key-id",
  merchantOrderId: "ORDER-001",
  chainCode: "polygon-erc20",
  coinCode: "usdt",
  amount: "10.00",
  splitterAddress: "0xYourSplitWalletAddress",
  subject: "Test Product",
  expireDuration: 600,
});

// HMAC-SHA256 signing
const uuid = Date.now().toString() + Math.random().toString(36).slice(2);
const timestamp = Date.now().toString();
const message = uuid + timestamp + body;
const signature = crypto
  .createHmac("sha256", SECRET_KEY)
  .update(message)
  .digest("base64");

fetch(`${BASE_URL}/pay/orders/api`, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "hashnut-request-uuid": uuid,
    "hashnut-request-timestamp": timestamp,
    "hashnut-request-sign": signature,
  },
  body,
})
  .then((res) => res.json())
  .then((data) => {
    console.log("Order ID:", data.data.payOrderId);
    console.log("Receipt Address:", data.data.receiptAddress);
  });

Response ​

json
{
  "code": 0,
  "data": {
    "payOrderId": "01J5X9NDEKTSV4RRFFQ69G5FAV",
    "merchantOrderId": "ORDER-001",
    "receiptAddress": "0x1234...5678",
    "amount": "10.00",
    "accessSign": "3B08A1F2...",
    "state": 0
  }
}

What's Next? ​

  • Payment Flow — Understand the full lifecycle of a payment
  • Notifications — Receive webhook callbacks when order state changes
  • Query Order — Poll order status and transaction details