import com.chinaums.open.api.OpenApiCache;
import com.chinaums.open.api.OpenApiContext;
import com.chinaums.open.api.constants.ConfigBean;
import com.chinaums.open.api.internal.util.http.HttpTransport;
import java.util.UUID;
public class OpenApiSdkTest {
public static void main(String[] args) throws Exception{
String url = "https://api-mop.chinaums.com/v1/netpay/bills/query-qrcode-info";
//开发者ID
String appId = "平台分配";
//开发者秘钥
String appKey = "平台分配";
//实例化客户端
ConfigBean configBean = new ConfigBean();
OpenApiContext context = new OpenApiContext();
String request = "{\"requestTimestamp\":\"2020-02-26 14:13:24\",
\"mid\":\"898340149000005\",
\"qrCodeId\":\"31942002268195125132885377\",
\"msgId\":\"800000000010\",
\"srcReserve\":\"test\",
\"systemId\":\"35325423\"}";
context.setStartTime(System.currentTimeMillis());
context.setRequestId(UUID.randomUUID().toString().replace("-", ""));
context.setOpenServUrl(url.split("/v")[0].concat("/"));
context.setApiServiceUrl(url);
context.setVersion(url.split("/")[3]);
context.setAppId(appId);
context.setAppKey(appKey);
context.setConfigBean(configBean);
context.setServiceCode(url.split("/v")[1].substring(1));
OpenApiCache.getCurrentToken(context);
System.out.println(HttpTransport.getInstance().doPost(context, request));
}
}
<?php
require_once "../utils/Log.php";
require_once "../utils/Tools.php";
require_once "../DefaultOpenApiClient.php";
class DataRequest
{
public $url = "";
public $serviceCode = "";
public $apiVersion ="";
public $needToken = true;
public $needDataTag = false;
public $data;
function __construct($data, $url)
{
$this->data = $data;
$apiVersion = preg_split("/[/]+/s",$url)[2];
$this->apiVersion = $apiVersion;
$serviceCode = strstr($url,$apiVersion);
$this->url = strstr($url,"/".$apiVersion,true);
$this->serviceCode = preg_replace("/^" . preg_quote($apiVersion, "/") . "/", "", $serviceCode);
}
}
class DataDemo{
public function main(){
$appid = "平台分配";
$appkey = "平台分配";
$url = "https://api-mop.chinaums.com/v1/netpay/bills/query-qrcode-info";
$data = json_encode(array("requestTimestamp"=>"2020-02-26 14=>13=>24",
"mid"=>"898340149000005",
"qrCodeId"=>"31942002268195125132885377",
"msgId"=>"800000000010",
"srcReserve"=>"test",
"systemId"=>"35325423"));
$reqiest = new DataRequest($data,$url);
$client = new DefaultOpenApiClient();
$content = $client->execute($reqiest,$appid,$appkey);
$obj = json_decode($content);
print_r($obj->errCode);
print_r($obj->errInfo);
}
}
$p = new DataDemo();
$p->main();
?>
# -*- coding: utf-8 -*-
from webapi.DefaultOpenApiClient import DefaultOpenApiClient
url = "https://api-mop.chinaums.com/v1/netpay/bills/query-qrcode-info"
class DataRequest(object):
def __init__(self, data: dict) -> dict:
self.data = data
self.serviceCode = url[len(url.split("/v")[0])+len(url.split("/")[3])+1: len(url)]
self.apiVersion = url.split("/")[3]
self.needToken = True
self.needDataTag = True
appId="平台分配"
appKey="平台分配"
client = DefaultOpenApiClient(appId, appKey)
cls = DataRequest({\"requestTimestamp\":\"2020-02-26 14:13:24\",
\"mid\":\"898340149000005\",
\"qrCodeId\":\"31942002268195125132885377\",
\"msgId\":\"800000000010\",
\"srcReserve\":\"test\",
\"systemId\":\"35325423\"})
response = client.execute(cls)
print(str(response.get("data")))
print(response.get("errCode"))
print(response.get("errInfo"))
print(response.get("resultCode"))
print(response.get("resultInfo"))
查询二维码静态信息
URL
- 生产环境:
POST
https://api-mop.chinaums.com/v1/netpay/bills/query-qrcode-info - 测试环境:
POST
https://test-api-open.chinaums.com/v1/netpay/bills/query-qrcode-info
描述:对于已经生成的二维码,因为某种原因需要获取二维码中的静态信息,在该使用场景下,可以使用该接口来查询已经生成二维码的静态信息。 接口使用限制:* 需保证查询二维码静态信息的消息来源与二维码中的原信息一致;* 该接口仅针对机构模式,其他模式无法使用;
ContentType:HTTP(S) + JSON
请求头
名称 | 必填 | 描述 | 示例值 |
---|---|---|---|
Authorization | 是 | 认证内容 (认证参考天满开发者中心->接入指引->平台认证方式:开发者中心) | OPEN-BODY-SIG AppId="****",Timestamp="20170606135700",Nonce="99930a147f5353dd8a8f29a5329f37e9",Signature="IPmdGHYCcfN+mto0/02zkwoUF1NT3YqPKaUykMaec1T=" |
请求参数
名称 | 类型 | 必填 | 最大长度 | 描述 | 示例值 |
---|---|---|---|---|---|
requestTimestamp | string | 是 | - | 报文请求时间 格式:yyyy-MM-dd HH:mm:ss | 2020-02-26 14:13:24 |
mid | string | 是 | 15 | 商户号 | 898340149000005 |
qrCodeId | string | 是 | 32 | 二维码ID | 31942002268195125132885377 |
msgId | string | 否 | 64 | 消息ID 原样返回 | 800000000010 |
srcReserve | string | 否 | 255 | 请求系统预留字段 | test |
systemId | string | 否 | 32 | 系统ID | 35325423 |
响应示例
{
"errCode":"SUCCESS",
"requestTimestamp":"2020-02-26 14:16:20",
"mid":"898340149000005",
"tid":"00000001",
"instMid":"QRPAYDEFAULT",
"merName":"测试商户",
"qrCodeUrl":"https://qr-test2.chinaums.com/bills/qrCode.do?id=31942002268195125132885377",
"errMsg":"查询二维码静态信息成功",
"msgId":"800000000010",
"srcReserve":"test",
"billNo":"10A31689733046250",
"billDate":"2020-02-26",
"billDesc":"test create qrCode",
"totalAmount":"2",
"goods":
[
{
"goodsId":"001",
"goodsName":"鸡蛋",
"quantity":"1",
"price":"1",
"goodsCategory":"food meterial",
"body":"two eggs"
}
],
"memberId":"20200226001",
"counterNo":"02",
"expireTime":"2030-02-26 13:51:25",
"notifyUrl":"http://www.test.com/notify",
"returnUrl":"http://www.test.com/return",
"installmentNumber":"12"
}
响应参数
名称 | 类型 | 必填 | 最大长度 | 描述 | 示例值 |
---|---|---|---|---|---|
errCode | string | 是 | - | 错误代码 平台错误码 业务错误码 |
SUCCESS |
requestTimestamp | string | 是 | - | 报文请求时间 格式:yyyy-MM-dd HH:mm:ss | 2020-02-26 14:16:20 |
mid | string | 是 | 15 | 商户号 | 898340149000005 |
tid | string | 是 | 8 | 终端号 | 00000001 |
instMid | string | 是 | 32 | 业务类型 QRPAYDEFAULT | QRPAYDEFAULT |
merName | string | 是 | - | 商户名称 | 测试商户 |
qrCodeUrl | string | 是 | - | 二维码 | https://qr-test2.chinaums.com/bills/qrCode.do?id=31942002268195125132885377 |
errMsg | string | 否 | - | 错误说明 | 查询二维码静态信息成功 |
msgId | string | 否 | 64 | 消息ID 原样返回 | 800000000010 |
srcReserve | string | 否 | 255 | 请求系统预留字段 | test |
billNo | string | 否 | 31 | 账单号 重要 | 10A31689733046250 |
billDate | string | 否 | - | 账单日期 格式:yyyy-MM-dd | 2020-02-26 |
billDesc | string | 否 | 255 | 账单描述 不超过128个汉字 | test create qrCode |
totalAmount | number | 否 | 100000000 | 支付总金额 重要,单位:分 | 2 |
goods | array | 否 | 商品信息 详见接口下方备注部分 | ||
goodsId | string | 否 | - | 商品ID | 001 |
goodsName | string | 否 | - | 商品名称 | 鸡蛋 |
quantity | string | 否 | - | 商品数量 | 1 |
price | string | 否 | - | 商品单价,单位:分 | 1 |
goodsCategory | string | 否 | - | 商品分类 | food meterial |
body | string | 否 | - | 商品说明 | two eggs |
memberId | string | 否 | 32 | 会员号 原样返回 | 20200226001 |
counterNo | string | 否 | 32 | 桌号、柜台号、房间号 自定义字段,原样返回 | 02 |
expireTime | string | 否 | - | 账单过期时间,格式yyyy-MM-dd HH:mm:ss | 2030-02-26 13:51:25 |
notifyUrl | string | 否 | - | 支付结果通知地址 | http://www.test.com/notify |
returnUrl | string | 否 | - | 网页跳转地址 | http://www.test.com/return |
installmentNumber | number | 否 | - | 花呗分期数 仅生成二维码时上送了才返 | 12 |