@@ -548,6 +548,20 @@ console.info(params)
548
548
549
549
## 常见问题
550
550
551
+ Q: ` APIv3 ` 上请求参数敏感信息如何加密?返回参数敏感信息如何解密?
552
+
553
+ > 接口区分国内版还是国际版,国内版的` RSA ` 填充方案是` RSA_PKCS1_OAEP_PADDING ` ,方法如下:
554
+ >
555
+ > 请求字段需要密文的,加密方法: ` Rsa.encrypt('原始信息', Rsa.from(platformPublicKeyFilePath, Rsa.KEY_TYPE_PUBLIC), Rsa.RSA_PKCS1_OAEP_PADDING) `
556
+ >
557
+ > 返回字段需要明文的,解密方法: ` Rsa.decrypt('密文base64', Rsa.from(merchantPrivateKeyFilePath, Rsa.KEY_TYPE_PRIVATE), Rsa.RSA_PKCS1_OAEP_PADDING) `
558
+ >
559
+ > 国际版的` RSA ` 填充方案是` RSA_PKCS1_PADDING ` (不是所有node版本都支持),方法如下:
560
+ >
561
+ > 请求字段需要密文的,加密方法: ` Rsa.encrypt('原始信息', Rsa.from(platformCertificateFilePath, Rsa.KEY_TYPE_PUBLIC), Rsa.RSA_PKCS1_PADDING) `
562
+ >
563
+ > 返回字段需要明文的,解密方法: ` Rsa.decrypt('密文base64', Rsa.from(merchantPrivateKeyFilePath, Rsa.KEY_TYPE_PRIVATE), Rsa.RSA_PKCS1_PADDING) `
564
+
551
565
Q: 如何安全地在应用内使用` APIv2 ` 及` APIv3 ` 对称密钥?
552
566
553
567
> ` v0.9.0 ` 提供了统一的对称密钥加载函数 ` Hash.keyObjectFrom(thing: BinaryLike): KeyObject ` ,建议应用升级至` v0.9.2 ` 使用此函数进行统一对称密钥管理;
@@ -572,16 +586,7 @@ Q: 敏感信息或者幂等操作要求额外头信息上送时,应该如何
572
586
573
587
> ` DELETE ` /` GET ` 请求的第一个参数,` POST ` /` PUT ` /` PATCH ` 请求的第二个参数,是 [AxiosRequestConfig](https://github.com/axios/axios) 对象,可以按需上送额外头参数,例如:
574
588
> ` ` ` js
575
- > wxpay .v3 .applyment4sub .applyment .$noop$ (
576
- > {},
577
- > { noop: ' ' , headers: { ' Wechatpay-Serial' : ' 123456' } },
578
- > ).then (console .info ).catch (console .error );
579
- > ` ` `
580
- > 可参考 [#17](https://github.com/TheNorthMemory/wechatpay-axios-plugin/issues/17)
581
-
582
- Q: 接口地址为slash(` / ` )结尾的,应该如何构建请求参数?
583
-
584
- > 动态参数` uri_template` 或者属性` property` 方式构建,可参考 [#16](https://github.com/TheNorthMemory/wechatpay-axios-plugin/issues/16)
589
+ > 可参考 [这里](https: // wechatpay.js.org/openapi/v3/applyment4sub/applyment/) 或 [这里](https://wechatpay.js.org/openapi/v3/marketing/partnerships/build) 的实现
585
590
586
591
## 单元测试
587
592
0 commit comments