银联商务天满服务平台
Java PHP Python



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 = "/v1/invoice/reverse";
        //开发者ID
        String appId = "平台分配";
        //开发者秘钥
        String appKey = "平台分配";
        //实例化客户端
        ConfigBean configBean = new ConfigBean();
        OpenApiContext context = new OpenApiContext();
        String request = "{\"merchantId\":\"\",
                    \"terminalId\":\"\",
                    \"merOrderDate\":\"\",
                    \"merOrderId\":\"\"}";
        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 = "/v1/invoice/reverse";
        $data = json_encode(array("merchantId"=>"",
                    "terminalId"=>"",
                    "merOrderDate"=>"",
                    "merOrderId"=>""));
        $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 = "/v1/invoice/reverse"

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({\"merchantId\":\"\",
                    \"terminalId\":\"\",
                    \"merOrderDate\":\"\",
                    \"merOrderId\":\"\"})
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/invoice/reverse

描述:红冲发票

ContentType:application/json

请求头

名称 必填 描述 示例值
Authorization 是 认证内容 OPEN-BODY-SIG AppId="****",Timestamp="20170606135700",Nonce="99930a147f5353dd8a8f29a5329f37e9",Signature="IPmdGHYCcfN+mto0/02zkwoUF1NT3YqPKaUykMaec1T="

请求参数

名称 类型 必填 最大长度 描述 示例值
merchantId string 是 64 银商商户号
terminalId string 是 64 银商终端号
merOrderDate string 是 64 格式 yyyyMMdd,建议使用原交易 支付日期
merOrderId string 是 64 建议使用原交易订单号(每笔交易 必须保证唯一,需按照规则生成, 以避免跟其他系统冲突,也避免重 复开票)

响应示例

{
  "resultCode":"",
  "resultMsg":"",
  "responseTimestamp":"",
  "status":"",
  "invoiceMaterial":"",
  "invoiceType":"",
  "invoiceNo":"",
  "invoiceCode":"",
  "checkCode":"",
  "cipherCode":"",
  "issueDate":"",
  "deviceNo":"",
  "merchantName":"",
  "merchantId":"",
  "terminalId":"",
  "merOrderId":"",
  "merOrderDate":"",
  "buyerName":"",
  "buyerTaxCode":"",
  "buyerAddress":"",
  "buyerTelephone":"",
  "buyerBank":"",
  "buyerAccount":"",
  "sellerName":"",
  "sellerTaxCode":"",
  "sellerAddress":"",
  "sellerTelphone":"",
  "sellerBank":"",
  "sellerAccount":"",
  "payee":"",
  "checker":"",
  "drawer":"",
  "remark":"",
  "taxMethod":"",
  "deductionAmount":"0",
  "totalPriceIncludingTax":"0",
  "totalTax":"0",
  "totalPrice":"0",
  "notifyMobileNo":"",
  "notifyEmail":"",
  "qrCode":"",
  "pdfUrl":"",
  "reverseInvoiceNo":"",
  "reverseInvoiceCode":"",
  "reverseCheckCode":"",
  "reverseCipherCode":"",
  "reverseDate":""
}

响应参数

名称 类型 必填 最大长度 描述 示例值
resultCode string 是 64
resultMsg string 是 64
responseTimestamp string 是 64
status string 是 64
invoiceMaterial string 是 64
invoiceType string 是 64
invoiceNo string 是 64
invoiceCode string 是 64
checkCode string 是 64
cipherCode string 是 64
issueDate string 是 64
deviceNo string 是 64
merchantName string 是 64
merchantId string 是 64
terminalId string 是 64
merOrderId string 是 64
merOrderDate string 是 64
buyerName string 是 64
buyerTaxCode string 是 64
buyerAddress string 是 64
buyerTelephone string 是 64
buyerBank string 是 64
buyerAccount string 是 64
sellerName string 是 64
sellerTaxCode string 是 64
sellerAddress string 是 64
sellerTelphone string 是 64
sellerBank string 是 64
sellerAccount string 是 64
payee string 是 64
checker string 是 64
drawer string 是 64
remark string 是 64
taxMethod string 是 64
deductionAmount number 是 64 0
totalPriceIncludingTax number 是 64 0
totalTax number 是 64 0
totalPrice number 是 64 0
notifyMobileNo string 是 64
notifyEmail string 是 64
qrCode string 是 64
pdfUrl string 是 64
reverseInvoiceNo string 是 64 红票的发票号码
reverseInvoiceCode string 是 64 红票的发票代
reverseCheckCode string 是 64 红票的校验码
reverseCipherCode string 是 64 红票的密码区
reverseDate string 是 64 红冲日期

错误码