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/uac/senseless-pay-and-open";
//开发者ID
String appId = "平台分配";
//开发者秘钥
String appKey = "平台分配";
//实例化客户端
ConfigBean configBean = new ConfigBean();
OpenApiContext context = new OpenApiContext();
String request = "{\"requestTimestamp\":\"2023-07-03 15:37:48\",
\"mid\":\"898100054115259\",
\"tid\":\"00000001\",
\"merOrderId\":\"319420230703153748462484\",
\"totalAmount\":\"1\",
\"planId\":\"d2041b5c28474a2c9bb8b70128d71160\",
\"msgId\":\"\",
\"contractType\":\"\",
\"orderDesc\":\"\",
\"srcReserve\":\"\",
\"goods\":\"[{\"goodsId\":\"\",\"goodsName\":\"\",\"quantity\":\"\",\"price\":\"\",\"goodsCategory\":\"\",\"body\":\"\",\"discount\":\"\",\"unit\":\"\"}]\",
\"attachedData\":\"\",
\"notifyUrl\":\"\",
\"systemId\":\"\",
\"custInfo\":\"\",
\"expireTime\":\"\",
\"discountCode\":\"\",
\"invokeScene\":\"\",
\"mchntWxMpAppId\":\"\",
\"mchntWxMpPath\":\"\",
\"ylyxId\":\"\",
\"ylyxName\":\"\",
\"ylyxMerAbbr\":\"\",
\"subOrders\":\"\"}";
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/uac/senseless-pay-and-open";
$data = json_encode(array("requestTimestamp"=>"2023-07-03 15=>37=>48",
"mid"=>"898100054115259",
"tid"=>"00000001",
"merOrderId"=>"319420230703153748462484",
"totalAmount"=>"1",
"planId"=>"d2041b5c28474a2c9bb8b70128d71160",
"msgId"=>"",
"contractType"=>"",
"orderDesc"=>"",
"srcReserve"=>"",
"goods"=>"json_encode(array([{"goodsId"=>"","goodsName"=>"","quantity"=>"","price"=>"","goodsCategory"=>"","body"=>"","discount"=>"","unit"=>""}]))",
"attachedData"=>"",
"notifyUrl"=>"",
"systemId"=>"",
"custInfo"=>"",
"expireTime"=>"",
"discountCode"=>"",
"invokeScene"=>"",
"mchntWxMpAppId"=>"",
"mchntWxMpPath"=>"",
"ylyxId"=>"",
"ylyxName"=>"",
"ylyxMerAbbr"=>"",
"subOrders"=>""));
$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/uac/senseless-pay-and-open"
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\":\"2023-07-03 15:37:48\",
\"mid\":\"898100054115259\",
\"tid\":\"00000001\",
\"merOrderId\":\"319420230703153748462484\",
\"totalAmount\":\"1\",
\"planId\":\"d2041b5c28474a2c9bb8b70128d71160\",
\"msgId\":\"\",
\"contractType\":\"\",
\"orderDesc\":\"\",
\"srcReserve\":\"\",
\"goods\":\"[{\"goodsId\":\"\",\"goodsName\":\"\",\"quantity\":\"\",\"price\":\"\",\"goodsCategory\":\"\",\"body\":\"\",\"discount\":\"\",\"unit\":\"\"}]\",
\"attachedData\":\"\",
\"notifyUrl\":\"\",
\"systemId\":\"\",
\"custInfo\":\"\",
\"expireTime\":\"\",
\"discountCode\":\"\",
\"invokeScene\":\"\",
\"mchntWxMpAppId\":\"\",
\"mchntWxMpPath\":\"\",
\"ylyxId\":\"\",
\"ylyxName\":\"\",
\"ylyxMerAbbr\":\"\",
\"subOrders\":\"\"})
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/uac/senseless-pay-and-open - 测试环境:
POST
https://test-api-open.chinaums.com/v1/netpay/uac/senseless-pay-and-open
描述:支付并签约
ContentType:HTTP(S)
请求头
名称 | 必填 | 描述 | 示例值 |
---|---|---|---|
Authorization | 是 | 认证内容(认证参考天满开发者中心->接入指引->平台认证方式:开发者中心 ) |
请求参数
名称 | 类型 | 必填 | 最大长度 | 描述 | 示例值 |
---|---|---|---|---|---|
requestTimestamp | string | 是 | 报文请求时间 格式yyyy-MM-dd HH:mm:ss | 2023-07-03 15:37:48 | |
mid | string | 是 | 8..32 | 商户号 | 898100054115259 |
tid | string | 是 | 2..32 | 终端号 | 00000001 |
merOrderId | string | 是 | 6..32 | 商户订单号 | 319420230703153748462484 |
totalAmount | Number | 是 | 1 | 支付总金额 单位分 | 1 |
planId | string | 是 | 32 | 银联无感支付签约模板ID | d2041b5c28474a2c9bb8b70128d71160 |
msgId | string | 否 | <=64 | 消息ID | |
contractType | string | 否 | <=48 | 签约类型 不传默认为NONE NONE:普通消费 COMPULSORY:支付并强制开通免密支付 OPTIONAL:支付并可选 | |
orderDesc | string | 否 | <=255 | 订单描述 | |
srcReserve | string | 否 | 请求系统预留字段 | ||
goods | array | 否 | 商品信息 | ||
goodsId | string | 否 | ⇐64 | 商品ID | |
goodsName | string | 否 | ⇐256 | 商品名称 | |
quantity | number | 否 | 1..1000000 | 商品数量 | |
price | number | 否 | 1..1000000 | 商品单价(分) | |
goodsCategory | string | 否 | ⇐64 | 商品分类 | |
body | string | 否 | ⇐1024 | 商品说明 | |
discount | string | 否 | 1..1000000 | ||
unit | string | 否 | ⇐32 | ||
attachedData | string | 否 | ⇐128 | 商户附加数据 | |
notifyUrl | string | 否 | ⇐255 | 签约结果通知地址 | |
systemId | string | 否 | ⇐32 | 系统ID | |
custInfo | string | 否 | ⇐256 | 客户信息 包括证件类型、证件号、姓名字段, 格式如下:{certifTp=值&certifId=值&customerNm=值},整体做Base64编码。 其中certifTp证件类型取值: 01:身份证 02:军官证 03:护照 04:港澳居民来往内地通行证; 05: 台湾居民来往大陆通行证; 06:警官证 07:士兵证 09:外国护照 12:港澳居民居住证 13:台湾居民居住证 99:其它证件 | |
expireTime | string | 否 | 64 | 订单过期时间 订单过期时间,为空则使用系统默认过期时间(30分钟),格式yyyy-MM-dd HH:mm:ss | |
discountCode | string | 否 | - | 优惠码 云闪付优惠码 | |
invokeScene | string | 否 | - | 交易发起场景 01:app 03:小程序 04:公众号 缺省值为01 | |
mchntWxMpAppId | string | 否 | - | 商户微信appId 商家的微信小程序或公众号的appId,交易发起场景为小程序或公众号时必填。 | |
mchntWxMpPath | string | 否 | - | 商户小程序path 用于签约完成/失败/取消后使用微信接口navigateToMiniProgram跳转,不上送则使用navigateBackMiniProgram接口返回上一个小程序 | |
ylyxId | string | 否 | 5-15 | 银联营销代码 | |
ylyxName | string | 否 | 40 | 银联营销名称 | |
ylyxMerAbbr | string | 否 | 16 | 银联营销二级子商户简称 | |
subOrders | string | 否 | 子订单信息 在传分账标记的情况下,若传子商户号,子商户分账金额必传,即ubOrders每个元素的mid和totalAmount非空 且 mid不超过20个。(分账方案subOrders里子商户分账总额+platformAmount要与支付总额totalAmount相等)。 | ||
mid | string | 否 | 8-32 | 子商户号 | |
merOrderId | string | 否 | 6-32 | 商户子订单号 | |
totalAmount | string | 否 | 100000000 | 子商户分账金额 |
响应示例
{
"errCode":"",
"errMsg":"",
"responseTimeStamp":"",
"mid":"",
"tid":"",
"merOrderId":"",
"totalAmount":0,
"msgId":"",
"seqId":"",
"settleRefId":"",
"targetMid":"",
"srcReserve":"",
"attachedData":"",
"status":"",
"connectSys":"",
"targetSys":"",
"targetStatus":"",
"relateSsn":"",
"orderCrtTime":"",
"cqpMpAppId":"",
"cqpMpPath":""
}
响应参数
名称 | 类型 | 必填 | 最大长度 | 描述 | 示例值 |
---|---|---|---|---|---|
errCode | string | 是 | <=64 | 错误代码 平台错误码 业务错误码 |
|
errMsg | string | 否 | <=255 | 错误信息 | |
responseTimeStamp | Date | 是 | 报文应答时间 格式yyyy-MM-dd HH:mm:ss | ||
mid | string | 是 | 8..32 | 商户号 | |
tid | string | 是 | 2..32 | 终端号 | |
merOrderId | string | 是 | 6..32 | 商户订单号 | |
totalAmount | number | 是 | 1..1000000 | 订单金额,单位分 | |
msgId | string | 否 | <=64 | 消息ID | |
seqId | string | 否 | 平台流水号 类似检索参考号 | ||
settleRefId | string | 否 | 清分ID 如果来源方传了bankRefId就等于bankRefId,否则等于seqId | ||
targetMid | string | 否 | 支付渠道商户号 各渠道情况不同,酌情转换 | ||
srcReserve | string | 否 | ⇐255 | 请求系统预留字段 | |
attachedData | string | 否 | ⇐128 | 商户附加数据 | |
status | string | 否 | 交易状态 | ||
connectSys | string | 否 | 链接系统 | ||
targetSys | string | 否 | 目标平台代码 | ||
targetStatus | string | 否 | 目标平台状态 | ||
relateSsn | string | 否 | ⇐32 | 银联受理订单号 商户调用支付控件时使用 | |
orderCrtTime | string | 否 | - | 订单创建时间 格式:yyyy-MM-dd HH:mm:ss 对应银联交易的报文请求时间,查询签约结果时使用 | |
cqpMpAppId | string | 否 | - | 云闪付小程序appId 云闪付小程序id 交易发起场景03/04,必传 用于商户跳转进行签约 | |
cqpMpPath | string | 否 | - | 云闪付小程序path 交易发起场景03/04,必传 用于商户跳转进行签约 |