public class OpenApiSdkTest {
public static void main(String[] args) throws Exception{
String url = "https://api-mop.chinaums.com/v1/inip/corporate-wallet/wechat-pay-point/order/create";
//开发者ID
String appId = "平台分配";
//开发者秘钥
String appKey = "平台分配";
//实例化客户端
ConfigBean configBean = new ConfigBean();
OpenApiContext context = new OpenApiContext();
String request = "{\"fenOrderId\":\"\",
\"mid\":\"\",
\"serviceId\":\"\",
\"serviceIntroduction\":\"\",
\"timeRange\":\"{\"startTime\":\"\",\"startTimeRemark\":\"\",\"endTime\":\"\",\"endTimeRemark\":\"\"}\",
\"riskFund\":\"{\"name\":\"\",\"amount\":\"\",\"description\":\"\"}\",
\"notifyUrl\":\"\",
\"tid\":\"\",
\"subAppId\":\"\",
\"postPayments\":\"[{\"name\":\"\",\"amount\":\"\",\"description\":\"\",\"count\":\"\"}]\",
\"postDiscounts\":\"[{\"name\":\"\",\"amount\":\"\",\"description\":\"\",\"count\":\"\"}]\",
\"location\":\"{\"startLocation\":\"\",\"endLocation\":\"\"}\",
\"openId\":\"\",
\"subOpenId\":\"\",
\"needUserConfirm\":\"\",
\"attach\":\"\",
\"vactInfo\":\"{}\"}";
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/inip/corporate-wallet/wechat-pay-point/order/create";
$data = json_encode(array("fenOrderId"=>"",
"mid"=>"",
"serviceId"=>"",
"serviceIntroduction"=>"",
"timeRange"=>"{"startTime"=>"","startTimeRemark"=>"","endTime"=>"","endTimeRemark"=>""}",
"riskFund"=>"{"name"=>"","amount"=>"","description"=>""}",
"notifyUrl"=>"",
"tid"=>"",
"subAppId"=>"",
"postPayments"=>"json_encode(array([{"name"=>"","amount"=>"","description"=>"","count"=>""}]))",
"postDiscounts"=>"json_encode(array([{"name"=>"","amount"=>"","description"=>"","count"=>""}]))",
"location"=>"{"startLocation"=>"","endLocation"=>""}",
"openId"=>"",
"subOpenId"=>"",
"needUserConfirm"=>"",
"attach"=>"",
"vactInfo"=>"{}"));
$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/inip/corporate-wallet/wechat-pay-point/order/create"
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({\"fenOrderId\":\"\",
\"mid\":\"\",
\"serviceId\":\"\",
\"serviceIntroduction\":\"\",
\"timeRange\":\"{\"startTime\":\"\",\"startTimeRemark\":\"\",\"endTime\":\"\",\"endTimeRemark\":\"\"}\",
\"riskFund\":\"{\"name\":\"\",\"amount\":\"\",\"description\":\"\"}\",
\"notifyUrl\":\"\",
\"tid\":\"\",
\"subAppId\":\"\",
\"postPayments\":\"[{\"name\":\"\",\"amount\":\"\",\"description\":\"\",\"count\":\"\"}]\",
\"postDiscounts\":\"[{\"name\":\"\",\"amount\":\"\",\"description\":\"\",\"count\":\"\"}]\",
\"location\":\"{\"startLocation\":\"\",\"endLocation\":\"\"}\",
\"openId\":\"\",
\"subOpenId\":\"\",
\"needUserConfirm\":\"\",
\"attach\":\"\",
\"vactInfo\":\"{}\"})
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/inip/corporate-wallet/wechat-pay-point/order/create - 测试环境:
POST
https://test-api-open.chinaums.com/v1/inip/corporate-wallet/wechat-pay-point/order/create
描述:记录商户创建支付分订单请求参数,转发商户请求至微信,并同步返回给商户
ContentType:application/json
请求头
名称 | 必填 | 描述 | 示例值 |
---|---|---|---|
Authorization | 是 | 认证内容 (认证参考天满开发者中心->接入指引->平台认证方式:开发者中心) | OPEN-BODY-SIG AppId="****",Timestamp="20170606135700",Nonce="99930a147f5353dd8a8f29a5329f37e9",Signature="IPmdGHYCcfN+mto0/02zkwoUF1NT3YqPKaUykMaec1T=" |
请求参数
名称 | 类型 | 必填 | 最大长度 | 描述 | 示例值 |
---|---|---|---|---|---|
fenOrderId | string | 是 | 32 | 支付分订单号 商户订单号由调用方维护 | |
mid | string | 是 | 32 | 商户号 银商商户号 | |
serviceId | string | 是 | 32 | 服务ID 该服务ID有本接口对应产品的权限 | |
serviceIntroduction | string | 是 | 32 | 服务信息 用于介绍本订单所提供的服务 | |
timeRange | object | 是 | 服务时间段 服务时间范围 | ||
startTime | string | 是 | 14 | 服务开始时间 支持三种格式:yyyyMMddHHmmss、yyyyMMdd和OnAccept ● 传入20091225091010表示2009年12月25日9点10分10秒。 ● 传入20091225默认时间为2009年12月25日 ● 传入OnAccept表示用户确认订单成功时间为【服务开始时间】。 根据传入时间精准度进行校验 1)若传入时间精准到秒,则校验精准到秒:【服务开始时间】>【商户调用创建订单接口时间】 2)若传入时间精准到日,则校验精准到日:【服务开始时间】>=【商户调用创建订单接口时间】。 | |
startTimeRemark | string | 否 | 20 | 服务开始时间备注 服务开始时间有填时,可填写服务开始时间备注,不超过20个字符,超出报错处理。 | |
endTime | string | 否 | 14 | 服务结束时间 用户端展示用途,支持两种格式:yyyyMMddHHmmss和yyyyMMdd 传入20091225091010表示2009年12月25日9点10分10秒 传入20091225默认认为时间为2009年12月25日23点59分59秒 | |
endTimeRemark | string | 否 | 20 | 服务结束时间备注 预计服务结束时间备注说明,预计服务结束时间有填时,可填写预计服务结束时间备注,不超过20个字符 | |
riskFund | object | 是 | 订单风险金 订单单风险金信息 | ||
name | string | 是 | 30 | 风险金名称 1.【评估不通过:交押金】模式:由微信支付分指定名称,商户可选择一种: 押金[DEPOSIT]、预付款[ADVANCE]、保证金[CASH_DEPOSIT] (若微信支付分提供的名称,商户均认为不合适,需联系微信支付分新增合适的名称) 2.【评估不通过:拒绝】模式:默认 ESTIMATE_ORDER_COST [预估订单费用] | |
amount | string | 是 | 64 | 风险金额 1.数字,必须>0(单位元) 2.风险金额≤每个服务ID的风险金额上限。 3.当商户优惠字段为空时,付费项目总金额≤风险金额 (未填写金额的付费项目,视为该付费项目金额为0) | |
description | string | 否 | 30 | 风险说明 | |
notifyUrl | string | 是 | 255 | 回调地址 商户接收用户确认订单和付款成功回调通知的地址 | |
tid | string | 是 | 32 | 银商终端号 | |
subAppId | string | 否 | 32 | 子商户公众号ID 子商户商户号,由微信支付生成并下发, need_user_confirm为O时, subOpenid和subAppid必填 | |
postPayments | array | 否 | 后付费项目 后付费项目列表,最多包含100条付费项目,用于用户侧展示与完结订单时的总金额计算创建订单接口: 1. name是选填; 2. 若name非空: amount和description,二者必须填其一,也可同时填写; | ||
name | string | 否 | 20 | 付费项目名称 | |
amount | number | 否 | - | 金额 | |
description | string | 否 | 20 | 计费说明 | |
count | number | 否 | 32 | 付费数量 | |
postDiscounts | array | 否 | 后付费商户优惠 商户优惠列表,最多包含30条商户优惠,用于用户侧展示与完结订单时的总金额计算创建订单接口: 1. name和description是选填,但是要填写的话,须同时填写; | ||
name | string | 否 | 20 | 优惠名称 | |
amount | number | 否 | - | 金额 | |
description | string | 否 | 30 | 优惠说明 | |
count | number | 否 | 32 | 优惠数量 | |
location | object | 否 | 服务位置 服务位置信息 如果传入,用户侧则显示此参数 | ||
startLocation | string | 否 | 50 | 服务开始地点 | |
endLocation | string | 否 | 50 | 服务结束位置 | |
openId | string | 否 | 128 | 从业机构公众号下的用户标识 微信用户在从业机构公众号AppID下的唯一标识;need_user_confirm为O时,openid与sub_openid必须填写并且只能填写一个 | |
subOpenId | string | 否 | 128 | 子商户公众号下的用户标识 微信用户在子商户公众号sub_appid下的唯一标识; need_user_confirm为O时, 1. openid与sub_openid必须填写并且只能填写一个 2. 如果填写了sub_openid,那么sub_appid必填 | |
needUserConfirm | boolean | 否 | - | 是否需要用户确认 O:不需要 M:需要确认 默认值O | |
attach | string | 否 | 256 | 附加数据 可作为自定义参数使用,需要先urlencode后传入,总长度不大于256字符,超出报错处理 | |
vactInfo | object | 否 | 255 | 账户信息 |
响应示例
{
"respCode":"",
"respDesc":"",
"fenOrderId":"",
"serviceId":"",
"mid":"",
"subAppId":"",
"serviceIntroduction":"",
"state":"",
"stateDescription":"",
"postPayments":
[
{
}
],
"postDiscounts":
[
{
}
],
"timeRange":
{
},
"location":
{
},
"riskFund":
{
},
"attach":"",
"notifyUrl":"",
"orderId":"",
"packageData":""
}
响应参数
名称 | 类型 | 必填 | 最大长度 | 描述 | 示例值 |
---|---|---|---|---|---|
respCode | string | 是 | - | 错误码 | |
respDesc | string | 否 | - | 错误信息 | |
fenOrderId | string | 是 | 1-300 | 支付分订单号 | |
serviceId | string | 是 | 32 | 服务ID | |
mid | string | 是 | 32 | 商户号 银商商户号 | |
subAppId | string | 否 | 32 | 子商户公众号ID | |
serviceIntroduction | string | 是 | 20 | 服务信息 | |
state | string | 是 | 32 | 服务订单状态 | |
stateDescription | string | 否 | 32 | 订单状态说明 | |
postPayments | array | 否 | - | 后付费项目 | |
postDiscounts | array | 否 | - | 后付费商户优惠 | |
timeRange | object | 否 | - | 服务时间段 | |
location | object | 否 | - | 服务位置 | |
riskFund | object | 否 | - | 订单风险金 | |
attach | string | 否 | 256 | 附加数据 | |
notifyUrl | string | 否 | 255 | 回调地址 | |
orderId | string | 否 | 64 | 微信支付服务订单号 | |
packageData | string | 否 | 1024 | 跳转微信侧数据包 |