source: branches/beta/data/downloads/module/mdl_paygent/mdl_paygent.inc @ 16788

Revision 16788, 28.0 KB checked in by satou, 15 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
53define("PAYGENT_AUTH_CANCEL", '021');
54define("PAYGENT_CARD_COMMIT", '022');
55define("PAYGENT_CARD_COMMIT_CANCEL", '023');
56
57// ̵¸Â¥ë¡¼¥×¤òÈò¤±¤ë
58define("PAYGENT_REF_LOOP", 1000);
59
60$arrDispKind = array(
61    PAYGENT_AUTH_CANCEL => '¥ª¡¼¥½¥ê¥­¥ã¥ó¥»¥ë',
62    PAYGENT_CARD_COMMIT => 'Çä¾å',
63    PAYGENT_CARD_COMMIT_CANCEL => 'Çä¾å¥­¥ã¥ó¥»¥ë'
64);
65
66// ¼õÃí»þ¤Î½é´ü¥¹¥Æ¡¼¥¿¥¹
67$arrInitStatus = array(
68    PAYGENT_CREDIT => ORDER_NEW,        // ¥¯¥ì¥¸¥Ã¥È¤Ï¿·µ¬¼õÉÕ
69    PAYGENT_ATM => ORDER_PAY_WAIT,      // ATM·èºÑ¤ÏÆþ¶âÂÔ¤Á
70    PAYGENT_CONVENI => ORDER_PAY_WAIT,  // ¥³¥ó¥Ó¥Ë¤ÏÆþ¶âÂÔ¤Á
71    PAYGENT_BANK => ORDER_PAY_WAIT      // ¶ä¹Ô¤ÏÆþ¶âÂÔ¤Á
72);
73
74define ("CHARGE_MAX", 500000);
75define ("SEVEN_CHARGE_MAX", 300000);
76
77// ÅÅʸ¥Ð¡¼¥¸¥ç¥ó
78define ("TELEGRAM_VERSION", '1.0');
79
80// ¥³¥ó¥Ó¥Ë¥³¡¼¥É
81define ("CODE_SEVENELEVEN", "00C001");  // ¥»¥Ö¥ó¥¤¥ì¥Ö¥ó
82define ("CODE_LOWSON", "00C002");       // ¥í¡¼¥½¥ó
83define ("CODE_MINISTOP", "00C004");     // ¥ß¥Ë¥¹¥È¥Ã¥×
84define ("CODE_FAMILYMART", "00C005");   // ¥Õ¥¡¥ß¥ê¡¼¥Þ¡¼¥È
85define ("CODE_SUNKUS", "00C006");       // ¥µ¥ó¥¯¥¹
86define ("CODE_CIRCLEK", "00C007");      // ¥µ¡¼¥¯¥ëK
87define ("CODE_YAMAZAKI", "00C014");     // ¥Ç¥¤¥ê¡¼¥ä¥Þ¥¶¥­
88define ("CODE_SEICOMART", "00C016");    // ¥»¥¤¥³¡¼¥Þ¡¼¥È
89
90//¥³¥ó¥Ó¥Ë¤Î¼ïÎà
91$arrConvenience = array(
92    CODE_SEICOMART => '¥»¥¤¥³¡¼¥Þ¡¼¥È',
93    CODE_LOWSON => '¥í¡¼¥½¥ó',
94    CODE_MINISTOP => '¥ß¥Ë¥¹¥È¥Ã¥×',
95    CODE_FAMILYMART => '¥Õ¥¡¥ß¥ê¡¼¥Þ¡¼¥È',
96    CODE_SUNKUS => '¥µ¥ó¥¯¥¹',
97    CODE_CIRCLEK => '¥µ¡¼¥¯¥ëK',
98    CODE_YAMAZAKI => '¥Ç¥¤¥ê¡¼¥ä¥Þ¥¶¥­',
99    CODE_SEVENELEVEN => '¥»¥Ö¥ó¥¤¥ì¥Ö¥ó'
100);
101   
102// ¥Í¥Ã¥È¥Ð¥ó¥¯¤Î¼ïÎà
103$arrNetBank = array(
104    'D005' => 'e-payment',
105    'D008' => '¥Í¥Ã¥È¿¶¹þEDI',
106    'D009' => 'One\'s ¥À¥¤¥ì¥¯¥È',
107    'D033' => '¥¸¥ã¥Ñ¥ó¥Í¥Ã¥È¶ä¹Ô',
108    'D036' => '¥¤¡¼¥Ð¥ó¥¯' 
109);
110   
111// ¥¯¥ì¥¸¥Ã¥Èʬ³ä²ó¿ô
112$arrPaymentClass = array(
113    '10' => '°ì³çʧ¤¤',
114    '61-2' => 'ʬ³ä2²óʧ¤¤',
115    '61-3' => 'ʬ³ä3²óʧ¤¤',
116    '61-6' => 'ʬ³ä6²óʧ¤¤',
117    '61-10' => 'ʬ³ä10²óʧ¤¤',
118    '61-15' => 'ʬ³ä15²óʧ¤¤',
119    '61-20' => 'ʬ³ä20²óʧ¤¤',
120    '80' => '¥ê¥Üʧ¤¤'
121);
122
123/**************************************************************************************************************
124 * ´Ø¿ô̾   ¡§sfGetPaygentShare
125 * ½èÍýÆâÍÆ ¡§¥Ú¥¤¥¸¥§¥ó¥È¾ðÊóÁ÷¿®¤Î¶¦Ä̽èÍý
126 * °ú¿ô1    ¡§
127 * °ú¿ô2    ¡§
128 * °ú¿ô3    ¡§
129 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
130 **************************************************************************************************************/
131function sfGetPaygentShare($telegram_kind, $order_id, $arrParam, $payment_id = "") {
132   
133    /** ¶¦ÄÌÅÅʸ **/   
134    // ¥Þ¡¼¥Á¥ã¥ó¥ÈID
135    $arrSend['merchant_id'] = $arrParam['merchant_id'];
136    // ÀܳID
137    $arrSend['connect_id'] = $arrParam['connect_id'];
138    // Àܳ¥Ñ¥¹¥ï¡¼¥É
139    $arrSend['connect_password'] = $arrParam['connect_password'];
140    // ÅÅʸ¼ïÊÌID
141    $arrSend['telegram_kind'] = $telegram_kind;
142    // ÅÅʸ¥Ð¡¼¥¸¥ç¥ó
143    $arrSend['telegram_version'] = TELEGRAM_VERSION;
144    // ¥Þ¡¼¥Á¥ã¥ó¥È¼è°úID
145    $arrSend['trading_id'] = $order_id;
146    // ·èºÑID
147    if (strlen($payment_id) > 0) $arrSend['payment_id'] = $payment_id;
148    // EC-CUBE¤«¤é¤ÎÅÅʸ¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
149    $arrSend['partner'] = 'lockon';
150   
151    return $arrSend;
152}
153   
154/**************************************************************************************************************
155 * ´Ø¿ô̾   ¡§sfSendPaygentCredit
156 * ½èÍýÆâÍÆ ¡§¥¯¥ì¥¸¥Ã¥È¾ðÊó¤ÎÁ÷¿®
157 * °ú¿ô1    ¡§
158 * °ú¿ô2    ¡§
159 * °ú¿ô3    ¡§
160 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
161 **************************************************************************************************************/
162function sfSendPaygentCredit($arrData, $arrInput, $uniqid) {
163    // Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
164    $p = new PaygentB2BModule();
165    $p->init();
166   
167    //¡¡¥¯¥ì¥¸¥Ã¥ÈÍѥѥé¥á¡¼¥¿¤Î¼èÆÀ
168    $arrPaymentDB = sfGetPaymentDB(MDL_PAYGENT_ID, "AND memo03 = 1");
169    $arrOtherParam = unserialize($arrPaymentDB[0]['other_param']);
170   
171    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
172    $arrSend = sfGetPaygentShare(PAYGENT_CREDIT, $arrData['order_id'], $arrPaymentDB[0]);
173   
174    /** ¸ÄÊÌÅÅʸ **/
175    // ·èºÑ¶â³Û
176    $arrSend['payment_amount'] = $arrData['payment_total'];
177    // ¥«¡¼¥ÉÈÖ¹æ
178    $arrSend['card_number'] = $arrInput['card_no01'].$arrInput['card_no02'].$arrInput['card_no03'].$arrInput['card_no04'];
179    // ¥«¡¼¥ÉÍ­¸ú´ü¸Â(MMYY)
180    $arrSend['card_valid_term'] = $arrInput['card_month'].$arrInput['card_year'];
181    // »Ùʧ¤¤¶èʬ¡¢Ê¬³ä²ó¿ô¤Î¼èÆÀ
182    list($payment_class, $split_count) = split("-", $arrInput['payment_class']);
183    // »Ùʧ¤¤¶èʬ
184    /*
185     * 10:1²ó
186     * 23:¥Ü¡¼¥Ê¥¹1²ó
187     * 61:ʬ³ä
188     * 80:¥ê¥Ü¥ë¥Ó¥ó¥°
189     */
190    $arrSend['payment_class'] = $payment_class;
191    // ʬ³ä²ó¿ô
192    $arrSend['split_count'] = $split_count;
193    // 3D¥»¥­¥å¥¢ÉÞÍܶèʬ
194    $arrSend['3dsecure_ryaku'] = '1';
195   
196    // ÅÅʸ¤ÎÁ÷ÉÕ
197    foreach($arrSend as $key => $val) {
198        $p->reqPut($key, $val);
199    }
200   
201    // ÅÅʸ¤ÎÁ÷¿®
202    $p->post();
203
204    // ±þÅú¤ò½èÍý
205    $arrRet = sfPaygentResponse(PAYGENT_CREDIT, $p, $uniqid, $arrInput);
206   
207    return $arrRet;
208}
209
210/**************************************************************************************************************
211 * ´Ø¿ô̾   ¡§sfSendPaygentConveni
212 * ½èÍýÆâÍÆ ¡§¥³¥ó¥Ó¥Ë¾ðÊó¤ÎÁ÷¿®
213 * °ú¿ô1    ¡§
214 * °ú¿ô2    ¡§
215 * °ú¿ô3    ¡§
216 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
217 **************************************************************************************************************/
218function sfSendPaygentConveni($arrData, $arrInput, $uniqid) {
219// Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
220    $p = new PaygentB2BModule();
221    $p->init();
222   
223    //¡¡¥³¥ó¥Ó¥ËÍѥѥé¥á¡¼¥¿¤Î¼èÆÀ
224    $arrPaymentDB = sfGetPaymentDB(MDL_PAYGENT_ID, "AND memo03 = 2");
225    $arrOtherParam = unserialize($arrPaymentDB[0]['other_param']);
226   
227    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
228    $arrSend = sfGetPaygentShare(PAYGENT_CONVENI, $arrData['order_id'], $arrPaymentDB[0]);
229   
230    /** ¸ÄÊÌÅÅʸ **/
231    // ·èºÑ¶â³Û
232    $arrSend['payment_amount'] = $arrData['payment_total'];
233    // ÍøÍѼÔÀ«
234    $arrSend['customer_family_name'] = $arrInput['customer_family_name'];
235    // ÍøÍѼÔ̾
236    $arrSend['customer_name'] = $arrInput['customer_name'];
237    // ÍøÍѼÔÀ«È¾³Ñ¥«¥Ê
238    $arrSend['customer_family_name_kana'] = mb_convert_kana($arrInput['customer_family_name_kana'],'k');
239    // ÍøÍѼÔ̾Ⱦ³Ñ¥«¥Ê
240    $arrSend['customer_name_kana'] = mb_convert_kana($arrInput['customer_name_kana'],'k');
241    // ÍøÍѼÔÅÅÏÃÈÖ¹æ
242    $arrSend['customer_tel'] = $arrInput['customer_tel'];
243    // »Ùʧ´ü¸ÂÆü
244    $arrSend['payment_limit_date'] = $arrOtherParam['payment_limit_date'];
245    // ¥³¥ó¥Ó¥Ë´ë¶È¥³¡¼¥É
246    $arrSend['cvs_company_id'] = $arrInput['cvs_company_id'];
247    // »Ùʧ¼ïÊÌ
248    $arrSend['sales_type'] = '1';
249   
250    // ÅÅʸ¤ÎÁ÷ÉÕ
251    foreach($arrSend as $key => $val) {
252        // Shift-JIS¤Ë¥¨¥ó¥³¡¼¥É¤¹¤ëɬÍפ¢¤ê
253        $enc_val = mb_convert_encoding($val, "Shift-JIS", CHAR_CODE);       
254        $p->reqPut($key, $enc_val);
255    }
256   
257    // ÅÅʸ¤ÎÁ÷¿®
258    $p->post();
259
260    // ±þÅú¤ò½èÍý
261    $arrRet = sfPaygentResponse(PAYGENT_CONVENI, $p, $uniqid, $arrInput);
262       
263    return $arrRet;
264}
265
266/**************************************************************************************************************
267 * ´Ø¿ô̾   ¡§sfSendPaygentATM
268 * ½èÍýÆâÍÆ ¡§ATM·èºÑ¾ðÊó¤ÎÁ÷¿®
269 * °ú¿ô1    ¡§
270 * °ú¿ô2    ¡§
271 * °ú¿ô3    ¡§
272 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
273 **************************************************************************************************************/
274function sfSendPaygentATM($arrData, $arrInput, $uniqid) {
275// Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
276    $p = new PaygentB2BModule();
277    $p->init();
278   
279    //¡¡ATM·èºÑÍѥѥé¥á¡¼¥¿¤Î¼èÆÀ
280    $arrPaymentDB = sfGetPaymentDB(MDL_PAYGENT_ID, "AND memo03 = 3");
281    $arrOtherParam = unserialize($arrPaymentDB[0]['other_param']);
282   
283    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
284    $arrSend = sfGetPaygentShare(PAYGENT_ATM, $arrData['order_id'], $arrPaymentDB[0]);
285   
286    /** ¸ÄÊÌÅÅʸ **/
287    // ·èºÑ¶â³Û
288    $arrSend['payment_amount'] = $arrData['payment_total'];
289    // ÍøÍѼÔÀ«
290    $arrSend['customer_family_name'] = $arrInput['customer_family_name'];
291    // ÍøÍѼÔ̾
292    $arrSend['customer_name'] = $arrInput['customer_name'];
293    // ÍøÍѼÔÀ«È¾³Ñ¥«¥Ê
294    $arrSend['customer_family_name_kana'] = mb_convert_kana($arrInput['customer_family_name_kana'],'k');
295    $arrSend['customer_family_name_kana'] = preg_replace("/Ž°/", "-", $arrSend['customer_family_name_kana']);
296    // ÍøÍѼÔ̾Ⱦ³Ñ¥«¥Ê
297    $arrSend['customer_name_kana'] = mb_convert_kana($arrInput['customer_name_kana'],'k');
298    $arrSend['customer_name_kana'] = preg_replace("/Ž°/", "-", $arrSend['customer_name_kana']);
299    // ·èºÑÆâÍÆ
300    $arrSend['payment_detail'] = $arrOtherParam['payment_detail'];
301    // ·èºÑÆâÍÆȾ³Ñ¥«¥Ê
302    $arrSend['payment_detail_kana'] = mb_convert_kana($arrOtherParam['payment_detail'],'k');
303    $arrSend['payment_detail_kana'] = preg_replace("/Ž°/", "-", $arrSend['payment_detail_kana']);
304    // »Ùʧ´ü¸ÂÆü
305    $arrSend['payment_limit_date'] = $arrOtherParam['payment_limit_date'];
306   
307    // ÅÅʸ¤ÎÁ÷ÉÕ
308    foreach($arrSend as $key => $val) {
309        // Shift-JIS¤Ë¥¨¥ó¥³¡¼¥É¤¹¤ëɬÍפ¢¤ê
310        $enc_val = mb_convert_encoding($val, "Shift-JIS", CHAR_CODE);       
311        $p->reqPut($key, $enc_val);
312    }
313   
314    // ÅÅʸ¤ÎÁ÷¿®
315    $p->post();
316   
317    // ±þÅú¤ò½èÍý
318    $arrRet = sfPaygentResponse(PAYGENT_ATM, $p, $uniqid, $arrInput);
319   
320    return $arrRet;
321}
322
323/**************************************************************************************************************
324 * ´Ø¿ô̾   ¡§sfSendPaygentBANK
325 * ½èÍýÆâÍÆ ¡§¶ä¹ÔNET·èºÑ¾ðÊó¤ÎÁ÷¿®
326 * °ú¿ô1    ¡§
327 * °ú¿ô2    ¡§
328 * °ú¿ô3    ¡§
329 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
330 **************************************************************************************************************/
331function sfSendPaygentBANK($arrData, $arrInput, $uniqid) {
332// Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
333    $p = new PaygentB2BModule();
334    $p->init();
335   
336    //¡¡¶ä¹ÔNETÍѥѥé¥á¡¼¥¿¤Î¼èÆÀ
337    $arrPaymentDB = sfGetPaymentDB(MDL_PAYGENT_ID, "AND memo03 = 4");
338    $arrOtherParam = unserialize($arrPaymentDB[0]['other_param']);
339   
340    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
341    $arrSend = sfGetPaygentShare(PAYGENT_BANK, $arrData['order_id'], $arrPaymentDB[0]);
342   
343    /** ¸ÄÊÌÅÅʸ **/
344    //$arrSend['bank_code'] = $arrInput['bank_code'];   
345    // ·èºÑ¶â³Û
346    $arrSend['amount'] = $arrData['payment_total'];
347    // ÀÁµáÆâÍÆ¥«¥Ê
348    $arrSend['claim_kana'] = mb_convert_kana($arrOtherParam['claim_kana'],'k');
349    $arrSend['claim_kana'] = preg_replace("/Ž°/", "-", $arrSend['claim_kana']);
350    // ÀÁµáÆâÍÆ´Á»ú
351    $arrSend['claim_kanji'] = $arrOtherParam['claim_kanji'];   
352    // ÍøÍѼÔÀ«
353    $arrSend['customer_family_name'] = $arrInput['customer_family_name'];
354    // ÍøÍѼÔ̾
355    $arrSend['customer_name'] = $arrInput['customer_name'];
356    // ÍøÍѼÔÀ«È¾³Ñ¥«¥Ê
357    $arrSend['customer_family_name_kana'] = mb_convert_kana($arrInput['customer_family_name_kana'],'k');
358    $arrSend['customer_family_name_kana'] = preg_replace("/Ž°/", "-", $arrSend['customer_family_name_kana']);
359    // ÍøÍѼÔ̾Ⱦ³Ñ¥«¥Ê
360    $arrSend['customer_name_kana'] = mb_convert_kana($arrInput['customer_name_kana'],'k');
361    $arrSend['customer_name_kana'] = preg_replace("/Ž°/", "-", $arrSend['customer_name_kana']);
362    // PC-Mobile¶èʬ
363    /*
364     * 0:PC
365     * 1:docomo
366     * 2:au
367     * 3:softbank
368     */
369    $arrSend['pc_mobile_type'] = '0';
370    // ŹÊÞ̾
371    $arrSend['merchant_name'] = $arrOtherParam['claim_kanji'];
372    // ´°Î»¸å¤ÎÌá¤ê£Õ£Ò£Ì
373    $arrSend['return_url'] = SITE_URL. "index.php";
374    // Ìá¤ê¥Ü¥¿¥ó£Õ£Ò£Ì
375    $arrSend['stop_return_url'] = SSL_URL. "shopping/load_payment_module.php";
376    // ¥³¥Ô¡¼¥é¥¤¥È
377    $arrSend['copy_right'] = $arrOtherParam['copy_right'];
378    // ¼«Í³¥á¥âÍó
379    $arrSend['free_memo'] = $arrOtherParam['free_memo'];
380    // »Ùʧ´ü´Ö(0DDhhmm)
381    $arrSend['asp_payment_term'] = sprintf("0%02d0000", $arrOtherParam['asp_payment_term']);
382   
383    // ÅÅʸ¤ÎÁ÷ÉÕ
384    foreach($arrSend as $key => $val) {
385        // Shift-JIS¤Ë¥¨¥ó¥³¡¼¥É¤¹¤ëɬÍפ¢¤ê
386        $enc_val = mb_convert_encoding($val, "Shift-JIS", CHAR_CODE);
387        $p->reqPut($key, $enc_val);
388    }
389   
390    // ÅÅʸ¤ÎÁ÷¿®
391    $p->post();
392   
393    // ±þÅú¤ò½èÍý
394    $arrRet = sfPaygentResponse(PAYGENT_BANK, $p, $uniqid, $arrInput);
395   
396    return $arrRet;
397}
398
399
400/**************************************************************************************************************
401 * ´Ø¿ô̾   ¡§sfPaygentResponse
402 * ½èÍýÆâÍÆ ¡§±þÅú¤ò½èÍý¤¹¤ë
403 * °ú¿ô1    ¡§
404 * °ú¿ô2    ¡§
405 * °ú¿ô3    ¡§
406 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
407 **************************************************************************************************************/
408function sfPaygentResponse($telegram_kind, $objPaygent, $uniqid, $arrInput) {
409    global $arrConvenience;
410    global $arrInitStatus;
411   
412    // ½èÍý·ë²Ì¼èÆÀ¡Ê¶¦ÄÌ¡Ë
413    $resultStatus = $objPaygent->getResultStatus(); # ½èÍý·ë²Ì 0=Àµ¾ï½ªÎ», 1=°Û¾ï½ªÎ»
414    $responseCode = $objPaygent->getResponseCode(); # °Û¾ï½ªÎ»»þ¡¢¥ì¥¹¥Ý¥ó¥¹¥³¡¼¥É¤¬¼èÆÀ¤Ç¤­¤ë
415    $responseDetail = $objPaygent->getResponseDetail(); # °Û¾ï½ªÎ»»þ¡¢¥ì¥¹¥Ý¥ó¥¹¾ÜºÙ¤¬¼èÆÀ¤Ç¤­¤ë
416
417    // Shift-JIS¤Ç±þÅú¤¬¤¢¤ë¤Î¤Ç¡¢¥¨¥ó¥³¡¼¥É¤¹¤ë¡£
418    $responseDetail = mb_convert_encoding($responseDetail, CHAR_CODE, "Shift-JIS");
419   
420    $arrResOther['result'] = $resultStatus;
421    $arrResOther['code'] = $responseCode;
422    $arrResOther['detail'] = $responseDetail;
423   
424    // ¼èÆÀ¤·¤¿Ãͤò¥í¥°¤ËÊݸ¤¹¤ë¡£
425    foreach($arrResOther as $key => $val) {
426        gfPrintLog($key."->".$val);
427    }
428       
429    // ¥ì¥¹¥Ý¥ó¥¹¤Î¼èÆÀ
430    while($objPaygent->hasResNext()) {
431        # ¥Ç¡¼¥¿¤¬Â¸ºß¤¹¤ë¸Â¤ê¡¢¼èÆÀ
432        $arrRes[] = $objPaygent->resNext(); # Í×µá·ë²Ì¼èÆÀ
433    }
434   
435    $arrRes[0]['result'] = $resultStatus;
436   
437    // ¼èÆÀ¤·¤¿Ãͤò¥í¥°¤ËÊݸ¤¹¤ë¡£
438    foreach($arrRes[0] as $key => $val) {
439        gfPrintLog($key."->".$val);
440    }
441   
442    // ·èºÑËè¤Ë°Û¤Ê¤ë½èÍý
443    switch($telegram_kind) {
444    // ¥¯¥ì¥¸¥Ã¥È·èºÑ¤Î¾ì¹ç
445    case PAYGENT_CREDIT:
446        // ½é´ü¥¹¥Æ¡¼¥¿¥¹¤òÀßÄꤹ¤ë¡£
447        $arrVal["status"] = $arrInitStatus[PAYGENT_CREDIT];
448        // ¶õ¤ÎÇÛÎó¤ò³ÊǼ¤·¤Æ¤ª¤¯
449        $arrVal["memo02"] = serialize(array());     
450        break;
451    // ¥³¥ó¥Ó¥Ë·èºÑ¤Î¾ì¹ç
452    case PAYGENT_CONVENI:
453        // ¥¿¥¤¥È¥ë¤òÀßÄꤹ¤ë
454        $arrMemo['title'] = sfSetConvMSG("¥³¥ó¥Ó¥Ë¤ª»Ùʧ¾ðÊó", true);
455        // ·èºÑ¥Ù¥ó¥À¼õÉÕÈÖ¹æ¡Ê¥³¥ó¥Ó¥Ë¤Ë¤è¤Ã¤Æ̾¾Î¤¬°Û¤Ê¤ë¡Ë
456        switch ($arrInput['cvs_company_id']) {
457        // ¥»¥Ö¥ó¥¤¥ì¥Ö¥ó
458        case CODE_SEVENELEVEN:
459            $receipt_num_name = "ʧ¹þɼÈÖ¹æ";
460            break;
461        // ¥í¡¼¥½¥ó¡¤¥Õ¥¡¥ß¥ê¡¼¥Þ¡¼¥È
462        case CODE_LOWSON:
463        case CODE_FAMILYMART:
464            $receipt_num_name = "¤ªµÒÍÍÈÖ¹æ";
465            break;
466        // ¥ß¥Ë¥¹¥È¥Ã¥×¡¤¥µ¥ó¥¯¥¹¡¤¥µ¡¼¥¯¥ëK¡¤¥Ç¥¤¥ê¡¼¥ä¥Þ¥¶¥­
467        case CODE_MINISTOP:
468        case CODE_SUNKUS:
469        case CODE_CIRCLEK:
470        case CODE_YAMAZAKI:
471            $receipt_num_name = "¥±¡¼¥¿¥¤¡¿¥ª¥ó¥é¥¤¥ó·èºÑÈÖ¹æ";
472            break;
473        // ¥»¥¤¥³¡¼¥Þ¡¼¥È
474        case CODE_SEICOMART:
475            $receipt_num_name = "¤ªµÒÍͤμõÉÕÈÖ¹æ";
476            break;
477        default:
478            break;
479        }
480        $arrMemo['receipt_number'] = sfSetConvMSG($receipt_num_name, $arrRes[0]['receipt_number']);
481        // ʧ¹þɼURL(PC) ¡§ ¥»¥Ö¥ó¥¤¥ì¥Ö¥ó¤Î¾ì¹ç¤Î¤ßʧ¹þɼURL¤¬Í­¸ú¤Ê¤Î¤Çɽ¼¨¤¹¤ë¡£
482        if($arrRes[0]['receipt_print_url'] != "" && $arrInput['cvs_company_id'] == CODE_SEVENELEVEN) {
483            $arrMemo['receipt_print_url'] = sfSetConvMSG("ʧ¹þɼURL", $arrRes[0]['receipt_print_url']);
484        }
485        // ³ÎǧÈÖ¹æ ¡§ ¥í¡¼¥½¥ó¡¤¥Õ¥¡¥ß¥ê¡¼¥Þ¡¼¥È¤Î¤ß³ÎǧÈֹ椬ɬÍפʤΤÇɽ¼¨¤¹¤ë¡£
486        if ($arrInput['cvs_company_id'] == CODE_LOWSON || $arrInput['cvs_company_id'] == CODE_FAMILYMART) {
487            $arrMemo['confirm_number'] = sfSetConvMSG("³ÎǧÈÖ¹æ", "400008");
488        }
489        // Âоݥ³¥ó¥Ó¥Ë
490        $arrCVS = split("-", $arrRes[0]['usable_cvs_company_id']);
491        foreach($arrCVS as $val) {
492            if($cvsLine != "") {
493                $cvsLine.= ",".$arrConvenience[$val];
494            } else {
495                $cvsLine = $arrConvenience[$val];
496            }
497        }
498        $arrMemo['usable_cvs_company_id'] = sfSetConvMSG("¤ª»Ùʧ²Äǽ¤Ê¥³¥ó¥Ó¥Ë", $cvsLine);
499        // »Ùʧ´üÆü
500        $arrMemo['payment_limit_date'] = sfSetConvMSG("¤ª»Ùʧ´üÆü", date("Yǯm·îdÆü", strtotime($arrRes[0]['payment_limit_date'])));
501        // ¥Ø¥ë¥×²èÌÌ
502        $arrMemo['help_url'] = sfSetConvMSG("¤ª»ÙʧÊýË¡¤ÎÀâÌÀ", "http://www.paygent.co.jp/service/pay_cvs.html");
503               
504        // ¼õÃí¥Æ¡¼¥Ö¥ë¤ËÊݸ
505        $arrVal["memo02"] = serialize($arrMemo);
506        // ½é´ü¥¹¥Æ¡¼¥¿¥¹¤òÀßÄꤹ¤ë¡£
507        $arrVal["status"] = $arrInitStatus[PAYGENT_CONVENI];       
508        break;
509    // ATM·èºÑ¤Î¾ì¹ç
510    case PAYGENT_ATM:
511        // ¥¿¥¤¥È¥ë¤òÀßÄꤹ¤ë
512        $arrMemo['title'] = sfSetConvMSG("ATM¤ª»Ùʧ¾ðÊó", true);   
513        $arrMemo['pay_center_number'] = sfSetConvMSG("¼ýǼµ¡´ØÈÖ¹æ", $arrRes[0]['pay_center_number']);
514        $arrMemo['customer_number'] = sfSetConvMSG("¤ªµÒÍÍÈÖ¹æ", $arrRes[0]['customer_number']);
515        $arrMemo['conf_number'] = sfSetConvMSG("³ÎǧÈÖ¹æ", $arrRes[0]['conf_number']);
516        // »Ùʧ´üÆü
517        $arrMemo['payment_limit_date'] = sfSetConvMSG("¤ª»Ùʧ´üÆü", date("Yǯm·îdÆü", strtotime($arrRes[0]['payment_limit_date'])));
518        // ¥Ø¥ë¥×²èÌÌ
519        $arrMemo['help_url'] = sfSetConvMSG("¤ª»ÙʧÊýË¡¤ÎÀâÌÀ", "http://www.paygent.co.jp/service/pay_atm.html");
520       
521        // ¼õÃí¥Æ¡¼¥Ö¥ë¤ËÊݸ
522        $arrVal["memo02"] = serialize($arrMemo);
523        // ½é´ü¥¹¥Æ¡¼¥¿¥¹¤òÀßÄꤹ¤ë¡£
524        $arrVal["status"] = $arrInitStatus[PAYGENT_ATM];       
525        break;
526    // ¶ä¹Ô¥Í¥Ã¥È¤Î¾ì¹ç
527    case PAYGENT_BANK:
528        // ½é´ü¥¹¥Æ¡¼¥¿¥¹¤òÀßÄꤹ¤ë¡£
529        $arrVal["status"] = $arrInitStatus[PAYGENT_BANK];
530        // ¶õ¤ÎÇÛÎó¤ò³ÊǼ¤·¤Æ¤ª¤¯
531        $arrVal["memo02"] = serialize(array());
532        break;
533    default:
534        break;
535    }
536   
537    // ¼õÃí¥Æ¡¼¥Ö¥ë¤Ëµ­Ï¿¤¹¤ë
538    $arrVal["memo01"] = MDL_PAYGENT_ID;     // ½èÍý·ë²Ì
539       
540    // memo02¤Ï¡¢»Ùʧ¾ðÊó¤ò³ÊǼ¤¹¤ë¡£
541    $arrVal["memo03"] = $resultStatus;      // ½èÍý·ë²Ì
542    $arrVal["memo04"] = $responseCode;      // ¥ì¥¹¥Ý¥ó¥¹¥³¡¼¥É
543    $arrVal["memo05"] = $responseDetail;    // ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
544    $arrVal["memo06"] = $arrRes[0]['payment_id'];       // ¾µÇ§ÈÖ¹æ
545    $arrVal["memo07"] = "";                 // ¥¹¥Æ¡¼¥¿¥¹¼èÆÀ¤Ç»ÈÍÑ
546    $arrVal["memo08"] = $telegram_kind;
547    $arrVal["memo09"] = "";                 // ¥«¡¼¥É·èºÑÏ¢·È¤Ç»ÈÍÑ
548    $arrVal["memo10"] = "";                 // ºÆ¼èÆÀÍѤÎnotice_id¤òÊݸ¤·¤Æ¤ª¤¯
549   
550    // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Ë¹¹¿·
551    sfRegistTempOrder($uniqid, $arrVal);
552   
553    // ¾µÇ§ÈÖ¹æ¤È¥á¥Ã¥»¡¼¥¸¤òÊÖ¤¹
554    return $arrRes[0];
555}
556
557/**************************************************************************************************************
558 * ´Ø¿ô̾   ¡§sfSetConvMSG
559 * ½èÍýÆâÍÆ ¡§¥³¥ó¥Ó¥Ë¾ðÊóɽ¼¨ÍÑ
560 * °ú¿ô1    ¡§
561 * °ú¿ô2    ¡§
562 * °ú¿ô3    ¡§
563 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
564 **************************************************************************************************************/
565function sfSetConvMSG($name, $value){
566    return array("name" => $name, "value" => $value);
567}
568
569/**************************************************************************************************************
570 * ´Ø¿ô̾   ¡§sfPaygentDisp
571 * ½èÍýÆâÍÆ ¡§¶¦Ä̤Îɽ¼¨½èÍý
572 * °ú¿ô1    ¡§
573 * °ú¿ô2    ¡§
574 * °ú¿ô3    ¡§
575 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
576 **************************************************************************************************************/
577function sfPaygentDisp($objPage, $payment_id) {
578    $objQuery = new SC_Query();
579    // »Ùʧ¤¤ÊýË¡¤ÎÀâÌÀ²èÁü¤ò¼èÆÀ¤¹¤ë¡£
580    $arrRet = $objQuery->select("payment_method, payment_image", "dtb_payment", "payment_id = ?", array($payment_id));
581    $objPage->tpl_payment_method = $arrRet[0]['payment_method'];
582    $objPage->tpl_payment_image = $arrRet[0]['payment_image'];
583    return $objPage;
584}
585
586/**************************************************************************************************************
587 * ´Ø¿ô̾   ¡§sfGetPaymentDB
588 * ½èÍýÆâÍÆ ¡§É¬Íפʥǡ¼¥¿¤ò¼èÆÀ¤¹¤ë¡£
589 * °ú¿ô1    ¡§
590 * °ú¿ô2    ¡§
591 * °ú¿ô3    ¡§
592 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
593 **************************************************************************************************************/
594function sfGetPaymentDB($module_id, $where = "", $arrWhereVal = array()){
595    $objQuery = new SC_Query();
596       
597    $arrVal = array($module_id);
598    $arrVal = array_merge($arrVal, $arrWhereVal);
599   
600    $arrRet = array();
601    $sql = "SELECT
602                module_id,
603                memo01 as merchant_id,
604                memo02 as connect_id,
605                memo03 as payment,
606                memo04 as connect_password,
607                memo05 as other_param
608            FROM dtb_payment WHERE module_id = ? " . $where;
609    $arrRet = $objQuery->getall($sql, $arrVal);
610
611    return $arrRet;
612}
613
614/**************************************************************************************************************
615 * ´Ø¿ô̾   ¡§sfPaygentBatch
616 * ½èÍýÆâÍÆ ¡§Æþ¶â¥¹¥Æ¡¼¥¿¥¹³Îǧ¥Ð¥Ã¥Á
617 * °ú¿ô1    ¡§
618 * °ú¿ô2    ¡§
619 * °ú¿ô3    ¡§
620 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
621 **************************************************************************************************************/
622function sfPaygentBatch() {
623    $objQuery = new SC_Query();
624   
625    // Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
626    $objPaygent = new PaygentB2BModule();
627    $objPaygent->init();
628   
629    //¡¡ÀßÄê¥Ñ¥é¥á¡¼¥¿¤Î¼èÆÀ
630    $arrPaymentDB = sfGetPaymentDB(MDL_PAYGENT_ID);
631
632    $where = "memo01 = ? AND status = ?";
633    $arrOrder = $objQuery->select("order_id", "dtb_order", $where, array(MDL_PAYGENT_ID, ORDER_PAY_WAIT));
634   
635    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
636    $arrSend = sfGetPaygentShare(PAYGENT_REF, 0, $arrPaymentDB[0]);
637       
638    if(count($arrOrder) > 0) {
639        sfUpdatePaymentStatus($objPaygent, $arrSend);
640    }   
641}
642
643/**************************************************************************************************************
644 * ´Ø¿ô̾   ¡§sfPaygentTest
645 * ½èÍýÆâÍÆ ¡§Àܳ¥Æ¥¹¥È
646 * °ú¿ô1    ¡§
647 * °ú¿ô2    ¡§
648 * °ú¿ô3    ¡§
649 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
650 **************************************************************************************************************/
651function sfPaygentTest($arrParam) {
652    $objQuery = new SC_Query();
653   
654    // Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
655    $objPaygent = new PaygentB2BModule();
656    $objPaygent->init();
657       
658    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
659    $arrSend = sfGetPaygentShare(PAYGENT_REF, '0', $arrParam);
660
661    // ÅÅʸ¤ÎÁ÷ÉÕ
662    foreach($arrSend as $key => $val) {
663        $objPaygent->reqPut($key, $val);
664    }
665    // ÅÅʸ¤ÎÁ÷¿®
666    $objPaygent->post();
667   
668    // ½èÍý·ë²Ì¼èÆÀ¡Ê¶¦ÄÌ¡Ë
669    $resultStatus = $objPaygent->getResultStatus(); # ½èÍý·ë²Ì 0=Àµ¾ï½ªÎ», 1=°Û¾ï½ªÎ»
670           
671    if($resultStatus == 0) {
672        return true;
673    } else {
674        return false;
675    }
676}
677
678/**************************************************************************************************************
679 * ´Ø¿ô̾   ¡§sfUpdatePaymentStatus
680 * ½èÍýÆâÍÆ ¡§Æþ¶â¥¹¥Æ¡¼¥¿¥¹º¹Ê¬¾È²ñ¥Ð¥Ã¥Á
681 * °ú¿ô1    ¡§
682 * °ú¿ô2    ¡§
683 * °ú¿ô3    ¡§
684 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
685 **************************************************************************************************************/
686function sfUpdatePaymentStatus($objPaygent, $arrSend) {
687    $objQuery = new SC_Query();
688    $i = 0;
689    // ¥¹¥Æ¡¼¥¿¥¹¤Î¼èÆÀ
690    while($i < 1000) {
691        $arrRet = sfGetPaymentStatus($objPaygent, $arrSend);
692       
693        // ¼èÆÀ¼ºÇÔ
694        if($arrRet['success_code'] == '1' || !isset($arrRet['success_code'])) {
695            gfPrintLog("º¹Ê¬¤Î¼èÆÀ¤¬½ªÎ»¤·¤Þ¤·¤¿¡£");
696            return;
697        }
698       
699        // ¼èÆÀÀ®¸ù     
700        if($arrRet['success_code'] == '0') {
701            if($arrRet['trading_id'] != "") {
702                // »Ùʧ¥¹¥Æ¡¼¥¿¥¹¤Î¹¹¿·
703                /*
704                 * 10:¿½¹þºÑ
705                 * 12:»Ùʧ´ü¸ÂÀÚ¤ì
706                 * 15:¿½¹þÃæÃÇ
707                 * 40:¾Ã¹þºÑ
708                 * 43:®Êó¸¡ÃκÑ
709                 * 61:®Êó¼è¾ÃºÑ
710                 * etc
711                 */
712                /*
713                    ¡Ú»Ø¼¨¥á¥â¡Û   
714               
715                    ¸½¾õ¡¢EC-CUBE¤Ç¤Ï¥³¥ó¥ÓÆó·èºÑ¡¦¥»¥Ö¥ó¥¤¥ì¥Ö¥ó¤Ë¤Ä¤¤¤Æ
716                    ³ÎÊó¤ò¼õ¤±¤ÆÆþ¶âºÑ¤ß¤È¤µ¤ì¤Æ¤¤¤ë¤è¤¦¤Ç¤¹¤¬¡¢
717                    ¥»¥Ö¥ó¤Î¾ì¹ç¤ÏÆþ¶â¸å¨»þ¤Ë®Êó¤¬ÊÀ¼Ò¦¤ËÆϤ­¡¢
718                    Æþ¶â¸å£²¢·£³Æü¸å¤Ë³ÎÊó¤¬ÆϤ¯¤è¤¦¤Ê»ÅÍͤȤʤäƤª¤ê¤Þ¤¹¡£
719                   
720                    ¥»¥Ö¥ó¤Ç¤Î·èºÑ¤Î¾ì¹ç¤Ï¡Ö®Êó¸¡ÃκѤߡÊ43¡Ë¡×¤ò¼õ¤±¤Æ
721                    Æþ¶âºÑ¤ß¤È¤¹¤ë¤è¤¦¤Ë²þ½¤¤·¤Æ¤¤¤¿¤À¤±¤Þ¤»¤ó¤Ç¤·¤ç¤¦¤«¡£
722                 */
723                if($arrRet['payment_status'] == '40' || $arrRet['payment_status'] == '43') {
724                    // Æþ¶âºÑ¤ß¤ËÊѹ¹¤¹¤ë¡£
725                    $arrVal['status'] = ORDER_PRE_END;
726                }
727                // ¼èÆÀ¥¹¥Æ¡¼¥¿¥¹¤òµ­²±¤¹¤ë¡£
728                $arrVal['memo07'] = $arrRet['payment_status'];
729                // ºÆÅپȲñ¤¹¤ë¾ì¹ç¤Ë»ÈÍѤ¹¤ë¡£
730                $arrVal['memo10'] = $arrRet['payment_notice_id'];               
731                $objQuery->update("dtb_order", $arrVal, "order_id = ?", array($arrRet['trading_id']));
732            }
733        }   
734        $i++;
735    }
736}
737
738/**************************************************************************************************************
739 * ´Ø¿ô̾   ¡§sfGetPaymentStatus
740 * ½èÍýÆâÍÆ ¡§Æþ¶â¥¹¥Æ¡¼¥¿¥¹º¹Ê¬¾È²ñ¡Êº¹Ê¬¾È²ñ¤Ç¤ÏÊѹ¹¤Î¤¢¤Ã¤¿¤â¤Î¤À¤±¼èÆÀ¤¹¤ë¤¿¤áorder_id¤ÏÉÔÍסË
741 * °ú¿ô1    ¡§
742 * °ú¿ô2    ¡§
743 * °ú¿ô3    ¡§
744 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
745 **************************************************************************************************************/
746function sfGetPaymentStatus($objPaygent, $arrSend, $notice_id = "") {
747    $objQuery = new SC_Query();
748   
749    // ´û¤Ë¼èÆÀ¤·¤¿º¹Ê¬¤ò¼èÆÀ
750    if($notice_id !== "") {
751        $arrSend['payment_notice_id'] = $notice_id;
752    }
753   
754    // ÅÅʸ¤ÎÁ÷ÉÕ
755    foreach($arrSend as $key => $val) {
756        $objPaygent->reqPut($key, $val);
757    }
758    // ÅÅʸ¤ÎÁ÷¿®
759    $objPaygent->post();
760   
761    // ¥ì¥¹¥Ý¥ó¥¹¤Î¼èÆÀ
762    while($objPaygent->hasResNext()) {
763        # ¥Ç¡¼¥¿¤¬Â¸ºß¤¹¤ë¸Â¤ê¡¢¼èÆÀ
764        $arrRes[] = $objPaygent->resNext(); # Í×µá·ë²Ì¼èÆÀ
765    }
766       
767    foreach($arrRes[0] as $key => $val) {
768        // Shift-JIS¤Ç±þÅú¤¬¤¢¤ë¤Î¤Ç¡¢¥¨¥ó¥³¡¼¥É¤¹¤ë¡£
769        $arrRes[0][$key] = mb_convert_encoding($val, CHAR_CODE, "Shift-JIS");
770        gfPrintLog($key."->".$arrRes[0][$key]);
771    }
772    return $arrRes[0];
773}
774
775/**************************************************************************************************************
776 * ´Ø¿ô̾   ¡§sfPaygentOrder($paygent_type)
777 * ½èÍýÆâÍÆ ¡§¼õÃíÏ¢·È
778 * °ú¿ô1    ¡§
779 * °ú¿ô2    ¡§
780 * °ú¿ô3    ¡§
781 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
782 **************************************************************************************************************/
783function sfPaygentOrder($paygent_type, $order_id) {
784    global $arrDispKind;
785   
786    // Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
787    $objPaygent = new PaygentB2BModule();
788    $objPaygent->init();
789   
790    // ÀßÄê¥Ñ¥é¥á¡¼¥¿¤Î¼èÆÀ
791    $arrPaymentDB = sfGetPaymentDB(MDL_PAYGENT_ID);
792   
793    // ½èÍýʬ´ô
794    switch($paygent_type) {
795    case 'auth_cancel':
796        $kind = PAYGENT_AUTH_CANCEL;
797        break;
798    case 'card_commit':
799        $kind = PAYGENT_CARD_COMMIT;
800        break;
801    case 'card_commit_cancel':
802        $kind = PAYGENT_CARD_COMMIT_CANCEL;
803        break;
804    }
805   
806    // ·èºÑID¤Î¼èÆÀ
807    $objQuery = new SC_Query();
808    $payment_id = $objQuery->get("dtb_order", "memo06", "order_id = ?", array($order_id));
809   
810    $arrSend = sfGetPaygentShare($kind, $order_id, $arrPaymentDB[0], $payment_id);
811   
812    // ÅÅʸ¤ÎÁ÷ÉÕ
813    foreach($arrSend as $key => $val) {
814        $objPaygent->reqPut($key, $val);
815    }
816    // ÅÅʸ¤ÎÁ÷¿®
817    $objPaygent->post();
818
819    // ¥ì¥¹¥Ý¥ó¥¹¤Î¼èÆÀ
820    while($objPaygent->hasResNext()) {
821        # ¥Ç¡¼¥¿¤¬Â¸ºß¤¹¤ë¸Â¤ê¡¢¼èÆÀ
822        $arrRes[] = $objPaygent->resNext(); # Í×µá·ë²Ì¼èÆÀ
823    }
824
825    $resultStatus = $objPaygent->getResultStatus(); # ½èÍý·ë²Ì 0=Àµ¾ï½ªÎ», 1=°Û¾ï½ªÎ»
826    gfPrintLog('result'."->".$resultStatus);
827   
828    foreach($arrRes[0] as $key => $val) {
829        // Shift-JIS¤Ç±þÅú¤¬¤¢¤ë¤Î¤Ç¡¢¥¨¥ó¥³¡¼¥É¤¹¤ë¡£
830        $arrRes[0][$key] = mb_convert_encoding($val, CHAR_CODE, "Shift-JIS");
831        gfPrintLog($key."->".$arrRes[0][$key]);
832    }
833   
834    // Àµ¾ï½ªÎ»
835    if($resultStatus == '0') {
836        $objQuery = new SC_Query();
837        $arrVal['memo09'] = $kind;
838        $objQuery->update("dtb_order", $arrVal, "order_id = ?", array($order_id));
839        $arrReturn['return'] = true;   
840    } else {
841        $arrReturn['return'] = false;
842    }
843    $arrReturn['kind'] = $kind;
844    return $arrReturn;
845}
846
847/**************************************************************************************************************
848 * ´Ø¿ô̾   ¡§sfPaygentOrderPage($objPage)
849 * ½èÍýÆâÍÆ ¡§É½¼¨Íѥѥ顼¥á¡¼¥¿¤òÄɲ乤롣
850 * °ú¿ô1    ¡§
851 * °ú¿ô2    ¡§
852 * °ú¿ô3    ¡§
853 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
854 **************************************************************************************************************/
855function sfPaygentOrderPage($objPage) {
856    global $arrDispKind;
857    $objPage->arrDispKind = $arrDispKind;
858    return $objPage;
859}
860?>
Note: See TracBrowser for help on using the repository browser.