Onerway
API Reference

WEBHOOK description

Understand Issuing webhook headers, payload envelope, merchant acknowledgement, and HMAC-SHA256 signature verification.

Use this page before implementing Issuing webhook callbacks. Onerway pushes card operation, card transaction, and 3DS events to the callback URL configured for the merchant.

Request headers

HeaderTypeRequiredDescription
Content-TypeStringYesFixed to application/json;charset=UTF-8.
x-timestampStringYesUnix timestamp in seconds.
x-signatureStringYesGenerate the HMAC-SHA256 signature from secret and x-timestamp + "." + raw_body. See Signature and verification.

Payload structure

FieldTypeRequiredDescription
request_idStringYesUnique event identifier for deduplication.
event_typeStringYesEvent type. Issuing currently sends issuing.cardOperateEvent, issuing.cardTransactionEvent, and issuing.card3dsEvent.
created_atStringYesEvent creation time in ISO 8601 format.
versionStringNoWebhook API version selected when the subscription is created. When no version is specified for the subscription, Onerway always returns 1.0.
dataObjectYesBusiness data. The structure depends on event_type.

Merchant response requirements

The merchant callback must return a JSON response. Onerway uses this response to decide whether the push was received successfully.

FieldTypeDescription
respCodeStringReturn 20000 to confirm receipt.
respMsgStringResponse message.

If the callback response code is not 20000, Onerway retries every 15 seconds, up to 10 times.

Signature and verification

Onerway signs asynchronous card operation, transaction, and 3DS event notifications with HMAC-SHA256. You must verify the signature before processing an event.

Generate and verify the signature as follows:

  1. Read x-timestamp and x-signature from the request headers.
  2. Read the raw request body without parsing or re-serializing it.
  3. Concatenate x-timestamp, a period (.), and raw_body to build the signed content:
x-timestamp + "." + raw_body
  1. Use the UTF-8 bytes of secret directly as the HMAC key. Do not Base64-decode secret.
  2. Apply HMAC-SHA256 to the signed content and encode the result as a lowercase hexadecimal string.
  3. To verify the notification, calculate the signature using the same rules and compare it securely with x-signature, ignoring hexadecimal letter case.
Calculate the signature from the raw request body exactly as received. Parsing and re-serializing the JSON can change whitespace, field order, or escape sequences and cause verification to fail.
import cn.hutool.core.util.HexUtil;
import cn.hutool.core.util.StrUtil;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

public final class RHSecureUtil {
    private RHSecureUtil() {
    }

    public static String signHmacSHA256(String secret, String content) throws Exception {
        Mac mac = Mac.getInstance("HmacSHA256");
        mac.init(new SecretKeySpec(secret.getBytes(), "HmacSHA256"));
        byte[] result = mac.doFinal(content.getBytes());
        return HexUtil.encodeHexStr(result);
    }

    public static boolean verifyHmacSHA256(String secret, String content, String signed) throws Exception {
        String hmacSHA256Str = signHmacSHA256(secret, content);
        return StrUtil.equalsAnyIgnoreCase(hmacSHA256Str, signed);
    }
}