klover2 / wechatpay-node-v3-ts

微信支付v3
MIT License
528 stars 82 forks source link

code review #68

Closed program-spiritual closed 3 months ago

program-spiritual commented 5 months ago
public getSignature(method: string, nonce_str: string, timestamp: string, url: string, body?: string | Record<string, any>): string {
    let str = method + '\n' + url + '\n' + timestamp + '\n' + nonce_str + '\n';
    if (body && body instanceof Object) body = JSON.stringify(body);
    if (body) str = str + body + '\n';
    if (method === 'GET') str = str + '\n';
    return this.sha256WithRsa(str);
  }

代码提升空间很大