tvrcgo / weixin-pay

微信支付 Nodejs SDK
MIT License
916 stars 241 forks source link

支付通知 #16

Closed lawrence-peng closed 7 years ago

lawrence-peng commented 7 years ago

底层没有进行签名验证,太不安全。交由用户自己做,使用性不好

lymanlai commented 7 years ago

@lawrence-peng 自己传nonce_str参数进去,同时保存该值到数据库 getBrandWCPayRequestParams返回的nonceStr是自己传的nonce_str经过微信服务器加密后返回的,所以是验证不了的。要验证你原始的nonce_str 类似这样:payResult是微信服务器notify我们的api的时候的参数, payLog则是我们自己之前的原始的nonce_str

  if (payLog.nonceStr !== payResult.nonce_str) {
    Logger.debug('nonce_str not validate', payLog.nonceStr, payResult.nonce_str)
    payLog.status = 'nonce_str not validate'
    await payLog.save()
    return wxpayFailedBody
  }
tvrcgo commented 7 years ago

@lawrence-peng fork 了自己来做 feature 吧