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
| Header | Type | Required | Description |
|---|---|---|---|
Content-Type | String | Yes | Fixed to application/json;charset=UTF-8. |
x-timestamp | String | Yes | Unix timestamp in seconds. |
x-signature | String | Yes | Generate the HMAC-SHA256 signature from secret and x-timestamp + "." + raw_body. See Signature and verification. |
Payload structure
| Field | Type | Required | Description |
|---|---|---|---|
request_id | String | Yes | Unique event identifier for deduplication. |
event_type | String | Yes | Event type. Issuing currently sends issuing.cardOperateEvent, issuing.cardTransactionEvent, and issuing.card3dsEvent. |
created_at | String | Yes | Event creation time in ISO 8601 format. |
version | String | No | Webhook API version selected when the subscription is created. When no version is specified for the subscription, Onerway always returns 1.0. |
data | Object | Yes | Business 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.
| Field | Type | Description |
|---|---|---|
respCode | String | Return 20000 to confirm receipt. |
respMsg | String | Response 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:
- Read
x-timestampandx-signaturefrom the request headers. - Read the raw request body without parsing or re-serializing it.
- Concatenate
x-timestamp, a period (.), andraw_bodyto build the signed content:
x-timestamp + "." + raw_body
- Use the UTF-8 bytes of
secretdirectly as the HMAC key. Do not Base64-decodesecret. - Apply HMAC-SHA256 to the signed content and encode the result as a lowercase hexadecimal string.
- 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);
}
}
import hashlib
import hmac
def sign_hmac_sha256(secret: str, content: str) -> str:
return hmac.new(
secret.encode("utf-8"),
content.encode("utf-8"),
hashlib.sha256,
).hexdigest()
def verify_hmac_sha256(secret: str, content: str, signed: str) -> bool:
expected = sign_hmac_sha256(secret, content)
return hmac.compare_digest(expected.lower(), signed.lower())
<?php
final class HmacSHA256Util
{
public static function signHmacSHA256(string $webhookSecret, string $content): string
{
return hash_hmac('sha256', $content, $webhookSecret);
}
public static function verifyHmacSHA256(string $webhookSecret, string $content, string $signed): bool
{
$expected = self::signHmacSHA256($webhookSecret, $content);
return hash_equals(strtolower($expected), strtolower($signed));
}
}