source: branches/feature-module-paygent/data/downloads/module/mdl_paygent/mdl_paygent.inc @ 15244

Revision 15244, 19.3 KB checked in by naka, 16 years ago (diff)
Line 
1<?php
2/**
3 *
4 * @copyright   2000-2006 LOCKON CO.,LTD. All Rights Reserved.
5 * @version CVS: $Id: mdl_epsilon.inc 7162 2006-11-18 09:53:33Z kakinaka $
6 * @link        http://www.lockon.co.jp/
7 *
8 */
9$paygent_credit_php_dir = realpath(dirname( __FILE__));
10// include_path¤Ëmdl_paygent¤Î¥Ñ¥¹¤ò´Þ¤á¤ë
11ini_set('include_path', $paygent_credit_php_dir . PATH_SEPARATOR . ini_get('include_path'));
12
13$paygent_module_dir = "jp/co/ks/merchanttool/connectmodule/";
14
15// ¥â¥¸¥å¡¼¥ë¥Õ¥¡¥¤¥ë¤Î¸ºß¥Á¥§¥Ã¥¯
16if(!file_exists($paygent_credit_php_dir . "/" . $paygent_module_dir)) {
17    print("¥Ú¥¤¥¸¥§¥ó¥ÈÄ󶡥⥸¥å¡¼¥ë¤òÀßÃÖ¤·¤Æ¤¯¤À¤µ¤¤¡£");
18    exit;
19}
20
21// paygent¥â¥¸¥å¡¼¥ë¤ÎÆɹþ
22include_once($paygent_module_dir . "entity/ResponseDataFactory.php");
23include_once($paygent_module_dir . "system/PaygentB2BModule.php");
24include_once($paygent_module_dir . "exception/PaygentB2BModuleConnectException.php");
25include_once($paygent_module_dir . "exception/PaygentB2BModuleException.php");
26
27// ¥Ú¥¤¥¸¥§¥ó¥È·èºÑ¤Î¥â¥¸¥å¡¼¥ëID¡Êdtb_module¤È¹ç¤ï¤»¤ë¡Ë
28define("MDL_PAYGENT_ID", 9);
29
30// ¥Ú¥¤¥¸¥§¥ó¥È¤Î³Æʧ¹þ¤ÎÂбþÈÖ¹æ
31/*
32    ÅÅʸ¼ïÊ̤òɽ¤¹¶èʬ
33    010¡§ATM·èºÑ¿½¹þ
34    020¡§Ž¶Ž°ŽÄŽÞ·èºÑŽµŽ°Ž¿ŽØ
35    021¡§Ž¶Ž°ŽÄŽÞ·èºÑŽµŽ°Ž¿ŽØŽ·Ž¬ŽÝŽ¾ŽÙ
36    022¡§Ž¶Ž°ŽÄŽÞ·èºÑÇä¾å
37    023¡§Ž¶Ž°ŽÄŽÞ·èºÑÇä¾åŽ·Ž¬ŽÝŽ¾ŽÙ
38    024¡§Ž¶Ž°ŽÄŽÞ·èºÑ3DŽµŽ°Ž¿ŽØ
39    030¡§ŽºŽÝŽËŽÞŽÆ·èºÑ(ÈÖ¹æÊý¼°)¿½¹þ
40    040¡§ŽºŽÝŽËŽÞŽÆ·èºÑ(ʧ¹þɼÊý¼°)¿½¹þ
41    050¡§¶ä¹ÔŽÈŽ¯ŽÄ·èºÑ¿½¹þ
42    060¡§¶ä¹Ô¥Í¥Ã¥È·èºÑASP
43    090¡§·èºÑ¾ðÊó¾È²ñ
44 */
45define("PAYGENT_BANK", '060');
46define("PAYGENT_ATM", '010');
47define("PAYGENT_CONVENI", '030');
48define("PAYGENT_CREDIT", '020');
49// ¥Ð¥Ã¥Á¤Ç»ÈÍѤ¹¤ë¡£
50define("PAYGENT_REF", '090');   
51
52// »Ùʧ¤¤ÊýË¡¤Î̾Á°
53define("MDL_PAYGENT_CREDIT_NAME", "PAYGENT¥¯¥ì¥¸¥Ã¥È·èºÑ");
54define("MDL_PAYGENT_CONVENI_NAME", "PAYGENT¥³¥ó¥Ó¥Ë·èºÑ");
55
56define ("CHARGE_MAX", 500000);
57define ("SEVEN_CHARGE_MAX", 300000);
58
59// ÅÅʸ¥Ð¡¼¥¸¥ç¥ó
60define ("TELEGRAM_VERSION", '1.0');
61
62//¥³¥ó¥Ó¥Ë¤Î¼ïÎà
63$arrConvenience = array(
64    '00C016' => '¥»¥¤¥³¡¼¥Þ¡¼¥È',
65    '00C002' => '¥í¡¼¥½¥ó',
66    '00C004' => '¥ß¥Ë¥¹¥È¥Ã¥×',
67    '00C005' => '¥Õ¥¡¥ß¥ê¡¼¥Þ¡¼¥È',
68    '00C006' => '¥µ¥ó¥¯¥¹',
69    '00C007' => '¥µ¡¼¥¯¥ëK',
70    '00C014' => '¥Ç¥¤¥ê¡¼¥ä¥Þ¥¶¥­',
71    '00C001' => '¥»¥Ö¥ó¥¤¥ì¥Ö¥ó'
72);
73   
74// ¥Í¥Ã¥È¥Ð¥ó¥¯¤Î¼ïÎà
75$arrNetBank = array(
76    'D005' => 'e-payment',
77    'D008' => '¥Í¥Ã¥È¿¶¹þEDI',
78    'D009' => 'One\'s ¥À¥¤¥ì¥¯¥È',
79    'D033' => '¥¸¥ã¥Ñ¥ó¥Í¥Ã¥È¶ä¹Ô',
80    'D036' => '¥¤¡¼¥Ð¥ó¥¯' 
81);
82   
83// ¥¯¥ì¥¸¥Ã¥Èʬ³ä²ó¿ô
84$arrPaymentClass = array(
85    '10' => '°ì³çʧ¤¤',
86    '61-2' => 'ʬ³ä2²óʧ¤¤',
87    '61-3' => 'ʬ³ä3²óʧ¤¤',
88    '61-6' => 'ʬ³ä6²óʧ¤¤',
89    '61-10' => 'ʬ³ä10²óʧ¤¤',
90    '61-15' => 'ʬ³ä15²óʧ¤¤',
91    '61-20' => 'ʬ³ä20²óʧ¤¤',
92    '80' => '¥ê¥Üʧ¤¤'
93);
94
95/**************************************************************************************************************
96 * ´Ø¿ô̾   ¡§sfGetPaygentShare
97 * ½èÍýÆâÍÆ ¡§¥Ú¥¤¥¸¥§¥ó¥È¾ðÊóÁ÷¿®¤Î¶¦Ä̽èÍý
98 * °ú¿ô1    ¡§
99 * °ú¿ô2    ¡§
100 * °ú¿ô3    ¡§
101 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
102 **************************************************************************************************************/
103function sfGetPaygentShare($telegram_kind, $order_id, $arrParam) {
104   
105    /** ¶¦ÄÌÅÅʸ **/   
106    // ¥Þ¡¼¥Á¥ã¥ó¥ÈID
107    $arrSend['merchant_id'] = $arrParam['merchant_id'];
108    // ÀܳID
109    $arrSend['connect_id'] = $arrParam['connect_id'];
110    // Àܳ¥Ñ¥¹¥ï¡¼¥É
111    $arrSend['connect_password'] = $arrParam['connect_password'];
112    // ÅÅʸ¼ïÊÌID
113    $arrSend['telegram_kind'] = $telegram_kind;
114    // ÅÅʸ¥Ð¡¼¥¸¥ç¥ó
115    $arrSend['telegram_version'] = TELEGRAM_VERSION;
116    // ¥Þ¡¼¥Á¥ã¥ó¥È¼è°úID
117    $arrSend['trading_id'] = $order_id;
118
119    return $arrSend;
120}
121   
122/**************************************************************************************************************
123 * ´Ø¿ô̾   ¡§sfSendPaygentCredit
124 * ½èÍýÆâÍÆ ¡§¥¯¥ì¥¸¥Ã¥È¾ðÊó¤ÎÁ÷¿®
125 * °ú¿ô1    ¡§
126 * °ú¿ô2    ¡§
127 * °ú¿ô3    ¡§
128 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
129 **************************************************************************************************************/
130function sfSendPaygentCredit($arrData, $arrInput, $uniqid) {
131// Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
132    $p = new PaygentB2BModule();
133    $p->init();
134   
135    //¡¡¥¯¥ì¥¸¥Ã¥ÈÍѥѥé¥á¡¼¥¿¤Î¼èÆÀ
136    $arrPaymentDB = sfGetPaymentDB(MDL_PAYGENT_ID, "AND memo03 = 1");
137    $arrOtherParam = unserialize($arrPaymentDB[0]['other_param']);
138   
139    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
140    $arrSend = sfGetPaygentShare(PAYGENT_CREDIT, $arrData['order_id'], $arrPaymentDB[0]);
141   
142    /** ¸ÄÊÌÅÅʸ **/
143   
144    // ·èºÑ¶â³Û
145    $arrSend['payment_amount'] = $arrData['payment_total'];
146    // ¥«¡¼¥ÉÈÖ¹æ
147    $arrSend['card_number'] = $arrInput['card_no01'].$arrInput['card_no02'].$arrInput['card_no03'].$arrInput['card_no04'];
148    // ¥«¡¼¥ÉÍ­¸ú´ü¸Â(MMYY)
149    $arrSend['card_valid_term'] = $arrInput['card_month'].$arrInput['card_year'];
150    // »Ùʧ¤¤¶èʬ¡¢Ê¬³ä²ó¿ô¤Î¼èÆÀ
151    list($payment_class, $split_count) = split("-", $arrInput['payment_class']);
152       
153    // »Ùʧ¤¤¶èʬ
154    /*
155     * 10:1²ó
156     * 23:¥Ü¡¼¥Ê¥¹1²ó
157     * 61:ʬ³ä
158     * 80:¥ê¥Ü¥ë¥Ó¥ó¥°
159     */
160    $arrSend['payment_class'] = $payment_class;
161    // ʬ³ä²ó¿ô
162    $arrSend['split_count'] = $split_count;
163    // 3D¥»¥­¥å¥¢ÉÞÍܶèʬ
164    $arrSend['3dsecure_ryaku'] = '1';
165   
166    // ÅÅʸ¤ÎÁ÷ÉÕ
167    foreach($arrSend as $key => $val) {
168        $p->reqPut($key, $val);
169    }
170   
171    // ÅÅʸ¤ÎÁ÷¿®
172    $p->post();
173
174    // ±þÅú¤ò½èÍý
175    $arrRet = sfPaygentResponse(PAYGENT_CREDIT, $p, $uniqid);
176   
177    return $arrRet;
178}
179
180/**************************************************************************************************************
181 * ´Ø¿ô̾   ¡§sfSendPaygentConveni
182 * ½èÍýÆâÍÆ ¡§¥³¥ó¥Ó¥Ë¾ðÊó¤ÎÁ÷¿®
183 * °ú¿ô1    ¡§
184 * °ú¿ô2    ¡§
185 * °ú¿ô3    ¡§
186 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
187 **************************************************************************************************************/
188function sfSendPaygentConveni($arrData, $arrInput, $uniqid) {
189// Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
190    $p = new PaygentB2BModule();
191    $p->init();
192   
193    //¡¡¥³¥ó¥Ó¥ËÍѥѥé¥á¡¼¥¿¤Î¼èÆÀ
194    $arrPaymentDB = sfGetPaymentDB(MDL_PAYGENT_ID, "AND memo03 = 2");
195    $arrOtherParam = unserialize($arrPaymentDB[0]['other_param']);
196   
197    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
198    $arrSend = sfGetPaygentShare(PAYGENT_CONVENI, $arrData['order_id'], $arrPaymentDB[0]);
199   
200    /** ¸ÄÊÌÅÅʸ **/
201   
202    // ·èºÑ¶â³Û
203    $arrSend['payment_amount'] = $arrData['payment_total'];
204    // ÍøÍѼÔÀ«
205    $arrSend['customer_family_name'] = $arrInput['customer_family_name'];
206    // ÍøÍѼÔ̾
207    $arrSend['customer_name'] = $arrInput['customer_name'];
208    // ÍøÍѼÔÀ«È¾³Ñ¥«¥Ê
209    $arrSend['customer_family_name_kana'] = mb_convert_kana($arrInput['customer_family_name_kana'],'k');
210    // ÍøÍѼÔ̾Ⱦ³Ñ¥«¥Ê
211    $arrSend['customer_name_kana'] = mb_convert_kana($arrInput['customer_name_kana'],'k');
212    // ÍøÍѼÔÅÅÏÃÈÖ¹æ
213    $arrSend['customer_tel'] = $arrInput['customer_tel'];
214    // »Ùʧ´ü¸ÂÆü
215    $arrSend['payment_limit_date'] = $arrOtherParam['payment_limit_date'];
216    // ¥³¥ó¥Ó¥Ë´ë¶È¥³¡¼¥É
217    $arrSend['cvs_company_id'] = $arrInput['cvs_company_id'];
218    // »Ùʧ¼ïÊÌ
219    $arrSend['sales_type'] = '1';
220   
221    // ÅÅʸ¤ÎÁ÷ÉÕ
222    foreach($arrSend as $key => $val) {
223        // Shift-JIS¤Ë¥¨¥ó¥³¡¼¥É¤¹¤ëɬÍפ¢¤ê
224        $enc_val = mb_convert_encoding($val, "Shift-JIS", CHAR_CODE);       
225        $p->reqPut($key, $enc_val);
226    }
227   
228    // ÅÅʸ¤ÎÁ÷¿®
229    $p->post();
230
231    // ±þÅú¤ò½èÍý
232    $arrRet = sfPaygentResponse(PAYGENT_CONVENI, $p, $uniqid);
233       
234    return $arrRet;
235}
236
237/**************************************************************************************************************
238 * ´Ø¿ô̾   ¡§sfSendPaygentATM
239 * ½èÍýÆâÍÆ ¡§ATM·èºÑ¾ðÊó¤ÎÁ÷¿®
240 * °ú¿ô1    ¡§
241 * °ú¿ô2    ¡§
242 * °ú¿ô3    ¡§
243 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
244 **************************************************************************************************************/
245function sfSendPaygentATM($arrData, $arrInput, $uniqid) {
246// Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
247    $p = new PaygentB2BModule();
248    $p->init();
249   
250    //¡¡ATM·èºÑÍѥѥé¥á¡¼¥¿¤Î¼èÆÀ
251    $arrPaymentDB = sfGetPaymentDB(MDL_PAYGENT_ID, "AND memo03 = 3");
252    $arrOtherParam = unserialize($arrPaymentDB[0]['other_param']);
253   
254    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
255    $arrSend = sfGetPaygentShare(PAYGENT_ATM, $arrData['order_id'], $arrPaymentDB[0]);
256   
257   
258    /** ¸ÄÊÌÅÅʸ **/
259   
260    // ·èºÑ¶â³Û
261    $arrSend['payment_amount'] = $arrData['payment_total'];
262
263    // ÍøÍѼÔÀ«
264    $arrSend['customer_family_name'] = $arrInput['customer_family_name'];
265    // ÍøÍѼÔ̾
266    $arrSend['customer_name'] = $arrInput['customer_name'];
267    // ÍøÍѼÔÀ«È¾³Ñ¥«¥Ê
268    $arrSend['customer_family_name_kana'] = mb_convert_kana($arrInput['customer_family_name_kana'],'k');
269    // ÍøÍѼÔ̾Ⱦ³Ñ¥«¥Ê
270    $arrSend['customer_name_kana'] = mb_convert_kana($arrInput['customer_name_kana'],'k');
271    // ·èºÑÆâÍÆ
272    $arrSend['payment_detail'] = $arrOtherParam['payment_detail'];
273    // ·èºÑÆâÍÆȾ³Ñ¥«¥Ê
274    $arrSend['payment_detail_kana'] = mb_convert_kana($arrOtherParam['payment_detail'],'k');
275    // »Ùʧ´ü¸ÂÆü
276    $arrSend['payment_limit_date'] = $arrOtherParam['payment_limit_date'];
277   
278    // ÅÅʸ¤ÎÁ÷ÉÕ
279    foreach($arrSend as $key => $val) {
280        // Shift-JIS¤Ë¥¨¥ó¥³¡¼¥É¤¹¤ëɬÍפ¢¤ê
281        $enc_val = mb_convert_encoding($val, "Shift-JIS", CHAR_CODE);       
282        $p->reqPut($key, $enc_val);
283    }
284   
285    // ÅÅʸ¤ÎÁ÷¿®
286    $p->post();
287   
288    // ±þÅú¤ò½èÍý
289    $arrRet = sfPaygentResponse(PAYGENT_ATM, $p, $uniqid);
290   
291    return $arrRet;
292}
293
294/**************************************************************************************************************
295 * ´Ø¿ô̾   ¡§sfSendPaygentBANK
296 * ½èÍýÆâÍÆ ¡§¶ä¹ÔNET·èºÑ¾ðÊó¤ÎÁ÷¿®
297 * °ú¿ô1    ¡§
298 * °ú¿ô2    ¡§
299 * °ú¿ô3    ¡§
300 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
301 **************************************************************************************************************/
302function sfSendPaygentBANK($arrData, $arrInput, $uniqid) {
303// Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
304    $p = new PaygentB2BModule();
305    $p->init();
306   
307    //¡¡¶ä¹ÔNETÍѥѥé¥á¡¼¥¿¤Î¼èÆÀ
308    $arrPaymentDB = sfGetPaymentDB(MDL_PAYGENT_ID, "AND memo03 = 4");
309    $arrOtherParam = unserialize($arrPaymentDB[0]['other_param']);
310   
311    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
312    $arrSend = sfGetPaygentShare(PAYGENT_BANK, $arrData['order_id'], $arrPaymentDB[0]);
313
314    /** ¸ÄÊÌÅÅʸ **/
315   
316    //$arrSend['bank_code'] = $arrInput['bank_code'];   
317    // ·èºÑ¶â³Û
318    $arrSend['amount'] = $arrData['payment_total'];
319    // ÀÁµáÆâÍÆ¥«¥Ê
320    $arrSend['claim_kana'] = $arrOtherParam['claim_kana'];
321    // ÀÁµáÆâÍÆ´Á»ú
322    $arrSend['claim_kanji'] = $arrOtherParam['claim_kanji'];   
323    // ÍøÍѼÔÀ«
324    $arrSend['customer_family_name'] = $arrInput['customer_family_name'];
325    // ÍøÍѼÔ̾
326    $arrSend['customer_name'] = $arrInput['customer_name'];
327    // ÍøÍѼÔÀ«È¾³Ñ¥«¥Ê
328    $arrSend['customer_family_name_kana'] = mb_convert_kana($arrInput['customer_family_name_kana'],'k');
329    // ÍøÍѼÔ̾Ⱦ³Ñ¥«¥Ê
330    $arrSend['customer_name_kana'] = mb_convert_kana($arrInput['customer_name_kana'],'k');
331    // PC-Mobile¶èʬ
332    /*
333     * 0:PC
334     * 1:docomo
335     * 2:au
336     * 3:softbank
337     */
338    $arrSend['pc_mobile_type'] = '0';
339    // Ìá¤ê£Õ£Ò£Ì
340    $arrSend['return_url'] = SSL_URL . "shopping/load_payment_module.php";
341   
342    // ÅÅʸ¤ÎÁ÷ÉÕ
343    foreach($arrSend as $key => $val) {
344        // Shift-JIS¤Ë¥¨¥ó¥³¡¼¥É¤¹¤ëɬÍפ¢¤ê
345        $enc_val = mb_convert_encoding($val, "Shift-JIS", CHAR_CODE);
346        $p->reqPut($key, $enc_val);
347    }
348   
349    // ÅÅʸ¤ÎÁ÷¿®
350    $p->post();
351   
352    // ±þÅú¤ò½èÍý
353    $arrRet = sfPaygentResponse(PAYGENT_BANK, $p, $uniqid);
354   
355    return $arrRet;
356}
357
358/**************************************************************************************************************
359 * ´Ø¿ô̾   ¡§sfPaygentResponse
360 * ½èÍýÆâÍÆ ¡§±þÅú¤ò½èÍý¤¹¤ë
361 * °ú¿ô1    ¡§
362 * °ú¿ô2    ¡§
363 * °ú¿ô3    ¡§
364 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
365 **************************************************************************************************************/
366
367function sfPaygentResponse($telegram_kind, $objPaygent, $uniqid) {
368    global $arrConvenience;
369   
370    // ½èÍý·ë²Ì¼èÆÀ¡Ê¶¦ÄÌ¡Ë
371    $resultStatus = $objPaygent->getResultStatus(); # ½èÍý·ë²Ì 0=Àµ¾ï½ªÎ», 1=°Û¾ï½ªÎ»
372    $responseCode = $objPaygent->getResponseCode(); # °Û¾ï½ªÎ»»þ¡¢¥ì¥¹¥Ý¥ó¥¹¥³¡¼¥É¤¬¼èÆÀ¤Ç¤­¤ë
373    $responseDetail = $objPaygent->getResponseDetail(); # °Û¾ï½ªÎ»»þ¡¢¥ì¥¹¥Ý¥ó¥¹¾ÜºÙ¤¬¼èÆÀ¤Ç¤­¤ë
374
375    // Shift-JIS¤Ç±þÅú¤¬¤¢¤ë¤Î¤Ç¡¢¥¨¥ó¥³¡¼¥É¤¹¤ë¡£
376    $responseDetail = mb_convert_encoding($responseDetail, CHAR_CODE, "Shift-JIS");
377       
378   
379    // ¥ì¥¹¥Ý¥ó¥¹¤Î¼èÆÀ
380    while($objPaygent->hasResNext()) {
381        # ¥Ç¡¼¥¿¤¬Â¸ºß¤¹¤ë¸Â¤ê¡¢¼èÆÀ
382        $arrRes[] = $objPaygent->resNext(); # Í×µá·ë²Ì¼èÆÀ
383    }
384   
385    // ·èºÑËè¤Ë°Û¤Ê¤ë½èÍý
386    switch($telegram_kind) {
387    // ¥¯¥ì¥¸¥Ã¥È·èºÑ¤Î¾ì¹ç
388    case PAYGENT_CREDIT:
389        // ¥¹¥Æ¡¼¥¿¥¹¤ò¿·µ¬¼õÉդˤ¹¤ë¡£
390        $arrVal["status"] = ORDER_NEW;
391        // ¶õ¤ÎÇÛÎó¤ò³ÊǼ¤·¤Æ¤ª¤¯
392        $arrVal["memo02"] = serialize(array());     
393        break;
394    // ¥³¥ó¥Ó¥Ë·èºÑ¤Î¾ì¹ç
395    case PAYGENT_CONVENI:       
396        // ¥¿¥¤¥È¥ë¤òÀßÄꤹ¤ë
397        $arrMemo['title'] = sfSetConvMSG("¥³¥ó¥Ó¥Ë¤ª»Ùʧ¾ðÊó", true);   
398        //ʧ¹þɼURL(PC)
399        if($arrRes[0]['receipt_print_url'] != "") {
400            $arrMemo['receipt_print_url'] = sfSetConvMSG("ʧ¹þɼURL", $arrRes[0]['receipt_print_url']);
401        }
402        //ʧ¹þɼÈÖ¹æ
403        $arrMemo['receipt_number'] = sfSetConvMSG("ʧ¹þɼÈÖ¹æ", $arrRes[0]['receipt_number']);
404        $arrCVS = split("-", $arrRes[0]['usable_cvs_company_id']);
405        foreach($arrCVS as $val) {
406            if($cvsLine != "") {
407                $cvsLine.= ",".$arrConvenience[$val];               
408            } else {
409                $cvsLine = $arrConvenience[$val];
410            }
411        }
412        //Âоݥ³¥ó¥Ó¥Ë
413        $arrMemo['usable_cvs_company_id'] = sfSetConvMSG("¤ª»Ùʧ²Äǽ¤Ê¥³¥ó¥Ó¥Ë", $cvsLine);         
414        // »Ùʧ´üÆü
415        $arrMemo['payment_limit_date'] = sfSetConvMSG("¤ª»Ùʧ´üÆü", date("Yǯm·îdÆü", strtotime($arrRes[0]['payment_limit_date'])));
416        // ¼õÃí¥Æ¡¼¥Ö¥ë¤ËÊݸ
417        $arrVal["memo02"] = serialize($arrMemo);
418        // ¥¹¥Æ¡¼¥¿¥¹¤òÆþ¶âÂÔ¤Á¤Ë¤¹¤ë¡£
419        $arrVal["status"] = ORDER_PAY_WAIT;     
420        break;
421    // ATM·èºÑ¤Î¾ì¹ç
422    case PAYGENT_ATM:
423        // ¥¿¥¤¥È¥ë¤òÀßÄꤹ¤ë
424        $arrMemo['title'] = sfSetConvMSG("ATM¤ª»Ùʧ¾ðÊó", true);   
425        $arrMemo['pay_center_number'] = sfSetConvMSG("¼ýǼµ¡´ØÈÖ¹æ", $arrRes[0]['pay_center_number']);
426        $arrMemo['customer_number'] = sfSetConvMSG("¤ªµÒÍÍÈÖ¹æ", $arrRes[0]['customer_number']);
427        $arrMemo['conf_number'] = sfSetConvMSG("³ÎǧÈÖ¹æ", $arrRes[0]['pay_center_number']);
428        // »Ùʧ´üÆü
429        $arrMemo['payment_limit_date'] = sfSetConvMSG("¤ª»Ùʧ´üÆü", date("Yǯm·îdÆü", strtotime($arrRes[0]['payment_limit_date'])));
430        // ¼õÃí¥Æ¡¼¥Ö¥ë¤ËÊݸ
431        $arrVal["memo02"] = serialize($arrMemo);
432        // ¥¹¥Æ¡¼¥¿¥¹¤òÆþ¶âÂÔ¤Á¤Ë¤¹¤ë¡£
433        $arrVal["status"] = ORDER_PAY_WAIT;     
434        break;
435    // ¶ä¹Ô¥Í¥Ã¥È¤Î¾ì¹ç
436    case PAYGENT_BANK:
437        // ¥¹¥Æ¡¼¥¿¥¹¤ò¿·µ¬¼õÉդˤ¹¤ë¡£
438        $arrVal["status"] = ORDER_NEW;
439        // ¶õ¤ÎÇÛÎó¤ò³ÊǼ¤·¤Æ¤ª¤¯
440        $arrVal["memo02"] = serialize(array());
441        break;
442    default:
443        break;
444    }
445   
446    // ¼õÃí¥Æ¡¼¥Ö¥ë¤Ëµ­Ï¿¤¹¤ë
447    $arrVal["memo01"] = MDL_PAYGENT_ID;     // ½èÍý·ë²Ì
448       
449    // memo02¤Ï¡¢»Ùʧ¾ðÊó¤ò³ÊǼ¤¹¤ë¡£
450    $arrVal["memo03"] = $resultStatus;      // ½èÍý·ë²Ì
451    $arrVal["memo04"] = $responseCode;      // ¥ì¥¹¥Ý¥ó¥¹¥³¡¼¥É
452    $arrVal["memo05"] = $responseDetail;    // ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
453    $arrVal["memo06"] = $arrRes[0]['payment_id'];       // ¾µÇ§ÈÖ¹æ
454
455    // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Ë¹¹¿·
456    sfRegistTempOrder($uniqid, $arrVal);
457   
458    // ¾µÇ§ÈÖ¹æ¤È¥á¥Ã¥»¡¼¥¸¤òÊÖ¤¹
459    return $arrRes[0];
460}
461
462/**************************************************************************************************************
463 * ´Ø¿ô̾   ¡§sfSetConvMSG
464 * ½èÍýÆâÍÆ ¡§¥³¥ó¥Ó¥Ë¾ðÊóɽ¼¨ÍÑ
465 * °ú¿ô1    ¡§
466 * °ú¿ô2    ¡§
467 * °ú¿ô3    ¡§
468 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
469 **************************************************************************************************************/
470function sfSetConvMSG($name, $value){
471    return array("name" => $name, "value" => $value);
472}
473
474/**************************************************************************************************************
475 * ´Ø¿ô̾   ¡§sfPaygentDisp
476 * ½èÍýÆâÍÆ ¡§¶¦Ä̤Îɽ¼¨½èÍý
477 * °ú¿ô1    ¡§
478 * °ú¿ô2    ¡§
479 * °ú¿ô3    ¡§
480 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
481 **************************************************************************************************************/
482function sfPaygentDisp($objPage, $payment_id) {
483    $objQuery = new SC_Query();
484    // »Ùʧ¤¤ÊýË¡¤ÎÀâÌÀ²èÁü¤ò¼èÆÀ¤¹¤ë¡£
485    $arrRet = $objQuery->select("payment_method, payment_image", "dtb_payment", "payment_id = ?", array($payment_id));
486    $objPage->tpl_payment_method = $arrRet[0]['payment_method'];
487    $objPage->tpl_payment_image = $arrRet[0]['payment_image'];
488    return $objPage;
489}
490
491/**************************************************************************************************************
492 * ´Ø¿ô̾   ¡§sfGetPaymentDB
493 * ½èÍýÆâÍÆ ¡§É¬Íפʥǡ¼¥¿¤ò¼èÆÀ¤¹¤ë¡£
494 * °ú¿ô1    ¡§
495 * °ú¿ô2    ¡§
496 * °ú¿ô3    ¡§
497 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
498 **************************************************************************************************************/
499function sfGetPaymentDB($module_id, $where = "", $arrWhereVal = array()){
500    $objQuery = new SC_Query();
501       
502    $arrVal = array($module_id);
503    $arrVal = array_merge($arrVal, $arrWhereVal);
504   
505    $arrRet = array();
506    $sql = "SELECT
507                module_id,
508                memo01 as merchant_id,
509                memo02 as connect_id,
510                memo03 as payment,
511                memo04 as connect_password,
512                memo05 as other_param
513            FROM dtb_payment WHERE module_id = ? " . $where;
514    $arrRet = $objQuery->getall($sql, $arrVal);
515
516    return $arrRet;
517}
518
519/**************************************************************************************************************
520 * ´Ø¿ô̾   ¡§sfPaygentBatch
521 * ½èÍýÆâÍÆ ¡§Æþ¶â¥¹¥Æ¡¼¥¿¥¹³Îǧ¥Ð¥Ã¥Á
522 * °ú¿ô1    ¡§
523 * °ú¿ô2    ¡§
524 * °ú¿ô3    ¡§
525 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
526 **************************************************************************************************************/
527function sfPaygentBatch() {
528    $objQuery = new SC_Query();
529   
530    // Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
531    $objPaygent = new PaygentB2BModule();
532    $objPaygent->init();
533   
534    //¡¡ÀßÄê¥Ñ¥é¥á¡¼¥¿¤Î¼èÆÀ
535    $arrPaymentDB = sfGetPaymentDB(MDL_PAYGENT_ID);
536
537    $where = "memo01 = ? AND status = ?";
538    $arrOrder = $objQuery->select("order_id", "dtb_order", $where, array(MDL_PAYGENT_ID, ORDER_PAY_WAIT));
539   
540    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
541    $arrSend = sfGetPaygentShare(PAYGENT_REF, 0, $arrPaymentDB[0]);
542   
543    for($i = 0; $i < count($arrOrder); $i++) {
544        $arrRet = sfUpdatePaymentStatus($objPaygent, $arrOrder[$i]['order_id'], $arrSend);
545    }
546       
547    return $arrRet;
548}
549
550/**************************************************************************************************************
551 * ´Ø¿ô̾   ¡§sfPaygentTest
552 * ½èÍýÆâÍÆ ¡§Àܳ¥Æ¥¹¥È
553 * °ú¿ô1    ¡§
554 * °ú¿ô2    ¡§
555 * °ú¿ô3    ¡§
556 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
557 **************************************************************************************************************/
558function sfPaygentTest($arrParam) {
559    $objQuery = new SC_Query();
560   
561    // Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
562    $objPaygent = new PaygentB2BModule();
563    $objPaygent->init();
564       
565    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
566    $arrSend = sfGetPaygentShare(PAYGENT_REF, '0', $arrParam);
567
568    // ÅÅʸ¤ÎÁ÷ÉÕ
569    foreach($arrSend as $key => $val) {
570        $objPaygent->reqPut($key, $val);
571    }
572    // ÅÅʸ¤ÎÁ÷¿®
573    $objPaygent->post();
574   
575    // ½èÍý·ë²Ì¼èÆÀ¡Ê¶¦ÄÌ¡Ë
576    $resultStatus = $objPaygent->getResultStatus(); # ½èÍý·ë²Ì 0=Àµ¾ï½ªÎ», 1=°Û¾ï½ªÎ»
577           
578    if($resultStatus == 0) {
579        return true;
580    } else {
581        return false;
582    }
583}
584
585/**************************************************************************************************************
586 * ´Ø¿ô̾   ¡§sfCheckPaymentStatus
587 * ½èÍýÆâÍÆ ¡§Æþ¶â¥¹¥Æ¡¼¥¿¥¹³Îǧ¥Ð¥Ã¥Á
588 * °ú¿ô1    ¡§
589 * °ú¿ô2    ¡§
590 * °ú¿ô3    ¡§
591 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
592 **************************************************************************************************************/
593function sfUpdatePaymentStatus($objPaygent, $order_id, $arrSend) {
594    $objQuery = new SC_Query();
595       
596    // ¥Þ¡¼¥Á¥ã¥ó¥È¼è°úID¤ÎÆþ¤ìÂؤ¨
597    $arrSend['trading_id'] = $order_id;
598   
599    // ÅÅʸ¤ÎÁ÷ÉÕ
600    foreach($arrSend as $key => $val) {
601        $objPaygent->reqPut($key, $val);
602    }
603    // ÅÅʸ¤ÎÁ÷¿®
604    $objPaygent->post();
605   
606    // ¥ì¥¹¥Ý¥ó¥¹¤Î¼èÆÀ
607    while($objPaygent->hasResNext()) {
608        # ¥Ç¡¼¥¿¤¬Â¸ºß¤¹¤ë¸Â¤ê¡¢¼èÆÀ
609        $arrRes[] = $objPaygent->resNext(); # Í×µá·ë²Ì¼èÆÀ
610    }
611   
612    foreach($arrRes[0] as $key => $val) {
613        // Shift-JIS¤Ç±þÅú¤¬¤¢¤ë¤Î¤Ç¡¢¥¨¥ó¥³¡¼¥É¤¹¤ë¡£
614        $arrRes[0][$key] = mb_convert_encoding($val, CHAR_CODE, "Shift-JIS");   
615    }
616   
617    // »Ùʧ¥¹¥Æ¡¼¥¿¥¹¤Î¹¹¿·
618    /*
619     * 10:¿½¹þºÑ
620     * 12:»Ùʧ´ü¸ÂÀÚ¤ì
621     * 15:¿½¹þÃæÃÇ
622     * 40:¾Ã¹þºÑ
623     * 43:®Êó¸¡ÃκÑ
624     * 61:®Êó¼è¾ÃºÑ
625     * etc
626     */
627    if($arrRes[0][payment_status] == '40') {
628        $arrVal['status'] = ORDER_PRE_END;
629    }
630   
631    $arrVal['memo07'] = $arrRes[0][payment_status];
632    $objQuery->update("dtb_order", $arrVal, "order_id = ?", array($order_id));
633   
634    return $arrRes[0];
635}
636
637?>
Note: See TracBrowser for help on using the repository browser.