登录
退出
首页
开放版图
苏宁有货
商家后台
文档中心
文档中心
API文档
消息中心
平台公告
工单
我的工单
提交工单
控制台
SDK调用示例
suning.govbus.invoice.confirm/
调用示例(JAVA)
复制全部代码
public class InvoiceConfirmTest{ public static void main(String[]args){ String serverUrl = "https://openpre.cnsuning.com/api/http/sopRequest"; String appKey = "你的appKey"; String appSecret = "你的appSecret"; Client client = new DefaultSuningClient(serverUrl, appKey, appSecret); InvoiceConfirmRequest request = new InvoiceConfirmRequest(); ApplyForInvoiceReqDTO applyForInvoiceReqDTO = new ApplyForInvoiceReqDTO(); applyForInvoiceReqDTO.setAddress("江苏省南京市秦淮区法院"); applyForInvoiceReqDTO.setCompanyName("江苏舜天有限公司"); applyForInvoiceReqDTO.setConsigneeMobileNum("17856789012"); applyForInvoiceReqDTO.setConsigneeName("张三"); applyForInvoiceReqDTO.setInvoiceContent("22"); applyForInvoiceReqDTO.setInvoiceType("6"); applyForInvoiceReqDTO.setRegAccount("23235254664336"); applyForInvoiceReqDTO.setRegAdd("江苏省南京市雨花区软件大道舜天集团"); applyForInvoiceReqDTO.setRegBank("453453434534354"); applyForInvoiceReqDTO.setRegTel("18767890345"); applyForInvoiceReqDTO.setTaxNo("32534346637"); applyForInvoiceReqDTO.setTitle("南京苏宁软件有限公司"); request.setApplyForInvoiceReqDTO(applyForInvoiceReqDTO); OrderInfoDTO orderInfoDTO = new OrderInfoDTO(); orderInfoDTO.setGcOrderNo("23423524334"); List
orderInfoDTOList = new ArrayList
(); orderInfoDTOList.add(orderInfoDTO); request.setOrderInfoDTO(orderInfoDTOList); try { request.setCheckParam(true); SuningResponse resp = client.excute(request); System.out.println("请求报文: \n" + resp.getReqParam()); if(resp instanceof InvoiceConfirmResponse){ System.out.println("响应报文: \n" + resp.getBody()); }else{ System.out.println("InvoiceConfirmResponse报错,请检查代码"); } } catch (SuningApiException e) { System.out.println("报错:" + e.getMessage()); } } }
调用示例(PHP)
复制全部代码
require_once(dirname(__FILE__).'/../../SuningSdk.php'); require_once(dirname(__FILE__).'/../../DefaultSuningClient.php'); $req = new InvoiceConfirmRequest(); //赋值…… $applyForInvoiceReqDTO = new ApplyForInvoiceReqDTO(); $applyForInvoiceReqDTO->setAddress("江苏省南京市秦淮区法院"); $applyForInvoiceReqDTO->setCompanyName("江苏舜天有限公司"); $applyForInvoiceReqDTO->setConsigneeMobileNum("17856789012"); $applyForInvoiceReqDTO->setConsigneeName("张三"); $applyForInvoiceReqDTO->setInvoiceContent("22"); $applyForInvoiceReqDTO->setInvoiceType("6"); $applyForInvoiceReqDTO->setRegAccount("23235254664336"); $applyForInvoiceReqDTO->setRegAdd("江苏省南京市雨花区软件大道舜天集团"); $applyForInvoiceReqDTO->setRegBank("453453434534354"); $applyForInvoiceReqDTO->setRegTel("18767890345"); $applyForInvoiceReqDTO->setTaxNo("32534346637"); $applyForInvoiceReqDTO->setTitle("南京苏宁软件有限公司"); $req->setApplyForInvoiceReqDTO($applyForInvoiceReqDTO); $orderInfoDTO = new OrderInfoDTO(); $orderInfoDTO->setGcOrderNo("23423524334"); $req->setOrderInfoDTO(array($orderInfoDTO)); //api入参校验逻辑开关,当测试稳定之后建议设置为 false 或者删除该行 $req -> setCheckParam('true'); $serverUrl = "https://openpre.cnsuning.com/api/http/sopRequest"; $appKey = "你的appKey"; $appSecret = "你的appSecret"; $client = new DefaultSuningClient($serverUrl,$appKey,$appSecret,'json'); $resp = $client -> execute($req); $reqJson = getReqJson($req); print_r("请求报文:\n".$reqJson); print_r("\n返回响应报文:\n".$resp); function getReqJson($req){ $paramsArray = $req -> getApiParams(); if(empty($paramsArray)){ $paramsArray = ''; } $paramsArray = array('sn_request' => array('sn_body' => array( "{$req -> getBizName()}" => $paramsArray ))); return json_encode($paramsArray); }
调用示例(.NET)
复制全部代码
using System; using System.Text; using System.Collections.Generic; using System.Linq; using suning_api_sdk.Logger; using suning_api_sdk; using suning_api_sdk.BizRequest.CustomGovbusRequest; using suning_api_sdk.Models.CustomGovbusModel; using suning_api_sdk.BizResponse.CustomGovbusResponse; using System.Diagnostics; namespace suning_api_sdk_test.CustomGovbusTest { public class InvoiceConfirmTest { public static void Main(string[] args) { SuningLogger.IsLogDebug = true; ISuningClient snClient = new DefaultSuningClient( "https://openpre.cnsuning.com/api/http/sopRequest", "你的appKey", "你的appSecret"); InvoiceConfirmRequest request = new InvoiceConfirmRequest(); InvoiceConfirmApplyForInvoiceReqDTOReq applyForInvoiceReqDTO = new InvoiceConfirmApplyForInvoiceReqDTOReq(); applyForInvoiceReqDTO.address = "江苏省南京市秦淮区法院"; applyForInvoiceReqDTO.companyName = "江苏舜天有限公司"; applyForInvoiceReqDTO.consigneeMobileNum = "17856789012"; applyForInvoiceReqDTO.consigneeName = "张三"; applyForInvoiceReqDTO.invoiceContent = "22"; applyForInvoiceReqDTO.invoiceType = "6"; applyForInvoiceReqDTO.regAccount = "23235254664336"; applyForInvoiceReqDTO.regAdd = "江苏省南京市雨花区软件大道舜天集团"; applyForInvoiceReqDTO.regBank = "453453434534354"; applyForInvoiceReqDTO.regTel = "18767890345"; applyForInvoiceReqDTO.taxNo = "32534346637"; applyForInvoiceReqDTO.title = "南京苏宁软件有限公司"; request.applyForInvoiceReqDTO = applyForInvoiceReqDTO; InvoiceConfirmOrderInfoDTOReq orderInfoDTO = new InvoiceConfirmOrderInfoDTOReq(); orderInfoDTO.gcOrderNo = "23423524334"; List
orderInfoDTOList = new List
(); orderInfoDTOList.Add(orderInfoDTO); request.orderInfoDTO = orderInfoDTOList; Console.WriteLine("请求报文:\n" + request.ToJson()); InvoiceConfirmResponse nqresp = snClient.Execute(request); if(null != nqresp){ Console.WriteLine("返回报文:\n" + nqresp.ToJson()); } } } }
调用示例(PYTHON)
复制全部代码
import suning.api request = suning.api.InvoiceConfirmRequest() domain = "https://openpre.cnsuning.com" appKey = "你的appKey" appSecret = "你的appSecret" request.setDomainInfo(domain,"80") request.setAppInfo(appKey,appSecret) request.applyForInvoiceReqDTO={"taxNo":"32534346637","title":"南京苏宁软件有限公司","consigneeName":"张三","regTel":"18767890345","address":"江苏省南京市秦淮区法院","regAdd":"江苏省南京市雨花区软件大道舜天集团","regAccount":"23235254664336","invoiceType":"6","companyName":"江苏舜天有限公司","regBank":"453453434534354","invoiceContent":"22","consigneeMobileNum":"17856789012"} request.orderInfoDTO=[{"gcOrderNo":"23423524334"}] try: result=request.getResponse() print(result) except Exception as e: print(e)