作者 lihan
1 个管道 的构建 通过 耗费 1 秒

支付宝

... ... @@ -358,6 +358,44 @@ class OrderController extends HomeBaseController
public function alipay()
{
if(!cmf_is_wechat()) {
header("Content-type: text/html; charset=utf-8");
require_once EXTEND_PATH . '/alipay/wappay/service/AlipayTradeService.php';
require_once EXTEND_PATH . '/alipay/wappay/buildermodel/AlipayTradeWapPayContentBuilder.php';
require EXTEND_PATH . '/alipay/config.php';
if (1 == 1) {
//商户订单号,商户网站订单系统中唯一订单号,必填
$out_trade_no = '20181017210243564' . rand(10000, 99999);
//订单名称,必填
$subject = '购买';
//付款金额,必填
$total_amount = 0.01;
//商品描述,可空
$body = '商品';
//超时时间
$timeout_express = "1m";
$payRequestBuilder = new \AlipayTradeWapPayContentBuilder();
$payRequestBuilder->setBody($body);
$payRequestBuilder->setSubject($subject);
$payRequestBuilder->setOutTradeNo($out_trade_no);
$payRequestBuilder->setTotalAmount($total_amount);
$payRequestBuilder->setTimeExpress($timeout_express);
$payResponse = new \AlipayTradeService($config);
$result = $payResponse->wapPay($payRequestBuilder, $config['return_url'], $config['notify_url']);
return;
}
}else {
return $this->fetch('alipay');
}
}
public function alipayDo() {
header("Content-type: text/html; charset=utf-8");
require_once EXTEND_PATH . '/alipay/wappay/service/AlipayTradeService.php';
require_once EXTEND_PATH . '/alipay/wappay/buildermodel/AlipayTradeWapPayContentBuilder.php';
... ... @@ -387,12 +425,8 @@ class OrderController extends HomeBaseController
$payResponse = new \AlipayTradeService($config);
$result = $payResponse->wapPay($payRequestBuilder, $config['return_url'], $config['notify_url']);
return ;
return;
}
}
public function alipayDo() {
}
}
\ No newline at end of file
... ...
... ... @@ -14,49 +14,13 @@
</style>
</head>
<body id="order-check" data-com="pagecommon">
<header class="navbar">
<h1 class="nav-header">确认订单</h1>
</header>
<div class="wrapper-list">
<h4>分水农家菜代金券</h4>
<dl class="list">
<dd>
<dl>
<dd class="kv-line-r dd-padding">
<h6>购买数量:</h6>
<p>1</p>
</dd>
<dd class="kv-line-r dd-padding">
<h6>项目单价:</h6>
<p>0.01元</p>
</dd>
<dd class="kv-line-r dd-padding">
<h6>总额:</h6>
<p>
<strong class="color-stronger highlight-price">0.01元</strong>
</p>
</dd>
</dl>
</dd>
</dl>
<div id="pay-methods-panel" class="pay-methods-panel">
<div class="wrapper buy-wrapper">
<!-- 该链接是拼接的请求,需要做urlEncode -->
<a href="{$url}" class="J-btn-submit btn mj-submit btn-strong btn-larger btn-block">确认支付</a>
<a href="{:url('order/Order/alipayDo')}" class="J-btn-submit btn mj-submit btn-strong btn-larger btn-block">确认支付</a>
</div>
</div>
</div>
<script type="text/javascript" src="__TMPL__/static/js/ap.js"></script>
<script>
var btn = document.querySelector(".J-btn-submit");
btn.addEventListener("click", function (e) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
//ele.href 是GET到支付宝收银台的URL
_AP.pay(e.target.href);
return false;
}, false);
</script>
</body>
</html>
... ...