[18864] | 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 |
---|
[20344] | 25 | require_once(CLASS_EX_REALDIR . "page_extends/LC_Page_Ex.php"); |
---|
[18864] | 26 | |
---|
| 27 | /** |
---|
| 28 | * 決済モジュールの呼び出しを行うクラス. |
---|
| 29 | * |
---|
| 30 | * @package Page |
---|
| 31 | * @author Kentaro Ohkouchi |
---|
| 32 | * @version $Id$ |
---|
| 33 | */ |
---|
[20344] | 34 | class LC_Page_Shopping_LoadPaymentModule extends LC_Page_Ex { |
---|
[18864] | 35 | |
---|
| 36 | // }}} |
---|
| 37 | // {{{ functions |
---|
| 38 | |
---|
| 39 | /** |
---|
| 40 | * Page を初期化する. |
---|
| 41 | * |
---|
| 42 | * @return void |
---|
| 43 | */ |
---|
| 44 | function init() { |
---|
| 45 | parent::init(); |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | /** |
---|
| 49 | * Page のプロセス. |
---|
| 50 | * |
---|
| 51 | * @return void |
---|
| 52 | */ |
---|
| 53 | function process() { |
---|
| 54 | $objSiteSess = new SC_SiteSession(); |
---|
[20444] | 55 | $objCartSess = new SC_CartSession_Ex(); |
---|
[19912] | 56 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
[18864] | 57 | |
---|
[19912] | 58 | if (!$objSiteSess->isPrePage()) { |
---|
| 59 | SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, $objSiteSess); |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | $uniqid = $objSiteSess->getUniqId(); |
---|
| 63 | $objPurchase->verifyChangeCart($uniqid, $objCartSess); |
---|
| 64 | |
---|
[18864] | 65 | $payment_id = $this->getPaymentId(); |
---|
| 66 | if ($payment_id === false) { |
---|
[19912] | 67 | SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true); |
---|
[18864] | 68 | return; |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | $module_path = $this->getModulePath($payment_id); |
---|
| 72 | if ($module_path === false) { |
---|
[19912] | 73 | SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, "", true, |
---|
[18864] | 74 | "モジュールファイルの取得に失敗しました。<br />この手続きは無効となりました。"); |
---|
| 75 | return; |
---|
| 76 | } |
---|
| 77 | require_once($module_path); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | /** |
---|
| 81 | * モバイルページを初期化する. |
---|
| 82 | * |
---|
| 83 | * @return void |
---|
| 84 | */ |
---|
| 85 | function mobileInit() { |
---|
| 86 | $this->init(); |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | /** |
---|
| 90 | * Page のプロセス(モバイル). |
---|
| 91 | * |
---|
| 92 | * @return void |
---|
| 93 | */ |
---|
| 94 | function mobileProcess() { |
---|
| 95 | $this->process(); |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | /** |
---|
| 99 | * デストラクタ. |
---|
| 100 | * |
---|
| 101 | * @return void |
---|
| 102 | */ |
---|
| 103 | function destroy() { |
---|
| 104 | parent::destroy(); |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | /** |
---|
| 108 | * 支払い方法IDをキーにして, 決済モジュールのパスを取得する. |
---|
| 109 | * |
---|
| 110 | * 決済モジュールが取得できた場合は, require 可能な決済モジュールのパスを返す. |
---|
| 111 | * 支払い方法IDが無効な場合, 取得したパスにファイルが存在しない場合は false |
---|
| 112 | * |
---|
| 113 | * @param integer $payment_id 支払い方法ID |
---|
| 114 | * @return string|boolean 成功した場合は決済モジュールのパス; |
---|
| 115 | * 失敗した場合 false |
---|
| 116 | */ |
---|
| 117 | function getModulePath($payment_id) { |
---|
| 118 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
| 119 | $sql = <<< __EOS__ |
---|
| 120 | SELECT module_path |
---|
| 121 | FROM dtb_payment |
---|
| 122 | WHERE payment_id = ? |
---|
| 123 | __EOS__; |
---|
| 124 | $module_path = $objQuery->getOne($sql, array($payment_id)); |
---|
| 125 | if (file_exists($module_path)) { |
---|
| 126 | return $module_path; |
---|
| 127 | } |
---|
| 128 | return false; |
---|
| 129 | } |
---|
| 130 | |
---|
| 131 | /** |
---|
| 132 | * 支払い方法ID を取得する. |
---|
| 133 | * |
---|
| 134 | * 以下の順序で支払い方法IDを取得する. |
---|
| 135 | * |
---|
| 136 | * 1. $_SESSION['payment_id'] |
---|
| 137 | * 2. $_POST['payment_id'] |
---|
| 138 | * 3. $_GET['payment_id'] |
---|
| 139 | * |
---|
| 140 | * 支払い方法IDが取得できない場合は false を返す. |
---|
| 141 | * |
---|
| 142 | * @access private |
---|
| 143 | * @return integer|boolean 支払い方法の取得に成功した場合は支払い方法IDを返す; |
---|
| 144 | * 失敗した場合は, false を返す. |
---|
| 145 | */ |
---|
| 146 | function getPaymentId() { |
---|
| 147 | if (isset($_SESSION['payment_id']) |
---|
| 148 | && !SC_Utils_Ex::isBlank($_SESSION['payment_id'])) { |
---|
| 149 | return $_SESSION['payment_id']; |
---|
| 150 | } |
---|
| 151 | |
---|
| 152 | if (isset($_POST['payment_id']) |
---|
| 153 | && !SC_Utils_Ex::isBlank($_POST['payment_id'])) { |
---|
| 154 | return $_POST['payment_id']; |
---|
| 155 | } |
---|
| 156 | |
---|
| 157 | if (isset($_GET['payment_id']) |
---|
| 158 | && !SC_Utils_Ex::isBlank($_GET['payment_id'])) { |
---|
| 159 | return $_GET['payment_id']; |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | return false; |
---|
| 163 | } |
---|
| 164 | } |
---|
| 165 | ?> |
---|