
银行卡四要素
企业用户实名使用个人用户实名使用个人用户无法使用
传入姓名、身份证号、银行卡号、手机号,验证开卡人银行卡号、姓名、身份证号、手机号是否一致。支持所有带银联标识的银行卡。
价格
¥0元/2次
新用户免费体验,自购买起有效期1个月
选择套餐:

接口名称:银行卡4要素验证
描述:验证银行卡号和姓名、身份证号、预留手机号是否一致
请求地址 url:https://api.shuxuntech.com/v1/bankcard4/check
请求方式 method:get/post
参数:
| 名称 | 参数位置 | 类型 | 是否必填 | 说明 |
|---|---|---|---|---|
| appKey | head | string | 是 | 数勋分配appKey |
| timestamp | head | string | 是 | 当前时间的毫秒数 |
| sign | head | string | 是 | 签名,说明 |
| name | query | string | 是 | 姓名 |
| bankcard | query | string | 是 | 银行卡号 |
| idCard | query | string | 是 | 身份证号 |
| mobile | query | string | 是 | 预留手机号 |
签名算法说明:
数勋分配的appKey、当前unix时间毫秒数timestamp、数勋分配的appSecret、 按顺序拼接sha256加密得到sign,查看如下示例
appKey = aaa;
timestamp = 1682476904289;
appSecret = bbb;
sign = sha256(appKey+timestamp+appSecret)
正确返回:
{
"code": "0",
"msg": "成功",
"isFee": 1,
"seqNo": "16gkrprd3raganiv418oocrrkudaz314",
"data": {
"result": 2,
"resultDesc": "核验不一致"
}
}
错误返回:
{
"code": "1",
"msg": "请输入合法的名字",
"isFee": 0,
"seqNo": null,
"data": null
}
返回字段描述:
| 字段名 | 类型 | 描述 |
|---|---|---|
| code | string | 错误码 |
| msg | string | 错误描述 |
| isFee | int | 是否计费(1:计费,0:不计费) |
| seqNo | string | 调用流水号 |
| data | object | 返回数据 |
data对象说明
| 字段名 | 类型 | 描述 |
|---|---|---|
| result | int | 核查结果(1:一致,2:不一致,3:无效卡号或卡状态异常) |
| resultDesc | string | 核查结果描述 |
code错误码说明
| code | 说明 |
|---|---|
| 0 | 成功 |
| 1 | 参数错误 |
| 2 | 无记录 |
| 3 | 第三方服务异常 |
| 4 | 签名错误 |
| 5 | 余额不足 |
| 6 | 调用频率超限 |
| 7 | 账号停用 |
| 8 | 接口已停用 |
| 9 | 联系服务商开通接口权限 |
| 10 | ip不在白名单 |
| 11 | 系统异常 |
| 12 | 实名状态错误 |
| 99 | 其他异常,具体返回为准 |
银行卡4要素
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.security.MessageDigest;
/**
* 银行卡4要素 - Java 示例代码
* 接口地址:https://api.shuxuntech.com/v1/bankcard4/check
*
* 说明:本示例只使用 JDK 原生 API(java.net / java.security),不依赖任何第三方 jar 包,
* 也不需要本项目的工具类,复制到本地即可编译运行:
* javac Bankcard4CheckDemo.java
* java Bankcard4CheckDemo
*/
public class Bankcard4CheckDemo {
/** 数勋分配的 appKey,请替换为您自己的 appKey */
private static final String APP_KEY = "您的appKey";
/** 数勋分配的 appSecret,请替换为您自己的 appSecret */
private static final String APP_SECRET = "您的appSecret";
/** 接口地址 */
private static final String API_URL = "https://api.shuxuntech.com/v1/bankcard4/check";
/** 姓名 */
private static final String NAME = "";
/** 银行卡号 */
private static final String BANKCARD = "";
/** 身份证号 */
private static final String ID_CARD = "";
/** 手机号 */
private static final String MOBILE = "";
public static void main(String[] args) throws Exception {
// 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
String timestamp = String.valueOf(System.currentTimeMillis());
// 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256,得到小写十六进制字符串
String sign = sha256Hex(APP_KEY + timestamp + APP_SECRET);
// 3、业务参数,拼到 url 的 query 里
String query = "name=" + urlEncode(NAME) + "&" + "bankcard=" + urlEncode(BANKCARD) + "&" + "idCard=" + urlEncode(ID_CARD) + "&" + "mobile=" + urlEncode(MOBILE);
String url = API_URL + (query.isEmpty() ? "" : "?" + query);
// 4、发起 GET 请求,appKey、timestamp、sign 放在请求头
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("appKey", APP_KEY);
conn.setRequestProperty("timestamp", timestamp);
conn.setRequestProperty("sign", sign);
conn.setConnectTimeout(10000);
conn.setReadTimeout(20000);
int status = conn.getResponseCode();
// 5、读取返回内容:报错时读错误流,避免只拿到一个异常看不到原因
InputStream in = (status >= 200 && status < 300) ? conn.getInputStream() : conn.getErrorStream();
String result = readAll(in);
conn.disconnect();
System.out.println("HTTP状态码=" + status);
System.out.println("返回结果=" + result);
}
/**
* sha256 加密,返回小写十六进制字符串
* 服务端校验签名用的就是这个算法(小写十六进制)
*/
private static String sha256Hex(String content) throws Exception {
byte[] bytes = MessageDigest.getInstance("SHA-256").digest(content.getBytes("UTF-8"));
StringBuilder sb = new StringBuilder(bytes.length * 2);
for (byte b : bytes) {
sb.append(Character.forDigit((b >> 4) & 0xF, 16));
sb.append(Character.forDigit(b & 0xF, 16));
}
return sb.toString();
}
/** url 编码,中文参数需要编码 */
private static String urlEncode(String value) throws Exception {
return URLEncoder.encode(value, "UTF-8");
}
/** 读取输入流内容 */
private static String readAll(InputStream in) throws Exception {
if (in == null) {
return "";
}
StringBuilder sb = new StringBuilder();
BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
try {
String line;
while ((line = reader.readLine()) != null) {
sb.append(line);
}
} finally {
reader.close();
}
return sb.toString();
}
}
# 银行卡4要素 - Python 示例代码
# 接口地址:https://api.shuxuntech.com/v1/bankcard4/check
#
# 说明:只使用 Python 标准库(urllib / hashlib / time),不需要 pip 安装任何第三方包,
# 保存为 bankcard4_check_demo.py 后直接执行 python bankcard4_check_demo.py 即可。
import hashlib
import time
import urllib.error
import urllib.parse
import urllib.request
# 数勋分配的 appKey,请替换为您自己的 appKey
APP_KEY = "您的appKey"
# 数勋分配的 appSecret,请替换为您自己的 appSecret
APP_SECRET = "您的appSecret"
# 接口地址
API_URL = "https://api.shuxuntech.com/v1/bankcard4/check"
# 姓名
NAME = ""
# 银行卡号
BANKCARD = ""
# 身份证号
ID_CARD = ""
# 手机号
MOBILE = ""
def sha256_hex(content):
"""sha256 加密,返回小写十六进制字符串,服务端校验签名用的就是这个算法"""
return hashlib.sha256(content.encode("utf-8")).hexdigest()
def main():
# 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
timestamp = str(int(time.time() * 1000))
# 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256
sign = sha256_hex(APP_KEY + timestamp + APP_SECRET)
# 3、业务参数
params = {}
params["name"] = NAME
params["bankcard"] = BANKCARD
params["idCard"] = ID_CARD
params["mobile"] = MOBILE
data = urllib.parse.urlencode(params)
# 4、发起 GET 请求,appKey、timestamp、sign 放在请求头
request = urllib.request.Request(API_URL + ("?" + data if data else ""), method="GET")
request.add_header("appKey", APP_KEY)
request.add_header("timestamp", timestamp)
request.add_header("sign", sign)
# 5、读取返回内容:报错时也把返回体读出来,避免只拿到一个异常看不到原因
try:
with urllib.request.urlopen(request, timeout=20) as response:
status = response.getcode()
body = response.read().decode("utf-8")
except urllib.error.HTTPError as e:
status = e.code
body = e.read().decode("utf-8")
print("HTTP状态码=" + str(status))
print("返回结果=" + body)
if __name__ == "__main__":
main()
<?php
/**
* 银行卡4要素 - PHP 示例代码
* 接口地址:https://api.shuxuntech.com/v1/bankcard4/check
*
* 说明:只使用 PHP 内置函数,不需要 composer 安装任何依赖,也不需要 curl 扩展,
* 保存为 bankcard4_check_demo.php 后直接执行 php bankcard4_check_demo.php 即可。
*/
// 数勋分配的 appKey,请替换为您自己的 appKey
$appKey = "您的appKey";
// 数勋分配的 appSecret,请替换为您自己的 appSecret
$appSecret = "您的appSecret";
// 接口地址
$url = "https://api.shuxuntech.com/v1/bankcard4/check";
// 姓名
$name = "";
// 银行卡号
$bankcard = "";
// 身份证号
$idCard = "";
// 手机号
$mobile = "";
// 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
$timestamp = sprintf('%.0f', microtime(true) * 1000);
// 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256
$sign = hash('sha256', $appKey . $timestamp . $appSecret);
// 3、业务参数
$params = array(
'name' => $name,
'bankcard' => $bankcard,
'idCard' => $idCard,
'mobile' => $mobile,
);
$body = http_build_query($params);
// 4、发起 GET 请求,appKey、timestamp、sign 放在请求头
$context = stream_context_create(array(
'http' => array(
'method' => 'GET',
'header' => "appKey: {$appKey}\r\n"
. "timestamp: {$timestamp}\r\n"
. "sign: {$sign}\r\n",
'timeout' => 20,
// 返回 4xx、5xx 时也把返回体读出来,方便排查
'ignore_errors' => true,
),
));
$requestUrl = ($body === '') ? $url : $url . '?' . $body;
$result = file_get_contents($requestUrl, false, $context);
// 打印结果
if (!empty($http_response_header[0])) {
echo "HTTP状态=" . $http_response_header[0] . PHP_EOL;
}
echo "返回结果=" . $result . PHP_EOL;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
/**
* 银行卡4要素 - C# 示例代码
* 接口地址:https://api.shuxuntech.com/v1/bankcard4/check
*
* 说明:只使用 .NET 基础类库(System.Net.Http / System.Security.Cryptography),不依赖任何第三方包。
* 需要 .NET Framework 4.5 及以上,或 .NET Core / .NET 5 及以上;
* 保存为 Bankcard4CheckDemo.cs 后,用 dotnet run 或 VS 控制台项目直接运行即可。
*/
public class Bankcard4CheckDemo
{
/** 数勋分配的 appKey,请替换为您自己的 appKey */
private const string AppKey = "您的appKey";
/** 数勋分配的 appSecret,请替换为您自己的 appSecret */
private const string AppSecret = "您的appSecret";
/** 接口地址 */
private const string ApiUrl = "https://api.shuxuntech.com/v1/bankcard4/check";
/** 姓名 */
private const string Name = "";
/** 银行卡号 */
private const string Bankcard = "";
/** 身份证号 */
private const string IdCard = "";
/** 手机号 */
private const string Mobile = "";
public static void Main(string[] args)
{
// 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
long millis = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;
string timestamp = millis.ToString();
// 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256
string sign = Sha256Hex(AppKey + timestamp + AppSecret);
// 3、业务参数
Dictionary<string, string> form = new Dictionary<string, string>();
form.Add("name", Name);
form.Add("bankcard", Bankcard);
form.Add("idCard", IdCard);
form.Add("mobile", Mobile);
string body = ToFormBody(form);
// 4、发起 GET 请求,appKey、timestamp、sign 放在请求头
using (HttpClient client = new HttpClient())
{
client.Timeout = TimeSpan.FromSeconds(20);
client.DefaultRequestHeaders.Add("appKey", AppKey);
client.DefaultRequestHeaders.Add("timestamp", timestamp);
client.DefaultRequestHeaders.Add("sign", sign);
string url = (body == "") ? ApiUrl : ApiUrl + "?" + body;
HttpResponseMessage response = client.GetAsync(url).GetAwaiter().GetResult();
// 5、读取返回内容,4xx、5xx 时 HttpClient 不会抛异常,这里同样能拿到返回体
string content = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
Console.WriteLine("HTTP状态码=" + (int)response.StatusCode);
Console.WriteLine("返回结果=" + content);
}
}
/** 拼装 application/x-www-form-urlencoded 内容,中文参数需要编码 */
private static string ToFormBody(Dictionary<string, string> form)
{
StringBuilder sb = new StringBuilder();
foreach (KeyValuePair<string, string> item in form)
{
if (sb.Length > 0)
{
sb.Append("&");
}
sb.Append(Uri.EscapeDataString(item.Key)).Append("=").Append(Uri.EscapeDataString(item.Value));
}
return sb.ToString();
}
/** sha256 加密,返回小写十六进制字符串,服务端校验签名用的就是这个算法 */
private static string Sha256Hex(string content)
{
using (SHA256 sha256 = SHA256.Create())
{
byte[] bytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(content));
StringBuilder sb = new StringBuilder(bytes.Length * 2);
foreach (byte b in bytes)
{
sb.Append(b.ToString("x2"));
}
return sb.ToString();
}
}
}
// 银行卡4要素 - Node.js 示例代码
// 接口地址:https://api.shuxuntech.com/v1/bankcard4/check
//
// 说明:只使用 Node.js 内置模块(https / crypto),不需要 npm 安装任何第三方包,
// 保存为 bankcard4_check_demo.js 后直接执行 node bankcard4_check_demo.js 即可(需 Node 10 及以上)。
const https = require('https');
const crypto = require('crypto');
// 数勋分配的 appKey,请替换为您自己的 appKey
const APP_KEY = '您的appKey';
// 数勋分配的 appSecret,请替换为您自己的 appSecret
const APP_SECRET = '您的appSecret';
// 接口地址
const API_URL = 'https://api.shuxuntech.com/v1/bankcard4/check';
// 姓名
const NAME = '';
// 银行卡号
const BANKCARD = '';
// 身份证号
const ID_CARD = '';
// 手机号
const MOBILE = '';
// sha256 加密,返回小写十六进制字符串,服务端校验签名用的就是这个算法
function sha256Hex(content) {
return crypto.createHash('sha256').update(content, 'utf8').digest('hex');
}
// 打印返回结果
function printResult(statusCode, body) {
console.log('HTTP状态码=' + statusCode);
console.log('返回结果=' + body);
}
// 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
const timestamp = String(Date.now());
// 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256
const sign = sha256Hex(APP_KEY + timestamp + APP_SECRET);
// 3、业务参数,放在 url 的 query 里(中文由 URLSearchParams 自动 URL 编码)
const query = new URLSearchParams({ name: NAME, bankcard: BANKCARD, idCard: ID_CARD, mobile: MOBILE }).toString();
const url = query ? API_URL + '?' + query : API_URL;
// 4、发起 GET 请求,appKey、timestamp、sign 放在请求头
const request = https.request(url, {
method: 'GET',
headers: {
appKey: APP_KEY,
timestamp: timestamp,
sign: sign
},
timeout: 20000
}, function (response) {
// 5、读取返回内容:即使报错(4xx、5xx)也能拿到返回体,避免只看到异常看不到原因
let body = '';
response.setEncoding('utf8');
response.on('data', function (chunk) { body += chunk; });
response.on('end', function () { printResult(response.statusCode, body); });
});
request.on('timeout', function () {
request.destroy();
console.log('请求超时');
});
request.on('error', function (err) {
console.log('请求异常=' + err.message);
});
request.end();
// 银行卡4要素 - Go 示例代码
// 接口地址:https://api.shuxuntech.com/v1/bankcard4/check
//
// 说明:只使用 Go 标准库(net/http、crypto/sha256、encoding/hex 等),不需要引入任何第三方包,
// 保存为 bankcard4_check_demo.go 后直接执行 go run bankcard4_check_demo.go 即可。
package main
import (
"crypto/sha256"
"encoding/hex"
"fmt"
"io"
"net/http"
"net/url"
"time"
)
// 数勋分配的 appKey,请替换为您自己的 appKey
const appKey = "您的appKey"
// 数勋分配的 appSecret,请替换为您自己的 appSecret
const appSecret = "您的appSecret"
// 接口地址
const apiURL = "https://api.shuxuntech.com/v1/bankcard4/check"
// 姓名
const name = ""
// 银行卡号
const bankcard = ""
// 身份证号
const idCard = ""
// 手机号
const mobile = ""
// sha256 加密,返回小写十六进制字符串,服务端校验签名用的就是这个算法
func sha256Hex(content string) string {
sum := sha256.Sum256([]byte(content))
return hex.EncodeToString(sum[:])
}
func main() {
// 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
timestamp := fmt.Sprintf("%d", time.Now().UnixNano()/int64(time.Millisecond))
// 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256
sign := sha256Hex(appKey + timestamp + appSecret)
// 3、业务参数,放在 url 的 query 里(url.Values 会自动对中文做 URL 编码)
query := url.Values{}
query.Set("name", name)
query.Set("bankcard", bankcard)
query.Set("idCard", idCard)
query.Set("mobile", mobile)
requestURL := apiURL
if len(query) > 0 {
requestURL = apiURL + "?" + query.Encode()
}
// 4、发起 GET 请求,appKey、timestamp、sign 放在请求头
req, err := http.NewRequest("GET", requestURL, nil)
if err != nil {
fmt.Println("创建请求失败=" + err.Error())
return
}
req.Header.Set("appKey", appKey)
req.Header.Set("timestamp", timestamp)
req.Header.Set("sign", sign)
client := &http.Client{Timeout: 20 * time.Second}
resp, err := client.Do(req)
if err != nil {
fmt.Println("请求异常=" + err.Error())
return
}
defer resp.Body.Close()
// 5、读取返回内容:即使报错(4xx、5xx)也能拿到返回体
body, _ := io.ReadAll(resp.Body)
fmt.Println("HTTP状态码=" + resp.Status)
fmt.Println("返回结果=" + string(body))
}
#!/usr/bin/env bash
# 银行卡4要素 - curl 示例代码
# 接口地址:https://api.shuxuntech.com/v1/bankcard4/check
#
# 说明:只依赖系统自带的 curl 和 openssl(用于计算 sha256),不需要安装任何第三方工具,
# 保存为 bankcard4_check_demo.sh 后直接执行 bash bankcard4_check_demo.sh 即可。
# 如果系统没有 openssl,可把下面 SIGN 那一行换成注释里的 sha256sum 写法。
# 数勋分配的 appKey,请替换为您自己的 appKey
APP_KEY="您的appKey"
# 数勋分配的 appSecret,请替换为您自己的 appSecret
APP_SECRET="您的appSecret"
# 接口地址
API_URL="https://api.shuxuntech.com/v1/bankcard4/check"
# 姓名
NAME=""
# 银行卡号
BANKCARD=""
# 身份证号
ID_CARD=""
# 手机号
MOBILE=""
# 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
TIMESTAMP=$(($(date +%s) * 1000))
# 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256,得到小写十六进制字符串
# 没有 openssl 时可用: SIGN=$(printf '%s' "${APP_KEY}${TIMESTAMP}${APP_SECRET}" | sha256sum | awk '{print $1}')
SIGN=$(printf '%s' "${APP_KEY}${TIMESTAMP}${APP_SECRET}" | openssl dgst -sha256 | awk '{print $NF}')
# 3、业务参数放在 url 的 query 里(--data-urlencode 会自动对中文做 URL 编码)
# 4、发起 GET 请求,appKey、timestamp、sign 放在请求头
# 5、-w 参数在返回内容后打印 HTTP 状态码,便于查看结果
curl -sS -G "${API_URL}" \
-H "appKey: ${APP_KEY}" \
-H "timestamp: ${TIMESTAMP}" \
-H "sign: ${SIGN}" \
--data-urlencode "name=${NAME}" \
--data-urlencode "bankcard=${BANKCARD}" \
--data-urlencode "idCard=${ID_CARD}" \
--data-urlencode "mobile=${MOBILE}" \
-w "\nHTTP状态码=%{http_code}\n"
java
python
php
c#
nodejs
go
curl
产品详情
API文档
示例代码
产品价格







