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

Revision 16946, 30.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    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        if (GC_MobileUserAgent::isMobile()) {
514            $arrMemo['help_url'] = sfSetConvMSG("¤ª»ÙʧÊýË¡¤ÎÀâÌÀ", "http://www.paygent.co.jp/mb/pay_help/conv.html");
515        } else {
516            $arrMemo['help_url'] = sfSetConvMSG("¤ª»ÙʧÊýË¡¤ÎÀâÌÀ", "http://www.paygent.co.jp/service/pay_cvs.html");
517        }
518               
519        // ¼õÃí¥Æ¡¼¥Ö¥ë¤ËÊݸ
520        $arrVal["memo02"] = serialize($arrMemo);
521        // ½é´ü¥¹¥Æ¡¼¥¿¥¹¤òÀßÄꤹ¤ë¡£
522        $arrVal["status"] = $arrInitStatus[PAYGENT_CONVENI];       
523        break;
524    // ATM·èºÑ¤Î¾ì¹ç
525    case PAYGENT_ATM:
526        // ¥¿¥¤¥È¥ë¤òÀßÄꤹ¤ë
527        $arrMemo['title'] = sfSetConvMSG("ATM¤ª»Ùʧ", true);   
528        $arrMemo['pay_center_number'] = sfSetConvMSG("¼ýǼµ¡´ØÈÖ¹æ", $arrRes[0]['pay_center_number']);
529        $arrMemo['customer_number'] = sfSetConvMSG("¤ªµÒÍÍÈÖ¹æ", $arrRes[0]['customer_number']);
530        $arrMemo['conf_number'] = sfSetConvMSG("³ÎǧÈÖ¹æ", $arrRes[0]['conf_number']);
531        // »Ùʧ´üÆü
532        $arrMemo['payment_limit_date'] = sfSetConvMSG("¤ª»Ùʧ´üÆü", date("Yǯm·îdÆü", strtotime($arrRes[0]['payment_limit_date'])));
533        // ¥Ø¥ë¥×²èÌÌ
534        if (GC_MobileUserAgent::isMobile()) {
535            $arrMemo['help_url'] = sfSetConvMSG("¤ª»ÙʧÊýË¡¤ÎÀâÌÀ", "http://www.paygent.co.jp/mb/pay_help/atm.html");
536        } else {
537            $arrMemo['help_url'] = sfSetConvMSG("¤ª»ÙʧÊýË¡¤ÎÀâÌÀ", "http://www.paygent.co.jp/service/pay_atm.html");
538        }
539       
540        // ¼õÃí¥Æ¡¼¥Ö¥ë¤ËÊݸ
541        $arrVal["memo02"] = serialize($arrMemo);
542        // ½é´ü¥¹¥Æ¡¼¥¿¥¹¤òÀßÄꤹ¤ë¡£
543        $arrVal["status"] = $arrInitStatus[PAYGENT_ATM];       
544        break;
545    // ¶ä¹Ô¥Í¥Ã¥È¤Î¾ì¹ç
546    case PAYGENT_BANK:
547        // ½é´ü¥¹¥Æ¡¼¥¿¥¹¤òÀßÄꤹ¤ë¡£
548        $arrVal["status"] = $arrInitStatus[PAYGENT_BANK];
549        // ¶õ¤ÎÇÛÎó¤ò³ÊǼ¤·¤Æ¤ª¤¯
550        $arrVal["memo02"] = serialize(array());
551        break;
552    default:
553        break;
554    }
555   
556    // ¼õÃí¥Æ¡¼¥Ö¥ë¤Ëµ­Ï¿¤¹¤ë
557    $arrVal["memo01"] = MDL_PAYGENT_ID;     // ½èÍý·ë²Ì
558       
559    // memo02¤Ï¡¢»Ùʧ¾ðÊó¤ò³ÊǼ¤¹¤ë¡£
560    $arrVal["memo03"] = $resultStatus;      // ½èÍý·ë²Ì
561    $arrVal["memo04"] = $responseCode;      // ¥ì¥¹¥Ý¥ó¥¹¥³¡¼¥É
562    $arrVal["memo05"] = $responseDetail;    // ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
563    $arrVal["memo06"] = $arrRes[0]['payment_id'];       // ¾µÇ§ÈÖ¹æ
564    $arrVal["memo07"] = "";                 // ¥¹¥Æ¡¼¥¿¥¹¼èÆÀ¤Ç»ÈÍÑ
565    $arrVal["memo08"] = $telegram_kind;
566    $arrVal["memo09"] = "";                 // ¥«¡¼¥É·èºÑÏ¢·È¤Ç»ÈÍÑ
567    $arrVal["memo10"] = "";                 // ºÆ¼èÆÀÍѤÎnotice_id¤òÊݸ¤·¤Æ¤ª¤¯
568   
569    // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Ë¹¹¿·
570    sfRegistTempOrder($uniqid, $arrVal);
571   
572    // ¾µÇ§ÈÖ¹æ¤È¥á¥Ã¥»¡¼¥¸¤òÊÖ¤¹
573    return $arrRes[0];
574}
575
576/**************************************************************************************************************
577 * ´Ø¿ô̾   ¡§sfSetConvMSG
578 * ½èÍýÆâÍÆ ¡§¥³¥ó¥Ó¥Ë¾ðÊóɽ¼¨ÍÑ
579 * °ú¿ô1    ¡§
580 * °ú¿ô2    ¡§
581 * °ú¿ô3    ¡§
582 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
583 **************************************************************************************************************/
584function sfSetConvMSG($name, $value){
585    return array("name" => $name, "value" => $value);
586}
587
588/**************************************************************************************************************
589 * ´Ø¿ô̾   ¡§sfPaygentDisp
590 * ½èÍýÆâÍÆ ¡§¶¦Ä̤Îɽ¼¨½èÍý
591 * °ú¿ô1    ¡§
592 * °ú¿ô2    ¡§
593 * °ú¿ô3    ¡§
594 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
595 **************************************************************************************************************/
596function sfPaygentDisp($objPage, $payment_id) {
597    $objQuery = new SC_Query();
598    // »Ùʧ¤¤ÊýË¡¤ÎÀâÌÀ²èÁü¤ò¼èÆÀ¤¹¤ë¡£
599    $arrRet = $objQuery->select("payment_method, payment_image", "dtb_payment", "payment_id = ?", array($payment_id));
600    $objPage->tpl_payment_method = $arrRet[0]['payment_method'];
601    $objPage->tpl_payment_image = $arrRet[0]['payment_image'];
602    return $objPage;
603}
604
605/**************************************************************************************************************
606 * ´Ø¿ô̾   ¡§sfGetPaymentDB
607 * ½èÍýÆâÍÆ ¡§É¬Íפʥǡ¼¥¿¤ò¼èÆÀ¤¹¤ë¡£
608 * °ú¿ô1    ¡§
609 * °ú¿ô2    ¡§
610 * °ú¿ô3    ¡§
611 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
612 **************************************************************************************************************/
613function sfGetPaymentDB($module_id, $where = "", $arrWhereVal = array()){
614    $objQuery = new SC_Query();
615       
616    $arrVal = array($module_id);
617    $arrVal = array_merge($arrVal, $arrWhereVal);
618   
619    $arrRet = array();
620    $sql = "SELECT
621                module_id,
622                memo01 as merchant_id,
623                memo02 as connect_id,
624                memo03 as payment,
625                memo04 as connect_password,
626                memo05 as other_param
627            FROM dtb_payment WHERE module_id = ? " . $where;
628    $arrRet = $objQuery->getall($sql, $arrVal);
629
630    return $arrRet;
631}
632
633/**************************************************************************************************************
634 * ´Ø¿ô̾   ¡§sfPaygentBatch
635 * ½èÍýÆâÍÆ ¡§Æþ¶â¥¹¥Æ¡¼¥¿¥¹³Îǧ¥Ð¥Ã¥Á
636 * °ú¿ô1    ¡§
637 * °ú¿ô2    ¡§
638 * °ú¿ô3    ¡§
639 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
640 **************************************************************************************************************/
641function sfPaygentBatch() {
642    $objQuery = new SC_Query();
643   
644    // Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
645    $objPaygent = new PaygentB2BModule();
646    $objPaygent->init();
647   
648    //¡¡ÀßÄê¥Ñ¥é¥á¡¼¥¿¤Î¼èÆÀ
649    $arrPaymentDB = sfGetPaymentDB(MDL_PAYGENT_ID);
650   
651    $where = "memo01 = ? AND status = ?";
652    $arrOrder = $objQuery->select("order_id", "dtb_order", $where, array(MDL_PAYGENT_ID, ORDER_PAY_WAIT));
653   
654    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
655    $arrSend = sfGetPaygentShare(PAYGENT_REF, 0, $arrPaymentDB[0]);
656   
657    if(count($arrOrder) > 0) {
658        sfUpdatePaymentStatus($objPaygent, $arrSend);
659    }   
660}
661
662/**************************************************************************************************************
663 * ´Ø¿ô̾   ¡§sfPaygentTest
664 * ½èÍýÆâÍÆ ¡§Àܳ¥Æ¥¹¥È
665 * °ú¿ô1    ¡§
666 * °ú¿ô2    ¡§
667 * °ú¿ô3    ¡§
668 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
669 **************************************************************************************************************/
670function sfPaygentTest($arrParam) {
671    $objQuery = new SC_Query();
672   
673    // Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
674    $objPaygent = new PaygentB2BModule();
675    $objPaygent->init();
676       
677    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
678    $arrSend = sfGetPaygentShare(PAYGENT_REF, '0', $arrParam);
679
680    // ÅÅʸ¤ÎÁ÷ÉÕ
681    foreach($arrSend as $key => $val) {
682        $objPaygent->reqPut($key, $val);
683    }
684    // ÅÅʸ¤ÎÁ÷¿®
685    $objPaygent->post();
686   
687    // ½èÍý·ë²Ì¼èÆÀ¡Ê¶¦ÄÌ¡Ë
688    $resultStatus = $objPaygent->getResultStatus(); # ½èÍý·ë²Ì 0=Àµ¾ï½ªÎ», 1=°Û¾ï½ªÎ»
689           
690    if($resultStatus == 0) {
691        return true;
692    } else {
693        return false;
694    }
695}
696
697/**************************************************************************************************************
698 * ´Ø¿ô̾   ¡§sfUpdatePaymentStatus
699 * ½èÍýÆâÍÆ ¡§Æþ¶â¥¹¥Æ¡¼¥¿¥¹º¹Ê¬¾È²ñ¥Ð¥Ã¥Á
700 * °ú¿ô1    ¡§
701 * °ú¿ô2    ¡§
702 * °ú¿ô3    ¡§
703 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
704 **************************************************************************************************************/
705function sfUpdatePaymentStatus($objPaygent, $arrSend) {
706    $objQuery = new SC_Query();
707   
708    if (DB_TYPE == "pgsql") $col = "cast(memo10 AS int4)";
709    elseif (DB_TYPE == "mysql") $col = "cast(memo10 AS SIGNED)";
710    $notice_id = $objQuery->max("dtb_order", $col, "memo01 = ?", array(MDL_PAYGENT_ID));
711   
712    $objQuery->begin();
713   
714    // ¥¹¥Æ¡¼¥¿¥¹¤Î¼èÆÀ
715    $i = 0;
716    while($i < 1000) {
717        $arrRet = sfGetPaymentStatus($objPaygent, $arrSend);
718       
719        // ¼èÆÀÀ®¸ù
720        if($arrRet['success_code'] == '0') {
721            // ̤¼èÆÀ·èºÑÄÌÃÎID¤ÎÊÝ»ý
722            if($arrRet['payment_notice_id'] > $notice_id + 1) {
723                for($notice_id++; $notice_id < $arrRet['payment_notice_id']; $notice_id++) {
724                    $arrErrId[] = $notice_id;
725                    gfPrintLog("·èºÑÄÌÃÎID=". $notice_id. "¤¬·çÈ֤Ǥ¹¡£");
726                }
727            }
728            $notice_id = $arrRet['payment_notice_id'];
729            sfUpdatePaygentOrder($objQuery, $arrRet);
730       
731        // ¼èÆÀ´°Î»
732        } elseif($arrRet['success_code'] == '1') {
733            gfPrintLog("º¹Ê¬¤Î¼èÆÀ¤¬½ªÎ»¤·¤Þ¤·¤¿¡£");
734            break;
735       
736        // ¼èÆÀ¼ºÇÔ
737        } elseif($arrRet['payment_notice_id'] == "") {
738            $notice_id++;
739            $arrErrId[] = $notice_id;
740            gfPrintLog("·èºÑÄÌÃÎID=". $notice_id. "¤¬·çÈ֤Ǥ¹¡£");
741        }
742       
743        $i++;
744    }
745   
746    // ¼èÆÀ¼ºÇÔ¥¹¥Æ¡¼¥¿¥¹¤ÎºÆ¼èÆÀ
747    for ($i = 0; $i < count($arrErrId); $i++) {
748        $arrRet = sfGetPaymentStatus($objPaygent, $arrSend, $arrErrId[$i]);
749       
750        // ºÆ¼èÆÀÀ®¸ù
751        if($arrRet['success_code'] == '0') {
752            sfUpdatePaygentOrder($objQuery, $arrRet);
753       
754        // ºÆ¼èÆÀ¼ºÇÔ
755        } elseif($arrRet['payment_notice_id'] == "") {
756            gfPrintLog("·èºÑÄÌÃÎID=". $arrErrId[$i]. "¤ÎºÆ¼èÆÀ¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£¥Ð¥Ã¥Á¤ò¶¯À©½ªÎ»¤·¤Þ¤¹¡£");
757            $err_flg = false;
758            break;
759        }
760       
761        // ºÆ¼èÆÀ´°Î»
762        if($i == count($arrErrId) - 1) {
763            gfPrintLog("º¹Ê¬¤ÎºÆ¼èÆÀ¤¬½ªÎ»¤·¤Þ¤·¤¿¡£");
764        }
765    }
766   
767    // ¥³¥ß¥Ã¥ÈÀ®ÈÝȽÄê
768    if ($err_flg === false) {
769        $objQuery->rollback();
770    } else {
771        $objQuery->commit();
772    }
773}
774
775/**************************************************************************************************************
776 * ´Ø¿ô̾   ¡§sfGetPaymentStatus
777 * ½èÍýÆâÍÆ ¡§Æþ¶â¥¹¥Æ¡¼¥¿¥¹º¹Ê¬¾È²ñ¡Êº¹Ê¬¾È²ñ¤Ç¤ÏÊѹ¹¤Î¤¢¤Ã¤¿¤â¤Î¤À¤±¼èÆÀ¤¹¤ë¤¿¤áorder_id¤ÏÉÔÍסË
778 * °ú¿ô1    ¡§
779 * °ú¿ô2    ¡§
780 * °ú¿ô3    ¡§
781 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
782 **************************************************************************************************************/
783function sfGetPaymentStatus($objPaygent, $arrSend, $notice_id = "") {
784    // ´û¤Ë¼èÆÀ¤·¤¿º¹Ê¬¤ò¼èÆÀ
785    if($notice_id !== "") {
786        $arrSend['payment_notice_id'] = $notice_id;
787    }
788   
789    // ÅÅʸ¤ÎÁ÷ÉÕ
790    foreach($arrSend as $key => $val) {
791        $objPaygent->reqPut($key, $val);
792    }
793    // ÅÅʸ¤ÎÁ÷¿®
794    $objPaygent->post();
795   
796    // ¥ì¥¹¥Ý¥ó¥¹¤Î¼èÆÀ
797    while($objPaygent->hasResNext()) {
798        # ¥Ç¡¼¥¿¤¬Â¸ºß¤¹¤ë¸Â¤ê¡¢¼èÆÀ
799        $arrRes[] = $objPaygent->resNext(); # Í×µá·ë²Ì¼èÆÀ
800    }
801   
802    foreach($arrRes[0] as $key => $val) {
803        // Shift-JIS¤Ç±þÅú¤¬¤¢¤ë¤Î¤Ç¡¢¥¨¥ó¥³¡¼¥É¤¹¤ë¡£
804        $arrRes[0][$key] = mb_convert_encoding($val, CHAR_CODE, "Shift-JIS");
805        gfPrintLog($key."->".$arrRes[0][$key]);
806    }
807   
808    return $arrRes[0];
809}
810
811/**************************************************************************************************************
812 * ´Ø¿ô̾   ¡§sfUpdatePaygentOrder($objQuery, $arrRet)
813 * ½èÍýÆâÍÆ ¡§»Ùʧ¥¹¥Æ¡¼¥¿¥¹¹¹¿·
814 * °ú¿ô1    ¡§
815 * °ú¿ô2    ¡§
816 * °ú¿ô3    ¡§
817 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
818 **************************************************************************************************************/
819function sfUpdatePaygentOrder($objQuery, $arrRet) {
820    /*
821     * 10:¿½¹þºÑ
822     * 12:»Ùʧ´ü¸ÂÀÚ¤ì
823     * 15:¿½¹þÃæÃÇ
824     * 40:¾Ã¹þºÑ
825     * 43:®Êó¸¡ÃκÑ
826     * 61:®Êó¼è¾ÃºÑ
827     * etc
828     */
829    if($arrRet['trading_id'] != "") {
830        // Æþ¶âºÑ¤ß¤ËÊѹ¹
831        if($arrRet['payment_status'] == '40' || $arrRet['payment_status'] == '43') {
832            $arrVal['status'] = ORDER_PRE_END;
833        // ¥­¥ã¥ó¥»¥ë¤ËÊѹ¹
834        } elseif($arrRet['payment_status'] == '12') {
835            $arrVal['status'] = ORDER_CANCEL;
836        }
837       
838        // ¼èÆÀ¥¹¥Æ¡¼¥¿¥¹¤òµ­²±¤¹¤ë¡£
839        $arrVal['memo07'] = $arrRet['payment_status'];
840        // ºÆÅپȲñ¤¹¤ë¾ì¹ç¤Ë»ÈÍѤ¹¤ë¡£
841        $arrVal['memo10'] = $arrRet['payment_notice_id'];
842        $objQuery->update("dtb_order", $arrVal, "order_id = ?", array($arrRet['trading_id']));
843    }
844}
845
846/**************************************************************************************************************
847 * ´Ø¿ô̾   ¡§sfPaygentOrder($paygent_type)
848 * ½èÍýÆâÍÆ ¡§¼õÃíÏ¢·È
849 * °ú¿ô1    ¡§
850 * °ú¿ô2    ¡§
851 * °ú¿ô3    ¡§
852 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
853 **************************************************************************************************************/
854function sfPaygentOrder($paygent_type, $order_id) {
855    global $arrDispKind;
856   
857    // Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
858    $objPaygent = new PaygentB2BModule();
859    $objPaygent->init();
860   
861    // ÀßÄê¥Ñ¥é¥á¡¼¥¿¤Î¼èÆÀ
862    $arrPaymentDB = sfGetPaymentDB(MDL_PAYGENT_ID);
863   
864    // ½èÍýʬ´ô
865    switch($paygent_type) {
866    case 'auth_cancel':
867        $kind = PAYGENT_AUTH_CANCEL;
868        break;
869    case 'card_commit':
870        $kind = PAYGENT_CARD_COMMIT;
871        break;
872    case 'card_commit_cancel':
873        $kind = PAYGENT_CARD_COMMIT_CANCEL;
874        break;
875    }
876   
877    // ·èºÑID¤Î¼èÆÀ
878    $objQuery = new SC_Query();
879    $payment_id = $objQuery->get("dtb_order", "memo06", "order_id = ?", array($order_id));
880   
881    $arrSend = sfGetPaygentShare($kind, $order_id, $arrPaymentDB[0], $payment_id);
882   
883    // ÅÅʸ¤ÎÁ÷ÉÕ
884    foreach($arrSend as $key => $val) {
885        $objPaygent->reqPut($key, $val);
886    }
887    // ÅÅʸ¤ÎÁ÷¿®
888    $objPaygent->post();
889
890    // ¥ì¥¹¥Ý¥ó¥¹¤Î¼èÆÀ
891    while($objPaygent->hasResNext()) {
892        # ¥Ç¡¼¥¿¤¬Â¸ºß¤¹¤ë¸Â¤ê¡¢¼èÆÀ
893        $arrRes[] = $objPaygent->resNext(); # Í×µá·ë²Ì¼èÆÀ
894    }
895
896    $resultStatus = $objPaygent->getResultStatus(); # ½èÍý·ë²Ì 0=Àµ¾ï½ªÎ», 1=°Û¾ï½ªÎ»
897    gfPrintLog('result'."->".$resultStatus);
898   
899    foreach($arrRes[0] as $key => $val) {
900        // Shift-JIS¤Ç±þÅú¤¬¤¢¤ë¤Î¤Ç¡¢¥¨¥ó¥³¡¼¥É¤¹¤ë¡£
901        $arrRes[0][$key] = mb_convert_encoding($val, CHAR_CODE, "Shift-JIS");
902        gfPrintLog($key."->".$arrRes[0][$key]);
903    }
904   
905    // Àµ¾ï½ªÎ»
906    if($resultStatus == '0') {
907        $objQuery = new SC_Query();
908        $arrVal['memo09'] = $kind;
909        $objQuery->update("dtb_order", $arrVal, "order_id = ?", array($order_id));
910        $arrReturn['return'] = true;   
911    } else {
912        $arrReturn['return'] = false;
913    }
914    $arrReturn['kind'] = $kind;
915    return $arrReturn;
916}
917
918/**************************************************************************************************************
919 * ´Ø¿ô̾   ¡§sfPaygentOrderPage($objPage)
920 * ½èÍýÆâÍÆ ¡§É½¼¨Íѥѥ顼¥á¡¼¥¿¤òÄɲ乤롣
921 * °ú¿ô1    ¡§
922 * °ú¿ô2    ¡§
923 * °ú¿ô3    ¡§
924 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
925 **************************************************************************************************************/
926function sfPaygentOrderPage($objPage) {
927    global $arrDispKind;
928    $objPage->arrDispKind = $arrDispKind;
929    return $objPage;
930}
931?>
Note: See TracBrowser for help on using the repository browser.