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

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