随着时代潮流的发展,企业也在寻找更加便捷、高效的办公模式,尤其是针对财务工作人员而言,繁琐的发票录入、查验工作占据了财务人员的大部分时间。对此,翔云提供了发票识别接口、发票查验接口,那么企业应当如何将这些接口集成在自己的应用上呢?
其实很简单,开发人员只需要在翔云开发者中心下载所需要的开发语言,更换产品参数便能快速集成,下面,基于Java发票查验接口的开发示例如下:
package com.test;
import okhttp3.*;
import org.json.JSONObject;
import java.io.*;
/**
* 需要添加依赖
*
*
* com.squareup.okhttp3
* okhttp
* 4.12.0
*
*/
class Sample {
static final OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder().build();
public static void main(String []args) throws IOException{
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("key","M***********g")
.addFormDataPart("secret","3***********6")
.addFormDataPart("typeId","3007")
.addFormDataPart("invoiceCode","********")
.addFormDataPart("invoiceNumber","*******")
.addFormDataPart("billingDate","********")
.addFormDataPart("totalAmount","*******")
.addFormDataPart("salesTaxNo","*********")
.addFormDataPart("checkCode","*******")
.addFormDataPart("orderNo","**********")
.build();
Request request = new Request.Builder()
.url("https://netocr.com/verapi/v2/verInvoice.do")
.method("POST", body)
.build();
Response response = HTTP_CLIENT.newCall(request).execute();
System.out.println(response.body().string());
}
}
状态码说明: