source: branches/feature-module-update/data/downloads/module/mdl_epsilon/card.php @ 16582

Revision 16582, 6.3 KB checked in by nanasess, 16 years ago (diff)

ライセンス表記変更

  • 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-2007 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("../require.php");
25require_once(DATA_PATH . "module/Request.php");
26require_once(MODULE_PATH . "mdl_epsilon/mdl_epsilon.inc");
27
28class LC_Page {
29    function LC_Page() {
30        /** 必ず指定する **/
31        $this->tpl_mainpage = 'mdl_epsilon/card.tpl';           // メインテンプレート
32        /*
33         session_start時のno-cacheヘッダーを抑制することで
34         「戻る」ボタン使用時の有効期限切れ表示を抑制する。
35         private-no-expire:クライアントのキャッシュを許可する。
36        */
37        session_cache_limiter('private-no-expire');     
38    }
39}
40
41$objPage = new LC_Page();
42$objView = new SC_SiteView();
43$objCampaignSess = new SC_CampaignSession();
44$objSiteInfo = $objView->objSiteInfo;
45$arrInfo = $objSiteInfo->data;
46
47// ユーザユニークIDの取得と購入状態の正当性をチェック
48$uniqid = sfCheckNormalAccess($objSiteSess, $objCartSess);
49
50// カート集計処理
51$objPage = sfTotalCart($objPage, $objCartSess, $arrInfo);
52
53// 一時受注テーブルの読込
54$arrData = sfGetOrderTemp($uniqid);
55
56// カート集計を元に最終計算
57$arrData = sfTotalConfirm($arrData, $objPage, $objCartSess, $arrInfo);
58
59// 代表商品情報
60$arrMainProduct = $objPage->arrProductsClass[0];
61
62// 支払い情報を取得
63$arrPayment = $objQuery->getall("SELECT module_id, memo01, memo02, memo03, memo04, memo05, memo06, memo07, memo08, memo09, memo10 FROM dtb_payment WHERE payment_id = ? ", array($arrData["payment_id"]));
64
65// trans_codeに値があり且つ、正常終了のときはオーダー確認を行う。
66if($_GET["result"] == "1"){
67   
68    // 正常な推移であることを記録しておく
69    $objSiteSess->setRegistFlag();
70   
71    // GETデータを保存
72    $arrVal["credit_result"] = $_GET["result"];
73    $arrVal["memo01"] = PAYMENT_CREDIT_ID;
74    $arrVal["memo03"] = $arrPayment[0]["module_id"];
75    $sqlval["memo04"] = sfGetXMLValue($arrXML,'RESULT','TRANS_CODE');
76
77    // トランザクションコード
78    $arrMemo["trans_code"] = array("name"=>"Epsilonトランザクションコード", "value" => $_GET["trans_code"]);
79    $arrVal["memo02"] = serialize($arrMemo);
80
81    // 決済送信データ作成
82    $arrModule['module_id'] = MDL_EPSILON_ID;
83    $arrModule['payment_total'] = $arrPayment[0]["payment_total"];
84    $arrModule['payment_id'] = PAYMENT_CREDIT_ID;
85    $arrVal["memo05"] = serialize($arrModule);
86
87    // 受注一時テーブルに更新
88    sfRegistTempOrder($uniqid, $arrVal);
89
90    // 完了画面へ
91    if (is_callable(SC_MobileUserAgent) && SC_MobileUserAgent::isMobile()) {
92        header("Location: " .  gfAddSessionId(URL_SHOP_COMPLETE));
93    } else {
94        header("Location: " .  URL_SHOP_COMPLETE);
95    }
96}
97
98// データ送信
99lfSendCredit($arrData, $arrPayment, $arrMainProduct);
100
101//---------------------------------------------------------------------------------------------------------------------------------------------------------
102
103// データ送信処理
104function lfSendCredit($arrData, $arrPayment, $arrMainProduct, $again = true){
105    global $objSiteSess;
106    global $objCampaignSess;
107   
108    // データ送信先CGI
109    $order_url = $arrPayment[0]["memo02"];
110
111    // 非会員のときは user_id に not_memberと送る
112    ($arrData["customer_id"] == 0) ? $user_id = "not_member" : $user_id = $arrData["customer_id"]; 
113   
114    // 送信データ生成
115    $item_name = $arrMainProduct["name"] . "×" . $arrMainProduct["quantity"] . "個 (代表)";
116    $arrSendData = array(
117        'contract_code' => $arrPayment[0]["memo01"],                        // 契約コード
118        'user_id' => $user_id ,                                             // ユーザID
119        'user_name' => $arrData["order_name01"].$arrData["order_name02"],   // ユーザ名
120        'user_mail_add' => $arrData["order_email"],                         // メールアドレス
121        'order_number' => $arrData["order_id"],                             // オーダー番号
122        'item_code' => $arrMainProduct["product_code"],                     // 商品コード(代表)
123        'item_name' => $item_name,                                          // 商品名(代表)
124        'item_price' => $arrData["payment_total"],                          // 商品価格(税込み総額)
125        'st_code' => $arrPayment[0]["memo04"],                              // 決済区分
126        'mission_code' => '1',                                              // 課金区分(固定)
127        'process_code' => '1',                                              // 処理区分(固定)
128        'xml' => '1',                                                       // 応答形式(固定)
129        'memo1' => "",                                                      // 予備01
130        'memo2' => ECCUBE_PAYMENT . "_" . date("YmdHis"),                   // 予備02
131    );
132
133    // データ送信
134    $arrXML = sfPostPaymentData($order_url, $arrSendData);
135   
136    // エラーがあるかチェックする
137    $err_code = sfGetXMLValue($arrXML,'RESULT','ERR_CODE');
138   
139    if($err_code != "") {
140        $err_detail = sfGetXMLValue($arrXML,'RESULT','ERR_DETAIL');
141       
142        // 決済区分エラーの場合には VISA,MASTER のみで再送信を試みる
143        if($err_code == "909" and $again){
144            $arrPayment[0]["memo04"] = "10000-0000-00000";
145            lfSendCredit($arrData, $arrPayment, $arrMainProduct, false);
146        }
147        sfDispSiteError(FREE_ERROR_MSG, "", true, "購入処理中に以下のエラーが発生しました。<br /><br /><br />・" . $err_detail . "<br /><br /><br />この手続きは無効となりました。");
148    } else {
149        // 正常な推移であることを記録しておく
150        $objSiteSess->setRegistFlag();
151       
152        // 携帯端末の場合は、セッションID・オーダー番号・戻ってくるURLを保存しておく。
153        if (is_callable(SC_MobileUserAgent) && SC_MobileUserAgent::isMobile()) {
154            sfMobileSetExtSessionId('order_number', $arrData['order_id'], 'shopping/load_payment_module.php');
155            sfMobileSetExtSessionId('order_number', $arrData['order_id'], 'shopping/confirm.php');
156        }
157
158        $url = sfGetXMLValue($arrXML,'RESULT','REDIRECT');
159        header("Location: " . $url);
160    }
161}
162
163?>
Note: See TracBrowser for help on using the repository browser.