7 * LICENSE: This source file is licensed under the terms of the GNU General Public License.
9 * @package Magic3 Framework
10 * @author 平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
11 * @copyright Copyright 2006-2012 Magic3 Project.
12 * @license http://www.gnu.org/copyleft/gpl.html GPL License
13 * @version SVN: $Id: admin_epsilonWidgetContainer.php 5437 2012-12-07 13:14:59Z fishbone $
14 * @link http://www.magic3.org
16 require_once($gEnvManager->getCurrentIWidgetContainerPath() . '/epsilonCommonDef.php');
17 require_once($gEnvManager->getContainerPath() . '/baseIWidgetContainer.php');
19 class admin_epsilonWidgetContainer extends BaseIWidgetContainer
21 const CONFIRM_TASK = 'confirm'; // 確認画面
22 const ERROR_TASK = 'error'; // エラー画面
23 const ACT_CANCEL = 'cancel'; // キャンセル処理実行
24 const ACT_COMPLETE = 'complete'; // 決済完了
29 function __construct()
32 parent::__construct();
37 * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
38 * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
40 * @param RequestManager $request HTTPリクエスト処理クラス
41 * @param string $act 実行処理
42 * @param object $configObj 定義情報オブジェクト
43 * @param object $optionObj 可変パラメータオブジェクト
44 * @return string テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
46 function _setTemplate($request, $act, $configObj, $optionObj)
48 return 'admin.tmpl.html';
53 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
55 * @param RequestManager $request HTTPリクエスト処理クラス
56 * @param string $act 実行処理
57 * @param object $configObj 定義情報オブジェクト
58 * @param object $optionObj 可変パラメータオブジェクト
61 function _assign($request, $act, $configObj, $optionObj)
64 $id = $optionObj->id; // ユニークなID(配送方法ID)
65 $init = $optionObj->init; // データ初期化を行うかどうか
68 $connectMode = $request->trimValueOf('iw_connect_mode'); // 接続モード
69 $contractCode = $request->trimValueOf('iw_contract_code'); // 契約番号
70 $url = $request->trimValueOf('iw_url'); // 本番サーバURL
72 if ($act == 'update'){ // 設定更新のとき
74 $this->checkInput($contractCode, '契約番号');
75 if ($connectMode == epsilonCommonDef::PRODUCTION_MODE){ // 本番サーバが選択されているとき
76 $this->checkUrl($url, '本番用URL');
79 if ($this->getMsgCount() == 0){ // エラーのないとき
80 $configObj->connectMode = $connectMode; // 接続モード
81 $configObj->contractCode = $contractCode; // 契約番号
82 $configObj->url = $url; // 本番サーバURL
83 $ret = $this->updateConfigObj($configObj);
84 if (!$ret) $this->setMsg(self::MSG_APP_ERR, 'インナーウィジェットデータの更新に失敗しました');
85 // ***** 正常に終了した場合はメッセージを残さない *****
87 } else if ($act == 'content'){ // 画面表示のとき
89 if (!empty($init)){ // 初期表示のとき
90 if (empty($configObj)){ // 定義値がないとき(管理画面なので最初は定義値が存在しない)
91 $connectMode = 'test'; // 接続モード
92 $contractCode = ''; // 契約番号
93 $url = ''; // 本番サーバURL
95 $connectMode = $configObj->connectMode; // 接続モード
96 $contractCode = $configObj->contractCode; // 契約番号
97 $url = $configObj->url; // 本番サーバURL
101 // インナーウィジェットのactを取得し、実行結果を表示
102 $iwidgetAct = $request->trimValueOf('iw_act');
103 if ($iwidgetAct == 'testconnect'){
104 $ret = $this->testConnect($contractCode);
105 if ($ret){ // サーバ接続成功
106 $msg = '<b><font color="green">サーバ接続に成功しました</font></b>'; // テーブル作成正常
108 $msg = '<b><font color="red">サーバ接続に失敗しました</font></b>'; // テーブル作成エラー
110 $this->tmpl->addVar("_widget", "test_result", $msg);
114 if ($connectMode == epsilonCommonDef::PRODUCTION_MODE){ // 本番モードのとき
115 $this->tmpl->addVar('_widget', 'production_checked', 'checked'); // 本番環境
117 $this->tmpl->addVar('_widget', 'test_checked', 'checked'); // テスト環境
119 $this->tmpl->addVar("_widget", "test_url", $this->convertToDispString(epsilonCommonDef::TEST_URL));
120 $this->tmpl->addVar("_widget", "contract_code", $contractCode); // 契約コード
121 $this->tmpl->addVar("_widget", "url", $url); // 本番サーバURL
122 if (empty($contractCode)) $this->tmpl->addVar("_widget", "test_disabled", "disabled"); // 「接続テスト」ボタン
125 $subPageId = $this->gPage->getPageSubIdByWidget($this->gEnv->getDefaultPageId(), $this->gEnv->getCurrentWidgetId());
126 $confirmUrl = $this->getUrl($this->gEnv->getDefaultUrl() . '?' .
127 M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $subPageId . '&' . M3_REQUEST_PARAM_OPERATION_TASK . '=' . self::CONFIRM_TASK . '&' .
128 M3_REQUEST_PARAM_OPERATION_ACT . '=' . self::ACT_COMPLETE, true);
129 $gobackUrl = $this->getUrl($this->gEnv->getDefaultUrl() . '?' .
130 M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $subPageId . '&' . M3_REQUEST_PARAM_OPERATION_TASK . '=' . self::CONFIRM_TASK . '&' .
131 M3_REQUEST_PARAM_OPERATION_ACT . '=' . self::ACT_CANCEL, true);
132 $errorUrl = $this->getUrl($this->gEnv->getDefaultUrl() . '?' .
133 M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $subPageId . '&' . M3_REQUEST_PARAM_OPERATION_TASK . '=' . self::ERROR_TASK, true);
134 $this->tmpl->addVar("_widget", "host_ip", $this->gRequest->trimServerValueOf('SERVER_ADDR')); // 決済サーバに接続するサーバのIP
135 $this->tmpl->addVar("_widget", "complete_url", $this->convertToDispString($confirmUrl));
136 $this->tmpl->addVar("_widget", "goback_url", $this->convertToDispString($gobackUrl));
137 $this->tmpl->addVar("_widget", "error_url", $this->convertToDispString($errorUrl));
143 * @param string $contractCode 契約番号
144 * @return bool true=成功、false=失敗
146 public function testConnect($contractCode)
149 $contract_code = $contractCode;
151 // 注文番号(注文毎にユニークな番号を割り当てます。ここでは仮に乱数を使用しています。)
152 $order_number = rand(0,99999999);
154 // 決済区分 (使用したい決済方法を指定してください。登録時に申し込まれていない決済方法は指定できません。)
155 // $st_code = '10100-0000-00000'; // 指定方法はCGI設定マニュアルの「決済区分について」を参照してください。
156 $st_code = '10000-0000-00000'; // クレジットカード決済のみ
157 // $st_code = '00100-0000-00000'; // コンビニ決済のみ
158 // $st_code = '10100-0000-00000'; // クレジットカード決済とコンビニ決済
161 // 課金区分 (1:一回のみ 2~10:月次課金)
162 // 月次課金について契約がない場合は利用できません。また、月次課金を設定した場合決済区分はクレジットカード決済のみとなります。
165 // 処理区分 (1:初回課金 2:登録済み課金 3:登録のみ 4:登録変更 8:月次課金解除 9:退会)
166 // 月次課金をご利用にならない場合は1:初回課金をご利用ください。
167 // 各処理区分のご利用に関してはCGI設定マニュアルの「処理区分について」を参照してください。
170 // 追加情報 1,2 (入力は必須ではありません)
171 $memo1 = "試験用オーダー情報";
174 // 商品コード (商品毎に識別コードを指定してください。ここでは仮に固定の値を指定しています。)
175 $item_code = "abc12345";
178 $item_name = "12345";
181 $user_id = 'testuser'; // ユーザーID
182 $user_name = 'テスト太郎'; // ユーザー氏名
183 $user_mail_add = 'test@example.com';// メールアドレス
185 $postParam = array();
186 $postParam['contract_code'] = $contract_code;
187 $postParam['user_id'] = $user_id;
188 $postParam['user_name'] = $user_name;
189 $postParam['user_mail_add'] = $user_mail_add;
190 $postParam['item_code'] = $item_code;
191 $postParam['item_name'] = $item_name;
192 $postParam['order_number'] = $order_number;
193 $postParam['st_code'] = $st_code;
194 $postParam['mission_code'] = $mission_code;
195 $postParam['item_price'] = $item_price;
196 $postParam['process_code'] = $process_code;
197 $postParam['memo1'] = $memo1;
198 $postParam['memo2'] = $memo2;
199 $postParam['xml'] = '1';
201 //$ret = $this->postData(epsilonCommonDef::TEST_URL, $postParam, $resultArray, true/*テストモード*/);
202 $ret = epsilonCommonDef::postData(epsilonCommonDef::TEST_URL, $postParam, $resultArray, true/*テストモード*/);