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

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\":\"\",
                    \"merOrderId\":\"\",
                    \"merOrderDate\":\"\"})
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/query-invoice

描述:发票状态查询

ContentType:application/json

请求头

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

请求参数

名称 类型 必填 最大长度 描述 示例值
merchantId string 64 银商商户号
terminalId string 64 银商终端号
merOrderId string 64 商户订单号
merOrderDate string 64 商户订单日期

响应示例

{
  "resultCode":"",
  "resultMsg":"",
  "responseTimestamp":"",
  "status":"",
  "invoiceMaterial":"",
  "invoiceType":"",
  "invoiceNo":"",
  "invoiceCode":"",
  "checkCode":"",
  "cipherCode":"",
  "issueDate":"",
  "reverseInvoiceNo":"",
  "reverseInvoiceCode":"",
  "reverseCheckCode":"",
  "reverseCipherCode":"",
  "reverseDate":"",
  "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":""
}

响应参数

名称 类型 必填 最大长度 描述 示例值
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
reverseInvoiceNo string 64
reverseInvoiceCode string 64
reverseCheckCode string 64
reverseCipherCode string 64
reverseDate 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

错误码