Skip to content

签名验证失败public boolean checkSign(Object xmlBean)方法的bug #250

Closed

Description

@jiangyang118

|wxJsYyPaymentPlugin verifyNotify error, valid failed|notifyResult={"appid":"**************","attach":null,"bankType":"ICBC_DEBIT","cashFee":157390,"cashFeeType":null,"couponCount":1,"couponFee":10,"couponList":[{"couponFee":10,"couponId":"2000000000472570000","couponType":null}],"deviceInfo":null,"errCode":null,"errCodeDes":null,"feeType":"CNY","isSubscribe":"N","mchId":"1403272402","nonceStr":"1497351146318","openid":"oeDfdwTwwZQ_cBhnmNDpjR0lTEF4","outTradeNo":"2017061342100429","resultCode":"SUCCESS","returnCode":"SUCCESS","returnMsg":null,"settlementTotalFee":null,"sign":"EA5C0AF580CFCF7708C8C168C2261B42","timeEnd":"20170613185233","totalFee":157400,"tradeType":"JSAPI","transactionId":"4003522001201706135577210346","xmlString":"<xml><appid><![CDATA[**************]]></appid><bank_type><![CDATA[ICBC_DEBIT]]></bank_type><cash_fee><![CDATA[157390]]></cash_fee><coupon_count><![CDATA[1]]></coupon_count><coupon_fee>10</coupon_fee><coupon_fee_0><![CDATA[10]]></coupon_fee_0><coupon_id_0><![CDATA[2000000000472570000]]></coupon_id_0><fee_type><![CDATA[CNY]]></fee_type><is_subscribe><![CDATA[N]]></is_subscribe><mch_id><![CDATA[1403272402]]></mch_id><nonce_str><![CDATA[1497351146318]]></nonce_str><openid><![CDATA[oeDfdwTwwZQ_cBhnmNDpjR0lTEF4]]></openid><out_trade_no><![CDATA[2017061342100429]]></out_trade_no><result_code><![CDATA[SUCCESS]]></result_code><return_code><![CDATA[SUCCESS]]></return_code><sign><![CDATA[EA5C0AF580CFCF7708C8C168C2261B42]]></sign><time_end><![CDATA[20170613185233]]></time_end><total_fee>157400</total_fee><trade_type><![CDATA[JSAPI]]></trade_type><transaction_id><![CDATA[4003522001201706135577210346]]></transaction_id></xml>"}

针对使用优惠劵的情况,xml中的coupon_id_0没法映射回来。针对上面的代码串,只能映射成WxPayOrderNotifyResult类中的couponList中的couponId,而couponId配置的注解是@XStreamAlias("coupon_id"),无法转成coupon_id_0导致签名验证失败。

Activity

  1. binarywang commented on Jun 15, 2017

    @binarywang
    Owner

    这块代码我看了确实是有问题,我抽空优化修复一下

  2. binarywang commented on Jun 15, 2017

    @binarywang
    Owner

    我又仔细看了下,做了单元测试测试了一下,没有问题啊,不过WxPayOrderNotifyCoupon里的注解确实有点多余,但是不影响。不知道你是如何调用代码的?

  3. jink2005 commented on Jul 1, 2017

    @jink2005

    我也遇到签名验证失败的情况,经对比官方生成的sign字符串,发现代码生成中缺少了如下字段:
    sub_is_subscribe
    sub_openid
    我用的是服务商号,应该是WxPayBaseResult类缺少了field。

    我的支付回调xml如下:
    <xml><appid><![CDATA[wx22f85d11b57c05ab]]></appid> <bank_type><![CDATA[CFT]]></bank_type> <cash_fee><![CDATA[1]]></cash_fee> <fee_type><![CDATA[CNY]]></fee_type> <is_subscribe><![CDATA[Y]]></is_subscribe> <mch_id><![CDATA[1468859502]]></mch_id> <nonce_str><![CDATA[1498904698488]]></nonce_str> <openid><![CDATA[oP2KSwOS5BSROsL_SkieFWKjf5Qw]]></openid> <out_trade_no><![CDATA[881096282905571328]]></out_trade_no> <result_code><![CDATA[SUCCESS]]></result_code> <return_code><![CDATA[SUCCESS]]></return_code> <sign><![CDATA[2B2B1E6DB57831AF7C95EAD0EF87A745]]></sign> <sub_appid><![CDATA[wxfd579770c42355b1]]></sub_appid> <sub_is_subscribe><![CDATA[Y]]></sub_is_subscribe> <sub_mch_id><![CDATA[1483460252]]></sub_mch_id> <sub_openid><![CDATA[oyEPuv5ZNDF5MKdakfoBxrQ2R8Ks]]></sub_openid> <time_end><![CDATA[20170701182503]]></time_end> <total_fee>1</total_fee> <trade_type><![CDATA[JSAPI]]></trade_type> <transaction_id><![CDATA[4008452001201707018352644521]]></transaction_id> </xml>

    微信官网生成sign无加密key ( https://pay.weixin.qq.com/wiki/doc/api/jsapi_sl.php?chapter=20_1 ):
    appid=wx22f85d11b57c05ab&bank_type=CFT&cash_fee=1&fee_type=CNY&is_subscribe=Y&mch_id=1468859502&nonce_str=1498904698488&openid=oP2KSwOS5BSROsL_SkieFWKjf5Qw&out_trade_no=881096282905571328&result_code=SUCCESS&return_code=SUCCESS&sub_appid=wxfd579770c42355b1&sub_is_subscribe=Y&sub_mch_id=1483460252&sub_openid=oyEPuv5ZNDF5MKdakfoBxrQ2R8Ks&time_end=20170701182503&total_fee=1&trade_type=JSAPI&transaction_id=4008452001201707018352644521

    2.7.0版本生成的sign不加key如下:
    appid=wx22f85d11b57c05ab&bank_type=CFT&cash_fee=1&fee_type=CNY&is_subscribe=Y&mch_id=1468859502&nonce_str=1498904698488&openid=oP2KSwOS5BSROsL_SkieFWKjf5Qw&out_trade_no=881096282905571328&result_code=SUCCESS&return_code=SUCCESS&sub_appid=wxfd579770c42355b1&sub_mch_id=1483460252&time_end=20170701182503&total_fee=1&trade_type=JSAPI&transaction_id=4008452001201707018352644521

  4. binarywang commented on Jul 3, 2017

    @binarywang
    Owner

    2.7.3.BETA版本已修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions