sign static method
Signs the payload using HMAC-SHA256 with secret.
Returns a 64-character lowercase hexadecimal digest.
Implementation
static String sign({
required String secret,
required String appKey,
required String userToken,
required int timestamp,
Map<String, dynamic>? raw,
bool? isPaying,
String? plan,
num? mrr,
String? currency,
}) {
if (secret.isEmpty) {
throw ArgumentError.value(secret, 'secret', 'SDK signing secret cannot be empty');
}
final canonical = canonicalize(
appKey: appKey,
userToken: userToken,
timestamp: timestamp,
raw: raw,
isPaying: isPaying,
plan: plan,
mrr: mrr,
currency: currency,
);
final hmac = Hmac(sha256, utf8.encode(secret));
final digest = hmac.convert(utf8.encode(canonical));
return digest.toString();
}