Skip to content

上传出租车电子发票文件

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

js
const { 
createReadStream
} =
require
('fs')
const {
basename
} =
require
('path')
const
localFilePath
= '/path/to/merchant-invoice-file.pdf'
const
stream
=
createReadStream
(
localFilePath
)
const
meta
= {
company_mchid
,
region_id
,
digest_algorithm
: 'DIGEST_ALGORITHM_SM3',
digest
: 'from upstream or local calculated',
} const
media
= {
meta
:
JSON
.
stringify
(
meta
),
file
:
stream
,
}
wxpay
.
v3
.
taxiInvoice
.
cards
.
uploadFile
.
post
(
media
, {
meta
,
headers
: { 'Content-Type': 'multipart/form-data' },
}) .
then
(
({
data
: {
fapiao_media_id
,
}, }) => ({
fapiao_media_id
,
}) )

参阅 官方文档

Released under the MIT License. (SITEMAP)