银行编码对应名称查询


根据银行简称查询银行详细名称。银行数据库会随时更新

请求地址:https://payjs.cn/api/bank

请求参数:

字段名称 字段类型 必填参数 说明
mchid string(32) Y 商户号
bank string(32) Y 银行简写
sign string(32) Y 数据签名 详见签名算法

请求返回:

字段名称 字段类型 必填参数 说明
return_code int Y 1:请求成功 0:请求失败
return_msg string(32) Y 返回消息
bank string(32) Y 银行名称
sign string(32) Y 数据签名 详见签名算法

未查询到银行名称则返回 "not found"

该接口请求频率为50次/分


演示代码:

// 引入 payjs.class.php
// 项目地址:https://github.com/payjs-cn/phpsdk

include("payjs.class.php");

$mchid = '123456';
$key = 'xxxxxx';

$data = [
    "mchid" => $mchid,
    "bank" => 'XXX',
];

$payjs = new Payjs($mchid, $key);
$result = $payjs->bank($data);

print_r($result);
# !/usr/bin/env Python3
# -*- coding: utf-8 -*-

import requests
import hashlib
from urllib.parse import urlencode,unquote
'''
银行编码查询
'''
mchid = ''    # PAYJS 商户号
bank = ''     # 银行简写
key = ''      # 填写通信密钥

order = {
    'mchid'   : mchid,
    'bank'    : bank
}

# 构造签名函数
def sign(attributes,key):
    attributes_new = {k: attributes[k] for k in sorted(attributes.keys())}
    return hashlib.md5((unquote(urlencode(attributes_new))+'&key='+key)
        .encode(encoding='utf-8')).hexdigest().upper()

order['sign'] = sign(order,key)
request_url = "https://payjs.cn/api/bank"
headers = {'content-type': 'application/x-www-form-urlencoded'}
response = requests.post(request_url, data=order,headers=headers)
if response:
    print(response.json())
package main

import (
    "fmt"
    "strings"
    "net/http"
    "net/url"
    "io/ioutil"
)

func main(){
    data := url.Values{"mchid":{"XXX"}, "bank":{"XXX"}, "sign":{"XXX"}}
    data2 := strings.NewReader(data.Encode())
    resp, err := http.Post("https://payjs.cn/api/bank", "application/x-www-form-urlencoded", data2)
    if err != nil {
        fmt.Println(err)
    }
    defer resp.Body.Close()
    body, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        // handle error
    }

    fmt.Println(string(body))
}
// 项目地址:https://github.com/payjs-cn/demo-nodejs
// 首先引入文件,并在config.js中配置商户号和通信密钥
var cfg = require("./config.js"); 
var pay = require("./pay.js");

//订单关闭接口  
var params = {
    'mchid': cfg.payjsmchid,     //PAYJS 平台订单号
    'bank': "",                 // 银行简称
};
pay.bank(params,function (msg) {
  console.log(msg);
  /**TODO 这里处理业务逻辑 */
});
// 完整代码:https://github.com/payjs-cn/demo-java
public Object Bank() {
    Map<String,String> payData = new HashMap<>();
    payData.put("mchid", PayjsConfig.mchid);
    payData.put("bank", "xxxxxx"); // 银行简称

    // 进行sign签名
    payData.put("sign", sign(payData, PayjsConfig.key));

    // 请求payjs
    String result = HttpsUtils.sendPost(PayjsConfig.bankUrl, JSON.toJSONString(payData),null);

    // 接口返回数据
    return JSON.parseObject(result);
}
// 完整项目地址:https://github.com/payjs-cn/sdk-csharp

Payjs pay = new Payjs("YOUR MCHID", "YOUR KEY");

Dictionary<string, string> param = new Dictionary<string, string>();
param["bank"] = "xxxxxx";

//返回原始json字符串
string jsonString = pay.bank(param);
powered by Gitbook最后更新: 2024-11-11