Skip to content

JSAPI下单

除付款码支付场景以外,商户系统先调用该接口在微信支付服务后台生成预支付交易单,返回正确的预支付交易会话标识后再按Native、JSAPI、APP等不同场景生成交易串调起支付。 官方文档

js
const { 
Formatter
,
Rsa
} =
require
('wechatpay-axios-plugin')
wxpay
.
v3
.
pay
.
transactions
.
jsapi
.
post
({
mchid
,
appid
,
description
,
out_trade_no
,
notify_url
,
amount
: {
total
,
currency
},
payer
: {
openid
},
}) .
then
(({
data
: {
prepay_id
} }) => {
const
nonceStr
=
Formatter
.
nonce
();
const
timeStamp
= '' +
Formatter
.
timestamp
();
const
packageStr
= 'prepay_id=' +
prepay_id
;
return {
appId
,
timeStamp
,
nonceStr
,
package
:
packageStr
,
signType
: 'RSA',
paySign
:
Rsa
.
sign
(
Formatter
.
joinedByLineFeed
(
appId
,
timeStamp
,
nonceStr
,
packageStr
),
merchantPrivateKeyInstance
) } })

Released under the MIT License. (SITEMAP)