微信公众号支付

Fecbbc 多商户 · dream · 于 3年前 发布 · 1563 次阅读

pc端微信扫码支付已经没问题,微信内部下单后点击支付会直接跳到手机端的首页。

共收到 13 条回复
Fecmall#13年前 0 个赞

1.信息太少,这个无法诊断

2.Fecmall 微信支付文档,您自己看一下吧

3.自行debug一下代码。

dream#23年前 0 个赞

1.打开/addons/fecmall/fecbbc/app/apphtml5/modules/Payment/controllers/WxpayjsapiController.php

2.修改 public function initFunc()函数名为: public function init()

3.修改调用方法$this->initFunc();$this->init();

 /**
     * 支付开始页面.
     */
    public function actionStart()
    {
        $this->initFunc();
        //Yii::$service->page->theme->layoutFile = 'wxpay_jsapi.php';
        $data = Yii::$service->payment->wxpayJsApi->getScanCodeStart();
        $data['success_url'] = Yii::$service->payment->getStandardSuccessRedirectUrl();
        return $this->render($this->action->id, $data);
    }

为:

/**
     * 支付开始页面.
     */
    public function actionStart()
    {
        $this->init();
        //Yii::$service->page->theme->layoutFile = 'wxpay_jsapi.php';
        $data = Yii::$service->payment->wxpayJsApi->getScanCodeStart();
        $data['success_url'] = Yii::$service->payment->getStandardSuccessRedirectUrl();
        return $this->render($this->action->id, $data);
    }

4.这样修改后,“微信JsApi支付(只能微信内使用)”就可以正常支付了。

5.但是支付成功后订单的支付状态都还处于“待支付”状态。

3楼 已删除.
Fecmall#43年前 0 个赞

1.搞不明白你为什么这么改,改的有点无厘头,结果也无厘头

2.对于init()方法,这个相当于对象的构造函数,是yii2框架里面的,只要这个类继承了 yii/base/BaseObject,那么 init()是会在类实例化对象的时候执行的,因此

public function actionStart()
    {
        $this->init();

在这里调用是多此一举,根本不需要调用,默认就会执行

3.你这个改名有什么意义?看不明白,更看不明白的是你改后的结果,居然还跑起来了?

你是不是改了啥代码?

附一下默认的文件内容

@fecbbc\app\apphtml5\modules\Payment\controllers\WxpayjsapiController.php

<?php
/**
 * FecShop file.
 *
 * @link http://www.fecshop.com/
 * @copyright Copyright (c) 2016 FecShop Software LLC
 * @license http://www.fecshop.com/license/
 */

namespace fecbbc\app\apphtml5\modules\Payment\controllers;

use fecshop\app\apphtml5\modules\Payment\PaymentController;
use Yii;

/**
 * @author Terry Zhao <2358269014@qq.com>
 * @since 1.0
 */
class WxpayjsapiController extends \fecshop\app\apphtml5\modules\Payment\controllers\WxpayjsapiController
{
    public $enableCsrfValidation = false;
    
    protected $_trade_no;
    protected $_order_models;
    
    public function initFunc()
    {
        $homeUrl = Yii::$service->url->homeUrl();
        $this->_trade_no = Yii::$service->order->getSessionTradeNo();
        if (!$this->_trade_no) {
            Yii::$service->url->redirect($homeUrl);
            exit;
        }

        $this->_order_models = Yii::$service->order->getOrderModelsByTradeNo($this->_trade_no);
        if (!is_array($this->_order_models) || empty($this->_order_models)) {
            Yii::$service->url->redirect($homeUrl);
            exit;
        }
    }
    
    /**
     * 支付开始页面.
     */
    public function actionStart()
    {
        $this->initFunc();
        //Yii::$service->page->theme->layoutFile = 'wxpay_jsapi.php';
        $data = Yii::$service->payment->wxpayJsApi->getScanCodeStart();
        $data['success_url'] = Yii::$service->payment->getStandardSuccessRedirectUrl();
        return $this->render($this->action->id, $data);
        
    }
    
    /**
     * IPN消息推送地址
     * IPN过来后,不清除session中的 increment_id ,也不清除购物车
     * 仅仅是更改订单支付状态。
     */
    public function actionIpn()
    {
        Yii::$service->payment->wxpay->ipn();
    }

}

2.@fecshop\app\apphtml5\modules\Payment\controllers\WxpayjsapiController

<?php
/**
 * FecShop file.
 *
 * @link http://www.fecshop.com/
 * @copyright Copyright (c) 2016 FecShop Software LLC
 * @license http://www.fecshop.com/license/
 */

namespace fecshop\app\apphtml5\modules\Payment\controllers;

use fecshop\app\apphtml5\modules\Payment\PaymentController;
use Yii;

/**
 * @author Terry Zhao <2358269014@qq.com>
 * @since 1.0
 */
class WxpayjsapiController extends PaymentController
{
    public $enableCsrfValidation = false;
    
    public function init()
    {
        parent::init();
    }
    
    /**
     * 支付开始页面.
     */
    public function actionStart()
    {
        
        Yii::$service->page->theme->layoutFile = 'wxpay_jsapi.php';
        $data = Yii::$service->payment->wxpayJsApi->getScanCodeStart();
        $data['success_url'] = Yii::$service->payment->getStandardSuccessRedirectUrl();
        return $this->render($this->action->id, $data);
        
    }
    
    /**
     * IPN消息推送地址
     * IPN过来后,不清除session中的 increment_id ,也不清除购物车
     * 仅仅是更改订单支付状态。
     */
    public function actionIpn()
    {
        Yii::$service->payment->wxpay->ipn();
    }

    /** 废弃
     *  成功支付页面.
     */
    public function actionSuccess()
    {
        $data = [
            'increment_id' => $this->_increment_id,
        ];
        // 清理购物车中的产品。(游客用户的购物车在成功页面清空)
        if (Yii::$app->user->isGuest) {
            Yii::$service->cart->clearCartProductAndCoupon();
        }
        // 清理session中的当前的increment_id
        Yii::$service->order->removeSessionIncrementId();

        return $this->render('../../payment/checkmoney/success', $data);
    }

    
}

dream#53年前 0 个赞

我debug到 这个初始化函数 init(),打断点是因为这个初始化函数发生的错误,我就用initFunc()这个函数重写了init(),结果是 微信内部支付就能用了。。。,但是支付状态没改变。

Fecmall#63年前 0 个赞

@dream #5楼

我debug到 这个初始化函数 init(),打断点是因为这个初始化函数发生的错误

发生了什么错误?这个是重点。你对照一下文件内容,是否一致,或者你复制覆盖一下文件内容试试。

dream#73年前 0 个赞

没出现错误,直接跳到了微信端的商城首页面。

Fecmall#83年前 0 个赞

深入追踪代码,找到为什么跳转,肯定有原因的。

dream#93年前 0 个赞

我怀疑是没有获取到前端的订单编号

Fecmall#103年前 0 个赞

@dream #9楼 您自己debug代码找原因吧。

dream#113年前 0 个赞
<?php
/**
 * FecShop file.
 *
 * @link http://www.fecshop.com/
 * @copyright Copyright (c) 2016 FecShop Software LLC
 * @license http://www.fecshop.com/license/
 */

namespace fecshop\app\apphtml5\modules\Payment;

use fecshop\app\apphtml5\modules\AppfrontController;
use Yii;

/**
 * @author Terry Zhao <2358269014@qq.com>
 * @since 1.0
 */
class PaymentController extends AppfrontController
{
    protected $_increment_id;
    protected $_order_model;

    public function init()
    {
        parent::init();
        $homeUrl = Yii::$service->url->homeUrl();
        $this->_increment_id = Yii::$service->order->getSessionIncrementId();
        if (!$this->_increment_id) {
            Yii::$service->url->redirect($homeUrl);
            exit;
        }

        $this->_order_model = Yii::$service->order->GetByIncrementId($this->_increment_id);
        if (!isset($this->_order_model['increment_id'])) {
            Yii::$service->url->redirect($homeUrl);
            exit;
        }

    }
}

我感觉是这地方跳转了

Fecmall#123年前 0 个赞

代码在你手里,还感觉个甚,去debug啊,猜个甚!!

不用这怀疑,那猜测,去debug代码

好了,该说的都说了

结帖。

dream#133年前 0 个赞

。。。

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics