1.微信支付:
1.哪些人哪些账号可以实现微信支付
1.企业账号的小程序后台 必须 给开发者 添加上白名单
2.这些开发者就可以共用这个appid 和他的权限了,
3.准备发送请求 创建订单 获取订单编号
4.发起 预支付接口
5.案例:
// //提交订单
handleOrderPay:function(){
var that=this
var k=wx.getStorageSync('key')
var u=wx.getStorageSync('u')
var openid = wx.getStorageSync('openid');
var receiver_name=that.data.user_address_contact //收货人姓名
var receiver_address=that.data.user_address_address //地址
var receiver_phone=that.data.user_address_phone //收货人电话
var point_cart_id=that.data.points_cart_id //购物车商品的id
var area_code=that.data.area_code //地址code码
wx.request({
url: “创建订单的接口”
method:'POST',
data:{
k:k,
u:u,
receiver_name:receiver_name, //收货人姓名
receiver_address:receiver_address, //收货人地址
receiver_phone:receiver_phone, //收货人联系方式
point_cart_id:point_cart_id, //购物车商品id
area_code:area_code,
openid:openid,
appid:app.data.appid,
},
header: {
"Content-Type": "application/x-www-form-urlencoded"
},
success:function(res){
var uorder=res.data.data.uorder
var total_buyprice=that.data.total_buyprice
console.log(total_buyprice)
if(total_buyprice>0){
wx.request({
url:“支付接口”
data:{
k:k,
u:u,
openid:openid,//用户openid的id必传
appid:app.data.appid, //用户的appid
uorder_id:uorder, //订单号
trade_type: 'WXAPP', //支付类型
},
success:function(res){
var reslust=res.data
wx.requestPayment({ //唤起微信支付
nonceStr:reslust.nonceStr,
package:reslust.package,
paySign: reslust.paySign,
signType: reslust.signType,
timeStamp:reslust.timeStamp,
success:function(){
wx.showToast({
title: '支付成功',
})
},
fail:function(){
wx.showToast({
title: '兑换失败',
})
}
})
}
})
//如果小于0或者等于0
}else{
wx.showToast({
title: '兑换成功',
})
setTimeout(() => {
wx.navigateTo({
url: "../jifen1/jifen"
})
}, 2000)
}
}
})
},