The applet obtains the payment QR code

The applet needs session_id to obtain the payment QR code. The session_id can be obtained through the PC Hook or other protocol classes. After obtaining it, it can be generated by a local request. It also needs timeStamp, nonceStr, package, and paySign parameters, these four parameters Obtained from the value returned after placing an order,

session_id get payment QR code source code

.版本 2
.支持库 e2ee
.支持库 spec

.子程序 功能_获取支付二维码, 字节集, , 成功返回二维码图片字节集,失败返回空字节集
.参数 session_id, 文本型, , sessionid,可通过api获取
.参数 timeStamp, 文本型, , 时间戳,部分可能是字母开头
.参数 nonceStr, 文本型, , 随机文本
.参数 package, 文本型, , 订单id
.参数 paySign, 文本型, , 签名
.参数 appid, 文本型, , appid
.局部变量 url, 文本型, , , 请求链接
.局部变量 http, 网站客户端
.局部变量 临_json1, 存取键值表
.局部变量 临_json2, 存取键值表
.局部变量 json, 存取键值表, , , 提交json数据
.局部变量 cookie, 文本型
.局部变量 Return, 文本型, , , 请求返回值
.局部变量 uuid, 文本型, , , 返回请求值
.局部变量 QRcode, 文本型
.局部变量 QRImg, 字节集
.局部变量 Str, 文本型

url = “https://open.weixin.qq.com/wxaruntime/getuuid?session_id=” + session_id  ' 请求链接
' 下面就是请求头
http.置请求头 (“Host”, “open.weixin.qq.com”)
http.置请求头 (“Accept”, “*/*”)
http.置请求头 (“Content-Type”, “application/x-www-form-urlencoded”)
http.置请求头 (“Expect”, “100-continue”)
' 下面开始组装参数
临_json1.置文本 (“adUxInfo”, “”)
临_json1.置文本 (“provider”, “wxpay”)
临_json1.置文本 (“timeStamp”, timeStamp)
临_json1.置文本 (“nonceStr”, nonceStr)
临_json1.置文本 (“package”, package)
临_json1.置文本 (“paySign”, paySign)
临_json1.置文本 (“signType”, “MD5”)
cookie = “busid=wxapp; appid=” + appid + “;; busid=wxapp; sessionid=;; busid=wxapp; scene=1001;; busid=wxapp; scene_note=”  ' cookies
临_json1.置文本 (“cookie”, cookie)
临_json1.置逻辑值 (“grantMessageQuota”, 真)  ' "grantMessageQuota":true
' ------------------------------------------------
临_json2.置文本 (“args”, 临_json1.到JSON (假, , , , ))  ' 把上面对象写进新对象的args里面
临_json2.置逻辑值 (“isBridgedJsApi”, 真)  ' "isBridgedJsApi":true
临_json2.置文本 (“jsapiType”, “appservice”)
临_json2.置文本 (“miniprogramAppID”, appid)
临_json2.置文本 (“name”, “requestPayment”)
临_json2.置文本 (“transitiveData”, “”)
' -------------------------------------------------
临_json1.清空 ()  ' 第一次的json对象已经用过了,清空,接着用
临_json1.置文本 (“invokeData”, 临_json2.到JSON (假, , , , ))
临_json1.置整数 (“pathType”, 1)  ' 把上面对象写进新对象的invokeData里面
临_json1.置文本 (“rumtimeAppid”, appid)
临_json1.置文本 (“runtimeSessionId”, session_id)
临_json1.置文本 (“runtimeTicket”, “Test”)
' 最后一次组装数据了
json.置文本 (“appid”, appid)
json.置文本 (“req_data”, 临_json1.到JSON (假, , , , ))  ' 把上面对象写进新对象的req_data里面
' https请求
Str = json.到JSON (假, , , , )
调试输出 (Str)
http.执行POST (url, Str, Return, 真, )
调试输出 (Return)
json.从JSON载入 (Return, , , )
uuid = json.取文本 (“uuid”)  ' {"uuid":"021GsGKy47ZNGa1h"}
.如果真 (uuid = “”)
    返回 ({  })
.如果真结束
' QRcode = “https://long.open.weixin.qq.com/wxaruntime/qrconnect?uuid=” + uuid  ' 这个好像不太对劲,用下面的哪个
QRcode = “https://api.weixin.qq.com/wxaruntime/readqrcode?uuid=” + uuid  ' 二维码的内容就是这个,只需要把他生成二维码即可
QRImg = 创建二维码 (到字节集 (QRcode), 0, , , 8, , 1, )  ' 创建支付二维码图片,这里写的是png格式
写到文件 (“D:\123.png”, QRImg)

返回 (QRImg)

Guess you like

Origin blog.csdn.net/qq_2974520784/article/details/128682019