source: branches/beta/data/downloads/module/mdl_paygent/mdl_paygent.php @ 17012

Revision 17012, 11.8 KB checked in by satou, 15 years ago (diff)

[ペイジェント決済モジュール]3Dセキュア対応

Line 
1<?php
2/**
3 *
4 * @copyright   2000-2007 LOCKON CO.,LTD. All Rights Reserved.
5 * @version CVS: $Id: mdl_epsilon.php 1.3 2007-12-13 11:50:00Z satou $
6 * @link        http://www.lockon.co.jp/
7 *
8 */
9
10require_once(MODULE_PATH . "mdl_paygent/mdl_paygent.inc");
11
12$arrPayment = array(
13    1 => '¥¯¥ì¥¸¥Ã¥È',
14    2 => '¥³¥ó¥Ó¥Ë',
15    3 => 'ATM·èºÑ',
16    4 => '¶ä¹Ô¥Í¥Ã¥È'
17);
18
19$arrCredit = array(
20    1 => 'VISA, MASTER, Diners',
21    2 => 'JCB, AMEX'
22);
23
24$arrActive = array(
25    1 => 'Í×',
26    0 => 'ÉÔÍ×'
27);
28
29//¥Ú¡¼¥¸´ÉÍý¥¯¥é¥¹
30class LC_Page {
31    //¥³¥ó¥¹¥È¥é¥¯¥¿
32    function LC_Page() {
33        //¥á¥¤¥ó¥Æ¥ó¥×¥ì¡¼¥È¤Î»ØÄê
34        $this->tpl_mainpage = MODULE_PATH . 'mdl_paygent/mdl_paygent.tpl';
35        $this->tpl_subtitle = '¥Ú¥¤¥¸¥§¥ó¥È·èºÑ¥â¥¸¥å¡¼¥ë';
36        global $arrPayment;
37        $this->arrPayment = $arrPayment;
38        global $arrCredit;
39        $this->arrCredit = $arrCredit;
40        global $arrConvenience;
41        $this->arrConvenience = $arrConvenience;
42        global $arrActive;
43        $this->arrActive = $arrActive;
44    }
45}
46$objPage = new LC_Page();
47$objView = new SC_AdminView();
48$objQuery = new SC_Query();
49
50// ¥³¥ó¥Ó¥ËÆþ¶â¥Á¥§¥Ã¥¯
51lfEpsilonCheck();
52
53// ǧ¾Ú³Îǧ
54$objSess = new SC_Session();
55sfIsSuccess($objSess);
56
57// ¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹
58$objFormParam = new SC_FormParam();
59$objFormParam = lfInitParam($objFormParam);
60// POSTÃͤμèÆÀ
61$objFormParam->setParam($_POST);
62
63// ÈÆÍѹàÌܤòÄɲÃ(ɬ¿Ü¡ª¡ª)
64sfAlterMemo();
65
66switch($_POST['mode']) {
67case 'edit':
68    // ÆþÎÏ¥¨¥é¡¼È½Äê
69    $objPage->arrErr = lfCheckError();
70
71    // ¥¨¥é¡¼¤Ê¤·¤Î¾ì¹ç¤Ë¤Ï¥Ç¡¼¥¿¤ò¹¹¿·
72    if(count($objPage->arrErr) == 0) {
73        // ¥Ç¡¼¥¿¹¹¿·
74        lfUpdPaymentDB(MDL_PAYGENT_ID);
75       
76        // javascript¼Â¹Ô
77        $objPage->tpl_onload = 'alert("ÅÐÏ¿´°Î»¤·¤Þ¤·¤¿¡£\n´ðËܾðÊó¡ä»ÙʧÊýË¡ÀßÄê¤è¤ê¾ÜºÙÀßÄê¤ò¤·¤Æ¤¯¤À¤µ¤¤¡£"); window.close();';
78    }
79    break;
80case 'module_del':
81    // ÈÆÍѹàÌܤθºß¥Á¥§¥Ã¥¯
82    if(sfColumnExists("dtb_payment", "memo01")){
83        // ¥Ç¡¼¥¿¤Îºï½ü¥Õ¥é¥°¤ò¤¿¤Æ¤ë
84        $objQuery->query("UPDATE dtb_payment SET del_flg = 1 WHERE module_id = ?", array(MDL_EPSILON_ID));
85    }
86    break;
87default:
88    // ¥Ç¡¼¥¿¤Î¥í¡¼¥É
89    lfLoadData();   
90    break;
91}
92
93$objPage->arrForm = $objFormParam->getFormParamList();
94
95$objView->assignobj($objPage);                  //ÊÑ¿ô¤ò¥Æ¥ó¥×¥ì¡¼¥È¤Ë¥¢¥µ¥¤¥ó¤¹¤ë
96$objView->display($objPage->tpl_mainpage);      //¥Æ¥ó¥×¥ì¡¼¥È¤Î½ÐÎÏ
97//-------------------------------------------------------------------------------------------------------
98/* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ */
99function lfInitParam($objFormParam) {
100    $arrSiteInfo = sf_getBasisData();
101    // ¥Ç¥Õ¥©¥ë¥ÈÃÍ
102    $arrDefault  = array(
103        'credit_3d' => "0",
104        'conveni_limit_date' => 15,
105        'atm_limit_date'     => 30,
106        'payment_detail' => $arrSiteInfo['shop_kana'],
107        'claim_kanji'    => $arrSiteInfo['shop_kana'],
108        'claim_kana'     => $arrSiteInfo['shop_kana'],
109        'asp_payment_term' => 7,
110    );
111    $objFormParam->addParam("¥Þ¡¼¥Á¥ã¥ó¥ÈID", "merchant_id", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
112    $objFormParam->addParam("ÀܳID", "connect_id", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
113    $objFormParam->addParam("Àܳ¥Ñ¥¹¥ï¡¼¥É", "connect_password", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
114    $objFormParam->addParam("3D¥»¥­¥å¥¢", "credit_3d", "", "n", array("EXIST_CHECK"), $arrDefault['credit_3d']);
115    $objFormParam->addParam("»Ùʧ´ü¸ÂÆü", "conveni_limit_date", 2, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), $arrDefault['conveni_limit_date']);
116    $objFormParam->addParam("»Ùʧ´ü¸ÂÆü", "atm_limit_date", 2, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), $arrDefault['atm_limit_date']);
117    $objFormParam->addParam("ɽ¼¨Å¹ÊÞ̾(¥«¥Ê)", "payment_detail", 12, "KVa", array("MAX_LENGTH_CHECK", "KANA_CHECK"), $arrDefault['payment_detail']);
118    $objFormParam->addParam("»Ùʧ´ü¸ÂÆü", "asp_payment_term", 2, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), $arrDefault['asp_payment_term']);
119    $objFormParam->addParam("ɽ¼¨Å¹ÊÞ̾(´Á»ú)", "claim_kanji", 12, "KVa", array("MAX_LENGTH_CHECK"), $arrDefault['claim_kanji']);
120    $objFormParam->addParam("ɽ¼¨Å¹ÊÞ̾(¥«¥Ê)", "claim_kana", 12, "KVa", array("MAX_LENGTH_CHECK", "KANA_CHECK"), $arrDefault['claim_kana']);
121    $objFormParam->addParam("ÍøÍÑ·èºÑ", "payment", "", "", array("EXIST_CHECK"));
122    $objFormParam->addParam("·èºÑ¥Ú¡¼¥¸ÍÑ¥³¥Ô¡¼¥é¥¤¥È(Ⱦ³Ñ±Ñ¿ô)", "copy_right", 64, "KVa", array("MAX_LENGTH_CHECK"));
123    $objFormParam->addParam("·èºÑ¥Ú¡¼¥¸ÍÑÀâÌÀʸ(Á´³Ñ)", "free_memo", 128, "KVa", array("MAX_LENGTH_CHECK"));   
124    return $objFormParam;
125}
126   
127// ¥¨¥é¡¼¥Á¥§¥Ã¥¯¤ò¹Ô¤¦
128function lfCheckError(){
129    global $objFormParam;
130    $arrErr = $objFormParam->checkError();
131       
132    if($_POST['conveni_limit_date'] != "" && !($_POST['conveni_limit_date'] >= 1 &&  $_POST['conveni_limit_date'] <= 60)) {
133            $arrErr['conveni_limit_date'] = "¢¨ »Ùʧ´ü¸ÂÆü¤Ï¡¢1¡Á60Æü¤Þ¤Ç¤Î´Ö¤ÇÀßÄꤷ¤Æ¤¯¤À¤µ¤¤¡£<br>";
134    }
135    if($_POST['atm_limit_date'] != "" && !($_POST['atm_limit_date'] >= 0 &&  $_POST['atm_limit_date'] <= 60)) {
136            $arrErr['atm_limit_date'] = "¢¨ »Ùʧ´ü¸ÂÆü¤Ï¡¢0¡Á60Æü¤Þ¤Ç¤Î´Ö¤ÇÀßÄꤷ¤Æ¤¯¤À¤µ¤¤¡£<br>";
137    }
138    if(isset($_POST['payment_detail']) && $_POST['payment_detail'] == '') {
139            $arrErr['payment_detail'] = "¢¨ ɽ¼¨Å¹ÊÞ̾(¥«¥Ê)¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£<br>";
140    }
141    if(isset($_POST['claim_kanji']) && $_POST['claim_kanji'] == '') {
142            $arrErr['claim_kanji'] = "¢¨ ɽ¼¨Å¹ÊÞ̾¡Ê´Á»ú¡Ë¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£<br>";
143    }
144    if(isset($_POST['claim_kana']) && $_POST['claim_kana'] == '') {
145            $arrErr['claim_kana'] = "¢¨ ɽ¼¨Å¹ÊÞ̾¡Ê¥«¥Ê¡Ë¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£<br>";
146    }
147    /** ¶¦ÄÌÅÅʸ **/   
148    // ¥Þ¡¼¥Á¥ã¥ó¥ÈID
149    $arrParam['merchant_id'] = $objFormParam->getValue('merchant_id');
150    // ÀܳID
151    $arrParam['connect_id'] = $objFormParam->getValue('connect_id');
152    // Àܳ¥Ñ¥¹¥ï¡¼¥É
153    $arrParam['connect_password'] = $objFormParam->getValue('connect_password');
154
155    // Àܳ¥Æ¥¹¥È¤ò¼Â¹Ô¤¹¤ë¡£
156    if(!sfPaygentTest($arrParam)) {
157        $arrErr['err'] = "¢¨ Àܳ»î¸³¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£";
158    }   
159   
160    return $arrErr;
161}
162
163// ÅÐÏ¿¥Ç¡¼¥¿¤òÆɤ߹þ¤à
164function lfLoadData(){
165    global $objFormParam;
166   
167    //¥Ç¡¼¥¿¤ò¼èÆÀ
168    $arrRet = sfGetPaymentDB(MDL_PAYGENT_ID, "AND del_flg = '0'");
169    $objFormParam->setParam($arrRet[0]);
170   
171   
172    // ²èÌÌɽ¼¨ÍѤ˥ǡ¼¥¿¤òÊÑ´¹
173    $arrDisp = array();
174   
175    foreach($arrRet as $key => $val){
176        // ÍøÍÑ·èºÑ¤òɽ¼¨ÍѤËÊÑ´¹
177        $arrDisp["payment"][$key] = $val["payment"];
178       
179        switch($val['payment']) {
180        // ¥¯¥ì¥¸¥Ã¥È
181        case '1':
182            $arrParam = unserialize($val['other_param']);
183            $arrDisp['credit_3d'] = $arrParam['credit_3d'];
184            break;
185        // ¥³¥ó¥Ó¥Ë
186        case '2':
187            $arrParam = unserialize($val['other_param']);
188            $arrDisp['conveni_limit_date'] = $arrParam['payment_limit_date'];
189            break;
190        // ATM·èºÑ
191        case '3':
192            $arrParam = unserialize($val['other_param']);
193            $arrDisp['payment_detail'] = $arrParam['payment_detail'];
194            $arrDisp['atm_limit_date'] = $arrParam['payment_limit_date'];
195            break;
196        // ¥Í¥Ã¥È¥Ð¥ó¥¯
197        case '4':
198            $arrParam = unserialize($val['other_param']);
199            $arrDisp['claim_kana'] = $arrParam['claim_kana'];
200            $arrDisp['claim_kanji'] = $arrParam['claim_kanji'];
201            $arrDisp['asp_payment_term'] = $arrParam['asp_payment_term'];
202            $arrDisp['copy_right'] = $arrParam['copy_right'];
203            $arrDisp['free_memo'] = $arrParam['free_memo'];
204            break;                 
205        }
206    }   
207   
208    $objFormParam->setParam($arrDisp);
209}
210
211// ¥Ç¡¼¥¿¤Î¹¹¿·½èÍý
212function lfUpdPaymentDB($module_id){
213    global $objQuery;
214    global $objSess;
215   
216    // ´ØÏ¢¤¹¤ë»Ùʧ¤¤ÊýË¡¤Îdel_flg¤òºï½ü¤Ë¤·¤Æ¤ª¤¯
217    $del_sql = "UPDATE dtb_payment SET del_flg = 1 WHERE module_id = ? ";
218    $arrDel = array($module_id);
219    $objQuery->query($del_sql, $arrDel);
220   
221    // ¥Ç¡¼¥¿ÅÐÏ¿
222    foreach($_POST["payment"] as $key => $val){
223        // ¥é¥ó¥¯¤ÎºÇÂçÃͤò¼èÆÀ¤¹¤ë
224        $max_rank = $objQuery->getone("SELECT max(rank) FROM dtb_payment");
225        // »ÙʧÊýË¡¥Ç¡¼¥¿¤ò¼èÆÀ
226        $arrPaymentData = sfGetPaymentDB(MDL_PAYGENT_ID, "AND memo03 = ?", array($val));
227       
228        // ¥¯¥ì¥¸¥Ã¥È¤Ë¥Á¥§¥Ã¥¯¤¬Æþ¤Ã¤Æ¤¤¤ì¤Ð¥¯¥ì¥¸¥Ã¥È¤òÅÐÏ¿¤¹¤ë
229        if($val == 1){
230            $arrParam = array();
231            $arrParam['credit_3d'] = $_POST['credit_3d'];
232            $arrData = array(
233                "payment_method" => "PAYGENT¥¯¥ì¥¸¥Ã¥È"
234                ,"fix" => 3
235                ,"creator_id" => $objSess->member_id
236                ,"create_date" => "now()"
237                ,"update_date" => "now()"
238                ,"upper_rule" => 500000
239                ,"module_id" => $module_id
240                ,"module_path" => MODULE_PATH . "mdl_paygent/paygent_credit.php"
241                ,"memo01" => $_POST["merchant_id"]
242                ,"memo02" => $_POST["connect_id"]
243                ,"memo03" => $val
244                ,"memo04" => $_POST["connect_password"]
245                ,"memo05" => serialize($arrParam)
246                ,"del_flg" => "0"
247                ,"charge_flg" => "2"
248                ,"upper_rule_max" => CHARGE_MAX
249               
250            );
251        }
252       
253        // ¥³¥ó¥Ó¥Ë¤Ë¥Á¥§¥Ã¥¯¤¬Æþ¤Ã¤Æ¤¤¤ì¤Ð¥³¥ó¥Ó¥Ë¤òÅÐÏ¿¤¹¤ë
254        if($val == 2){
255            $arrParam = array();
256            $arrParam['payment_limit_date'] = $_POST['conveni_limit_date'];
257            $arrData = array(
258                "payment_method" => "PAYGENT¥³¥ó¥Ó¥Ë"
259                ,"fix" => 3
260                ,"creator_id" => $objSess->member_id
261                ,"create_date" => "now()"
262                ,"update_date" => "now()"
263                ,"upper_rule" => $upper_rule
264                ,"module_id" => $module_id
265                ,"module_path" => MODULE_PATH . "mdl_paygent/paygent_conveni.php"
266                ,"memo01" => $_POST["merchant_id"]
267                ,"memo02" => $_POST["connect_id"]
268                ,"memo03" => $val
269                ,"memo04" => $_POST["connect_password"]
270                ,"memo05" => serialize($arrParam)
271                ,"del_flg" => "0"
272                ,"charge_flg" => "1"
273                ,"upper_rule_max" => $upper_rule_max
274            );
275        }
276       
277        // ATM·èºÑ¤Ë¥Á¥§¥Ã¥¯¤¬Æþ¤Ã¤Æ¤¤¤ì¤ÐATM·èºÑ¤òÅÐÏ¿¤¹¤ë
278        if($val == 3){
279            $arrParam = array();
280            $arrParam['payment_detail'] = $_POST['payment_detail'];
281            $arrParam['payment_limit_date'] = $_POST['atm_limit_date'];
282            $arrData = array(
283                "payment_method" => "PAYGENTATM·èºÑ"
284                ,"fix" => 3
285                ,"creator_id" => $objSess->member_id
286                ,"create_date" => "now()"
287                ,"update_date" => "now()"
288                ,"upper_rule" => $upper_rule
289                ,"module_id" => $module_id
290                ,"module_path" => MODULE_PATH . "mdl_paygent/paygent_atm.php"
291                ,"memo01" => $_POST["merchant_id"]
292                ,"memo02" => $_POST["connect_id"]
293                ,"memo03" => $val
294                ,"memo04" => $_POST["connect_password"]
295                ,"memo05" => serialize($arrParam)
296                ,"del_flg" => "0"
297                ,"charge_flg" => "1"
298                ,"upper_rule_max" => $upper_rule_max
299            );
300        }
301       
302        // ¶ä¹ÔNET¤Ë¥Á¥§¥Ã¥¯¤¬Æþ¤Ã¤Æ¤¤¤ì¤ÐATM·èºÑ¤òÅÐÏ¿¤¹¤ë
303        if($val == 4){
304            $arrParam = array();
305            $arrParam['claim_kana'] = $_POST['claim_kana'];
306            $arrParam['claim_kanji'] = $_POST['claim_kanji'];
307            $arrParam['asp_payment_term'] = $_POST['asp_payment_term'];
308            $arrParam['copy_right'] = $_POST['copy_right'];
309            $arrParam['free_memo'] = $_POST['free_memo'];
310            $arrData = array(
311                "payment_method" => "PAYGENT¶ä¹Ô¥Í¥Ã¥È"
312                ,"fix" => 3
313                ,"creator_id" => $objSess->member_id
314                ,"create_date" => "now()"
315                ,"update_date" => "now()"
316                ,"upper_rule" => $upper_rule
317                ,"module_id" => $module_id
318                ,"module_path" => MODULE_PATH . "mdl_paygent/paygent_bank.php"
319                ,"memo01" => $_POST["merchant_id"]
320                ,"memo02" => $_POST["connect_id"]
321                ,"memo03" => $val
322                ,"memo04" => $_POST["connect_password"]
323                ,"memo05" => serialize($arrParam)
324                ,"del_flg" => "0"
325                ,"charge_flg" => "1"
326                ,"upper_rule_max" => $upper_rule_max
327            );
328        }
329       
330       
331        // ¥Ç¡¼¥¿¤¬Â¸ºß¤·¤Æ¤¤¤ì¤ÐUPDATE¡¢Ìµ¤±¤ì¤ÐINSERT
332        if(count($arrPaymentData) > 0){
333            $objQuery->update("dtb_payment", $arrData, " module_id = '" . $module_id . "' AND memo03 = '" . $val ."'");
334        }else{
335            $arrData["rank"] = $max_rank + 1;
336            $objQuery->insert("dtb_payment", $arrData);
337        }
338    }
339}
340
341// ¥³¥ó¥Ó¥ËÆþ¶â³Îǧ½èÍý
342function lfEpsilonCheck(){
343    global $objQuery;
344   
345    // trans_code ¤ò»ØÄꤵ¤ì¤Æ¤¤¤Æ³î¤Ä¡¢Æþ¶âºÑ¤ß¤Î¾ì¹ç
346    if($_POST["trans_code"] != "" and $_POST["paid"] == 1 and $_POST["order_number"] != ""){
347        // ¥¹¥Æ¡¼¥¿¥¹¤òÆþ¶âºÑ¤ß¤ËÊѹ¹¤¹¤ë
348        $sql = "UPDATE dtb_order SET status = 6, update_date = now() WHERE order_id = ? AND memo04 = ? ";
349        $objQuery->query($sql, array($_POST["order_number"], $_POST["trans_code"]));
350       
351        // POST¤ÎÆâÍƤòÁ´¤Æ¥í¥°Êݸ
352        $log_path = DATA_PATH . "logs/epsilon.log";
353        gfPrintLog("epsilon conveni start---------------------------------------------------------", $log_path);
354        foreach($_POST as $key => $val){
355            gfPrintLog( "\t" . $key . " => " . $val, $log_path);
356        }
357        gfPrintLog("epsilon conveni end-----------------------------------------------------------", $log_path);
358       
359        //±þÅú·ë²Ì¤òɽ¼¨
360        echo "1";
361    }
362}
363
364?>
Note: See TracBrowser for help on using the repository browser.