1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2010 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 |
---|
25 | require_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 | */ |
---|
37 | class LC_Page_Shopping_LoadPaymentModule extends LC_Page_Ex { |
---|
38 | |
---|
39 | // }}} |
---|
40 | // {{{ functions |
---|
41 | |
---|
42 | /** |
---|
43 | * Page を初期化する. |
---|
44 | * |
---|
45 | * @return void |
---|
46 | */ |
---|
47 | function init() { |
---|
48 | parent::init(); |
---|
49 | } |
---|
50 | |
---|
51 | /** |
---|
52 | * Page のプロセス. |
---|
53 | * |
---|
54 | * @return void |
---|
55 | */ |
---|
56 | function process() { |
---|
57 | |
---|
58 | $order_id = $this->getOrderId(); |
---|
59 | if ($order_id === false) { |
---|
60 | SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true); |
---|
61 | return; |
---|
62 | } |
---|
63 | |
---|
64 | $module_path = $this->getModulePath($order_id); |
---|
65 | if ($module_path === false) { |
---|
66 | SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, "", true, |
---|
67 | "モジュールファイルの取得に失敗しました。<br />この手続きは無効となりました。"); |
---|
68 | return; |
---|
69 | } |
---|
70 | require_once($module_path); |
---|
71 | } |
---|
72 | |
---|
73 | /** |
---|
74 | * デストラクタ. |
---|
75 | * |
---|
76 | * @return void |
---|
77 | */ |
---|
78 | function destroy() { |
---|
79 | parent::destroy(); |
---|
80 | } |
---|
81 | |
---|
82 | /** |
---|
83 | * 受注IDをキーにして, 決済モジュールのパスを取得する. |
---|
84 | * |
---|
85 | * 決済モジュールが取得できた場合は, require 可能な決済モジュールのパスを返す. |
---|
86 | * 受注IDが無効な場合, 取得したパスにファイルが存在しない場合は false |
---|
87 | * |
---|
88 | * @param integer $order_id 受注ID |
---|
89 | * @return string|boolean 成功した場合は決済モジュールのパス; |
---|
90 | * 失敗した場合 false |
---|
91 | */ |
---|
92 | function getModulePath($order_id) { |
---|
93 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
94 | $sql = <<< __EOS__ |
---|
95 | SELECT module_path |
---|
96 | FROM dtb_payment T1 |
---|
97 | JOIN dtb_order T2 |
---|
98 | ON T1.payment_id = T2.payment_id |
---|
99 | WHERE order_id = ? |
---|
100 | __EOS__; |
---|
101 | $module_path = $objQuery->getOne($sql, array($order_id)); |
---|
102 | if (file_exists($module_path)) { |
---|
103 | return $module_path; |
---|
104 | } |
---|
105 | return false; |
---|
106 | } |
---|
107 | |
---|
108 | /** |
---|
109 | * 受注ID を取得する. |
---|
110 | * |
---|
111 | * 以下の順序で受注IDを取得する. |
---|
112 | * |
---|
113 | * 1. $_SESSION['order_id'] |
---|
114 | * 2. $_POST['order_id'] |
---|
115 | * 3. $_GET['order_id'] |
---|
116 | * |
---|
117 | * 受注IDが取得できない場合は false を返す. |
---|
118 | * |
---|
119 | * @access private |
---|
120 | * @return integer|boolean 受注IDの取得に成功した場合は受注IDを返す; |
---|
121 | * 失敗した場合は, false を返す. |
---|
122 | */ |
---|
123 | function getOrderId() { |
---|
124 | if (isset($_SESSION['order_id']) |
---|
125 | && !SC_Utils_Ex::isBlank($_SESSION['order_id']) |
---|
126 | && SC_Utils_Ex::sfIsInt($_SESSION['order_id'])) { |
---|
127 | return $_SESSION['order_id']; |
---|
128 | } |
---|
129 | |
---|
130 | if (isset($_POST['order_id']) |
---|
131 | && !SC_Utils_Ex::isBlank($_POST['order_id']) |
---|
132 | && SC_Utils_Ex::sfIsInt($_POST['order_id'])) { |
---|
133 | return $_POST['order_id']; |
---|
134 | } |
---|
135 | |
---|
136 | if (isset($_GET['order_id']) |
---|
137 | && !SC_Utils_Ex::isBlank($_GET['order_id']) |
---|
138 | && SC_Utils_Ex::sfIsInt($_GET['order_id'])) { |
---|
139 | return $_GET['order_id']; |
---|
140 | } |
---|
141 | return false; |
---|
142 | } |
---|
143 | } |
---|
144 | ?> |
---|