首页 > 微信 > 详细

微信、支付宝、银联二维码付款码规则

时间:2020-08-28 22:55:33      阅读:101      评论:0      收藏:0      [点我收藏+]
int IsNumber(const char * authcode, int len)
{
    for (int i = 0; i < len; i++){
        if (authcode[i] >= 0&&authcode[i] <= 9){
            continue;
        }
        else{
            return i;
        }
    }
    return len;
}

BOOL IsValidAuthCode(const char * authcode, int len)
{
    int validLen = IsNumber(authcode, len);
    if (validLen < 16)
    {
        return false;
    }
    if (authcode[0] == 1)
    {
        //微信
        if (authcode[1] == 0
            || authcode[1] == 1
            || authcode[1] == 2
            || authcode[1] == 3
            || authcode[1] == 4
            || authcode[1] == 5)
        {
            if (validLen == 18)
            {
                return true;
            }
        }
    }
    if (authcode[0] == 2)
    {
        //支付宝
        if (authcode[1] == 5
            || authcode[1] == 6
            || authcode[1] == 7
            || authcode[1] == 8
            || authcode[1] == 9)
        {
            if (validLen >= 16 && validLen <= 24)
            {
                return true;
            }
        }
    }
    else if (authcode[0] == 6)
    {
        //银联二维码
        if (authcode[1] == 2)
        {
            if (validLen == 19)
            {
                return true;
            }
        }
    }
    else if (authcode[0] == 3 && authcode[1] == 0)
    {
        //支付宝
        if (validLen >= 16 && validLen <= 24)
        {
            return true;
        }
    }
    return false;
}

微信:10、11、12、13、14、15开头18位
https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=5_1


支付宝:25、26、27、28、29、30开头长度16-24位
https://blog.csdn.net/Chillax_li/article/details/103271198


银联二维码:62开头19位

 

微信、支付宝、银联二维码付款码规则

原文:https://www.cnblogs.com/zhangmo/p/13578409.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!