Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memo is required. But Not Found In params #1

Closed
Micjoyce opened this issue May 3, 2017 · 4 comments
Closed

memo is required. But Not Found In params #1

Micjoyce opened this issue May 3, 2017 · 4 comments

Comments

@Micjoyce
Copy link

Micjoyce commented May 3, 2017

手机支付过程中,meno 有可能返回的值为空字符串
https://doc.open.alipay.com/doc2/detail.htm?treeId=204&articleId=105462&docType=1

{
    memo = "";
    result = "{
        \"alipay_trade_wap_pay_response\":{
            \"code\":\"10000\",
            \"msg\":\"Success\",
            \"out_trade_no\":\"70501111111S001111119\",
            \"trade_no\":\"2014112400001000340011111118\",
            \"total_amount\":9.00,
            \"seller_id\":\"2088111111116894\"
        },
   \"sign\":
\"WLRdHxAfnP1Z+lTyiu9LoFRbw80rCKXz0PLBtB9EnLb6Jsq6R0TuX0BkWXF9hhKmbtdXHzMq4OM9l9H7IGs92kTvJbmvp80vnLcx+i8KOCqveVoXJrO8v0QtX1xuEQpyrmfG9BQLX8p5dw0+8iba2BeHVjGueQGmUwU72wXiWtg=\"
    }";
    resultStatus = "9000"; 
}

因此在verifyPayment的时候meno不应该是required,

  memo: {
    type: 'string',
    // required: true, 
  },
  result: {
    type: 'object',  // --->
    required: true
  },

而且返回的result 应该是 string类型的数据.

但是当我将result转化为object的时候,会返回{ code: '-1', message: 'result. Length equal 0.', data: {} }的错误。

@Micjoyce
Copy link
Author

Micjoyce commented May 3, 2017

在验证字符串的时候添加

if (!data) return
修改为
if (checker.type !== 'string' || !data) return

可以修复这个问题。

Luncher pushed a commit that referenced this issue May 4, 2017
fix memo required and result is object BUg

#1
@Luncher
Copy link
Owner

Luncher commented May 4, 2017

谢谢你的反馈,可能是当时文档没有看清楚。问题已经修复

@Luncher Luncher closed this as completed May 4, 2017
@Micjoyce
Copy link
Author

Micjoyce commented May 5, 2017

还有一个小问题 utils.js 中的 verifySign在验证异步回调的时候不能验证通过。

export function verifySign(publicKey, response, omit, options) {
  const type = responseType(response)
  if (!type || !response.sign) {
    return false
  } else {
    // const sign = Base64.decode(response.sign)  // 这一句应该改为下面这一句,不然异步回掉的验证不能通过。
    const sign = response.sign // new
    const resp = makeSignStr(response[type], omit)
    const algorithm = signAlgorithm(options.sign_type)
    const verify = crypto.createVerify(algorithm)
    verify.update(resp, 'utf8')
    return verify.verify(publicKey, sign, 'base64')
  }
}

@Luncher
Copy link
Owner

Luncher commented May 5, 2017

好的,你能把校验的参数一并贴一下吗?我明天试一试,谢谢!:)

Luncher added a commit that referenced this issue May 6, 2017
No need decode async notify sign

#1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants