source: branches/beta/data/downloads/module/mdl_remise/remise_recv.php @ 16656

Revision 16656, 5.4 KB checked in by adachi, 16 years ago (diff)

ルミーズ決済結果通知の受信スクリプトを追加

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php
Line 
1<?php
2/**
3 *
4 * @copyright   2000-2007 LOCKON CO.,LTD. All Rights Reserved.
5 * @version CVS: $Id$
6 * @link        http://www.lockon.co.jp/
7 *
8 */
9require_once '../require.php';
10require_once MODULE_PATH . "mdl_remise/mdl_remise.inc";
11
12// ¥ë¥ß¡¼¥º¥«¡¼¥É¥¯¥ì¥¸¥Ã¥È·èºÑ·ë²ÌÄÌÃνèÍý
13lfRemiseCreditResultCheck();
14
15// ¥³¥ó¥Ó¥ËÆþ¶â¥Á¥§¥Ã¥¯
16lfRemiseConveniCheck();
17
18//-------------------------------------------------------------------------------------------------------
19
20// ¥ë¥ß¡¼¥º¥«¡¼¥É¥¯¥ì¥¸¥Ã¥È·èºÑ·ë²ÌÄÌÃνèÍý
21function lfRemiseCreditResultCheck(){
22    $objQuery = new SC_Query;
23
24    $log_path = DATA_PATH . "logs/remise_card_result.log";
25    gfPrintLog("remise card result : ".$_POST["X-TRANID"] , $log_path);
26
27    // TRAN_ID ¤ò»ØÄꤵ¤ì¤Æ¤¤¤Æ¡¢¥«¡¼¥É¾ðÊ󤬤¢¤ë¾ì¹ç
28    if (isset($_POST["X-TRANID"]) && isset($_POST["X-PARTOFCARD"])) {
29
30        $errFlg = FALSE;
31
32        gfPrintLog("remise card result start----------", $log_path);
33        foreach($_POST as $key => $val){
34            gfPrintLog( "\t" . $key . " => " . $val, $log_path);
35        }
36        gfPrintLog("remise credit result end  ----------", $log_path);
37
38        // IP¥¢¥É¥ì¥¹À©¸æ¤¹¤ë¾ì¹ç
39        if (REMISE_IP_ADDRESS_DENY == 1) {
40            gfPrintLog("remise remoto ip address : ".$_SERVER["REMOTE_HOST"]."-".$_SERVER["REMOTE_ADDR"], $log_path);
41            if (!isset($_SERVER["REMOTE_ADDR"]) || !lfIpAddressDenyCheck($_SERVER["REMOTE_ADDR"])) {
42                print("NOT REMISE SERVER");
43                exit;
44            }
45        }
46
47        // ÀÁµáÈÖ¹æ¤È¶â³Û¤Î¼èÆÀ
48        $order_id = 0;
49        $payment_total = 0;
50
51        if (isset($_POST["X-S_TORIHIKI_NO"])) {
52            $order_id = $_POST["X-S_TORIHIKI_NO"];
53        }
54
55        if (isset($_POST["X-TOTAL"])) {
56            $payment_total = $_POST["X-TOTAL"];
57        }
58
59        gfPrintLog("order_id : ".$order_id, $log_path);
60        gfPrintLog("payment_total : ".$payment_total, $log_path);
61
62        // Ãíʸ¥Ç¡¼¥¿¼èÆÀ
63        $arrTempOrder = $objQuery->getall("SELECT payment_total FROM dtb_order_temp WHERE order_id = ? ", array($order_id));
64
65        // ¶â³Û¤ÎÁê°ã
66        if (count($arrTempOrder) > 0) {
67            gfPrintLog("ORDER payment_total : ".$arrTempOrder[0]['payment_total'], $log_path);
68            if ($arrTempOrder[0]['payment_total'] == $payment_total) {
69                $errFlg = TRUE;
70            }
71        }
72
73        if ($errFlg) {
74            print(REMISE_PAYMENT_CHARGE_OK);
75            exit;
76        }
77        print("ERROR");
78        exit;
79    }
80}
81
82// ¥³¥ó¥Ó¥ËÆþ¶â³Îǧ½èÍý
83function lfRemiseConveniCheck(){
84    $objQuery = new SC_Query;
85
86    $log_path = DATA_PATH . "logs/remise_cv_charge.log";
87    gfPrintLog("remise conveni result : ".$_POST["JOB_ID"] , $log_path);
88
89    // ɬÍפʥǡ¼¥¿¤¬Á÷¿®¤µ¤ì¤Æ¤¤¤Æ¡¢¼ýǼÄÌÃΤμ«Æ°¼õ¿®¤òµö²Ä¤·¤Æ¤¤¤ë¾ì¹ç
90    if(isset($_POST["JOB_ID"]) && isset($_POST["REC_FLG"]) && REMISE_CONVENIENCE_RECIVE == 1){
91
92        $errFlg = FALSE;
93
94        // ¼ýǼºÑ¤ß¤Î¾ì¹ç
95        if ($_POST["REC_FLG"] == REMISE_CONVENIENCE_CHARGE) {
96            // POST¤ÎÆâÍƤòÁ´¤Æ¥í¥°Êݸ
97            gfPrintLog("remise conveni charge start----------", $log_path);
98            foreach($_POST as $key => $val){
99                gfPrintLog( "\t" . $key . " => " . $val, $log_path);
100            }
101            gfPrintLog("remise conveni charge end  ----------", $log_path);
102
103            // IP¥¢¥É¥ì¥¹À©¸æ¤¹¤ë¾ì¹ç
104            if (REMISE_IP_ADDRESS_DENY == 1) {
105                gfPrintLog("remise remoto ip address : ".$_SERVER["REMOTE_HOST"]."-".$_SERVER["REMOTE_ADDR"], $log_path);
106                if (!isset($_SERVER["REMOTE_ADDR"]) || !lfIpAddressDenyCheck($_SERVER["REMOTE_ADDR"])) {
107                    print("NOT REMISE SERVER");
108                    exit;
109                }
110            }
111
112            // ÀÁµáÈÖ¹æ¤È¶â³Û¤Î¼èÆÀ
113            $order_id = 0;
114            $payment_total = 0;
115
116            if (isset($_POST["S_TORIHIKI_NO"])) {
117                $order_id = $_POST["S_TORIHIKI_NO"];
118            }
119
120            if (isset($_POST["TOTAL"])) {
121                $payment_total = $_POST["TOTAL"];
122            }
123
124            gfPrintLog("order_id : ".$order_id, $log_path);
125            gfPrintLog("payment_total : ".$payment_total, $log_path);
126
127            // Ãíʸ¥Ç¡¼¥¿¼èÆÀ
128            $arrTempOrder = $objQuery->getall("SELECT payment_total FROM dtb_order_temp WHERE order_id = ? ", array($order_id));
129
130            // ¶â³Û¤ÎÁê°ã
131            if (count($arrTempOrder) > 0) {
132                gfPrintLog("ORDER payment_total : ".$arrTempOrder[0]['payment_total'], $log_path);
133                if ($arrTempOrder[0]['payment_total'] == $payment_total) {
134                    $errFlg = TRUE;
135                }
136            }
137
138            // JOB_ID¤ÈÀÁµáÈֹ档Æþ¶â¶â³Û¤¬°ìÃפ¹¤ë¾ì¹ç¤Î¤ß¡¢¥¹¥Æ¡¼¥¿¥¹¤òÆþ¶âºÑ¤ß¤ËÊѹ¹¤¹¤ë
139            if ($errFlg) {
140                $sql = "UPDATE dtb_order SET status = 6, update_date = now() ".
141                    "WHERE order_id = ? AND memo04 = ? ";
142                $objQuery->query($sql, array($order_id, $_POST["JOB_ID"]));
143
144                //±þÅú·ë²Ì¤òɽ¼¨
145                print(REMISE_CONVENIENCE_CHARGE_OK);
146                exit;
147            }
148        }
149        print("ERROR");
150        exit;
151    }
152}
153
154/**
155 * IP¥¢¥É¥ì¥¹ÂÓ°è¥Á¥§¥Ã¥¯
156 * @param $ip IP¥¢¥É¥ì¥¹
157 * @return boolean
158 */
159function lfIpAddressDenyCheck($ip) {
160
161    // IP¥¢¥É¥ì¥¹ÈϰϤËÆþ¤Ã¤Æ¤Ê¤¤¾ì¹ç
162    if (ip2long(REMISE_IP_ADDRESS_S) > ip2long($ip) ||
163        ip2long(REMISE_IP_ADDRESS_E) < ip2long($ip)) {
164        return FALSE;
165    }
166    return TRUE;
167}
168
169?>
Note: See TracBrowser for help on using the repository browser.