当前位置:网站首页>App wechat payment unicloud version of uniapp payment (with source code)
App wechat payment unicloud version of uniapp payment (with source code)
2022-06-30 12:52:00 【Source code Haoyouduo】
1 First on the renderings

Why want to use unicloud ? Don't build your own server , Don't buy domain name , Don't file domain names , No need to support https. Just a simple cloud function , You can easily realize the wechat payment function
ask : What is the server language , Is there a frame limit ?
answer : Server based on uniCloud Development , No frame limit , You can integrate with any framework .
ask : My project is not uniCloud, yes java、php Other languages , Can I use it ?
answer : Sure , The payment link is deployed in the cloud development environment , Notify your server interface when the payment is successful .
2 preparation
- 1, appid, On the wechat open platform (https://open.weixin.qq.com) Registration application account number . Note here the company needs to 300 Yuan certification fee . Apply to activate wechat payment function in application details .
- 2, The merchant number that has applied for wechat payment ( Merchant id, Merchant secret key ).
- 3,appid Associated with your merchant id

3 To configure
1、 stay manifest.json file “App The module configuration ” Term “Payment( payment )” Next , Check “ Wechat payment ” term

Parameter description
- appid
Application of wechat open platform application ID(AppID) - iOS Platform common links (Universal Link)
stay iOS General links for wechat payment on the platform , It must be connected with wechat open platform “ Management Center ” > “ Application details ” > “ Development information ” Medium “Universal Links” The configuration in the item is consistent
notes : About general Links , If the configuration is not consistent ,iOS It is impossible to return to after the payment is completed APP Of .
2、 find uniCloud -> cloudfunctions -> common Cloud functions uni-config-center -> uni-pay -> config.json->wxConfigApp Change it to your own appId, Merchant ID and secret key
Intra app initiated payment ——API Use
call uni.requestPayment(OBJECT) Initiate payment ,OBJECT Parameters in provider Property value is fixed to wxpay
Here is orderInfo, The attribute value is the order object . It is still worth noting that package, The value directly transmitted by wechat is packageValue.
partnerid, Wechat sends you partnerId.
prepayid, The wechat message is prepayId.
noncestr, Wechat sends you nonceStr.
timestamp, Wechat sends you timeStamp.
You must pay attention to the case , Otherwise, the order request fails , Let you ask questions , Find the pain .
// Order object , from uniCloud obtain
let orderInfo = {
"appid": res.data.orderInfo.appId, // application ID(AppID)
"partnerid": res.data.orderInfo.partnerId, // Merchant number (PartnerID)
"prepayid": res.data.orderInfo.prepayId, // Pre payment transaction session ID
"package": res.data.orderInfo.packageValue, // Fixed value
"noncestr": res.data.orderInfo.nonceStr, // Random string
"timestamp": res.data.orderInfo.timeStamp, // Time stamp ( Company : second )
"sign": res.data.orderInfo.sign, // Signature , Used here MD5 Signature
};
uni.requestPayment({
provider: "wxpay",
orderInfo: orderInfos,
success(res) {
console.log('success:' + JSON.stringify(res));
console.log(" Successful payment ");
},
fail(err) {
console.log('fail:' + JSON.stringify(err));
console.log(" Failure to pay ");
});
Source code address
https://ext.dcloud.net.cn/plugin?id=8612
Just download the source code appid、 Wechat merchant No 、 Change the key to your own and you can use it
help
If you have problems with payment, add me if you don't understand qq2214904953 consulting
Author related articles
Decompile to get any wechat applet source code —— Just read this one
边栏推荐
- Charles打断点修改请求数据&响应数据
- Docker安装Mysql8和sqlyong连接报错2058的解决方法[随笔记录]
- An interesting thing happened in the project
- [qnx hypervisor 2.2 user manual]6.2.3 communication between guest and external
- FlinkSQL自定义UDTF使用的四种方式
- Sublist3r error reporting solution
- Dark horse notes -- wrapper class, regular expression, arrays class
- 波卡跨链通信源码探秘: 要素篇
- 写信宝小程序开源
- 2022-06-23 帆软部分公式及sql生成(月份、季度取数)
猜你喜欢

Dark horse notes -- List series collections and generics

资源变现小程序开通微信官方小商店教程

【MySQL】MySQL的安装与配置

资源变现小程序开通流量主教程

顺应媒体融合趋势,中科闻歌携手美摄打造数智媒宣

RK356x U-Boot研究所(命令篇)3.3 env相关命令的用法

Motor control Clarke( α/β) Derivation of equal amplitude transformation

【 surprise】 la vitesse de téléchargement de Thunderbolt n'est pas aussi rapide que celle de la machine virtuelle

【惊了】迅雷下载速度竟然比不上虚拟机中的下载速度

Apple executives openly "open the connection": Samsung copied the iPhone and only added a large screen
随机推荐
FFMpeg AVBufferPool 的理解与掌握
Problems and analysis in JMeter performance testing. How many problems have you encountered?
7 lightweight and easy-to-use tools to relieve pressure and improve efficiency for developers, and help enterprises' agile cloud launch | wonderful review of techo day
Definition of variables and assignment of variables in MySQL
Flink SQL console, group not recognized_ Concat function?
MySQL判断执行条件为NULL时,返回0,出错问题解决 Incorrect parameter count in the call to native function ‘ISNULL‘,
[one day learning awk] array usage
Docker installation of mysql8 and sqlyong connection error 2058 solution [jottings]
Determining the subject area of data warehouse construction
The spiral matrix of the force buckle rotates together (you can understand it)
JMeter's performance test process and performance test focus
Dark horse notes -- List series collections and generics
[MySQL] MySQL installation and configuration
Terms related to JMeter performance test and performance test passing standards
微信小程序报错:TypeError: Cannot read property ‘setData‘ of undefined
golang基础 —— 切片几种声明方式
Kubeedge's core philosophy
Introduction to the renewal of substrate source code: the pledge amount is greatly reduced, and rocksdb can be completely disabled
资源变现小程序开通流量主教程
Wechat launched the picture big bang function; Apple's self-developed 5g chip may have failed; Microsoft solves the bug that causes edge to stop responding | geek headlines