Giter Club home page Giter Club logo

bankcardinfo's Introduction

通过银行卡号查询银行类型和银行卡类型

Build Status via Travis CI Coverage Status NPM version

建议升级使用1.0.0+的版本,该版本不向下兼容,即不再支持getBankInfoByCardNoAsync,getBankInfoByCardNo这两个API,旧版本用户请升级并使用 getBankBin API替换

2.0.0版本开始支持promise写法

npm install bankcardinfo

成功获取卡bin信息时,返回值为json对象

{
	bankName:"**工商银行",
	bankCode:"ICBC",
	cardType:"DC",
	cardTypeName:"储蓄卡"
}

API

传入卡号,异步返回。当第一个参数为空时,表示获取卡bin信息成功(标准API)

var BIN = require('bankcardinfo');
//callback 方式调用
BIN.getBankBin('6227003320240034988',function(err,data){
	if(!err){
		//todo 
		{
			bankName:"**工商银行",
			bankCode:"ICBC",
			cardType:"DC",
			cardTypeName:"储蓄卡"
		}
	}
})
// promise 方式调用, 2.0.0 及以上版本支持
BIN.getBankBin('6227003320240034988')
	.then(function (data) {

	})
	.catch(function (err) {

	})

0.3.3版本以下API(存在并发请求的Bug,建议升级到1.0.0+)

传入卡号,异步返回。只返回一个参数,当非空时,表示获取卡bin信息成功(非标准API)

var BIN = require('bankcardinfo');
BIN.getBankInfoByCardNoAsync('6227003320240034988',function(data){
	if(data){
		//todo 
		//data 
	}
})

传入卡号,同步返回。当返回值非空时,表示获取卡bin信息成功

var BIN = require('bankcardinfo');
var binData = BIN.getBankInfoByCardNo('6227003320240034988');
if(binData){
	//todo
}

小结

  1. 优先使用系统自带的获取卡bin信息(2013年国内银行卡集)
  2. 当系统自带的规则获取不到卡bin时,会调用支付宝的接口来获取,测试地址
  3. 支持AMD & CMD
  4. 可在browser端使用,直接引入index.js文件,建议在服务端使用。

未来

由于模块自带的卡bin获取规则是2013年全国银行的卡集合,所以卡规则需要不断完善。可在模块中收集用户新卡规则,但是会涉及用户隐私及安全问题,及时收集,也只会收集部分够认证的卡位即可。

bankcardinfo's People

Contributors

navyxie avatar bigwin-book 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.