[更新]增加微信支付测试退款

This commit is contained in:
邹景立 2017-04-13 22:56:11 +08:00
parent ac8551e4ee
commit 0e397dfc31
2 changed files with 24 additions and 19 deletions

View File

@ -65,27 +65,35 @@ class Config extends BasicAdmin {
$order_no = session('pay-test-order-no');
if (empty($order_no)) {
$order_no = DataService::createSequence(10, 'wechat-pay-test');
session('pay-test-order-no',$order_no);
session('pay-test-order-no', $order_no);
}
// 该订单号已经支付
if(PayService::isPay($order_no)){
return json(['code'=>2,'order_no'=>$order_no]);
if (PayService::isPay($order_no)) {
return json(['code' => 2, 'order_no' => $order_no]);
}
// 订单号未支付生成支付二维码URL
$url = PayService::createWechatPayQrc($pay, $order_no, 1, '扫码支付测试!');
if ($url !== false) {
return json(['code'=>1,'url'=>$url,'order_no'=>$order_no]);
return json(['code' => 1, 'url' => $url, 'order_no' => $order_no]);
}
// 生成支付二维码URL失败
$this->error("生成支付二维码失败,{$pay->errMsg}[{$pay->errCode}]");
break;
// 检查订单是否支付成功
case 'check':
$order_no = $this->request->get('order_no');
if (PayService::isPay($order_no)) {
$this->success('已经支付成功!', '');
case 'refund':
$order_no = session('pay-test-order-no');
if (empty($order_no)) {
$this->error('指定测试订单号不存在,请重新开始支付测试!');
}
$this->error('订单尚未支付!');
if (!PayService::isPay($order_no)) {
$this->error('指定测试订单未支付或未收到微信支付通过!');
}
$pay = &load_wechat('pay');
$refund_no = DataService::createSequence(10, 'wechat-pay-test');
if (false !== PayService::putWechatRefund($pay, $order_no, 1, $refund_no)) {
$this->success('操作退款成功!', '');
}
$this->error("操作退款失败,{$pay->errMsg}[{$pay->errCode}]");
break;
default:
$this->assign('title', '微信支付配置');

View File

@ -106,7 +106,6 @@
if (ret.code === 2) {
ret.url = '__STATIC__/theme/default/img/wechat/qrc_payed.jpg';
timer && window.clearInterval(timer), timer = null;
$('[refund-qrc-test]').removeClass('hide');
}
if (isShow) {
$('.pay-qrc-test').attr('src', ret.url)
@ -115,29 +114,27 @@
type: 1, title: false, closeBtn: 1, shadeClose: true,
content: '<img class="pay-qrc-test" src="' + ret.url + '"/>'
+ '<p style="text-align:center">请用微信扫码测试支付!</p>'
+ '<p class="refund-qrc-test hide"><a class="btn btn-xs btn-warning">退款测试</a></p>',
+ '<p class="refund-qrc-test"><a class="btn btn-xs btn-warning">退款测试</a></p>',
end: function () {
isShow = false;
timer && window.clearInterval(timer), timer = null;
isShow = false;
},
success: function (layero, index) {
isShow = true;
timer = setInterval(payTest, 1000);
if(ret.code===2){
$('[refund-qrc-test]').removeClass('hide');
}
timer = setInterval(payTest, 3000);
}
});
}
}
return false;
});
}, !isShow);
}
$('[data-pay-test]').on('click', payTest);
$('body').on('click', '[refund-qrc-test] a', function () {
$.msg.success('退款功能开发中哦!');
/*! 发起退款操作 */
$('body').on('click', '.refund-qrc-test a', function () {
$.form.load('{:url("pay")}?action=refund');
});
});