source: branches/feature-module-paygent/data/downloads/module/mdl_paygent/mdl_paygent.inc @ 15878

Revision 15878, 20.3 KB checked in by naka, 14 years ago (diff)
Line 
1<?php
2/**
3 *
4 * @copyright   2000-2006 LOCKON CO.,LTD. All Rights Reserved.
5 * @version CVS: $Id: mdl_epsilon.inc 7162 2006-11-18 09:53:33Z kakinaka $
6 * @link        http://www.lockon.co.jp/
7 *
8 */
9$paygent_credit_php_dir = realpath(dirname( __FILE__));
10// include_path¤Ëmdl_paygent¤Î¥Ñ¥¹¤ò´Þ¤á¤ë
11ini_set('include_path', $paygent_credit_php_dir . PATH_SEPARATOR . ini_get('include_path'));
12
13$paygent_module_dir = "jp/co/ks/merchanttool/connectmodule/";
14
15// ¥â¥¸¥å¡¼¥ë¥Õ¥¡¥¤¥ë¤Î¸ºß¥Á¥§¥Ã¥¯
16if(!file_exists($paygent_credit_php_dir . "/" . $paygent_module_dir)) {
17    print("¥Ú¥¤¥¸¥§¥ó¥ÈÄ󶡥⥸¥å¡¼¥ë¤òÀßÃÖ¤·¤Æ¤¯¤À¤µ¤¤¡£");
18    exit;
19}
20
21// paygent¥â¥¸¥å¡¼¥ë¤ÎÆɹþ
22include_once($paygent_module_dir . "entity/ResponseDataFactory.php");
23include_once($paygent_module_dir . "system/PaygentB2BModule.php");
24include_once($paygent_module_dir . "exception/PaygentB2BModuleConnectException.php");
25include_once($paygent_module_dir . "exception/PaygentB2BModuleException.php");
26
27// ¥Ú¥¤¥¸¥§¥ó¥È·èºÑ¤Î¥â¥¸¥å¡¼¥ëID¡Êdtb_module¤È¹ç¤ï¤»¤ë¡Ë
28define("MDL_PAYGENT_ID", 9);
29
30// ¥Ú¥¤¥¸¥§¥ó¥È¤Î³Æʧ¹þ¤ÎÂбþÈÖ¹æ
31/*
32    ÅÅʸ¼ïÊ̤òɽ¤¹¶èʬ
33    010¡§ATM·èºÑ¿½¹þ
34    020¡§Ž¶Ž°ŽÄŽÞ·èºÑŽµŽ°Ž¿ŽØ
35    021¡§Ž¶Ž°ŽÄŽÞ·èºÑŽµŽ°Ž¿ŽØŽ·Ž¬ŽÝŽ¾ŽÙ
36    022¡§Ž¶Ž°ŽÄŽÞ·èºÑÇä¾å
37    023¡§Ž¶Ž°ŽÄŽÞ·èºÑÇä¾åŽ·Ž¬ŽÝŽ¾ŽÙ
38    024¡§Ž¶Ž°ŽÄŽÞ·èºÑ3DŽµŽ°Ž¿ŽØ
39    030¡§ŽºŽÝŽËŽÞŽÆ·èºÑ(ÈÖ¹æÊý¼°)¿½¹þ
40    040¡§ŽºŽÝŽËŽÞŽÆ·èºÑ(ʧ¹þɼÊý¼°)¿½¹þ
41    050¡§¶ä¹ÔŽÈŽ¯ŽÄ·èºÑ¿½¹þ
42    060¡§¶ä¹Ô¥Í¥Ã¥È·èºÑASP
43    090¡§·èºÑ¾ðÊó¾È²ñ
44    091¡§º¹Ê¬¾È²ñ
45*/
46define("PAYGENT_BANK", '060');
47define("PAYGENT_ATM", '010');
48define("PAYGENT_CONVENI", '030');
49define("PAYGENT_CREDIT", '020');
50// ¥Ð¥Ã¥Á¤Ç»ÈÍѤ¹¤ë¡£
51define("PAYGENT_REF", '091');
52
53
54// ¼õÃí»þ¤Î½é´ü¥¹¥Æ¡¼¥¿¥¹
55$arrInitStatus = array(
56    PAYGENT_CREDIT => ORDER_NEW,        // ¥¯¥ì¥¸¥Ã¥È¤Ï¿·µ¬¼õÉÕ
57    PAYGENT_ATM => ORDER_PAY_WAIT,      // ATM·èºÑ¤ÏÆþ¶âÂÔ¤Á
58    PAYGENT_CONVENI => ORDER_PAY_WAIT,  // ¥³¥ó¥Ó¥Ë¤ÏÆþ¶âÂÔ¤Á
59    PAYGENT_BANK => ORDER_NEW,          // ¶ä¹Ô¤Ï¿·µ¬¼õÉÕ
60);
61
62define ("CHARGE_MAX", 500000);
63define ("SEVEN_CHARGE_MAX", 300000);
64
65// ÅÅʸ¥Ð¡¼¥¸¥ç¥ó
66define ("TELEGRAM_VERSION", '1.0');
67
68//¥³¥ó¥Ó¥Ë¤Î¼ïÎà
69$arrConvenience = array(
70    '00C016' => '¥»¥¤¥³¡¼¥Þ¡¼¥È',
71    '00C002' => '¥í¡¼¥½¥ó',
72    '00C004' => '¥ß¥Ë¥¹¥È¥Ã¥×',
73    '00C005' => '¥Õ¥¡¥ß¥ê¡¼¥Þ¡¼¥È',
74    '00C006' => '¥µ¥ó¥¯¥¹',
75    '00C007' => '¥µ¡¼¥¯¥ëK',
76    '00C014' => '¥Ç¥¤¥ê¡¼¥ä¥Þ¥¶¥­',
77    '00C001' => '¥»¥Ö¥ó¥¤¥ì¥Ö¥ó'
78);
79   
80// ¥Í¥Ã¥È¥Ð¥ó¥¯¤Î¼ïÎà
81$arrNetBank = array(
82    'D005' => 'e-payment',
83    'D008' => '¥Í¥Ã¥È¿¶¹þEDI',
84    'D009' => 'One\'s ¥À¥¤¥ì¥¯¥È',
85    'D033' => '¥¸¥ã¥Ñ¥ó¥Í¥Ã¥È¶ä¹Ô',
86    'D036' => '¥¤¡¼¥Ð¥ó¥¯' 
87);
88   
89// ¥¯¥ì¥¸¥Ã¥Èʬ³ä²ó¿ô
90$arrPaymentClass = array(
91    '10' => '°ì³çʧ¤¤',
92    '61-2' => 'ʬ³ä2²óʧ¤¤',
93    '61-3' => 'ʬ³ä3²óʧ¤¤',
94    '61-6' => 'ʬ³ä6²óʧ¤¤',
95    '61-10' => 'ʬ³ä10²óʧ¤¤',
96    '61-15' => 'ʬ³ä15²óʧ¤¤',
97    '61-20' => 'ʬ³ä20²óʧ¤¤',
98    '80' => '¥ê¥Üʧ¤¤'
99);
100
101/**************************************************************************************************************
102 * ´Ø¿ô̾   ¡§sfGetPaygentShare
103 * ½èÍýÆâÍÆ ¡§¥Ú¥¤¥¸¥§¥ó¥È¾ðÊóÁ÷¿®¤Î¶¦Ä̽èÍý
104 * °ú¿ô1    ¡§
105 * °ú¿ô2    ¡§
106 * °ú¿ô3    ¡§
107 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
108 **************************************************************************************************************/
109function sfGetPaygentShare($telegram_kind, $order_id, $arrParam) {
110   
111    /** ¶¦ÄÌÅÅʸ **/   
112    // ¥Þ¡¼¥Á¥ã¥ó¥ÈID
113    $arrSend['merchant_id'] = $arrParam['merchant_id'];
114    // ÀܳID
115    $arrSend['connect_id'] = $arrParam['connect_id'];
116    // Àܳ¥Ñ¥¹¥ï¡¼¥É
117    $arrSend['connect_password'] = $arrParam['connect_password'];
118    // ÅÅʸ¼ïÊÌID
119    $arrSend['telegram_kind'] = $telegram_kind;
120    // ÅÅʸ¥Ð¡¼¥¸¥ç¥ó
121    $arrSend['telegram_version'] = TELEGRAM_VERSION;
122    // ¥Þ¡¼¥Á¥ã¥ó¥È¼è°úID
123    $arrSend['trading_id'] = $order_id;
124    // EC-CUBE¤«¤é¤ÎÅÅʸ¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
125    $arrSend['partner'] = 'lockon';
126
127    return $arrSend;
128}
129   
130/**************************************************************************************************************
131 * ´Ø¿ô̾   ¡§sfSendPaygentCredit
132 * ½èÍýÆâÍÆ ¡§¥¯¥ì¥¸¥Ã¥È¾ðÊó¤ÎÁ÷¿®
133 * °ú¿ô1    ¡§
134 * °ú¿ô2    ¡§
135 * °ú¿ô3    ¡§
136 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
137 **************************************************************************************************************/
138function sfSendPaygentCredit($arrData, $arrInput, $uniqid) {
139// Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
140    $p = new PaygentB2BModule();
141    $p->init();
142   
143    //¡¡¥¯¥ì¥¸¥Ã¥ÈÍѥѥé¥á¡¼¥¿¤Î¼èÆÀ
144    $arrPaymentDB = sfGetPaymentDB(MDL_PAYGENT_ID, "AND memo03 = 1");
145    $arrOtherParam = unserialize($arrPaymentDB[0]['other_param']);
146   
147    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
148    $arrSend = sfGetPaygentShare(PAYGENT_CREDIT, $arrData['order_id'], $arrPaymentDB[0]);
149   
150    /** ¸ÄÊÌÅÅʸ **/
151   
152    // ·èºÑ¶â³Û
153    $arrSend['payment_amount'] = $arrData['payment_total'];
154    // ¥«¡¼¥ÉÈÖ¹æ
155    $arrSend['card_number'] = $arrInput['card_no01'].$arrInput['card_no02'].$arrInput['card_no03'].$arrInput['card_no04'];
156    // ¥«¡¼¥ÉÍ­¸ú´ü¸Â(MMYY)
157    $arrSend['card_valid_term'] = $arrInput['card_month'].$arrInput['card_year'];
158    // »Ùʧ¤¤¶èʬ¡¢Ê¬³ä²ó¿ô¤Î¼èÆÀ
159    list($payment_class, $split_count) = split("-", $arrInput['payment_class']);
160       
161    // »Ùʧ¤¤¶èʬ
162    /*
163     * 10:1²ó
164     * 23:¥Ü¡¼¥Ê¥¹1²ó
165     * 61:ʬ³ä
166     * 80:¥ê¥Ü¥ë¥Ó¥ó¥°
167     */
168    $arrSend['payment_class'] = $payment_class;
169    // ʬ³ä²ó¿ô
170    $arrSend['split_count'] = $split_count;
171    // 3D¥»¥­¥å¥¢ÉÞÍܶèʬ
172    $arrSend['3dsecure_ryaku'] = '1';
173   
174    // ÅÅʸ¤ÎÁ÷ÉÕ
175    foreach($arrSend as $key => $val) {
176        $p->reqPut($key, $val);
177    }
178   
179    // ÅÅʸ¤ÎÁ÷¿®
180    $p->post();
181
182    // ±þÅú¤ò½èÍý
183    $arrRet = sfPaygentResponse(PAYGENT_CREDIT, $p, $uniqid);
184   
185    return $arrRet;
186}
187
188/**************************************************************************************************************
189 * ´Ø¿ô̾   ¡§sfSendPaygentConveni
190 * ½èÍýÆâÍÆ ¡§¥³¥ó¥Ó¥Ë¾ðÊó¤ÎÁ÷¿®
191 * °ú¿ô1    ¡§
192 * °ú¿ô2    ¡§
193 * °ú¿ô3    ¡§
194 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
195 **************************************************************************************************************/
196function sfSendPaygentConveni($arrData, $arrInput, $uniqid) {
197// Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
198    $p = new PaygentB2BModule();
199    $p->init();
200   
201    //¡¡¥³¥ó¥Ó¥ËÍѥѥé¥á¡¼¥¿¤Î¼èÆÀ
202    $arrPaymentDB = sfGetPaymentDB(MDL_PAYGENT_ID, "AND memo03 = 2");
203    $arrOtherParam = unserialize($arrPaymentDB[0]['other_param']);
204   
205    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
206    $arrSend = sfGetPaygentShare(PAYGENT_CONVENI, $arrData['order_id'], $arrPaymentDB[0]);
207   
208    /** ¸ÄÊÌÅÅʸ **/
209   
210    // ·èºÑ¶â³Û
211    $arrSend['payment_amount'] = $arrData['payment_total'];
212    // ÍøÍѼÔÀ«
213    $arrSend['customer_family_name'] = $arrInput['customer_family_name'];
214    // ÍøÍѼÔ̾
215    $arrSend['customer_name'] = $arrInput['customer_name'];
216    // ÍøÍѼÔÀ«È¾³Ñ¥«¥Ê
217    $arrSend['customer_family_name_kana'] = mb_convert_kana($arrInput['customer_family_name_kana'],'k');
218    // ÍøÍѼÔ̾Ⱦ³Ñ¥«¥Ê
219    $arrSend['customer_name_kana'] = mb_convert_kana($arrInput['customer_name_kana'],'k');
220    // ÍøÍѼÔÅÅÏÃÈÖ¹æ
221    $arrSend['customer_tel'] = $arrInput['customer_tel'];
222    // »Ùʧ´ü¸ÂÆü
223    $arrSend['payment_limit_date'] = $arrOtherParam['payment_limit_date'];
224    // ¥³¥ó¥Ó¥Ë´ë¶È¥³¡¼¥É
225    $arrSend['cvs_company_id'] = $arrInput['cvs_company_id'];
226    // »Ùʧ¼ïÊÌ
227    $arrSend['sales_type'] = '1';
228   
229    // ÅÅʸ¤ÎÁ÷ÉÕ
230    foreach($arrSend as $key => $val) {
231        // Shift-JIS¤Ë¥¨¥ó¥³¡¼¥É¤¹¤ëɬÍפ¢¤ê
232        $enc_val = mb_convert_encoding($val, "Shift-JIS", CHAR_CODE);       
233        $p->reqPut($key, $enc_val);
234    }
235   
236    // ÅÅʸ¤ÎÁ÷¿®
237    $p->post();
238
239    // ±þÅú¤ò½èÍý
240    $arrRet = sfPaygentResponse(PAYGENT_CONVENI, $p, $uniqid);
241       
242    return $arrRet;
243}
244
245/**************************************************************************************************************
246 * ´Ø¿ô̾   ¡§sfSendPaygentATM
247 * ½èÍýÆâÍÆ ¡§ATM·èºÑ¾ðÊó¤ÎÁ÷¿®
248 * °ú¿ô1    ¡§
249 * °ú¿ô2    ¡§
250 * °ú¿ô3    ¡§
251 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
252 **************************************************************************************************************/
253function sfSendPaygentATM($arrData, $arrInput, $uniqid) {
254// Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
255    $p = new PaygentB2BModule();
256    $p->init();
257   
258    //¡¡ATM·èºÑÍѥѥé¥á¡¼¥¿¤Î¼èÆÀ
259    $arrPaymentDB = sfGetPaymentDB(MDL_PAYGENT_ID, "AND memo03 = 3");
260    $arrOtherParam = unserialize($arrPaymentDB[0]['other_param']);
261   
262    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
263    $arrSend = sfGetPaygentShare(PAYGENT_ATM, $arrData['order_id'], $arrPaymentDB[0]);
264   
265   
266    /** ¸ÄÊÌÅÅʸ **/
267   
268    // ·èºÑ¶â³Û
269    $arrSend['payment_amount'] = $arrData['payment_total'];
270
271    // ÍøÍѼÔÀ«
272    $arrSend['customer_family_name'] = $arrInput['customer_family_name'];
273    // ÍøÍѼÔ̾
274    $arrSend['customer_name'] = $arrInput['customer_name'];
275    // ÍøÍѼÔÀ«È¾³Ñ¥«¥Ê
276    $arrSend['customer_family_name_kana'] = mb_convert_kana($arrInput['customer_family_name_kana'],'k');
277    // ÍøÍѼÔ̾Ⱦ³Ñ¥«¥Ê
278    $arrSend['customer_name_kana'] = mb_convert_kana($arrInput['customer_name_kana'],'k');
279    // ·èºÑÆâÍÆ
280    $arrSend['payment_detail'] = $arrOtherParam['payment_detail'];
281    // ·èºÑÆâÍÆȾ³Ñ¥«¥Ê
282    $arrSend['payment_detail_kana'] = mb_convert_kana($arrOtherParam['payment_detail'],'k');
283    // »Ùʧ´ü¸ÂÆü
284    $arrSend['payment_limit_date'] = $arrOtherParam['payment_limit_date'];
285   
286    // ÅÅʸ¤ÎÁ÷ÉÕ
287    foreach($arrSend as $key => $val) {
288        // Shift-JIS¤Ë¥¨¥ó¥³¡¼¥É¤¹¤ëɬÍפ¢¤ê
289        $enc_val = mb_convert_encoding($val, "Shift-JIS", CHAR_CODE);       
290        $p->reqPut($key, $enc_val);
291    }
292   
293    // ÅÅʸ¤ÎÁ÷¿®
294    $p->post();
295   
296    // ±þÅú¤ò½èÍý
297    $arrRet = sfPaygentResponse(PAYGENT_ATM, $p, $uniqid);
298   
299    return $arrRet;
300}
301
302/**************************************************************************************************************
303 * ´Ø¿ô̾   ¡§sfSendPaygentBANK
304 * ½èÍýÆâÍÆ ¡§¶ä¹ÔNET·èºÑ¾ðÊó¤ÎÁ÷¿®
305 * °ú¿ô1    ¡§
306 * °ú¿ô2    ¡§
307 * °ú¿ô3    ¡§
308 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
309 **************************************************************************************************************/
310function sfSendPaygentBANK($arrData, $arrInput, $uniqid) {
311// Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
312    $p = new PaygentB2BModule();
313    $p->init();
314   
315    //¡¡¶ä¹ÔNETÍѥѥé¥á¡¼¥¿¤Î¼èÆÀ
316    $arrPaymentDB = sfGetPaymentDB(MDL_PAYGENT_ID, "AND memo03 = 4");
317    $arrOtherParam = unserialize($arrPaymentDB[0]['other_param']);
318   
319    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
320    $arrSend = sfGetPaygentShare(PAYGENT_BANK, $arrData['order_id'], $arrPaymentDB[0]);
321
322    /** ¸ÄÊÌÅÅʸ **/
323   
324    //$arrSend['bank_code'] = $arrInput['bank_code'];   
325    // ·èºÑ¶â³Û
326    $arrSend['amount'] = $arrData['payment_total'];
327    // ÀÁµáÆâÍÆ¥«¥Ê
328    $arrSend['claim_kana'] = $arrOtherParam['claim_kana'];
329    // ÀÁµáÆâÍÆ´Á»ú
330    $arrSend['claim_kanji'] = $arrOtherParam['claim_kanji'];   
331    // ÍøÍѼÔÀ«
332    $arrSend['customer_family_name'] = $arrInput['customer_family_name'];
333    // ÍøÍѼÔ̾
334    $arrSend['customer_name'] = $arrInput['customer_name'];
335    // ÍøÍѼÔÀ«È¾³Ñ¥«¥Ê
336    $arrSend['customer_family_name_kana'] = mb_convert_kana($arrInput['customer_family_name_kana'],'k');
337    // ÍøÍѼÔ̾Ⱦ³Ñ¥«¥Ê
338    $arrSend['customer_name_kana'] = mb_convert_kana($arrInput['customer_name_kana'],'k');
339    // PC-Mobile¶èʬ
340    /*
341     * 0:PC
342     * 1:docomo
343     * 2:au
344     * 3:softbank
345     */
346    $arrSend['pc_mobile_type'] = '0';
347    // ŹÊÞ̾
348    $arrSend['merchant_name'] = $arrOtherParam['claim_kanji']; 
349    // ´°Î»¸å¤ÎÌá¤ê£Õ£Ò£Ì
350    $arrSend['return_url'] = SSL_URL . "shopping/load_payment_module.php";
351    // Ìá¤ê¥Ü¥¿¥ó£Õ£Ò£Ì
352    $arrSend['stop_return_url'] = SSL_URL . "shopping/load_payment_module.php";
353   
354    // ¥³¥Ô¡¼¥é¥¤¥È
355    $arrSend['copy_right'] = $arrOtherParam['copy_right'];
356    // ¼«Í³¥á¥âÍó
357    $arrSend['free_memo'] = $arrOtherParam['free_memo'];
358    // »Ùʧ´ü´Ö(0DDhhmm)
359    $arrSend['asp_payment_term'] = sprintf("0%02d0000", $arrOtherParam['asp_payment_term']);
360   
361    // ÅÅʸ¤ÎÁ÷ÉÕ
362    foreach($arrSend as $key => $val) {
363        // Shift-JIS¤Ë¥¨¥ó¥³¡¼¥É¤¹¤ëɬÍפ¢¤ê
364        $enc_val = mb_convert_encoding($val, "Shift-JIS", CHAR_CODE);
365        $p->reqPut($key, $enc_val);
366    }
367   
368    // ÅÅʸ¤ÎÁ÷¿®
369    $p->post();
370   
371    // ±þÅú¤ò½èÍý
372    $arrRet = sfPaygentResponse(PAYGENT_BANK, $p, $uniqid);
373   
374    return $arrRet;
375}
376
377/**************************************************************************************************************
378 * ´Ø¿ô̾   ¡§sfPaygentResponse
379 * ½èÍýÆâÍÆ ¡§±þÅú¤ò½èÍý¤¹¤ë
380 * °ú¿ô1    ¡§
381 * °ú¿ô2    ¡§
382 * °ú¿ô3    ¡§
383 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
384 **************************************************************************************************************/
385
386function sfPaygentResponse($telegram_kind, $objPaygent, $uniqid) {
387    global $arrConvenience;
388    global $arrInitStatus;
389   
390    // ½èÍý·ë²Ì¼èÆÀ¡Ê¶¦ÄÌ¡Ë
391    $resultStatus = $objPaygent->getResultStatus(); # ½èÍý·ë²Ì 0=Àµ¾ï½ªÎ», 1=°Û¾ï½ªÎ»
392    $responseCode = $objPaygent->getResponseCode(); # °Û¾ï½ªÎ»»þ¡¢¥ì¥¹¥Ý¥ó¥¹¥³¡¼¥É¤¬¼èÆÀ¤Ç¤­¤ë
393    $responseDetail = $objPaygent->getResponseDetail(); # °Û¾ï½ªÎ»»þ¡¢¥ì¥¹¥Ý¥ó¥¹¾ÜºÙ¤¬¼èÆÀ¤Ç¤­¤ë
394
395    // Shift-JIS¤Ç±þÅú¤¬¤¢¤ë¤Î¤Ç¡¢¥¨¥ó¥³¡¼¥É¤¹¤ë¡£
396    $responseDetail = mb_convert_encoding($responseDetail, CHAR_CODE, "Shift-JIS");
397       
398   
399    // ¥ì¥¹¥Ý¥ó¥¹¤Î¼èÆÀ
400    while($objPaygent->hasResNext()) {
401        # ¥Ç¡¼¥¿¤¬Â¸ºß¤¹¤ë¸Â¤ê¡¢¼èÆÀ
402        $arrRes[] = $objPaygent->resNext(); # Í×µá·ë²Ì¼èÆÀ
403    }
404   
405    // ·èºÑËè¤Ë°Û¤Ê¤ë½èÍý
406    switch($telegram_kind) {
407    // ¥¯¥ì¥¸¥Ã¥È·èºÑ¤Î¾ì¹ç
408    case PAYGENT_CREDIT:
409        // ½é´ü¥¹¥Æ¡¼¥¿¥¹¤òÀßÄꤹ¤ë¡£
410        $arrVal["status"] = $arrInitStatus[PAYGENT_CREDIT];
411        // ¶õ¤ÎÇÛÎó¤ò³ÊǼ¤·¤Æ¤ª¤¯
412        $arrVal["memo02"] = serialize(array());     
413        break;
414    // ¥³¥ó¥Ó¥Ë·èºÑ¤Î¾ì¹ç
415    case PAYGENT_CONVENI:       
416        // ¥¿¥¤¥È¥ë¤òÀßÄꤹ¤ë
417        $arrMemo['title'] = sfSetConvMSG("¥³¥ó¥Ó¥Ë¤ª»Ùʧ¾ðÊó", true);   
418        //ʧ¹þɼURL(PC)
419        if($arrRes[0]['receipt_print_url'] != "") {
420            $arrMemo['receipt_print_url'] = sfSetConvMSG("ʧ¹þɼURL", $arrRes[0]['receipt_print_url']);
421        }
422        //ʧ¹þɼÈÖ¹æ
423        $arrMemo['receipt_number'] = sfSetConvMSG("ʧ¹þɼÈÖ¹æ", $arrRes[0]['receipt_number']);
424        $arrCVS = split("-", $arrRes[0]['usable_cvs_company_id']);
425        foreach($arrCVS as $val) {
426            if($cvsLine != "") {
427                $cvsLine.= ",".$arrConvenience[$val];               
428            } else {
429                $cvsLine = $arrConvenience[$val];
430            }
431        }
432        //Âоݥ³¥ó¥Ó¥Ë
433        $arrMemo['usable_cvs_company_id'] = sfSetConvMSG("¤ª»Ùʧ²Äǽ¤Ê¥³¥ó¥Ó¥Ë", $cvsLine);         
434        // »Ùʧ´üÆü
435        $arrMemo['payment_limit_date'] = sfSetConvMSG("¤ª»Ùʧ´üÆü", date("Yǯm·îdÆü", strtotime($arrRes[0]['payment_limit_date'])));
436        // ¼õÃí¥Æ¡¼¥Ö¥ë¤ËÊݸ
437        $arrVal["memo02"] = serialize($arrMemo);
438        // ½é´ü¥¹¥Æ¡¼¥¿¥¹¤òÀßÄꤹ¤ë¡£
439        $arrVal["status"] = $arrInitStatus[PAYGENT_CONVENI];       
440        break;
441    // ATM·èºÑ¤Î¾ì¹ç
442    case PAYGENT_ATM:
443        // ¥¿¥¤¥È¥ë¤òÀßÄꤹ¤ë
444        $arrMemo['title'] = sfSetConvMSG("ATM¤ª»Ùʧ¾ðÊó", true);   
445        $arrMemo['pay_center_number'] = sfSetConvMSG("¼ýǼµ¡´ØÈÖ¹æ", $arrRes[0]['pay_center_number']);
446        $arrMemo['customer_number'] = sfSetConvMSG("¤ªµÒÍÍÈÖ¹æ", $arrRes[0]['customer_number']);
447        $arrMemo['conf_number'] = sfSetConvMSG("³ÎǧÈÖ¹æ", $arrRes[0]['pay_center_number']);
448        // »Ùʧ´üÆü
449        $arrMemo['payment_limit_date'] = sfSetConvMSG("¤ª»Ùʧ´üÆü", date("Yǯm·îdÆü", strtotime($arrRes[0]['payment_limit_date'])));
450        // ¼õÃí¥Æ¡¼¥Ö¥ë¤ËÊݸ
451        $arrVal["memo02"] = serialize($arrMemo);
452        // ½é´ü¥¹¥Æ¡¼¥¿¥¹¤òÀßÄꤹ¤ë¡£
453        $arrVal["status"] = $arrInitStatus[PAYGENT_ATM];       
454        break;
455    // ¶ä¹Ô¥Í¥Ã¥È¤Î¾ì¹ç
456    case PAYGENT_BANK:
457        // ½é´ü¥¹¥Æ¡¼¥¿¥¹¤òÀßÄꤹ¤ë¡£
458        $arrVal["status"] = $arrInitStatus[PAYGENT_BANK];
459        // ¶õ¤ÎÇÛÎó¤ò³ÊǼ¤·¤Æ¤ª¤¯
460        $arrVal["memo02"] = serialize(array());
461        break;
462    default:
463        break;
464    }
465   
466    // ¼õÃí¥Æ¡¼¥Ö¥ë¤Ëµ­Ï¿¤¹¤ë
467    $arrVal["memo01"] = MDL_PAYGENT_ID;     // ½èÍý·ë²Ì
468       
469    // memo02¤Ï¡¢»Ùʧ¾ðÊó¤ò³ÊǼ¤¹¤ë¡£
470    $arrVal["memo03"] = $resultStatus;      // ½èÍý·ë²Ì
471    $arrVal["memo04"] = $responseCode;      // ¥ì¥¹¥Ý¥ó¥¹¥³¡¼¥É
472    $arrVal["memo05"] = $responseDetail;    // ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
473    $arrVal["memo06"] = $arrRes[0]['payment_id'];       // ¾µÇ§ÈÖ¹æ
474
475    // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Ë¹¹¿·
476    sfRegistTempOrder($uniqid, $arrVal);
477   
478    // ¾µÇ§ÈÖ¹æ¤È¥á¥Ã¥»¡¼¥¸¤òÊÖ¤¹
479    return $arrRes[0];
480}
481
482/**************************************************************************************************************
483 * ´Ø¿ô̾   ¡§sfSetConvMSG
484 * ½èÍýÆâÍÆ ¡§¥³¥ó¥Ó¥Ë¾ðÊóɽ¼¨ÍÑ
485 * °ú¿ô1    ¡§
486 * °ú¿ô2    ¡§
487 * °ú¿ô3    ¡§
488 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
489 **************************************************************************************************************/
490function sfSetConvMSG($name, $value){
491    return array("name" => $name, "value" => $value);
492}
493
494/**************************************************************************************************************
495 * ´Ø¿ô̾   ¡§sfPaygentDisp
496 * ½èÍýÆâÍÆ ¡§¶¦Ä̤Îɽ¼¨½èÍý
497 * °ú¿ô1    ¡§
498 * °ú¿ô2    ¡§
499 * °ú¿ô3    ¡§
500 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
501 **************************************************************************************************************/
502function sfPaygentDisp($objPage, $payment_id) {
503    $objQuery = new SC_Query();
504    // »Ùʧ¤¤ÊýË¡¤ÎÀâÌÀ²èÁü¤ò¼èÆÀ¤¹¤ë¡£
505    $arrRet = $objQuery->select("payment_method, payment_image", "dtb_payment", "payment_id = ?", array($payment_id));
506    $objPage->tpl_payment_method = $arrRet[0]['payment_method'];
507    $objPage->tpl_payment_image = $arrRet[0]['payment_image'];
508    return $objPage;
509}
510
511/**************************************************************************************************************
512 * ´Ø¿ô̾   ¡§sfGetPaymentDB
513 * ½èÍýÆâÍÆ ¡§É¬Íפʥǡ¼¥¿¤ò¼èÆÀ¤¹¤ë¡£
514 * °ú¿ô1    ¡§
515 * °ú¿ô2    ¡§
516 * °ú¿ô3    ¡§
517 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
518 **************************************************************************************************************/
519function sfGetPaymentDB($module_id, $where = "", $arrWhereVal = array()){
520    $objQuery = new SC_Query();
521       
522    $arrVal = array($module_id);
523    $arrVal = array_merge($arrVal, $arrWhereVal);
524   
525    $arrRet = array();
526    $sql = "SELECT
527                module_id,
528                memo01 as merchant_id,
529                memo02 as connect_id,
530                memo03 as payment,
531                memo04 as connect_password,
532                memo05 as other_param
533            FROM dtb_payment WHERE module_id = ? " . $where;
534    $arrRet = $objQuery->getall($sql, $arrVal);
535
536    return $arrRet;
537}
538
539/**************************************************************************************************************
540 * ´Ø¿ô̾   ¡§sfPaygentBatch
541 * ½èÍýÆâÍÆ ¡§Æþ¶â¥¹¥Æ¡¼¥¿¥¹³Îǧ¥Ð¥Ã¥Á
542 * °ú¿ô1    ¡§
543 * °ú¿ô2    ¡§
544 * °ú¿ô3    ¡§
545 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
546 **************************************************************************************************************/
547function sfPaygentBatch() {
548    $objQuery = new SC_Query();
549   
550    // Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
551    $objPaygent = new PaygentB2BModule();
552    $objPaygent->init();
553   
554    //¡¡ÀßÄê¥Ñ¥é¥á¡¼¥¿¤Î¼èÆÀ
555    $arrPaymentDB = sfGetPaymentDB(MDL_PAYGENT_ID);
556
557    $where = "memo01 = ? AND status = ?";
558    $arrOrder = $objQuery->select("order_id", "dtb_order", $where, array(MDL_PAYGENT_ID, ORDER_PAY_WAIT));
559   
560    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
561    $arrSend = sfGetPaygentShare(PAYGENT_REF, 0, $arrPaymentDB[0]);
562   
563    for($i = 0; $i < count($arrOrder); $i++) {
564        $arrRet = sfUpdatePaymentStatus($objPaygent, $arrOrder[$i]['order_id'], $arrSend);
565    }
566       
567    return $arrRet;
568}
569
570/**************************************************************************************************************
571 * ´Ø¿ô̾   ¡§sfPaygentTest
572 * ½èÍýÆâÍÆ ¡§Àܳ¥Æ¥¹¥È
573 * °ú¿ô1    ¡§
574 * °ú¿ô2    ¡§
575 * °ú¿ô3    ¡§
576 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
577 **************************************************************************************************************/
578function sfPaygentTest($arrParam) {
579    $objQuery = new SC_Query();
580   
581    // Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
582    $objPaygent = new PaygentB2BModule();
583    $objPaygent->init();
584       
585    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
586    $arrSend = sfGetPaygentShare(PAYGENT_REF, '0', $arrParam);
587
588    // ÅÅʸ¤ÎÁ÷ÉÕ
589    foreach($arrSend as $key => $val) {
590        $objPaygent->reqPut($key, $val);
591    }
592    // ÅÅʸ¤ÎÁ÷¿®
593    $objPaygent->post();
594   
595    // ½èÍý·ë²Ì¼èÆÀ¡Ê¶¦ÄÌ¡Ë
596    $resultStatus = $objPaygent->getResultStatus(); # ½èÍý·ë²Ì 0=Àµ¾ï½ªÎ», 1=°Û¾ï½ªÎ»
597           
598    if($resultStatus == 0) {
599        return true;
600    } else {
601        return false;
602    }
603}
604
605/**************************************************************************************************************
606 * ´Ø¿ô̾   ¡§sfCheckPaymentStatus
607 * ½èÍýÆâÍÆ ¡§Æþ¶â¥¹¥Æ¡¼¥¿¥¹³Îǧ¥Ð¥Ã¥Á
608 * °ú¿ô1    ¡§
609 * °ú¿ô2    ¡§
610 * °ú¿ô3    ¡§
611 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
612 **************************************************************************************************************/
613function sfUpdatePaymentStatus($objPaygent, $order_id, $arrSend) {
614    $objQuery = new SC_Query();
615       
616    // ¥Þ¡¼¥Á¥ã¥ó¥È¼è°úID¤ÎÆþ¤ìÂؤ¨
617    $arrSend['trading_id'] = $order_id;
618   
619    // ÅÅʸ¤ÎÁ÷ÉÕ
620    foreach($arrSend as $key => $val) {
621        $objPaygent->reqPut($key, $val);
622    }
623    // ÅÅʸ¤ÎÁ÷¿®
624    $objPaygent->post();
625   
626    // ¥ì¥¹¥Ý¥ó¥¹¤Î¼èÆÀ
627    while($objPaygent->hasResNext()) {
628        # ¥Ç¡¼¥¿¤¬Â¸ºß¤¹¤ë¸Â¤ê¡¢¼èÆÀ
629        $arrRes[] = $objPaygent->resNext(); # Í×µá·ë²Ì¼èÆÀ
630    }
631   
632    foreach($arrRes[0] as $key => $val) {
633        // Shift-JIS¤Ç±þÅú¤¬¤¢¤ë¤Î¤Ç¡¢¥¨¥ó¥³¡¼¥É¤¹¤ë¡£
634        $arrRes[0][$key] = mb_convert_encoding($val, CHAR_CODE, "Shift-JIS");
635        gfPrintLog($key."->".$arrRes[0][$key]);
636    }
637   
638    if($arrRes[0]['payment_status'] != "") {
639        gfPrintLog("¼õÃíÈÖ¹æ:" . $order_id . " »Ùʧ¥¹¥Æ¡¼¥¿¥¹:" . $arrRes[0]['payment_status']);   
640    } else {
641        gfPrintLog("¼õÃíÈÖ¹æ:" . $order_id . " »Ùʧ¥¹¥Æ¡¼¥¿¥¹:¼èÆÀ¤Ê¤·");   
642    }
643       
644    // »Ùʧ¥¹¥Æ¡¼¥¿¥¹¤Î¹¹¿·
645    /*
646     * 10:¿½¹þºÑ
647     * 12:»Ùʧ´ü¸ÂÀÚ¤ì
648     * 15:¿½¹þÃæÃÇ
649     * 40:¾Ã¹þºÑ
650     * 43:®Êó¸¡ÃκÑ
651     * 61:®Êó¼è¾ÃºÑ
652     * etc
653     */
654    if($arrRes[0]['payment_status'] == '40') {
655        // Æþ¶âºÑ¤ß¤ËÊѹ¹¤¹¤ë¡£
656        $arrVal['status'] = ORDER_PRE_END;
657    }
658       
659    $arrVal['memo07'] = $arrRes[0]['payment_status'];
660    $objQuery->update("dtb_order", $arrVal, "order_id = ?", array($order_id));
661   
662    return $arrRes[0];
663}
664
665?>
Note: See TracBrowser for help on using the repository browser.