StandardController.php 2.1 KB
Newer Older
T
Terry 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
<?php
/**
 * FecShop file.
 *
 * @link http://www.fecshop.com/
 * @copyright Copyright (c) 2016 FecShop Software LLC
 * @license http://www.fecshop.com/license/
 */

namespace fecshop\app\appserver\modules\Payment\controllers\paypal;

use fecshop\app\appserver\modules\AppserverController;
use Yii;

/**
 * @author Terry Zhao <2358269014@qq.com>
 * @since 1.0
 */
class StandardController extends AppserverController
{
    public $enableCsrfValidation = false;
    
    /**
     * 1.start部分,跳转到paypal前的部分
     */
    public function actionStart()
    {
T
Terry 已提交
28 29 30
        if(Yii::$app->request->getMethod() === 'OPTIONS'){
            return [];
        }
T
Terry 已提交
31 32 33 34 35 36 37
        return $this->getBlock()->startExpress();
    }
    /**
     * 2.Review  从paypal确认后返回的部分
     */
    public function actionReview()
    {
T
Terry 已提交
38 39 40
        if(Yii::$app->request->getMethod() === 'OPTIONS'){
            return [];
        }
T
Terry 已提交
41 42 43 44 45 46 47
        return $this->getBlock('placeorder')->getLastData();
    }
    /**
     * IPN,paypal消息接收部分
     */
    public function actionIpn()
    {
T
Terry 已提交
48 49 50
        if(Yii::$app->request->getMethod() === 'OPTIONS'){
            return [];
        }
T
Terry 已提交
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
        \Yii::info('paypal ipn begin', 'fecshop_debug');
       
        $post = Yii::$app->request->post();
        if (is_array($post) && !empty($post)) {
            $post = \Yii::$service->helper->htmlEncode($post);
            ob_start();
            ob_implicit_flush(false);
            var_dump($post);
            $post_log = ob_get_clean();
            \Yii::info($post_log, 'fecshop_debug');
            //Yii::$service->payment->paypal->receiveIpn($post);
        }
    }
    /**
     * paypal 取消后的部分。
     */
    /*
    public function actionCancel()
    {
        $innerTransaction = Yii::$app->db->beginTransaction();
        try {
            if(Yii::$service->order->cancel()){
                $innerTransaction->commit();
            }else{
                $innerTransaction->rollBack();
            }
        } catch (Exception $e) {
            $innerTransaction->rollBack();
        }
        return Yii::$service->url->redirectByUrlKey('checkout/onepage');
    }
    */
}