source: branches/version-2_12-dev/data/class/pages/shopping/LC_Page_Shopping_LoadPaymentModule.php @ 22567

Revision 22567, 4.4 KB checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24// {{{ requires
25require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
26
27/**
28 * 決済モジュールの呼び出しを行うクラス.
29 *
30 * 決済フローの妥当性検証は, トランザクションID等を使用して, 決済モジュール側で
31 * 行う必要がある.
32 *
33 * @package Page
34 * @author Kentaro Ohkouchi
35 * @version $Id$
36 */
37class LC_Page_Shopping_LoadPaymentModule extends LC_Page_Ex
38{
39
40    // }}}
41    // {{{ functions
42
43    /**
44     * Page を初期化する.
45     *
46     * @return void
47     */
48    function init()
49    {
50        parent::init();
51    }
52
53    /**
54     * Page のプロセス.
55     *
56     * @return void
57     */
58    function process()
59    {
60
61        $order_id = $this->getOrderId();
62        if ($order_id === false) {
63            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
64            return;
65        }
66
67        $module_path = $this->getModulePath($order_id);
68        if ($module_path === false) {
69            $msg = 'モジュールファイルの取得に失敗しました。<br />この手続きは無効となりました。';
70            SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', true, $msg);
71            return;
72        }
73        require_once $module_path;
74    }
75
76    /**
77     * デストラクタ.
78     *
79     * @return void
80     */
81    function destroy()
82    {
83        parent::destroy();
84    }
85
86    /**
87     * 受注IDをキーにして, 決済モジュールのパスを取得する.
88     *
89     * 決済モジュールが取得できた場合は, require 可能な決済モジュールのパスを返す.
90     * 受注IDが無効な場合, 取得したパスにファイルが存在しない場合は false
91     *
92     * @param integer $order_id 受注ID
93     * @return string|boolean 成功した場合は決済モジュールのパス;
94     *                        失敗した場合 false
95     */
96    function getModulePath($order_id)
97    {
98        $objPurchase = new SC_Helper_Purchase_Ex();
99        $objPayment = new SC_Helper_Payment_Ex();
100
101        $order = $objPurchase->getOrder($order_id);
102        $payment = $objPayment->get($order['payment_id']);
103        $module_path = $payment['module_path'];
104
105        if (file_exists($module_path)) {
106            return $module_path;
107        }
108        return false;
109    }
110
111    /**
112     * 受注ID を取得する.
113     *
114     * 以下の順序で受注IDを取得する.
115     *
116     * 1. $_SESSION['order_id']
117     * 2. $_POST['order_id']
118     * 3. $_GET['order_id']
119     *
120     * 受注IDが取得できない場合は false を返す.
121     *
122     * @access private
123     * @return integer|boolean 受注IDの取得に成功した場合は受注IDを返す;
124     *                         失敗した場合は, false を返す.
125     */
126    function getOrderId()
127    {
128        if (isset($_SESSION['order_id'])
129            && !SC_Utils_Ex::isBlank($_SESSION['order_id'])
130            && SC_Utils_Ex::sfIsInt($_SESSION['order_id'])) {
131            return $_SESSION['order_id'];
132        }
133
134        if (isset($_POST['order_id'])
135            && !SC_Utils_Ex::isBlank($_POST['order_id'])
136            && SC_Utils_Ex::sfIsInt($_POST['order_id'])) {
137            return $_POST['order_id'];
138        }
139
140        if (isset($_GET['order_id'])
141            && !SC_Utils_Ex::isBlank($_GET['order_id'])
142            && SC_Utils_Ex::sfIsInt($_GET['order_id'])) {
143            return $_GET['order_id'];
144        }
145        return false;
146    }
147
148    /**
149     * 決済モジュールから遷移する場合があるため, トークンチェックしない.
150     */
151    function doValidToken()
152    {
153        // nothing.
154    }
155}
Note: See TracBrowser for help on using the repository browser.