zoukankan      html  css  js  c++  java
  • 微信、支付宝、银联二维码付款码规则

    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位

  • 相关阅读:
    MySQL索引原理
    MyBatis执行流程的各阶段介绍
    实现单栈实现支持getMin的栈
    缓存LRU算法——使用HashMap和双向链表实现
    Hystrix资源隔离
    各种负载均衡策略-图解
    接口调用超时的实现原理
    Spring Bean生命周期的各阶段介绍
    TAR命令详解 复习
    INT MOD
  • 原文地址:https://www.cnblogs.com/zhangmo/p/13578409.html
Copyright © 2011-2022 走看看