Skip to content

上传电子发票文件

调用【将电子发票插入微信用户卡包】接口之前,需要先调用本接口上传电子发票文件,获取文件ID。上传的发票文件会在三天后过期,因此上传后请尽快调用【将电子发票插入微信用户卡包】接口执行插入微信用户卡包的操作。 官方文档

js
const { 
Multipart
} =
require
('wechatpay-axios-plugin')
const {
createReadStream
} =
require
('fs')
const {
basename
} =
require
('path')
const
localFilePath
= '/path/to/merchant-invoice-file.pdf'
const
stream
=
createReadStream
(
localFilePath
)
const
media
= new
Multipart
()
.
append
('meta',
JSON
.
stringify
({
sub_mchid
,
file_type
: 'PDF',
digest_alogrithm
: 'SM3',
digest
: 'from upstream or local calculated',
})) .
append
('file',
stream
,
basename
(
localFilePath
))
wxpay
.
v3
.
newTaxControlFapiao
.
fapiaoApplications
.
uploadFapiaoFile
.
post
(
media
)
.
then
(
({
data
: {
fapiao_media_id
,
}, }) => ({
fapiao_media_id
,
}) )

Released under the MIT License. (SITEMAP)