跳到主要内容

附录1

签名验证

HTTP

String responseBody = "001XeyJlcGsiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIm..."
String responseSignedMessage = response.header("Signature");
Signature vrfResSignature = Signature.getInstance("SHA512withECDSA");
vrfResSignature.initVerify(publicKeySigning);
Boolean result = vrfResSignature.verify(decodeBase64AsByteArray(decodeURL(responseSignedMessage)));

预授权付款

String jsonStr = "{"
+ "\"sequenceNo\":\"1\","
+ "\"sourceSystem\":\"mxx\","
+ "\"MsgVer\":\"1.0\","
+ "\"TxnID\":\"20XX0825023XXXXX\","
+ "\"ResultCode\":\"0\","
+ "\"RespCd\":\"00\","
+ "\"OrgRespCd\":\"00\","
+ "\"RRN\":\"32376300XXXX\","
+ "\"STAN\":\"006XXX\","
+ "\"AuthIdResp\":\"945XXX\","
+ "\"MRN\":\"23237V6XXX\","
+ "\"TxnDTTime\":\"20230825143413\","
+ "\"PaymentScheme\":\"MC\""
+ "}";
byte[] messageBytes = jsonStr.getBytes();
signature.update(messageBytes);
boolean verified = signature.verify(signedMessageBytes);