银行编码对应名称查询


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

请求地址: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次/分


演示代码:

<?php
/**
 * 引入 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);

php

<?php
/**
 * 引入 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);

python

# !/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())

go

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))
}

powered by Gitbook最后更新: 2020-07-28