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

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