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/ucp/order";
//开发者ID
String appId = "平台分配";
//开发者秘钥
String appKey = "平台分配";
//实例化客户端
ConfigBean configBean = new ConfigBean();
OpenApiContext context = new OpenApiContext();
String request = "{\"requestTimestamp\":\"2022-04-19 17:28:03\",
\"mid\":\"898201612345678\",
\"tid\":\"88880001\",
\"merOrderId\":\"327M202204141726689725391331\",
\"totalAmount\":\"1\",
\"payerBankNo\":\"\",
\"payerAcctNo\":\"\",
\"payerAcctName\":\"\",
\"payerAcctType\":\"\",
\"subMchntInfo\":\"[{\"mchntName\":\"\",\"mcc\":\"\",\"mid\":\"\",\"certNo\":\"\",\"totalAmount\":\"\",\"goodsActlNum\":\"\",\"goods\":\"[{\"goodsName\":\"\",\"price\":\"\",\"quantity\":\"\",\"totalAmount\":\"\"}]\"}]\",
\"expireTime\":\"\",
\"payerUnionCreditNo\":\"\",
\"sceneCode\":\"\",
\"subMchntActlNum\":\"\",
\"msgId\":\"\",
\"orderDesc\":\"\",
\"srcReserve\":\"\",
\"attachedData\":\"\",
\"notifyUrl\":\"\",
\"systemId\":\"\"}";
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/ucp/order";
$data = json_encode(array("requestTimestamp"=>"2022-04-19 17=>28=>03",
"mid"=>"898201612345678",
"tid"=>"88880001",
"merOrderId"=>"327M202204141726689725391331",
"totalAmount"=>"1",
"payerBankNo"=>"",
"payerAcctNo"=>"",
"payerAcctName"=>"",
"payerAcctType"=>"",
"subMchntInfo"=>"json_encode(array([{"mchntName"=>"","mcc"=>"","mid"=>"","certNo"=>"","totalAmount"=>"","goodsActlNum"=>"","goods"=>"json_encode(array([{"goodsName"=>"","price"=>"","quantity"=>"","totalAmount"=>""}]))"}]))",
"expireTime"=>"",
"payerUnionCreditNo"=>"",
"sceneCode"=>"",
"subMchntActlNum"=>"",
"msgId"=>"",
"orderDesc"=>"",
"srcReserve"=>"",
"attachedData"=>"",
"notifyUrl"=>"",
"systemId"=>""));
$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/ucp/order"
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\":\"2022-04-19 17:28:03\",
\"mid\":\"898201612345678\",
\"tid\":\"88880001\",
\"merOrderId\":\"327M202204141726689725391331\",
\"totalAmount\":\"1\",
\"payerBankNo\":\"\",
\"payerAcctNo\":\"\",
\"payerAcctName\":\"\",
\"payerAcctType\":\"\",
\"subMchntInfo\":\"[{\"mchntName\":\"\",\"mcc\":\"\",\"mid\":\"\",\"certNo\":\"\",\"totalAmount\":\"\",\"goodsActlNum\":\"\",\"goods\":\"[{\"goodsName\":\"\",\"price\":\"\",\"quantity\":\"\",\"totalAmount\":\"\"}]\"}]\",
\"expireTime\":\"\",
\"payerUnionCreditNo\":\"\",
\"sceneCode\":\"\",
\"subMchntActlNum\":\"\",
\"msgId\":\"\",
\"orderDesc\":\"\",
\"srcReserve\":\"\",
\"attachedData\":\"\",
\"notifyUrl\":\"\",
\"systemId\":\"\"})
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
- 生产环境:
POSThttps://api-mop.chinaums.com/v1/netpay/ucp/order - 测试环境:
POSThttps://test-api-open.chinaums.com/v1/netpay/ucp/order
描述:下单
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 | 2022-04-19 17:28:03 | |
| mid | string | 是 | 8..32 | 商户号 | 898201612345678 |
| tid | string | 是 | 2..32 | 终端号 | 88880001 |
| merOrderId | string | 是 | 6..32 | 商户订单号 | 327M202204141726689725391331 |
| totalAmount | string | 是 | 1..100000000 | 支付总金额 单位分 | 1 |
| payerBankNo | string | 是 | <=12 | 付款方开户行行号 | |
| payerAcctNo | string | 是 | <=44 | 付款方账号 Base64编码 | |
| payerAcctName | string | 是 | <=240 | 付款方账号名称 Base64编码 | |
| payerAcctType | string | 是 | <=13 | 付款方账户类型 个人账户上送 “PERSONAL_ACCT”; 企业账户上送“BUSINESS_ACCT” |
|
| subMchntInfo | array | 否 | 二级商户信息展示列表,JSONArray格式,最多4个。 goods为商品展示列表,JSONArray格式,最多4个。 | ||
| mchntName | string | 是 | <=60 | 二级商户名称 | |
| mcc | string | 是 | <=4 | 二级商户mcc | |
| mid | string | 是 | <=15 | 二级商户号 | |
| certNo | string | 是 | <=32 | 二级商户证件编码(统一社会信用代码),base64编码 | |
| totalAmount | number | 是 | <=10000000 | 二级商户商品总金额。单位:分 | |
| goodsActlNum | number | 是 | <=99999 | 二级商户商品种类实际数量 | |
| goods | array | 是 | 商品展示列表 | ||
| goodsName | string | 是 | <=64 | 商品名称 | |
| price | number | 是 | <=10000000 | 商品单价,单位:分 | |
| quantity | number | 是 | <=10000000 | 商品数量 | |
| totalAmount | number | 是 | <=10000000 | 商品总金额,单位:分 | |
| expireTime | string | 否 | - | 格式yyyy-MM-dd HH:mm:ss 默认15天,不得超过15天 | |
| payerUnionCreditNo | string | 否 | <=18 | 付款方社会统一信用代码 | |
| sceneCode | string | 否 | - | 业务场景编码 | |
| subMchntActlNum | string | 否 | <=9999 | 二级商户实际数量 订单交易中涉及的卖家商户的实际数量,最大为9999 | |
| msgId | string | 否 | <=64 | 消息ID | |
| orderDesc | string | 否 | <=96 | 订单描述。中文支持最大32个汉字,英文支持最大64个字符。 | |
| srcReserve | string | 否 | <=96 | 请求系统预留字段。中文支持最大32个汉字,英文支持最大64个字符。 | |
| attachedData | string | 否 | <=128 | 商户附加数据 | |
| notifyUrl | string | 否 | <=255 | 支付结果通知地址 | |
| systemId | string | 否 | <=32 | 系统ID |
响应示例
{
"errCode":"",
"responseTimeStamp":"",
"mid":"",
"tid":"",
"merOrderId":"",
"totalAmount":"",
"errMsg":"",
"msgId":"",
"merName":"",
"seqId":"",
"settleRefId":"",
"targetMid":"",
"srcReserve":"",
"attachedData":"",
"status":"",
"connectSys":"",
"targetSys":"",
"targetStatus":""
}响应参数
| 名称 | 类型 | 必填 | 最大长度 | 描述 | 示例值 |
|---|---|---|---|---|---|
| errCode | string | 是 | <=64 | 错误代码 平台错误码 业务错误码 |
|
| responseTimeStamp | string | 是 | 报文应答时间 格式yyyy-MM-dd HH:mm:ss | ||
| mid | string | 是 | 8..32 | 商户号 原样返回 | |
| tid | string | 是 | 2..32 | 终端号 原样返回 | |
| merOrderId | string | 是 | 6..32 | 商户订单号 | |
| totalAmount | string | 是 | 1..100000000 | 支付总金额 单位分 | |
| errMsg | string | 否 | <=255 | 错误信息 | |
| msgId | string | 否 | <=64 | 消息ID 原样返回 | |
| merName | string | 否 | 商户名称 | ||
| seqId | string | 否 | 平台流水号 类似检索参考号 | ||
| settleRefId | string | 否 | 清分ID 如果来源方传了bankRefId就等于bankRefId,否则等于seqId | ||
| targetMid | string | 否 | 支付渠道商户号 各渠道情况不同,酌情转换 | ||
| srcReserve | string | 否 | 请求系统预留字段 | ||
| attachedData | string | 否 | <=128 | 商户附加数据 | |
| status | string | 否 | 交易状态 | ||
| connectSys | string | 否 | 链接系统 | ||
| targetSys | string | 否 | 目标平台代码 | ||
| targetStatus | string | 否 | 目标平台状态 |
