File tree 3 files changed +38
-1
lines changed
3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -282,6 +282,21 @@ const queryObj = {
282
282
const signResult = sdk .checkNotifySign (queryObj );
283
283
```
284
284
285
+ 如果遇到验签失败,请尝试使用 ` checkNotifySignV2() ` 方法代替,它默认不会对 value 进行 decode
286
+ 如 https://github.com/alipay/alipay-sdk-nodejs-all/issues/45 场景问题。
287
+
288
+ ``` ts
289
+ const postData = {
290
+ sign_type: ' RSA2' ,
291
+ sign: ' QfTb8tqE1BMhS5qAn.....' ,
292
+ gmt_create: ' 2019-08-15 15:56:22' ,
293
+ other_biz_field: ' ....' ,
294
+ }
295
+
296
+ // true | false
297
+ const signResult = sdk .checkNotifySignV2 (postData );
298
+ ```
299
+
285
300
## alipay-sdk v3 到 v4 的升级说明
286
301
287
302
从 v3 到 v4 有以下不兼容变更,请参考示例代码进行更新
@@ -437,6 +452,16 @@ curl 方式调用支付宝 [API v3 协议](https://opendocs.alipay.com/open-v3/0
437
452
| bizContent | 业务请求参数 | ` object ` | 否 |
438
453
| needEncrypt | 自动 AES 加解密 | ` boolean ` | 否 |
439
454
455
+ ### alipaySdk.checkNotifySignV2(postData)
456
+
457
+ 通知验签,默认不会对 value 进行 decode
458
+
459
+ ** Returns** : ` Boolean ` - 是否验签成功
460
+
461
+ | Param | Type | Description |
462
+ | --- | --- | --- |
463
+ | postData | ` JSON ` | 服务端的消息内容 |
464
+
440
465
### alipaySdk.checkNotifySign(postData, raw)
441
466
442
467
通知验签
Original file line number Diff line number Diff line change @@ -784,6 +784,17 @@ export class AlipaySdk {
784
784
}
785
785
}
786
786
787
+ /**
788
+ * 通知验签,不对 value 进行 decode
789
+ * @param {JSON } postData 服务端的消息内容
790
+ * @return { Boolean } 验签是否成功
791
+ */
792
+ public checkNotifySignV2 ( postData : any ) {
793
+ // 修复常见问题 https://github.com/alipay/alipay-sdk-nodejs-all/issues/45
794
+ // 由于要保持 checkNotifySign 方法兼容性,所以新增一个 checkNotifySignV2 代替
795
+ return this . checkNotifySign ( postData , true ) ;
796
+ }
797
+
787
798
/**
788
799
* 通知验签
789
800
* @param {JSON } postData 服务端的消息内容
Original file line number Diff line number Diff line change @@ -735,7 +735,7 @@ describe('test/alipay.test.ts', () => {
735
735
} ) ;
736
736
} ) ;
737
737
738
- describe ( 'checkNotifySign' , ( ) => {
738
+ describe ( 'checkNotifySign(), checkNotifySignV2() ' , ( ) => {
739
739
let sdk : AlipaySdk ;
740
740
beforeEach ( ( ) => {
741
741
sdk = new AlipaySdk ( {
@@ -835,6 +835,7 @@ describe('test/alipay.test.ts', () => {
835
835
point_amount : '0.00' ,
836
836
} ;
837
837
assert . equal ( sdk . checkNotifySign ( postData ) , true ) ;
838
+ assert . equal ( sdk . checkNotifySignV2 ( postData ) , true ) ;
838
839
} ) ;
839
840
840
841
it ( 'verify fail' , ( ) => {
You can’t perform that action at this time.
0 commit comments