我有一个 Angular 项目,我必须在其中实现数据传输支付。但我无法生成付款标志。
我正在按照此链接上给出的过程(在此处输入链接描述)生成符号。
但我无法实现它。
我正在使用角度库 crypto-js 生成 HMAC-SHA-256 签名字符串。
这是我的javascript代码。
const merchantId = 'xxxxxxx';
const refNo = '1234567890';
const amount = 0;
const currency = 'CHF';
const theme = 'DT2015';
const paymentmethod = 'VIS';
const stringSs = merchantId+amount+currency+refNo;
const base = 16;
// My Hmac Key
const s = 'fa3d0ea1772cf21e53158283e4f123ebf1eb1ccfb15619e2fc91ee6860a2e5e48409e902b610ce5dc6f7f77fab8affb60d69b2a7aa9acf56723d868d36ab3f32';
// Step 1: Code to generate hex to byte of hmac key
const a = s.replace(/../g, '$&_').slice (0, -1).split ('_').map ((x) => parseInt (x, base));
// Step 3: Sign the string with HMAC-SHA-256 together with your HMAC key
const signedString = HmacSHA256(a, stringSs);
// Step 4: Translate the signature from byte to hex format
const signString = enc.Hex.stringify(signedString);
您能帮我解决这个问题,以建议我做错了什么或可以通过什么方式实现。
HUWWW
蝴蝶不菲
相关分类