Wechatqrcode.php 1.14 KB
<?php

use Action\WebAction;
use Shopping\PayModel;
use WebPlugin\Helpers;

class WechatqrcodeController extends WebAction
{
    /**
     * 微信扫码支付
     *
     * @param int order_code 订单号
     */
    public function indexAction()
    {
        $uid = $this->getUid(true);
        if (!$uid) {
            $this->go(Helpers::url('/signin.html', array('refer' => $this->server('HTTP_REFERER'))));
        }

        $orderCode = $this->get('order_code', $this->get('ordercode'));
        $data = PayModel::weixinQrcode($uid, $orderCode);
        if (isset($data['error'])) {
            $this->helpJsRedirect($data['message']);
        }

        $this->setSimpleHeader();
        // 轮询是否支付成功地址
        $data['payHost'] = Helpers::url('/pay/notice/wechatcallback', array('ordercode' => $orderCode));
        // 支付成功跳转地址
        $data['paySuccessUrl'] = Helpers::url('/pay/notice/wechatqrcodereturn', array('order_code' => $orderCode));
        $this->_view->display('index', array(
            'wechatqrcode' => $data,
            'wechatqrcodePage' => true
        ));
    }
}