登录
退出
首页
开放版图
苏宁有货
商家后台
文档中心
文档中心
API文档
消息中心
平台公告
工单
我的工单
提交工单
控制台
SDK调用示例
suning.selfmarket.electronicinvoice.add/
调用示例(JAVA)
复制全部代码
import com.suning.api.entity.selfmarket.ElectronicinvoiceAddRequest; import com.suning.api.entity.selfmarket.ElectronicinvoiceAddResponse; ElectronicinvoiceAddRequest request = new ElectronicinvoiceAddRequest(); request.setBatchCode("KP202204000000"); InvoiceList invoiceList= new InvoiceList(); invoiceList.setFileType("xml"); invoiceList.setInvoiceContent("JVBERi0xLjcKJeLjz9MKMSAwIG9iago8PC9NZXRhZGF0"); List
invoiceListList =new ArrayList
(); invoiceListList.add(invoiceList); request.setInvoiceList(invoiceListList); request.setSupplierCode("10000007"); //api入参校验逻辑开关,当测试稳定之后建议设置为 false 或者删除该行 request.setCheckParam(true); String serverUrl = "https://openpre.cnsuning.com/api/http/sopRequest"; String appKey = "你的appKey"; String appSecret = "你的appSecret"; DefaultSuningClient client = new DefaultSuningClient(serverUrl, appKey,appSecret, "json"); try { ElectronicinvoiceAddResponse response = client.excute(request); System.out.println("返回json/xml格式数据 :" + response.getBody()); } catch (SuningApiException e) { e.printStackTrace(); }
调用示例(PHP)
复制全部代码
$req = new ElectronicinvoiceAddRequest(); $req -> setBatchCode("KP202204000000"); $invoiceList= new InvoiceList(); $invoiceList-> setFileType("xml"); $invoiceList-> setInvoiceContent("JVBERi0xLjcKJeLjz9MKMSAwIG9iago8PC9NZXRhZGF0"); $req -> setInvoiceList(array($invoiceList)); $req -> setSupplierCode("10000007"); //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); print_r("返回响应报文:".$resp);
调用示例(.NET)
复制全部代码
using suning_api_sdk.BizRequest.CustomSelfmarketRequest; using suning_api_sdk.BizResponse.CustomSelfmarketResponse; using suning_api_sdk.Models.CustomSelfmarketModel; ElectronicinvoiceAddRequest request = new ElectronicinvoiceAddRequest(); request.batchCode="KP202204000000"; ElectronicinvoiceAddInvoiceListReq invoiceList= new ElectronicinvoiceAddInvoiceListReq(); invoiceList.fileType="xml"; invoiceList.invoiceContent="JVBERi0xLjcKJeLjz9MKMSAwIG9iago8PC9NZXRhZGF0"; List
invoiceListList =new ArrayList
(); invoiceListList.add(invoiceList); request.invoiceList=invoiceListList; request.supplierCode="10000007"; //开启日志调试,当测试稳定之后建议设置为 false 或者删除该行 SuningLogger.IsLogDebug = true; string serverUrl = "https://openpre.cnsuning.com/api/http/sopRequest"; string appKey = "你的appKey"; string appSecret = "你的appSecret"; ISuningClient client = new DefaultSuningClient(serverUrl, appKey,appSecret); ElectronicinvoiceAddResponse response = client.Execute(request);
调用示例(PYTHON)
复制全部代码
# -*- coding: utf-8 -*- import suning.api request = suning.api.selfmarket.ElectronicinvoiceAddRequest() request.batchCode="KP202204000000"; request. invoiceList= [{ fileType:"xml", invoiceContent:"JVBERi0xLjcKJeLjz9MKMSAwIG9iago8PC9NZXRhZGF0", }]; request.supplierCode="10000007"; domain = "https://openpre.cnsuning.com" appKey = "你的appKey" appSecret = "你的appSecret" request.setDomainInfo(domain,"80") request.setAppInfo(appKey,appSecret) try: result=request.getResponse() print(result) except Exception as e: print(e)