微信支付服务器端demo,asp写的微信小程序支付demo-服务器端是asp+mdb的

这个微信小程序支付demo代码是我用asp写的,微信小程序端加上服务器端用的asp和mdb数据库,下面是代码分享:

订单说明:{{paydata.title}}

支付金额:分

支付

-----------------------

//index.js

//获取应用实例

var app = getApp()

Page({

data: {

paydata: { title: "支付测试", total_fee:1},

userInfo: {}

},

onLoad: function () {

console.log(‘onLoad‘);

//判断是否获取到了详细信息

if (!wx.getStorageSync("userInfo")) {

wx.navigateTo({ url: ‘/pages/login/index‘})

}

},

// 监听输入

bindKeyInput: function (e) {

console.log(e.detail.value);

this.setData({

‘paydata.total_fee‘: e.detail.value

})

},

//

payoff: function(e){

var that = this;

//获取openid

app.wxlogin(function (re) {

console.log(re);

//判断有无openid

if (re) {

that.setData({ ‘paydata.openid‘:re })

//下单

that.xiadan();

}

});

},

//下单

xiadan: function (){

var that = this;

wx.request({

url: app.globalData.apiurl+‘c=payorder‘,

method: ‘POST‘,

header: { ‘content-type‘: ‘application/x-www-form-urlencoded‘ },

data: that.data.paydata,

success: function(res) {

console.log(res);

if(res.data.code=="0"){

//发起支付

that.requestPayment(res.data.data);

}else{

wx.showModal({

title: ‘提示‘,

content: ‘支付发起失败‘,

showCancel:false

});

}

}

})

},

//申请支付

requestPayment: function(obj){

console.log(obj);

var that=this;

wx.requestPayment({

‘timeStamp‘: obj.timeStamp,

‘nonceStr‘: obj.nonceStr,

‘package‘: obj.package,

‘signType‘: obj.signType,

‘paySign‘: obj.paySign,

‘success‘:function(res){

wx.showModal({

title: ‘提示‘,

content: ‘成功支付:‘ + that.data.paydata.total_fee+‘分‘,

showCancel: false

});

},

‘fail‘:function(res){

wx.showModal({

title: ‘提示‘,

content: ‘支付失败‘,

showCancel: false

});

}

})

},

})

=============================================

互相学习电话微信:18611436777(加微信注明事由)

20181026130227344976.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值