CheckmoneyController.php 1.9 KB
Newer Older
R
root 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
<?php
/**
 * FecShop file.
 *
 * @link http://www.fecshop.com/
 * @copyright Copyright (c) 2016 FecShop Software LLC
 * @license http://www.fecshop.com/license/
 */
namespace fecshop\app\appfront\modules\Payment\controllers;
use Yii;
use fec\helpers\CModule;
use fec\helpers\CRequest;
use fecshop\app\appfront\modules\AppfrontController;
R
root 已提交
14
use fecshop\app\appfront\modules\Payment\PaymentController;
R
root 已提交
15 16 17 18
/**
 * @author Terry Zhao <2358269014@qq.com>
 * @since 1.0
 */
R
root 已提交
19
class CheckmoneyController extends PaymentController
R
root 已提交
20 21
{
    public $enableCsrfValidation = true;
R
root 已提交
22 23 24
	/**
	 * 支付开始页面
	 */
R
root 已提交
25
	public function actionStart(){
R
root 已提交
26 27 28 29 30 31 32
		$payment_method = isset($this->_order_model['payment_method']) ? $this->_order_model['payment_method'] : '';
		if($payment_method){
			$complateUrl = Yii::$service->payment->getStandardSuccessRedirectUrl($payment_method);
			if($complateUrl){
				# 登录用户,在支付前清空购物车。
				if(!Yii::$app->user->isGuest){
					Yii::$service->cart->clearCart();
R
root 已提交
33
				}
R
root 已提交
34 35
				Yii::$service->url->redirect($complateUrl);
				exit;
R
root 已提交
36 37
			}
		}
R
root 已提交
38
		
R
root 已提交
39 40
		$homeUrl = Yii::$service->url->homeUrl();
		Yii::$service->url->redirect($homeUrl);
R
root 已提交
41
	}
R
root 已提交
42
	/**
R
root 已提交
43
	 * 成功支付页面
R
root 已提交
44
	 */
R
root 已提交
45
	public function actionSuccess(){
R
root 已提交
46 47 48 49 50
		$data = [
			'increment_id' => $this->_increment_id,
		];
		# 清理购物车中的产品。(游客用户的购物车在成功页面清空)
		if(Yii::$app->user->isGuest){
R
root 已提交
51 52
			Yii::$service->cart->clearCart();
		}
R
root 已提交
53 54 55
		# 清理session中的当前的increment_id
		Yii::$service->order->removeSessionIncrementId();
		return $this->render('../../payment/checkmoney/success',$data);
R
root 已提交
56 57
	}
	
R
root 已提交
58 59 60 61 62
	/**
	 * IPN消息推送地址
	 * IPN过来后,不清除session中的 increment_id ,也不清除购物车
	 * 仅仅是更改订单支付状态。
	 */
R
root 已提交
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
	public function actionIpn(){
		
	}
	
}