




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
精準票據(jù)識別服務(wù)對接規(guī)范1.概述 42.壓縮與解壓縮 42.1示例代碼 42.1.1Java開發(fā) 42.1.2C++開發(fā) 72.1.3C#開發(fā) 112.2壓縮方法說明 132.3壓縮方法驗證 133.證書加密說明 143.1加解密使用的密鑰說明 143.1.1演示版密鑰使用說明 143.1.2正式版密鑰使用說明 14JAVA開發(fā) 143.2.1Jar包說明 143.2.2方法說明 143.2.3加解密流程說明 163.2.4示例代碼 163.3C++開發(fā) 173.3.1DLL庫說明 173.3.2方法說明 173.3.3加解密流程說明 193.3.4示例代碼 19C#開發(fā) 213.5加解密錯誤碼 214.對接說明 214.1獲取身份令牌 214.1.1請求報文示例與數(shù)據(jù)項說明 224.1.2返回報文示例與數(shù)據(jù)項說明 234.2外層報文說明 244.2.1公共請求參數(shù) 244.2.2公共返回參數(shù) 254.3票種編碼表 264.4票種返回字段列表 264.4.1增值稅專用/普通/電子發(fā)票 264.4.2增值稅卷式發(fā)票 284.4.3機動車銷售統(tǒng)一發(fā)票 294.4.4二手車銷售統(tǒng)一發(fā)票 304.4.5出租車票 324.4.6火車票 334.4.7客運汽車票 334.4.8機票行程單 344.4.9車輛通行費 354.4.10定額發(fā)票 354.4.11其他類型 354.5錯誤碼 365.服務(wù)列表及參數(shù)說明 375.1票據(jù)識別服務(wù) 375.1.1精準票據(jù)識別請求 375.1.2精準票據(jù)識別結(jié)果查詢 386.對接聯(lián)系人 494進行程序開發(fā)。2.壓縮與解壓縮2.1示例代碼1.1Java開發(fā)torgapachecommonscodecbinaryBaseyteArrayInputStreamyteArrayOutputStreamOExceptionnputStreamutputStreamilzipGZIPInputStreamlzipGZIPOutputStreampublicclassGZipUtils{publicstaticintBUFFER1024;publicstaticStringEXT".gz";publicstaticbooleancompress(byte[]data,ByteArrayOutputStreambaos)throwsIOException{yteArrayInputStreambaisnewByteArrayInputStreamdatatry{baoscatch(Exceptione){e.printStackTrace();finally{baisclose}}publicstaticvoidcompress(InputStreamis,OutputStreamos)throwsException{tputStreamgosnewGZIPOutputStreamosbytedatanewbyte[BUFFER];while((count=is.read(data,0,BUFFER))!=-1){ritedatacount}}publicstaticbooleandecompress(byte[]data,ByteArrayOutputStreambaos)throwsIOException{try{ssbaisbaoscatch(Exceptione){ckTracefinally{baisclose}}reamisOutputStreamosthrowsExceptionputStreamgisnewGZIPInputStreamisbytedatanewbyte[BUFFER];while((count=gis.read(data,0,BUFFER))!=-1){os.write(data,0,count);}}publicstaticvoidmain(String[]args)throwsIOException{intiii}SystemoutprintlnstrlengthyteArrayOutputStreambaosnewByteArrayOutputStreamBooleanstrZipReturncompressstrgetBytes,baos);if(false==strZipReturn){tprintln}byteoutputbaos.toByteArray();osflushosclosetrSystemoutprintlnoutputStrlength);ByteArrayOutputStreambaosnewByteArrayOutputStream);BooleanstrReturndecompressstrZipBytebaos;if(false==strReturn){outprintln}bytedata=baos2.toByteArray();aosflushaosclosessagenewStringdataystemoutprintlnstrMessage}}2.1.2C++開發(fā)boolCompressData(INconststring&sSrcData,OUTstring&sDstData,string&sErr){nsSrcDatasizeuLongfiDataCnt=compressBound(iOrgLen+1);//壓縮后的最長長度,需要把字符ytefpDstDatanullptrYQAutoPtrBytefPtrDstDatapDstDataiDataCnt);pDstData{}memset(pDstData,0,iDataCnt);BytefpInpuDataBytef*)sSrcData.c_str();tiRltcompresspDstDataiDataCntpInpuDataiOrgLenboolbRltfalse;ingsTmp{NDTbRlttrue;eakErrsTmptostringiRltZERRNObRltfalse;eakRRORsErrsTmptostringiRltZSTREAMERROR";bRltfalse;eakORsErrsTmptostringiRltZDATAERRORbRltfalse;eakRsErrsTmptostringiRltZMEMERRORbRltfalse;eakORsErrsTmptostringiRltZBUFERROR;bRltfalse;eakERRORsErrsTmptostringiRltZVERSIONERROR;bRltfalse;eakbRltfalse;eak}{ntintiBaseLeniDataCnt2;unsignedcharpBaseDatanullptr;YQAutoPtrunsignedcharAutoPtrpBaseData,iBase64Len);rpBaseData{}memset(pBase64Data,0,iBase64Len);memcpy(pBase64Data,pDstData,iDataCnt);BaseEncodepBase4Data,mLen);signcharpBaseData}}rcDataintiOrgnLenOUTstringsDstDatastring{{sErr確";}intiDcdDataLen=0;char*pDcdData=nullptr;intiSrcDataLensSrcDatalength+1;YQAutoPtrcharPtrDcdDatapDcdDataiSrcDataLen;DcdData{}memset(pDcdData,0,iSrcDataLen);memcpy(pDcdData,sSrcData.c_str(),iSrcDataLen);BaseDecodepDcdData&iDcdDataLen);intiDeBsLenstrlenpDcdData)+1;BytefpBSrcData(Bytef*)pDcdData;ytefpDstDatanullptrYQAutoPtrBytefPtrDstDatapDstDataiOrgnLen+1);pDstData{}memset(pDstData,0,iOrgnLen+1);uLongfiDstLen=iOrgnLen+1;ntiRltuncompresspDstDataiDstLenpBSrcDataiDcdDataLenboolbRltfalse;ringsTmp{NDTgncharpDstDatabRlttrue;eaksErrsTmptostringiRltZERRNObRltfalse;eakRRORsErrsTmptostringiRltZSTREAMERROR;bRltfalse;eakORsErrsTmptostringiRltZDATAERRORbRltfalse;eakRsErr=sTmp+to_string(iRlt)+",Z_MEM_ERROR";bRltfalse;eakORsErr=sTmp+to_string(iRlt)+",Z_BUF_ERROR";bRltfalse;eakERRORsErr=sTmp+to_string(iRlt)+",Z_VERSION_ERROR";bRltfalse;eakbRltfalse;eak}}2.1.3C#開發(fā)CAencrypt{{alconststringNameZlibzlibdllnalconststringNameZlibzlibdllernalstaticboolIsIntPtrSizetnsiprivatestaticexternintcompress_32(byte[]dest,refSystem.UInt32destLen,bytesource,System.UInt32sourceLen);tSetAnsiBytesourceSystemUInt2sourceLen);tnsiprivatestaticexternintcompress64(byte[]dest,refSystem.UInt32destLen,byte]source,System.UInt32sourceLen);trSetAnsiBytesourceSystemUInt2sourceLen);[DllImport(NameZlib32,EntryPoint="compressBound",ExactSpelling=true,CharSetCharSetAnsiCallingConventionCallingConvention.StdCall)]publicstaticexternSystemUInt2compressBound_32(System.UInt32lLength);[DllImport(NameZlib64,EntryPoint="compressBound",ExactSpelling=true,CharSetCharSetAnsiCallingConventionCallingConvention.StdCall)]publicstaticexternSystemUInt32compressBound_64(System.UInt32lLength);{bytearrBufSrc=Encoding.UTF8.GetBytes(value);SystemUIntnBufSrcSystemUIntarrBufSrcLengthDst{fDstcompressBoundnBufSrc}{fDstcompressBoundnBufSrc}compressarrBufDstrefnBufDstarrBufSrcnBufSrc}{compressarrBufDstrefnBufDstarrBufSrcnBufSrc}//Compress(byteArray,byteArray.Length,reftmpArray,refaa);ifiRtn{ArrayCopyarrBufDst,arrDstAct,nBufDst);rtToBaseStringarrDstAct}}publicstaticstringzlibDecompressstringstrSource){{temUIntsourceLenSystemUIntBufferSourceLengthSystemUIntdestLen00;byteBufferByteDest=newbyte[destLen];Source==uncompress_32(BufferByteDest,SourceifiRtn{bytearrDstActnewbyte[destLen];ArrayCopy(BufferByteDest,arrDstAct,destLen);stringstrRe=System.Text.Encoding.UTF8.GetString(BufferByteDest,0,ferByteDestLengthtrReTrim}iRtn{return壓縮后的內(nèi)容";}}}2.2壓縮方法說明(1)壓縮與解壓縮的函數(shù)需要配對使用;UTF)→CA加密→壓縮→Base64編碼;Base解壓縮→CA解密→內(nèi)層報文(明文,UTF-8格式)。2.3壓縮方法驗證(1)壓縮前報文(UTF-8格式):(2)壓縮后報文(經(jīng)過Base64編碼)HsIAAAAAAAAADMfLJrvMVfUrHavEhOToCiuFghMSFISUVziJLSBAKG4N+0rAAAA用戶可以用上面壓縮前、壓縮后的報文在自己的壓縮、解壓縮函數(shù)上進行測試,如果結(jié)果與上面的一致,則說明3.證書加密說明3.1加解密使用的密鑰說明3.1.1演示版密鑰使用說明公(1)演示版調(diào)用方公鑰:CLIENT_DECRYPTCER=YS01TEST.cer(2)演示版調(diào)用方私鑰:CLIENT_DECRYPTPFX=YS01TEST.pfx密碼:CLIENT_DECRYPTPFX_KEY=szeNe6kEb5cer3.1.2正式版密鑰使用說明在正式環(huán)境中,平臺商注冊成功后,會通過郵件方式獲取到正式版調(diào)用方公鑰、正式版調(diào)用方私鑰和正式版調(diào)用3.2.1Jar包說明Jar中的核心類是CaApi,封裝了加解密的算法實現(xiàn)。3.2.2方法說明加密并簽名方法archar是是archar是archar是是false為測試,要使用測是解密并驗簽方法archar是是archar是是是false為測試,要使用測archar是3.2.3加解密流程說明A3.2.4示例代碼publicstaticvoidmain(String[]args){rintiii{try{byteclientPfx=FileUtils.readFileToByteArray(newetPropertyAddressCLIENTDECRYPTPFXbyteclientCer=FileUtils.readFileToByteArray(newegetPropertyAddressCLIENTDECRYPTCERentPswgetPropertyCLIENTDECRYPTPFXKEYbyteserverCer=FileUtils.readFileToByteArray(newetPropertyAddressPLATFORMDECRYPTCERbyteserverPfx=FileUtils.readFileToByteArray(newetPropertyAddressPLATFORMDECRYPTPFXverPswgetPropertyPLATFORMDECRYPTPFXKEY公鑰加密byteaCaApi.encrypt7sign(newString(serverCer),clientPfx,SystemoutprintlnnewStringnewBase).encode(a)));戶端的公鑰驗簽gbCaApidecryptchecknewStringclientCerserverPfxe端的公鑰加密bytecCaApi.encrypt7sign(newString(clientCer),serverPfx,SystemoutprintlnnewStringnewBase).encode(c)));公鑰驗簽gdCaApidecryptchecknewStringserverCerclientPfxfalsetemoutprintlnd}xceptione{ackTrace}}}3.3C++開發(fā)3.3.1DLL庫說明3.3.2方法說明加密并簽名方法內(nèi)容是容是容是長度是保護是是是是是解密并驗簽方法內(nèi)容是內(nèi)容是長度是的保護是是是容是EMigCertLen度明文明文長度題題長度列號列號3.3.3加解密流程說明3.3.4示例代碼inintargcTCHARargv{charpSMtrustsNULLpSMencBaseCertNULL*pSM2sigPfx=NULL;enharpSMpasswdcharpSMpasswdcharpSMinDatagfdfdgfdggj098";ataLenstrlenpSMinDatantiFileLenTempif(readFile("trust.txt",NULL,&iFileLenTemp)>0){pSMtrustsnewchar[iFileLenTemp+1];memset(pSM2trusts,0,iFileLenTemp+1);dFiletrusttxtpSMtrustsiFileLenTempreturnif(readFile("test2.cer",NULL,&iFileLenTemp)>0){pSM2encBase64Cert=newchar[iFileLenTemp+1];memset(pSM2encBase64Cert,0,iFileLenTemp+1);readFiletestcerpSMencBaseCertiFileLenTempreturnif(readFile("test2_123456.pfx",NULL,&iFileLenTemp)>0){pSMsigPfxnewchar[iFileLenTemp+1];memset(pSM2sigPfx,0,iFileLenTemp+1);readFiletestpfxpSMsigPfx,&iFileLenTemp);iFileLenTempreturnntrvrszOutDataLensizeofszOutDatarvaisinoPKCSsignedAndEnvelopedMultipSMtrustspSMencBase4Cert,pSM2sigPfx,iSM2sigPfxLen,pSM2passwd,pSM2inData,iSM2inDataLen,\TszOutDataOUTiOutDataLenprintf("aisino_PKCS7_signedAndEnvelopedMultierr:%d\n",rv);noPKCSgetLastErrorprintfLastErrorcodeis:%d\n",rv);returnprintf("aisino_PKCS7_signedAndEnvelopedMultiok!\n");}rszSigCertLensizeofszSigCertszTMOutDatataLensizeofszTMOutDataszSubjectLensizeofszSubjectszSerialLensizeofszSerialrvaisinoPKCSunpackMultiINpSMtrustsINpSMsigPfxINiSM2sigPfxLen,INpSM2passwd,INszOutData,INiOutDataLen,\OUTszSigCertiSigCertLenszTMOutData&iTMOutDataLen,szSubject,ialiSerialLenprintf("aisino_PKCS7_unpackMultierr:%d\n",rv);noPKCSgetLastErrorprintfLastErrorcodeis:%d\n",rv);returnprintf("aisino_PKCS7_unpackMultiok!\n");}turn}3.4C#開發(fā)3.5加解密錯誤碼12試信任鏈或測試證書34證書驗證錯誤(包括過期)56密文不是合格的ca加密密文,檢查是正確ca789文件的公鑰不是一對4.對接說明4.1獲取身份令牌向51發(fā)票開放平臺調(diào)用令牌接口地址獲取access_token,攜帶令牌才可以調(diào)用中臺服務(wù)。有效期24小時,當前token失效或過期才需要申請新的token,請開發(fā)者做好令牌的管理。4.1.1請求報文示例與數(shù)據(jù)項說明{ationCode}請求數(shù)據(jù)項說明1archar是2taxpayerIdarchar是3rminalIdarchar3否4archar是cSHA5Coderchar是6amparchar是yyyyMMddHHmmss格式7archar是:為密metaxpayerIdtelIdsigntypeauthoCodetimestamp拼后轉(zhuǎn)為大寫,4.1.2返回報文示例與數(shù)據(jù)項說明報文示例{token"expires_in":"access_token的過期時長(單位秒)"}返回報文數(shù)據(jù)項說明1archar是2archar是3archar是4是accesstoken的過期時長(單位秒)4.2外層報文說明4.2.1公共請求參數(shù){}是1是Code是是是是SHA是AaceCodezipCodeencryptCodeaccessndatagramsigntype行含有密鑰散列函數(shù)算法,得到結(jié)果作為簽4.2.2公共返回參數(shù){e}1Code1acSHAipCodeencryptCodeaccesstagramsigntype列函數(shù)算法,得到結(jié)果作為簽4.3票種編碼表定額發(fā)票(包含停車票、地鐵票、手撕票等多種定額票據(jù))4.4票種返回字段列表4.4.1增值稅專用/普通/電子發(fā)票sitionmarktmarkblockchain√code√odecandidatescodelastsixderecognizext√市ealiontypetiontypechs√gnizee√e√發(fā)票代碼(發(fā)票右上角)√nize√esize√emachine_code√kayeraddress√payerbankinfo√ayername√payer_tax_id√retaxamount√pretaxamount_recognizeovince省eiptor√s√fo√llertaxid√√t√tdigits√√rk4.4.2增值稅卷式發(fā)票ame√code√市eal√iontype√tiontypechs√machine_codemachine_noe√ayernamepayer_tax_id√retaxamountovince省√ollinvoicecode√rollinvoiceno√√llertaxid√√tntdigits√4.4.3機動車銷售統(tǒng)一發(fā)票nt√ntcapitalizationbuyer_id√buyer_tax_idbuyername√cateno√ext市√√√√d√machine_code√agenumberretaxamount√print_coderintnumberroductionplace√ovince省√s√ccount√llertaxid√me√o√entreceipt√hicleengineno√iclemodel√hiclesalesinvoicecode√hiclesalesinvoiceno√icletypehiclevin√4.4.4二手車銷售統(tǒng)一發(fā)票t√tcapitalization√ioncompany√tioncompanyaddress√tioncompanybankaccount√tioncompanyphone√auction_company_tax_id√uyeraddress√buyer_id√buyername√buyerphone√ext√市√efrom√√d√machine_code√market_address√market_bank_account號√market_name√market_phone√market_tax_id號√es√rintcode√rintno√ovince省gisterno√s√lerid√√√√usedvehiclesales_invoice_code√usedvehicle_sales_invoice_no√iclemodel√icletype√hiclevin√4.4.5出租車票nt√boardingtime√√√d√√√mileage√ovince√√etcode√ketno√waiting_time4.4.6火車票nt√oardinggatenum√estation√d√passenger_id√passenger_infoassengername√urchasetype√√√√√icketinvoiceno√4.4.7客運汽車票t√busticketcode√busticketno√√estation√d√passenger_id√assengername√√time√4.4.8機票行程單tcode√numtransportserialnumber√nt√√code√ernationalflag√no√√charge√CN√√√dtaxespassenger_id√assengername√√4.4.9車輛通行費nt√√√√ighwayflag√d√√ehicletollcode√hicletollno√4.4.10定額發(fā)票nt√ighwayflagd√hicletollcodeehicletollno4.4.11其他類型nt√yerbuyernamebuyer_tax_id√code市√eal√√therinvoicecoderinvoiceno√ovince省√llertaxid√4.5錯誤碼12境,確認無誤再次請求3境,確認無誤再次請求456運維人員7于當前平臺商或者檢查請求編號格式是否正確89式,確認無誤后再次發(fā)送編號,確保票種類型在支持的票種類型范圍內(nèi)5.服務(wù)列表及參數(shù)說明類類5.1票據(jù)識別服務(wù)5.1.1精準票據(jù)識別請求。接口編碼:51fessional.recognition.request/api/v1.0/51fessional.recognition.request1請求報文示例與數(shù)據(jù)項說明{}char是char4否參考“票種編碼表”2返回報文示例與數(shù)據(jù)項說明{}返回報文中datagram數(shù)據(jù)項說明:request_idchar5.1.2精準票據(jù)識別結(jié)果查詢/api/v1.0/51fessional.recognition.query1請求報文示例與數(shù)據(jù)項說明[id]1request_idchar是,2返回報文示例與數(shù)據(jù)項說明{"data":[{ionkeydatevalueetaxamountvalueriptionkeyrollinvoicecodevalueiptionkeyrollinvoicenovalue...]",{}]}返回報文中datagram數(shù)據(jù)項說明:票sitionmarkchar1tmarkchar1blockchainchar1charcodecharodecandidatescharcodelastsixcharderecognizecharxtchar市charealchar1iontypechartiontypechscharcharognizechar期echar8echar8發(fā)票代碼(發(fā)票右charichar碼charescharzecharechar碼charmachine_codecharecharkchar1ayeraddresscharpayerbankinfo號charayernamecharpayer_tax_id號charretaxamountcharpretaxamountrecognchar額ovince省chareiptorcharscharfo號charcharllertaxid號char.char.char5.tchar.ntdigitschar.char.rkchar1.char5amearcharcodear市charealchar1iontypecharptiontypechscharcharcharmachine_codecharmachine_nocharecharayernamecharpayer_tax_idcharretaxamountcharovince省charollinvoicecodecharrollinvoicenocharcharllertaxidcharcharchar5tchartdigitscharchar5ntchartcapitalizationcharbuyer_idcharbuyer_tax_idcharcatenocharcharxtchar市charcharcharcharchardcharchar5machine_codecharagenumberchar8retaxamountcharrintcodecharrintnumbercharroductionplacearovince省arsarcharccountcharcharc
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- YY/T 1860.1-2024無源外科植入物植入物涂層第1部分:通用要求
- 購房補充合同范本
- 城市垃圾處理站承包合同協(xié)議書
- 股權(quán)合伙合同協(xié)議
- 單位實習生勞動合同范本
- 簡易短期借款合同文本
- 度工業(yè)用地使用權(quán)轉(zhuǎn)讓合同書
- 農(nóng)業(yè)技術(shù)合作協(xié)議合同范本
- 軟件租賃與服務(wù)合同
- 校園欺凌心理安全課件
- 中央2025年全國婦聯(lián)所屬在京事業(yè)單位招聘93人筆試歷年參考題庫附帶答案詳解
- CentOS 7系統(tǒng)配置與管理(Linux 試題庫) 習題答案 (楊海艷 第2版)
- 手機直連衛(wèi)星的可用頻率分析
- 部編四下語文《口語交際:轉(zhuǎn)述》公開課教案教學設(shè)計【一等獎】
- 氮氣窒息事故案例經(jīng)驗分享
- 2工藝用水驗證報告
- 原子雜化軌道理論
- 充填開采之 矸石充填術(shù)
- 醫(yī)院醫(yī)療設(shè)備采購流程圖
- 人力外包項目實施方案
- BQB480-2014無取向電工鋼
評論
0/150
提交評論