天天看点

使用阿里云接口进行银行卡四要素实名认证

如今随着互联网产业的多元化发展,尤其是互联网金融,O2O,共享经济等新兴商业形式的兴起,企业对实名认证业务的数据形式和数据质量有了更高的需求。如今也衍生出银行卡实名认证业务,通过接口将银行卡号、手机号、身份证号码、姓名上传至阿里云,再与银联系统进行匹配,判断信息的真实性。

在使用接口服务的方面我推荐使用技术实力强大的阿里云;

首先点击【阿里云API接口】购买成功后在控制台中可以得到您的appcode;

发送数据:

Map<String, String> bodys = new HashMap<String, String>();
bodys.put("ReturnBankInfo", "YES");
bodys.put("cardNo", "62155811111111111");
bodys.put("idNo", "340421199922225555");
bodys.put("name", "张三");
bodys.put("phoneNo", "13522221111");
           

返回数据:

{
  "name": "张三",
  "cardNo": "6225756663322156",
  "idNo": "34042158962596321",
  "phoneNo": "13699995555",
  "respMessage": "结果匹配",
  "respCode": "0000",
  "bankName": "招商银行",
  "bankKind": "招商银行信用卡",
  "bankType": "信用卡",
  "bankCode": "CMB"
}
           

具体实现类:(以java为例,其他语言在产品页面详细查看)

import java.util.HashMap;
import java.util.Map;

import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;

import com.netgate.util.send.HttpUtils;

public class AlipayBankNoCheck {

	public static void main(String[] args) {
	    String host = "https://yunyidata.market.alicloudapi.com";
	    String path = "/bankAuthenticate4";
	    String method = "POST";
	    String appcode = "你的appcode";
	    Map<String, String> headers = new HashMap<String, String>();
	    //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
	    headers.put("Authorization", "APPCODE " + appcode);
	    //根据API的要求,定义相对应的Content-Type
	    headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	    Map<String, String> querys = new HashMap<String, String>();
	    Map<String, String> bodys = new HashMap<String, String>();
	    bodys.put("cardNo", "621555888555222669");
	    bodys.put("idNo", "3404251111122222255555");
	    bodys.put("name", "张三");
	    bodys.put("phoneNo", "13355558888");
	    
	    try {
	    	/**
	    	* 重要提示如下:
	    	* HttpUtils请从
	    	* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java
	    	* 下载
	    	*
	    	* 相应的依赖请参照
	    	* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
	    	*/
	    	HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
	    	System.out.println(response.toString());
	    	//获取response的body
	    	System.out.println(EntityUtils.toString(response.getEntity()));
	    } catch (Exception e) {
	    	e.printStackTrace();
	    }
	}
	
}
           

 工具类下载地址:

https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java

其他语言的实例代码页面中间都有。

继续阅读