Skip to content

上传出租车电子发票文件

服务商调用插卡接口前,需调用本接口上传出租车电子发票文件来获取文件ID。文件ID有效期为3天,有效期内未成功调用插卡接口需重新调用本接口上传发票文件。

请求参数类型描述
bodyobjectmultipart/form-data 数据结构
fileobject出租车电子发票文件。文件支持PDF、JPG、BMP、PNG格式,文件大小不能超过5M
metastring媒体文件元信息,使用json表示
company_mchidstring出租车经营主体商户号
region_idnumber行政区划代码
digeststring文件的SM3摘要
digest_algorithmstring文件摘要算法 DIGEST_ALGORITHM_SM3枚举值
php
$media = new \WeChatPay\Util\MediaUtil('file:///path/to/fapiao.pdf');
$meta = [
  'company_mchid'    => 'your_sub_mchid', //服务商模式下必传
  'region_id'        => 310100,
  'digest_algorithm' => 'DIGEST_ALGORITHM_SM3',
  'digest'           => 'your_fapiao_pdf_sm3_string',
];
$media->setMeta(\json_encode($meta));

$instance->v3->taxiInvoice->cards->uploadFile->postAsync([
  'body' => $media->getStream(),
  'headers' => [
    'Content-Type' => $media->getContentType(),
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$media = new \WeChatPay\Util\MediaUtil('file:///path/to/fapiao.pdf');
$json  = [
  'company_mchid'    => 'your_sub_mchid', //服务商模式下必传
  'region_id'        => 310100,
  'digest_algorithm' => 'DIGEST_ALGORITHM_SM3',
  'digest'           => 'your_fapiao_pdf_sm3_string',
];
$media->setMeta(\json_encode($json));

$instance->chain('v3/taxi-invoice/cards/upload-file')->postAsync([
  'body' => $media->getStream(),
  'headers' => [
    'Content-Type' => $media->getContentType(),
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$media = new \WeChatPay\Util\MediaUtil('file:///path/to/fapiao.pdf');
$json  = [
  'company_mchid'    => 'your_sub_mchid', //服务商模式下必传
  'region_id'        => 310100,
  'digest_algorithm' => 'DIGEST_ALGORITHM_SM3',
  'digest'           => 'your_fapiao_pdf_sm3_string',
];
$media->setMeta(\json_encode($json));

$instance['v3/taxi-invoice/cards/upload-file']->postAsync([
  'body' => $media->getStream(),
  'headers' => [
    'Content-Type' => $media->getContentType(),
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$media = new \WeChatPay\Util\MediaUtil('file:///path/to/fapiao.pdf');
$json  = [
  'company_mchid'    => 'your_sub_mchid', //服务商模式下必传
  'region_id'        => 310100,
  'digest_algorithm' => 'DIGEST_ALGORITHM_SM3',
  'digest'           => 'your_fapiao_pdf_sm3_string',
];
$media->setMeta(\json_encode($json));

$response = $instance->v3->taxiInvoice->cards->uploadFile->post([
  'body' => $media->getStream(),
  'headers' => [
    'Content-Type' => $media->getContentType(),
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$media = new \WeChatPay\Util\MediaUtil('file:///path/to/fapiao.pdf');
$json  = [
  'company_mchid'    => 'your_sub_mchid', //服务商模式下必传
  'region_id'        => 310100,
  'digest_algorithm' => 'DIGEST_ALGORITHM_SM3',
  'digest'           => 'your_fapiao_pdf_sm3_string',
];
$media->setMeta(\json_encode($json));

$response = $instance->chain('v3/taxi-invoice/cards/upload-file')->post([
  'body' => $media->getStream(),
  'headers' => [
    'Content-Type' => $media->getContentType(),
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$media = new \WeChatPay\Util\MediaUtil('file:///path/to/fapiao.pdf');
$json  = [
  'company_mchid'    => 'your_sub_mchid', //服务商模式下必传
  'region_id'        => 310100,
  'digest_algorithm' => 'DIGEST_ALGORITHM_SM3',
  'digest'           => 'your_fapiao_pdf_sm3_string',
];
$media->setMeta(\json_encode($json));

$response = $instance['v3/taxi-invoice/cards/upload-file']->post([
  'body' => $media->getStream(),
  'headers' => [
    'Content-Type' => $media->getContentType(),
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典类型描述
fapiao_media_idstring出租车电子发票文件ID

参阅 官方文档

Published on the GitHub by TheNorthMemory