TF Fiscal

NFC-e 消费者发票

POST/api/nfce/create

开具 NFC-e

开具 NFC-e(模型 65,始终为州内出库,无运输)。与 NFe 端点的主要区别:消费者对象名为 client(不是 cliente);地址号为 client.number;消费者为可选;不存在 impostos.ipi、shipping_address、delivery_address 或 transportation。pag_info 中的金额字段名为 amount。

必需请求头

tokenstringstringNFC-e 企业 token
signstringstringMD5 签名:MD5(token + path + body + timestamp)
timestampstringstringUnix 时间戳(秒,5 分钟窗口)

Body(根)

nature_of_operation*stringstring操作性质(如 "商品销售")
issuance_type*stringstring开具类型:请传 "1"(正常)。
ambiente*stringstring"1" 生产、"2" 测试环境(homologação)。
products*arrayarray商品列表(详见下文)
idstringstring外部标识——写入 xPed,去掉空格并截断为 15 个字符。
ind_presstringstring购买者在场方式:"1" 现场(默认)或 "4" 送货上门——模型 65 下税务局接受的值("5" 场外现场,视州而定)。
ind_intermedstringstring请使用 "0"(无中介)。
total_discount_amountdecimaldecimal发票总折扣。
trocodecimaldecimal找零金额(vTroco)。
segurodecimaldecimal保险金额——按各商品数量(而非金额)比例分摊并逐项四舍五入,合计可能与传入值相差几分
outras_despesasdecimaldecimal其他附加费用——按各商品数量(而非金额)比例分摊并逐项四舍五入,合计可能与传入值相差几分
informacoes_complementaresstringstring给消费者的补充信息
informacoes_fiscostringstring给税务机关的信息
clientobjectobject消费者数据(可选 — 见表格)
pag_infoarrayarray付款(默认:现金、即时付款 — 见表格)

 * 必填字段。category_id 或 impostos 二选一,必填。

返回字段(data)

uuidstringstringNFC-e 内部标识符。
statusstringstring状态:"Success"(已授权)、"Failed"(被拒/失败)、"Contingencia"(离线应急开具,待传输)
motivostringstring税务机关针对 cStat 的文本;
nfceintint已开具的 NFC-e 号码(注意:字段名是 nfce,不是 nfe)
serieintintNFC-e 系列号
chavestringstring44 位访问密钥(未授权时为空)
modelostringstring单据模型:"nfce"
xmlstringstring已授权 XML 的 URL
danfestringstringNFC-e DANFE 的 URL — 开具时为空;
离线应急开具时(税务局不可用时自动启用),返回的 status 为 "Contingencia",并带有额外字段 contingencia: true 和 tpEmis: 9;该发票需要之后传输给税务局。

返回 — 拒绝 / 错误

当税务局拒绝该发票时,success 为 false,data.motivo 给出原因;chave 返回为空。字段校验错误(提交税务局之前)返回 success: false,消息位于 message,且没有 data 对象。
{
  "success": false,
  "data": {
    "uuid": "65f8b9a1c2d3e4f5a6b7c8d9",
    "status": "Failed",
    "motivo": "Rejeição 226: Código da UF do Emitente diverge da UF autorizadora / 拒绝 226: 发件人所在州代码与授权州不一致",
    "nfce": 5,
    "serie": 1,
    "chave": "",
    "modelo": "nfce",
    "xml": "",
    "danfe": ""
  }
}

示例

# sign = md5(token + path + body + timestamp)
# 按接口路径生成的调用模板,占位符替换为实际值
curl -X POST "https://api.tffiscal.com/api/nfce/create" \
  -H "Content-Type: application/json" \
  -H "token: $TOKEN" \
  -H "timestamp: $TIMESTAMP" \
  -H "sign: $SIGN" \
  -d @body.json

NFC-e 完整示例

示例 1 — 现场销售(无收货方)

{
  "nature_of_operation": "Venda de mercadoria",
  "issuance_type": "1",
  "ambiente": "2",
  "ind_pres": "1",
  "products": [
    {
      "codigo": "001",
      "name": "Refrigerante 350ml",
      "ncm": "22021000",
      "count": 3,
      "unit": "UN",
      "unit_price": 5.50,
      "total_price": 16.50,
      "category_id": "TF123",
      "origem": 0,
      "indicador_total": 1
    }
  ],
  "pag_info": [
    { "payment_indicator": "0", "payment_method": "17" }
  ]
}

示例 2 — 送货上门(含收货方)

{
  "nature_of_operation": "Venda de mercadoria",
  "issuance_type": "1",
  "ambiente": "2",
  "ind_pres": "4",
  "client": {
    "cpf": "12345678909",
    "name": "Maria Silva",
    "endereco": "Rua das Flores",
    "number": "456",
    "bairro": "Jardim Primavera",
    "city": "São Paulo",
    "uf": "SP",
    "cep": "04567000"
  },
  "products": [
    {
      "codigo": "PIZZA01",
      "name": "Pizza Grande Marguerita",
      "ncm": "19059090",
      "count": 1,
      "unit": "UN",
      "unit_price": 45.90,
      "total_price": 45.90,
      "category_id": "TF124",
      "origem": 0,
      "indicador_total": 1
    }
  ],
  "pag_info": [
    { "payment_indicator": "0", "payment_method": "03" }
  ],
  "informacoes_complementares": "Entrega em até 40 minutos"
}