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

Revision 16789, 28.8 KB checked in by satou, 15 years ago (diff)

【ペイジェントクレジット決済の修正】
文字数制限にEC-CUBEとの差異があったため、対応しました。

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