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

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