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

Revision 22926, 4.2 KB checked in by Seasoft, 11 years ago (diff)

#2287 (環境によりデストラクタが正しく動作しないケースがある)
#2288 (リクエスト単位で実行されるべきログ出力がブロックにも適用されている)
#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

  • 不明確な仕様にコメントを残した。
  • 親デストラクタを呼ぶだけの記述は可読性が悪くなると考え削除した。(上述のチケットで OS の仕様に依存したデストラクタとなるため、敢えてアプリケーション側で記述しておく意義は薄れたという認識のもと。)
  • 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
24require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
25
26/**
27 * 決済モジュールの呼び出しを行うクラス.
28 *
29 * 決済フローの妥当性検証は, トランザクションID等を使用して, 決済モジュール側で
30 * 行う必要がある.
31 *
32 * @package Page
33 * @author Kentaro Ohkouchi
34 * @version $Id$
35 */
36class LC_Page_Shopping_LoadPaymentModule extends LC_Page_Ex
37{
38    /**
39     * Page を初期化する.
40     *
41     * @return void
42     */
43    function init()
44    {
45        parent::init();
46    }
47
48    /**
49     * Page のプロセス.
50     *
51     * @return void
52     */
53    function process()
54    {
55        $order_id = $this->getOrderId();
56        if ($order_id === false) {
57            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
58            return;
59        }
60
61        $module_path = $this->getModulePath($order_id);
62        if ($module_path === false) {
63            $msg = 'モジュールファイルの取得に失敗しました。<br />この手続きは無効となりました。';
64            SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', true, $msg);
65            return;
66        }
67        require_once $module_path;
68    }
69
70    /**
71     * 受注IDをキーにして, 決済モジュールのパスを取得する.
72     *
73     * 決済モジュールが取得できた場合は, require 可能な決済モジュールのパスを返す.
74     * 受注IDが無効な場合, 取得したパスにファイルが存在しない場合は false
75     *
76     * @param integer $order_id 受注ID
77     * @return string|boolean 成功した場合は決済モジュールのパス;
78     *                        失敗した場合 false
79     */
80    function getModulePath($order_id)
81    {
82        $objPurchase = new SC_Helper_Purchase_Ex();
83        $objPayment = new SC_Helper_Payment_Ex();
84
85        $order = $objPurchase->getOrder($order_id);
86        $payment = $objPayment->get($order['payment_id']);
87        $module_path = $payment['module_path'];
88
89        if (file_exists($module_path)) {
90            return $module_path;
91        }
92
93        return false;
94    }
95
96    /**
97     * 受注ID を取得する.
98     *
99     * 以下の順序で受注IDを取得する.
100     *
101     * 1. $_SESSION['order_id']
102     * 2. $_POST['order_id']
103     * 3. $_GET['order_id']
104     *
105     * 受注IDが取得できない場合は false を返す.
106     *
107     * @access private
108     * @return integer|boolean 受注IDの取得に成功した場合は受注IDを返す;
109     *                         失敗した場合は, false を返す.
110     */
111    function getOrderId()
112    {
113        if (isset($_SESSION['order_id'])
114            && !SC_Utils_Ex::isBlank($_SESSION['order_id'])
115            && SC_Utils_Ex::sfIsInt($_SESSION['order_id'])) {
116            return $_SESSION['order_id'];
117        }
118
119        if (isset($_POST['order_id'])
120            && !SC_Utils_Ex::isBlank($_POST['order_id'])
121            && SC_Utils_Ex::sfIsInt($_POST['order_id'])) {
122            return $_POST['order_id'];
123        }
124
125        if (isset($_GET['order_id'])
126            && !SC_Utils_Ex::isBlank($_GET['order_id'])
127            && SC_Utils_Ex::sfIsInt($_GET['order_id'])) {
128            return $_GET['order_id'];
129        }
130
131        return false;
132    }
133
134    /**
135     * 決済モジュールから遷移する場合があるため, トークンチェックしない.
136     */
137    function doValidToken()
138    {
139        // nothing.
140    }
141}
Note: See TracBrowser for help on using the repository browser.