• 沒有找到結果。

功能介绍

支持9种增值税发票的信息核验,包括增值税专用发票、增值税普通发票、增值税普通 发票(卷式)、增值税电子专用发票、增值税电子普通发票、增值税电子普通发票

(通行费)、二手车销售统一发票、机动车销售统一发票、区块链电子发票,支持返 回票面的全部信息。该接口的使用限制请参见约束与限制,详细使用指导请参见OCR

服务使用简介章节。

说明

● 每份发票每天最多可查验5次。

● 可查验最近5年内(国家税务总局)增值税发票管理系统开具的发票。

调试

您可以在API Explorer中调试该接口。

前提条件

在使用发票验真识别之前,需要您完成服务申请和认证鉴权,具体操作流程请参见开

通服务和认证鉴权章节。

说明

用户首次使用需要先申请开通。服务只需要开通一次即可,后面使用时无需再次申请。如未开通 服务,调用服务时会提示ModelArts.4204报错,请在调用服务前先进入控制台开通服务,并注 意开通服务区域与调用服务的区域保持一致。

URI

POST https://{endpoint}/v2/{project_id}/ocr/invoice-verification

4-108 路径参数

参数 是否必选 说明

endpoint 是 指定承载REST服务端点的服务器域名或IP,不同 服务不同区域的endpoint不同,您可以从终端节

点中获取。

例如,OCR服务在“华北-北京四”区域的

“endpoint”为“ocr.cn-north-4.myhuaweicloud.com”。

project_id 是 项目ID,您可以从获取项目ID中获取。

请求参数

4-109 请求 Header 参数

参数 是否必选 参数类型 描述

X-Auth-Token 是 String 用户Token。

用于获取操作API的权限。获取 Token接口响应消息头中X-Subject-Token的值即为Token。

Content-Type 是 String 发送的实体的MIME类型,参数 值为“application/json”。

4-110 请求 Body 参数

参数 是否必选 参数类

说明

code 是 String 发票代码。

number 是 String 发票号码。

issue_date 是 String 发票日期格式YYYY-MM-DD。

check_cod

e 否 String 校验码后六位。

● 以下种类发票,参数不可为空

增值税普通发票、增值税电子普通发票、

增值税普通发票(卷式)、增值税电子普 通发票(通行费)、区块链电子发票。

● 填写5位校验码 区块链电子发票。

参数 是否必选 参数类 型

说明

subtotal_a

mount 否 String 合计金额(不含税)。

● 以下种类发票,参数不可为空

增值税专用发票、增值税电子专用发票、

机动车销售统一发票、二手车销售统一发 票、区块链电子发票。

● 填写发票合计金额(不含税)

增值税专用发票、增值税电子专用发票、

机动车销售统一发票、区块链电子发票。

● 填写发票车价合计 二手车发票。

响应参数

说明

根据识别的结果,可能有不同的HTTP响应状态码(status code)。例如,200表示API调用成 功,400表示调用失败,详细的状态码和响应参数说明如下。

状态码: 200

4-111 响应 Body 参数

参数 参数类型 描述

result Object 调用成功时表示调用结果。调用失败时无此字 段。

依据发票类型不同,返回参数不同。

增值税发票

含增值税专用发票、增值税普通发票、增值 税普通发票(卷式)、增值税电子专用发 票、增值税电子普通发票、增值税电子普通 发票(通行费)、区块链电子发票。

机动车销售统一发票

二手车销售统一发票

4-112 InvoiceVerificationResult 增值税发票

参数 参数类型 描述

result Object 调用成功时返回的调用结果。

参数 参数类型 描述

type String 发票类型,取值范围:

● 增值税专用发票:vat_special

● 增值税普通发票:vat_normal

● 增值税普通发票(卷式):vat_normal_roll

● 增值税电子专用发票:vat_special_electronic

● 增值税电子普通发票:vat_normal_electronic

● 增值税电子普通发票(通行费):

vat_normal_electronic_toll

● 区块链电子发票:blockchain_electronic

code String 发票代码。

number String 发票号码。

issue_date String 开票日期。

machine_number String 机器编号。

check_code String 校验码。

status String 发票状态,取值范围:

● 正常:valid

● 已作废:invalidated

● 已红冲:reversed subtotal_amount String 合计金额(不含税)。

subtotal_tax String 合计税额。

total String 价税合计(小写)。

total_in_words String 价税合计(大写)。

remarks String 备注。

receiver String 收款人。

issuer String 开票人。

reviewer String 复核人。

buyer_name String 购买方名称。

buyer_id String 购买方纳税人识别号。

buyer_address String 购买方地址、电话。

buyer_bank String 购买方开户行及账号。

seller_name String 销售方名称。

seller_id String 销售方纳税人识别号。

参数 参数类型 描述

seller_address String 销售方地址、电话。

seller_bank String 销售方开户行及账号。

deductible_toll String 通行费发票返回信息:

● Y:可抵扣通行费

● N:不可抵扣通行费 result_code String 取值范围见表4-115。

result_message String 取值范围见表4-115。

items object 发票中包含的消费信息。

name String 货物或应税劳务、服务名称、项目名称(通行 费)。

specification String 规格型号。

unit String 单位。

quantity String 数量。

unit_price String 单价。

amount String 金额。

tax_rate String 税率。

tax String 税额。

license_plate_nu

mber String 车牌号。

vehicle_type String 类型。

start_date String 通行日期起。

end_date String 通行日期止。

4-113 InvoiceVerificationResult 机动车销售统一发票

参数 参数类型 描述

result object 调用成功时返回的调用结果。

type String 发票类型,取值范围:

机动车销售统一发票:motor_vehicle_sales。

code String 发票代码。

number String 发票号码。

issue_date String 开票日期。

参数 参数类型 描述 machine_number String 机器编号。

status String 发票状态,取值范围:

● 正常:valid

● 已作废:invalidated

● 已红冲:reversed subtotal_amount String 不含税价(小写)。

total String 价税合计(小写)。

total_in_words String 价税合计(大写)。

issuer String 开票人。

buyer_name String 购方名称。

buyer_organizati

on_number String 购买方身份证号码/组织机构代码。

buyer_id String 购买方纳税人识别号。

seller_name String 销货单位名称。

seller_id String 销售方纳税人识别号。

seller_phone String 销售方电话。

seller_account String 销售方账号。

seller_address String 销售方地址。

seller_bank String 销售方开户银行。

tax_rate String 税率。

tax String 税额。

tax_authority String 主管税务机关名称。

tax_authority_co

de String 主管税务机关代码。

tax_payment_rec

eipt String 完税凭证号码。

tonnage String 吨位。

seating_capacity String 限乘人数。

vehicle_type String 车辆类型。

brand_model String 厂牌型号。

manufacturing_lo

cation String 产地。

参数 参数类型 描述 quality_certificate String 合格证号。

import_certificate String 进口证明书号。

inspection_numb

er String 商检单号。

engine_number String 发动机号码。

vehicle_identifica

tion_number String 车辆识别代号/车架号码。

result_code String 取值范围见表4-115。

result_message String 取值范围见表4-115。

4-114 InvoiceVerificationResult 二手车销售统一发票

参数 参数类型 描述

result object 调用成功时返回的调用结果。

type String 发票类型,取值范围:

二手车销售统一发票:used_vehicle_sales。

code String 发票代码。

number String 发票号码。

issue_date String 开票日期。

machine_number String 机器编号。

status String 发票状态,取值范围:

● 正常:valid

● 已作废:invalidated

● 已红冲:reversed total String 车价合计(小写)。

total_in_words String 车价合计(大写)。

remarks String 备注。

issuer String 开票人。

buyer_name String 买方单位/个人。

buyer_organizati

on_number String 买单位代码/身份证号码。

buyer_address String 买方单位/个人住址。

参数 参数类型 描述 buyer_phone String 买方电话。

seller_name String 卖方单位/个人。

seller_organizatio

n_number String 卖方单位代码/身份证号码。

seller_address String 卖方单位 /个人住址。

seller_phone String 卖方电话。

vehicle_license_pl

ate_number String 车牌照号。

registration_certif

icate_number String 登记证号。

vehicle_type String 车辆类型。

vehicle_identifica

tion_number String 车辆识别代号/车架号码。

brand_model String 厂牌型号。

transfer_motor_v ehicle_departme nt_name

String 转入地车辆车管所名称。

auction_unit_na

me String 经营,拍卖单位。

auction_unit_add

ress String 经营,拍卖单位地址。

auction_unit_tax_

number String 经营,拍卖单位纳税人识别号。

auction_unit_ban

k_and_account String 开户银行及账号。

auction_unit_pho

ne String 经营,拍卖单位电话。

used_vehicle_mar

ket_name String 二手车市场。

used_vehicle_mar

ket_tax_number String 二手车市场纳税人识别号。

used_vehicle_mar

ket_address String 二手车市场地址。

used_vehicle_mar ket_bank_and_ac count

String 二手车市场开户银行及账号。

参数 参数类型 描述 used_vehicle_mar

ket_phone String 二手车市场电话。

result_code String 取值范围见表4-115。

result_message String 取值范围见表4-115。

4-115 业务状态码 业务状态码

(result_code

描述信息(result_message) 处理方法

1000 The invoice verification information is consistent with the tax authority’s

information.

无需处理,发票验证信息与税务 机关信息一致。

1001 One invoice can be verified for

only five times per day. 超过当天查验次数,请第二天再 查验。

1002 The invoice verification information cannot be found in the tax authority’s information.

被查验发票信息有误,请核对发 票信息是否填写正确。

1003 The invoice verification information is inconsistent with the tax authority’s information.

被查验发票信息有误,请核对发 票信息是否填写正确。

1004 Only invoices issued within the

last five years can be verified. 超过5年的发票不能查验。

1005 Unsupported invoice type. 被查验发票信息有误,请核对发 票信息是否填写正确。

1006 The invoice verification

information is abnormal in the tax authority’s information.

被查验发票信息有误,请核对发 票信息是否填写正确。

1007 This batch of invoices is being

verified. 该批次发票正在核验中,请第二

天再查验。

1008 The request to the invoice verification service provided by the State Taxation

Administration of China timed out.

(国税局)发票查询服务请求超 时,请提交工单咨询

业务状态码

(result_code

描述信息(result_message) 处理方法

1009 Verification request rejected.

Online invoice verification is currently not supported in this region.

(国税局)查验请求被拒绝,此 区域暂未开通线上查验通道

1010 Parameter error. 请检查服务请求参数,是否传入 不必要的参数。

1011 Invalid request. 被查验发票信息有误,请核对发 票信息是否填写正确。

1012 Incorrect parameter length. 请检查服务请求参数,参数长度 有要求,是否超过限制。

1013 The parameter cannot be left

blank. 请检查服务请求参数,必要参数

不能为空。

状态码: 400

4-116 响应 Body 参数

参数 参数类型 描述

error_code String 调用失败时的错误码,具体请参见错误码。

当出现错误码“ModelArts.4204”时,请参考为

什么调用API时提示“ModelArts.4204”?章

节。

调用成功时无此字段。

error_msg String 调用失败时的错误信息。

调用成功时无此字段。

请求示例

说明

● “endpoint”即调用API的请求地址,不同服务不同区域的“endpoint”不同,具体请参见 终端节点。

例如,发票验真服务部署在“华北-北京四”区域的“endpoint”为“ocr.cn-

north-4.myhuaweicloud.com”,请求URL为“https://ocr.cn-north-4.myhuaweicloud.com/v2/{project_id}/ocr/invoice-verification”,“project_id”为 项目ID,获取方法请参见获取项目ID

● 如何获取Token具体操作请参见构造请求。

● 请求示例

POST https://{endpoint}/v2/{project_id}/ocr/invoice-verification Request Header:

Content-Type: application/json

X-Auth-Token:

MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...

Request Body:

{ "code": "031001900000", "number": "12528000", "issue_date": "2020-08-09", "check_code": "000000"

}

● Python3语言请求代码示例(其他语言参照下列示例编写或使用OCR SDK)

# encoding:utf-8 import requests

url = " https://{endpoint}/v2/{project_id}/ocr/invoice-verification"

token = "用户获取得到的实际token值"

headers = {'Content-Type': 'application/json', 'X-Auth-Token': token}

payload = {

"code": "031001900000", "number": "12528000", "issue_date": "2020-08-09", "check_code": "000000"

}

response = requests.post(url, headers=headers, json=payload) print(response.text)

"machine_number": "661xxxxx1000", "check_code": "79xxxxx8040xxxx00000", "status": "valid", "buyer_id": "91xxxxx0192xxxx00", "buyer_address": "",

"buyer_bank": "",

"seller_name": "xxx投资发展有限公司", "seller_id": "913101177858977000",

"seller_address": "xx市xx区xx镇xx路xx号 021-xxxx1000", "seller_bank": "xx银行xx支行310xxxxxxxxx00000000", "deductible_toll": "N",

"tax_rate": "免税",

"result_message": "The invoice verification information is consistent with the tax authority’s information."

} }

成功响应示例(机动车销售统一发票)

成功响应示例(机动车销售统一发票)