Skip to content

开具电子发票

商户完成收款后,调用本接口开具电子发票并插入微信用户的卡包。若是非微信支付场景,需要先通过【获取抬头填写链接】接口获取抬头填写链接,并等待用户完成填写才能调用本接口;若是微信支付场景,则无需额外获取抬头填写链接。

请求参数类型描述
jsonobject声明请求的JSON数据结构
sub_mchidstring子商户号
scenestring开票场景
fapiao_apply_idstring发票申请单号
buyer_informationobject购买方信息
typestring购买方类型
namestring名称
taxpayer_idstring纳税人识别号
addressstring地址
telephonestring电话
bank_namestring开户银行
bank_accountstring银行账号
phonestring手机号
emailstring邮箱地址
fapiao_informationobject[]需要开具的发票信息
fapiao_idstring商户发票单号
total_amountinteger总价税合计
need_listboolean是否以清单形式开具发票
remarkstring发票备注
itemsobject[]发票行信息
tax_codestring税局侧规定的货物或应税劳务、服务税收分类编码
goods_categorystring税局侧规定的货物或应税劳务、服务分类名称
goods_namestring货物或应税劳务、服务名称
goods_idnumber企业侧维护的货物或应税劳务、服务编码
specificationstring规格型号
unitstring单位
quantityinteger数量
total_amountinteger单行金额合计
tax_ratenumber税率
tax_prefer_markstring税收优惠政策标识
discountboolean是否折扣行
headersobject声明请求的头参数
Wechatpay-Serialstring平台公钥ID/平台公钥证书序列号
php
$instance->v3->newTaxControlFapiao->fapiaoApplications->postAsync([
  'json' => [
    'sub_mchid' => '1900000109',
    'scene' => 'WITH_WECHATPAY',
    'fapiao_apply_id' => '4200000444201910177461284488',
    'buyer_information' => [
      'type' => 'ORGANIZATION',
      'name' => '深圳市南山区测试企业',
      'taxpayer_id' => '202003261233701778',
      'address' => '深圳市南山区深南大道10000号',
      'telephone' => '075512345678',
      'bank_name' => '测试银行',
      'bank_account' => '62001234567890',
      'phone' => 'pVd1HJ6zyvPedzGaV+X3qtmrq9bb9tPttdY+aQ6zB',
      'email' => 'pVd1HJ6zyvPedzGaV+X3qtmrq9bb9tPttdY+aQ6zB',
    ],
    'fapiao_information' => [[
      'fapiao_id' => '20200701123456',
      'total_amount' => 382895,
      'need_list' => true,
      'remark' => '备注',
      'items' => [[
        'tax_code' => '3010101020203000000',
        'goods_category' => '运输服务',
        'goods_name' => '出租汽车客运服务',
        'goods_id' => 1,
        'specification' => 'A4',
        'unit' => '次',
        'quantity' => 100000000,
        'total_amount' => 429900,
        'tax_rate' => 1300,
        'tax_prefer_mark' => 'NO_FAVORABLE',
        'discount' => true,
      ],],
    ],],
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r($response->getStatusCode() === 202);
})
->wait();
php
$instance->chain('v3/new-tax-control-fapiao/fapiao-applications')->postAsync([
  'json' => [
    'sub_mchid' => '1900000109',
    'scene' => 'WITH_WECHATPAY',
    'fapiao_apply_id' => '4200000444201910177461284488',
    'buyer_information' => [
      'type' => 'ORGANIZATION',
      'name' => '深圳市南山区测试企业',
      'taxpayer_id' => '202003261233701778',
      'address' => '深圳市南山区深南大道10000号',
      'telephone' => '075512345678',
      'bank_name' => '测试银行',
      'bank_account' => '62001234567890',
      'phone' => 'pVd1HJ6zyvPedzGaV+X3qtmrq9bb9tPttdY+aQ6zB',
      'email' => 'pVd1HJ6zyvPedzGaV+X3qtmrq9bb9tPttdY+aQ6zB',
    ],
    'fapiao_information' => [[
      'fapiao_id' => '20200701123456',
      'total_amount' => 382895,
      'need_list' => true,
      'remark' => '备注',
      'items' => [[
        'tax_code' => '3010101020203000000',
        'goods_category' => '运输服务',
        'goods_name' => '出租汽车客运服务',
        'goods_id' => 1,
        'specification' => 'A4',
        'unit' => '次',
        'quantity' => 100000000,
        'total_amount' => 429900,
        'tax_rate' => 1300,
        'tax_prefer_mark' => 'NO_FAVORABLE',
        'discount' => true,
      ],],
    ],],
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r($response->getStatusCode() === 202);
})
->wait();
php
$instance['v3/new-tax-control-fapiao/fapiao-applications']->postAsync([
  'json' => [
    'sub_mchid' => '1900000109',
    'scene' => 'WITH_WECHATPAY',
    'fapiao_apply_id' => '4200000444201910177461284488',
    'buyer_information' => [
      'type' => 'ORGANIZATION',
      'name' => '深圳市南山区测试企业',
      'taxpayer_id' => '202003261233701778',
      'address' => '深圳市南山区深南大道10000号',
      'telephone' => '075512345678',
      'bank_name' => '测试银行',
      'bank_account' => '62001234567890',
      'phone' => 'pVd1HJ6zyvPedzGaV+X3qtmrq9bb9tPttdY+aQ6zB',
      'email' => 'pVd1HJ6zyvPedzGaV+X3qtmrq9bb9tPttdY+aQ6zB',
    ],
    'fapiao_information' => [[
      'fapiao_id' => '20200701123456',
      'total_amount' => 382895,
      'need_list' => true,
      'remark' => '备注',
      'items' => [[
        'tax_code' => '3010101020203000000',
        'goods_category' => '运输服务',
        'goods_name' => '出租汽车客运服务',
        'goods_id' => 1,
        'specification' => 'A4',
        'unit' => '次',
        'quantity' => 100000000,
        'total_amount' => 429900,
        'tax_rate' => 1300,
        'tax_prefer_mark' => 'NO_FAVORABLE',
        'discount' => true,
      ],],
    ],],
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r($response->getStatusCode() === 202);
})
->wait();
php
$response = $instance->v3->newTaxControlFapiao->fapiaoApplications->post([
  'json' => [
    'sub_mchid' => '1900000109',
    'scene' => 'WITH_WECHATPAY',
    'fapiao_apply_id' => '4200000444201910177461284488',
    'buyer_information' => [
      'type' => 'ORGANIZATION',
      'name' => '深圳市南山区测试企业',
      'taxpayer_id' => '202003261233701778',
      'address' => '深圳市南山区深南大道10000号',
      'telephone' => '075512345678',
      'bank_name' => '测试银行',
      'bank_account' => '62001234567890',
      'phone' => 'pVd1HJ6zyvPedzGaV+X3qtmrq9bb9tPttdY+aQ6zB',
      'email' => 'pVd1HJ6zyvPedzGaV+X3qtmrq9bb9tPttdY+aQ6zB',
    ],
    'fapiao_information' => [[
      'fapiao_id' => '20200701123456',
      'total_amount' => 382895,
      'need_list' => true,
      'remark' => '备注',
      'items' => [[
        'tax_code' => '3010101020203000000',
        'goods_category' => '运输服务',
        'goods_name' => '出租汽车客运服务',
        'goods_id' => 1,
        'specification' => 'A4',
        'unit' => '次',
        'quantity' => 100000000,
        'total_amount' => 429900,
        'tax_rate' => 1300,
        'tax_prefer_mark' => 'NO_FAVORABLE',
        'discount' => true,
      ],],
    ],],
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
]);
print_r($response->getStatusCode() === 202);
php
$response = $instance->chain('v3/new-tax-control-fapiao/fapiao-applications')->post([
  'json' => [
    'sub_mchid' => '1900000109',
    'scene' => 'WITH_WECHATPAY',
    'fapiao_apply_id' => '4200000444201910177461284488',
    'buyer_information' => [
      'type' => 'ORGANIZATION',
      'name' => '深圳市南山区测试企业',
      'taxpayer_id' => '202003261233701778',
      'address' => '深圳市南山区深南大道10000号',
      'telephone' => '075512345678',
      'bank_name' => '测试银行',
      'bank_account' => '62001234567890',
      'phone' => 'pVd1HJ6zyvPedzGaV+X3qtmrq9bb9tPttdY+aQ6zB',
      'email' => 'pVd1HJ6zyvPedzGaV+X3qtmrq9bb9tPttdY+aQ6zB',
    ],
    'fapiao_information' => [[
      'fapiao_id' => '20200701123456',
      'total_amount' => 382895,
      'need_list' => true,
      'remark' => '备注',
      'items' => [[
        'tax_code' => '3010101020203000000',
        'goods_category' => '运输服务',
        'goods_name' => '出租汽车客运服务',
        'goods_id' => 1,
        'specification' => 'A4',
        'unit' => '次',
        'quantity' => 100000000,
        'total_amount' => 429900,
        'tax_rate' => 1300,
        'tax_prefer_mark' => 'NO_FAVORABLE',
        'discount' => true,
      ],],
    ],],
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
]);
print_r($response->getStatusCode() === 202);
php
$response = $instance['v3/new-tax-control-fapiao/fapiao-applications']->post([
  'json' => [
    'sub_mchid' => '1900000109',
    'scene' => 'WITH_WECHATPAY',
    'fapiao_apply_id' => '4200000444201910177461284488',
    'buyer_information' => [
      'type' => 'ORGANIZATION',
      'name' => '深圳市南山区测试企业',
      'taxpayer_id' => '202003261233701778',
      'address' => '深圳市南山区深南大道10000号',
      'telephone' => '075512345678',
      'bank_name' => '测试银行',
      'bank_account' => '62001234567890',
      'phone' => 'pVd1HJ6zyvPedzGaV+X3qtmrq9bb9tPttdY+aQ6zB',
      'email' => 'pVd1HJ6zyvPedzGaV+X3qtmrq9bb9tPttdY+aQ6zB',
    ],
    'fapiao_information' => [[
      'fapiao_id' => '20200701123456',
      'total_amount' => 382895,
      'need_list' => true,
      'remark' => '备注',
      'items' => [[
        'tax_code' => '3010101020203000000',
        'goods_category' => '运输服务',
        'goods_name' => '出租汽车客运服务',
        'goods_id' => 1,
        'specification' => 'A4',
        'unit' => '次',
        'quantity' => 100000000,
        'total_amount' => 429900,
        'tax_rate' => 1300,
        'tax_prefer_mark' => 'NO_FAVORABLE',
        'discount' => true,
      ],],
    ],],
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
]);
print_r($response->getStatusCode() === 202);
返回字典类型描述

参阅 官方文档

Published on the GitHub by TheNorthMemory