Index: /branches/version-2_5-dev/data/class/pages/shopping/LC_Page_Shopping_LoadPaymentModule.php
===================================================================
--- /branches/version-2_5-dev/data/class/pages/shopping/LC_Page_Shopping_LoadPaymentModule.php	(revision 18864)
+++ /branches/version-2_5-dev/data/class/pages/shopping/LC_Page_Shopping_LoadPaymentModule.php	(revision 18864)
@@ -0,0 +1,159 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(CLASS_PATH . "pages/LC_Page.php");
+
+/**
+ * 決済モジュールの呼び出しを行うクラス.
+ *
+ * @package Page
+ * @author Kentaro Ohkouchi
+ * @version $Id$
+ */
+class LC_Page_Shopping_LoadPaymentModule extends LC_Page {
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        $objSiteSess = new SC_SiteSession();
+        $objCartSess = new SC_CartSession();
+        SC_Utils::sfIsPrePage($objSiteSess);
+        SC_Utils::sfCheckNormalAccess($objSiteSess, $objCartSess);
+
+        $payment_id = $this->getPaymentId();
+        if ($payment_id === false) {
+            SC_Utils::sfDispSiteError(PAGE_ERROR, "", true);
+            return;
+        }
+
+        $module_path = $this->getModulePath($payment_id);
+        if ($module_path === false) {
+            SC_Utils::sfDispSiteError(FREE_ERROR_MSG, "", true,
+                                      "モジュールファイルの取得に失敗しました。<br />この手続きは無効となりました。");
+            return;
+        }
+        require_once($module_path);
+    }
+
+    /**
+     * モバイルページを初期化する.
+     *
+     * @return void
+     */
+    function mobileInit() {
+        $this->init();
+    }
+
+    /**
+     * Page のプロセス(モバイル).
+     *
+     * @return void
+     */
+    function mobileProcess() {
+        $this->process();
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+    /**
+     * 支払い方法IDをキーにして, 決済モジュールのパスを取得する.
+     *
+     * 決済モジュールが取得できた場合は, require 可能な決済モジュールのパスを返す.
+     * 支払い方法IDが無効な場合, 取得したパスにファイルが存在しない場合は false
+     *
+     * @param integer $payment_id 支払い方法ID
+     * @return string|boolean 成功した場合は決済モジュールのパス;
+     *                        失敗した場合 false
+     */
+    function getModulePath($payment_id) {
+        $objQuery =& SC_Query::getSingletonInstance();
+        $sql = <<< __EOS__
+            SELECT module_path
+              FROM dtb_payment
+             WHERE payment_id = ?
+__EOS__;
+        $module_path = $objQuery->getOne($sql, array($payment_id));
+        if (file_exists($module_path)) {
+            return $module_path;
+        }
+        return false;
+    }
+
+    /**
+     * 支払い方法ID を取得する.
+     *
+     * 以下の順序で支払い方法IDを取得する.
+     *
+     * 1. $_SESSION['payment_id']
+     * 2. $_POST['payment_id']
+     * 3. $_GET['payment_id']
+     *
+     * 支払い方法IDが取得できない場合は false を返す.
+     *
+     * @access private
+     * @return integer|boolean 支払い方法の取得に成功した場合は支払い方法IDを返す;
+     *                         失敗した場合は, false を返す.
+     */
+    function getPaymentId() {
+        if (isset($_SESSION['payment_id'])
+            && !SC_Utils_Ex::isBlank($_SESSION['payment_id'])) {
+            return $_SESSION['payment_id'];
+        }
+
+        if (isset($_POST['payment_id'])
+            && !SC_Utils_Ex::isBlank($_POST['payment_id'])) {
+            return $_POST['payment_id'];
+        }
+
+        if (isset($_GET['payment_id'])
+            && !SC_Utils_Ex::isBlank($_GET['payment_id'])) {
+            return $_GET['payment_id'];
+        }
+
+        return false;
+    }
+}
+?>
Index: /branches/version-2_5-dev/data/class_extends/page_extends/shopping/LC_Page_Shopping_LoadPaymentModule_Ex.php
===================================================================
--- /branches/version-2_5-dev/data/class_extends/page_extends/shopping/LC_Page_Shopping_LoadPaymentModule_Ex.php	(revision 18864)
+++ /branches/version-2_5-dev/data/class_extends/page_extends/shopping/LC_Page_Shopping_LoadPaymentModule_Ex.php	(revision 18864)
@@ -0,0 +1,68 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(CLASS_PATH . "pages/shopping/LC_Page_Shopping_LoadPaymentModule.php");
+
+/**
+ * 決済モジュールの呼び出しを行うクラス(拡張).
+ *
+ * LC_Page_Shopping_LoadPaymentModule をカスタマイズする場合はこのクラスを編集する.
+ *
+ * @package Page
+ * @author Kentaro Ohkouchi
+ * @version $Id$
+ */
+class LC_Page_Shopping_LoadPaymentModule_Ex extends LC_Page_Shopping_LoadPaymentModule {
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        parent::process();
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+}
+?>
Index: /branches/version-2_5-dev/test/class/page/shopping/LC_Page_Shopping_LoadPaymentModule_Test.php
===================================================================
--- /branches/version-2_5-dev/test/class/page/shopping/LC_Page_Shopping_LoadPaymentModule_Test.php	(revision 18864)
+++ /branches/version-2_5-dev/test/class/page/shopping/LC_Page_Shopping_LoadPaymentModule_Test.php	(revision 18864)
@@ -0,0 +1,113 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+// {{{ requires
+require_once(realpath(dirname(__FILE__)) . '/../../../require.php');
+require_once(realpath(dirname(__FILE__)) . '/../../../../data/class/pages/shopping/LC_Page_Shopping_LoadPaymentModule.php');
+
+/**
+ * LC_Page_Admin_Products_ProductClass のテストケース.
+ *
+ * @package Page
+ * @author Kentaro Ohkouchi
+ * @version $Id$
+ */
+class LC_Page_Shopping_LoadPaymentModule_Test extends PHPUnit_Framework_TestCase {
+
+    function setUp() {
+        $this->objQuery =& SC_Query::getSingletonInstance();
+        $this->objQuery->begin();
+        $this->objPage = new LC_Page_Shopping_LoadPaymentModule();
+    }
+
+    function tearDown() {
+        $this->objQuery->rollback();
+        $this->objPage = null;
+    }
+
+    function testGetPaymentIdBySession() {
+        $_SESSION['payment_id'] = 1;
+        $_GET['payment_id'] = 2;
+        $_POST['payment_id'] = 3;
+
+        $this->expected = $_SESSION['payment_id'];
+        $this->actual = $this->objPage->getPaymentId();
+
+        $this->verify();
+    }
+
+    function testGetPaymentIdByPOST() {
+        $_GET['payment_id'] = 1;
+        $_POST['payment_id'] = 1;
+
+        $this->expected = $_POST['payment_id'];
+        $this->actual = $this->objPage->getPaymentId();
+
+        $this->verify();
+    }
+
+    function testGetPaymentIdByGET() {
+        $_GET['payment_id'] = 2;
+
+        $this->expected = $_GET['payment_id'];
+        $this->actual = $this->objPage->getPaymentId();
+
+        $this->verify();
+    }
+
+    function testGetPaymentIdIsNull() {
+        $this->assertFalse($this->objPage->getPaymentId());
+    }
+
+    function testGetModulePath() {
+        $payment_id = 10000;
+        $module_path = __FILE__;
+        $this->setPayment($payment_id, $module_path);
+
+        $this->expected = __FILE__;
+        $this->actual = $this->objPage->getModulePath($payment_id);
+
+        $this->verify();
+    }
+
+    function testGetModulePathIsFailure() {
+        $payment_id = 10000;
+        $module_path = "aaa";
+        $this->setPayment($payment_id, $module_path);
+
+        $this->actual = $this->objPage->getModulePath($payment_id);
+
+        $this->assertFalse($this->actual);
+
+    }
+
+    function verify() {
+        $this->assertEquals($this->expected, $this->actual);
+    }
+
+    function setPayment($payment_id, $module_path) {
+        $this->objQuery->insert("dtb_payment", array('payment_id' => $payment_id,
+                                                     'module_path' => $module_path,
+                                                     'creator_id' => 1));
+    }
+}
Index: /branches/version-2_5-dev/html/shopping/load_payment_module.php
===================================================================
--- /branches/version-2_5-dev/html/shopping/load_payment_module.php	(revision 18701)
+++ /branches/version-2_5-dev/html/shopping/load_payment_module.php	(revision 18864)
@@ -21,50 +21,15 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
+
+// {{{ requires
 require_once("../require.php");
+require_once(CLASS_EX_PATH . "page_extends/shopping/LC_Page_Shopping_LoadPaymentModule_Ex.php");
 
-$objSiteSess = new SC_SiteSession();
-$objCartSess = new SC_CartSession();
-$objQuery = new SC_Query();
+// }}}
+// {{{ generate page
 
-// 前のページで正しく登録手続きが行われた記録があるか判定
-SC_Utils::sfIsPrePage($objSiteSess);
-GC_Utils::gfPrintLog("before");
-// SPSモジュール連携用
-if (file_exists(MODULE_PATH . 'mdl_sps/inc/include.php')
- && !$objCartSess->getTotalQuantity()) {
-
-    require_once MODULE_PATH . 'mdl_sps/inc/include.php';
-    header("Location: " . ERROR_URL);
-    exit;
-}
-
-// アクセスの正当性の判定
-$uniqid = SC_Utils::sfCheckNormalAccess($objSiteSess, $objCartSess);
-GC_Utils::gfPrintLog("after");
-
-$payment_id = $_SESSION["payment_id"];
-
-// 支払いIDが無い場合にはエラー
-if($payment_id == ""){
-	SC_Utils::sfDispSiteError(PAGE_ERROR, "", true);
-}
-
-// 決済情報を取得する
-$objDB = new SC_Helper_DB_Ex();
-
-if($objDB->sfColumnExists("dtb_payment", "memo01")){
-	$sql = "SELECT module_path, memo01, memo02, memo03, memo04, memo05, memo06, memo07, memo08, memo09, memo10 FROM dtb_payment WHERE payment_id = ?";
-	$arrPayment = $objQuery->getall($sql, array($payment_id));
-}
-
-if(count($arrPayment) > 0) {
-	$path = $arrPayment[0]['module_path'];
-	if(file_exists($path)) {
-		require_once($path);
-		exit;
-	} else {
-		SC_Utils::sfDispSiteError(FREE_ERROR_MSG, "", true, "モジュールファイルの取得に失敗しました。<br />この手続きは無効となりました。");
-	}
-}
-
+$objPage = new LC_Page_Shopping_LoadPaymentModule_Ex();
+register_shutdown_function(array($objPage, "destroy"));
+$objPage->init();
+$objPage->process();
 ?>
