Giter Club home page Giter Club logo

bankbin's Introduction

BankBin

按银行卡卡号检测该银行卡类型,银行名称,银行代码 银行卡信息库更新于(2018-09)

通过银行卡号查询银行类型和银行卡类型,修复在与阿里API,混用时,导致的返回结果有可能会被上一次的Promise覆盖。

在input事件中高频率调用时,如果开启async配置,出现多个promise 中, 上一次的xhr在未完成请求的情况下会被cancle掉

采用 es6 class构造类 import导入 银行卡信息库

安装

npm install bankbin

#返回结果

validated 为true时,验证成功

{
    cardNo:"6217003810020275930"
    data: {
        cardType: "DC",
        cardTypeName: "储蓄卡",
        bankName: "**建设银行",
        bankCode: "CCB"
    }
    validated:true
    msg:"匹配成功"
}

使用方式 new BankBin(cardNo,options)

成功获取银行卡信息后,返回一个对象.

promise.then方式调用

    import BankBin from 'bankbin';

    new BankBin(6217003810020275930).then(function(res){
            console.log(res)
    },function(res){
        console.log('验证失败')
    });

async/await方式调用

    import BankBin from 'bankbin';

    try{
        const res = await new BankBin(6217003810020275930);
        console.log(res)
    } catch (e){
        console.log('验证失败')
    }

options 参数

{
    async : false,              //默认false,  是否在内置银行卡信息中查询失败后,调用支付宝开放式银行卡查询API。
    timeout : 10000             //默认10000,  async参数为true时,生效.  API调用超时时间
}

//例:
try{
    const res = await new BankBin(6217003810020275930, { async : true });
    console.log(res)
} catch (e){
    console.log('验证失败')
}

小结

  1. 优先使用内置的银行卡信息库进行规则匹配,当前内置123个银行信息,能满足国内众多银行卡信息识别。银行卡信息库更新于(2018-09)
  2. 当系统自带的规则获取不到卡bin时,会调用支付宝的接口来获取,测试地址
  3. 支持 es6 import

bankbin's People

Contributors

xiaohuangyuson avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.