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/preauth-cancel";
//开发者ID
String appId = "平台分配";
//开发者秘钥
String appKey = "平台分配";
//实例化客户端
ConfigBean configBean = new ConfigBean();
OpenApiContext context = new OpenApiContext();
String request = "{\"requestTimestamp\":\"2023-07-19 12:03:02\",
\"mid\":\"89844035541APR4\",
\"tid\":\"APR40001\",
\"instMid\":\"QRPAYDEFAULT\",
\"billNo\":\"124F2023071912021792962162\",
\"billDate\":\"2023-07-19\",
\"merOrderId\":\"124F20230719120217929621620\",
\"authIdRespCd\":\"000665\",
\"msgId\":\"\",
\"srcReserve\":\"\"}";
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/preauth-cancel";
$data = json_encode(array("requestTimestamp"=>"2023-07-19 12=>03=>02",
"mid"=>"89844035541APR4",
"tid"=>"APR40001",
"instMid"=>"QRPAYDEFAULT",
"billNo"=>"124F2023071912021792962162",
"billDate"=>"2023-07-19",
"merOrderId"=>"124F20230719120217929621620",
"authIdRespCd"=>"000665",
"msgId"=>"",
"srcReserve"=>""));
$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/preauth-cancel"
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-19 12:03:02\",
\"mid\":\"89844035541APR4\",
\"tid\":\"APR40001\",
\"instMid\":\"QRPAYDEFAULT\",
\"billNo\":\"124F2023071912021792962162\",
\"billDate\":\"2023-07-19\",
\"merOrderId\":\"124F20230719120217929621620\",
\"authIdRespCd\":\"000665\",
\"msgId\":\"\",
\"srcReserve\":\"\"})
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/preauth-cancel - 测试环境:
POST
https://test-api-open.chinaums.com/v1/netpay/bills/preauth-cancel
描述:调用支付接口时未返回明确的返回结果(如由于系统错误或网络异常导致无返回结果),可使用本接口将交易进行撤销。
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 | 2023-07-19 12:03:02 |
mid | string | 是 | 32 | 商户号 | 89844035541APR4 |
tid | string | 是 | 32 | 终端号 | APR40001 |
instMid | string | 是 | - | 业务类型 QRPAYDEFAULT | QRPAYDEFAULT |
billNo | string | 是 | 31 | 账单号 | 124F2023071912021792962162 |
billDate | string | 是 | - | 账单日期 格式:yyyy-MM-dd | 2023-07-19 |
merOrderId | string | 是 | 32 | 预授权订单号 | 124F20230719120217929621620 |
authIdRespCd | string | 是 | 64 | 授权标识应答码 | 000665 |
msgId | string | 否 | 64 | 消息ID 原样返回 | |
srcReserve | string | 否 | 255 | 请求系统预留字段 |
响应示例
{
"errCode":"SUCCESS",
"errMsg":"",
"responseTimestamp":"2023-07-19 12:03:02",
"mid":"89844035541APR4",
"tid":"APR40001",
"billPayment":
{
"merOrderId":"124F20230719120217929621620",
"billBizType":"bills",
"paySeqId":"35311772967N",
"totalAmount":"2100",
"buyerPayAmount":"2100",
"invoiceAmount":"2100",
"discountAmount":"2100",
"buyerId":"",
"buyerUsername":"",
"payDetail":"现金支付21.00元",
"payTime":"2023-07-19 12:02:19",
"settleDate":"2023-07-19",
"status":"TRADE_CLOSED",
"targetOrderId":"16230719433399059491",
"targetSys":"ACP",
"activityIds":""
},
"msgId":"",
"srcReserve":"",
"billNo":"124F2023071912021792962162",
"billDate":"2023-07-19",
"instMid":"QRPAYDEFAULT",
"billQRCode":"",
"billStatus":"CLOSED",
"cardAttr":"CREDIT_CARD"
}
响应参数
名称 | 类型 | 必填 | 最大长度 | 描述 | 示例值 |
---|---|---|---|---|---|
errCode | string | 是 | 64 | 错误代码 平台错误码 业务错误码 |
SUCCESS |
errMsg | string | 否 | 255 | 错误说明 | |
responseTimestamp | string | 是 | - | 报文响应时间 格式:yyyy-MM-dd HH:mm:ss | 2023-07-19 12:03:02 |
mid | string | 是 | - | 商户号 | 89844035541APR4 |
tid | string | 是 | - | 终端号 | APR40001 |
billPayment | object | 是 | 预授权撤销账单信息 | ||
merOrderId | string | 否 | - | 商户订单号 | 124F20230719120217929621620 |
billBizType | string | 否 | - | 账单业务类型 | bills |
paySeqId | string | 否 | - | 交易参考号 | 35311772967N |
totalAmount | number | 否 | - | 账单流水总金额,单位:分 | 2100 |
buyerPayAmount | number | 否 | - | 实付金额 ,单位:分 | 2100 |
invoiceAmount | number | 否 | - | 开票金额 ,单位:分 | 2100 |
discountAmount | number | 否 | - | 折扣金额 ,单位:分 | 2100 |
buyerId | string | 否 | - | 买家ID | |
buyerUsername | string | 否 | - | 买家用户名 | |
payDetail | string | 否 | - | 支付详情 | 现金支付21.00元 |
payTime | string | 否 | - | 支付时间 格式:yyyy-MM-dd HH:mm:ss | 2023-07-19 12:02:19 |
settleDate | string | 否 | - | 结算时间 格式:yyyy-MM-dd | 2023-07-19 |
status | string | 否 | - | 交易状态 | TRADE_CLOSED |
targetOrderId | string | 否 | - | 目标平台单号 | 16230719433399059491 |
targetSys | string | 否 | - | 目标系统 | ACP |
activityIds | string | 否 | - | 微信活动ID | |
msgId | string | 否 | 64 | 消息ID 原样返回 | |
srcReserve | string | 否 | 255 | 请求系统预留字段 | |
billNo | string | 否 | 31 | 账单号 | 124F2023071912021792962162 |
billDate | string | 否 | - | 账单日期 格式:yyyy-MM-dd | 2023-07-19 |
instMid | string | 否 | - | 业务类型 QRPAYDEFAULT | QRPAYDEFAULT |
billQRCode | string | 否 | - | 账单二维码 | |
billStatus | string | 否 | - | 账单状态 | CLOSED |
cardAttr | string | 否 | - | 借贷记标识 DEBIT_CARD(借记卡); CREDIT_CARD(贷记卡) |
CREDIT_CARD |