Skip to content

上传电子小票

商户将支付成功回传的参数填入指定字段,可以给指定微信支付订单上传电子小票。 上传成功后,用户可以在账单详情页看到商户上传的电子小票。 官方文档

js
const { 
Multipart
,
Rsa
} =
require
('wechatpay-axios-plugin')
const {
createReadStream
} =
require
('fs')
const {
basename
} =
require
('path')
const
localFilePath
= '/path/to/merchant-receipt-file.jpg'
const
stream
=
createReadStream
(
localFilePath
)
const
media
= new
Multipart
()
.
append
('meta',
JSON
.
stringify
({
transaction_id
,
transaction_mchid
,
transaction_sub_mchid
,
out_trade_no
,
openid
,
upload_time
,
merchant_contact_information
: {
consultation_phone_number
:
Rsa
.
encrypt
(
phone_number
,
platformCertificateInstance
),
},
sha256
: 'from upstream or local calculated',
})) .
append
('file',
stream
,
basename
(
localFilePath
))
wxpay
.
v3
.
marketing
.
shoppingReceipt
.
shoppingreceipts
.
post
(
media
, {
headers
})
.
then
(
({
data
: {
receipt
,
}, }) => ({
receipt
,
}) )

Released under the MIT License. (SITEMAP)