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

Revision 16578, 23.9 KB checked in by naka, 14 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    $arrRetOther['result'] = $resultStatus;
408    $arrRetOther['code'] = $responseCode;
409    $arrRetOther['detail'] = $responseDetail;
410   
411    // ¼èÆÀ¤·¤¿Ãͤò¥í¥°¤ËÊݸ¤¹¤ë¡£
412    foreach($arrRetOther as $key => $val) {
413        gfPrintLog($key."->".$arrRes[0][$key]);
414    }
415   
416    // ¥ì¥¹¥Ý¥ó¥¹¤Î¼èÆÀ
417    while($objPaygent->hasResNext()) {
418        # ¥Ç¡¼¥¿¤¬Â¸ºß¤¹¤ë¸Â¤ê¡¢¼èÆÀ
419        $arrRes[] = $objPaygent->resNext(); # Í×µá·ë²Ì¼èÆÀ
420    }
421   
422    // ¼èÆÀ¤·¤¿Ãͤò¥í¥°¤ËÊݸ¤¹¤ë¡£
423    foreach($arrRes[0] as $key => $val) {
424        gfPrintLog($key."->".$arrRes[0][$key]);
425    }
426   
427    // ·èºÑËè¤Ë°Û¤Ê¤ë½èÍý
428    switch($telegram_kind) {
429    // ¥¯¥ì¥¸¥Ã¥È·èºÑ¤Î¾ì¹ç
430    case PAYGENT_CREDIT:
431        // ½é´ü¥¹¥Æ¡¼¥¿¥¹¤òÀßÄꤹ¤ë¡£
432        $arrVal["status"] = $arrInitStatus[PAYGENT_CREDIT];
433        // ¶õ¤ÎÇÛÎó¤ò³ÊǼ¤·¤Æ¤ª¤¯
434        $arrVal["memo02"] = serialize(array());     
435        break;
436    // ¥³¥ó¥Ó¥Ë·èºÑ¤Î¾ì¹ç
437    case PAYGENT_CONVENI:       
438        // ¥¿¥¤¥È¥ë¤òÀßÄꤹ¤ë
439        $arrMemo['title'] = sfSetConvMSG("¥³¥ó¥Ó¥Ë¤ª»Ùʧ¾ðÊó", true);   
440        //ʧ¹þɼURL(PC)
441        if($arrRes[0]['receipt_print_url'] != "") {
442            $arrMemo['receipt_print_url'] = sfSetConvMSG("ʧ¹þɼURL", $arrRes[0]['receipt_print_url']);
443        }
444        //ʧ¹þɼÈÖ¹æ
445        $arrMemo['receipt_number'] = sfSetConvMSG("ʧ¹þɼÈÖ¹æ", $arrRes[0]['receipt_number']);
446        $arrCVS = split("-", $arrRes[0]['usable_cvs_company_id']);
447        foreach($arrCVS as $val) {
448            if($cvsLine != "") {
449                $cvsLine.= ",".$arrConvenience[$val];               
450            } else {
451                $cvsLine = $arrConvenience[$val];
452            }
453        }
454        //Âоݥ³¥ó¥Ó¥Ë
455        $arrMemo['usable_cvs_company_id'] = sfSetConvMSG("¤ª»Ùʧ²Äǽ¤Ê¥³¥ó¥Ó¥Ë", $cvsLine);         
456        // »Ùʧ´üÆü
457        $arrMemo['payment_limit_date'] = sfSetConvMSG("¤ª»Ùʧ´üÆü", date("Yǯm·îdÆü", strtotime($arrRes[0]['payment_limit_date'])));
458        // ¼õÃí¥Æ¡¼¥Ö¥ë¤ËÊݸ
459        $arrVal["memo02"] = serialize($arrMemo);
460        // ½é´ü¥¹¥Æ¡¼¥¿¥¹¤òÀßÄꤹ¤ë¡£
461        $arrVal["status"] = $arrInitStatus[PAYGENT_CONVENI];       
462        break;
463    // ATM·èºÑ¤Î¾ì¹ç
464    case PAYGENT_ATM:
465        // ¥¿¥¤¥È¥ë¤òÀßÄꤹ¤ë
466        $arrMemo['title'] = sfSetConvMSG("ATM¤ª»Ùʧ¾ðÊó", true);   
467        $arrMemo['pay_center_number'] = sfSetConvMSG("¼ýǼµ¡´ØÈÖ¹æ", $arrRes[0]['pay_center_number']);
468        $arrMemo['customer_number'] = sfSetConvMSG("¤ªµÒÍÍÈÖ¹æ", $arrRes[0]['customer_number']);
469        $arrMemo['conf_number'] = sfSetConvMSG("³ÎǧÈÖ¹æ", $arrRes[0]['conf_number']);
470        // »Ùʧ´üÆü
471        $arrMemo['payment_limit_date'] = sfSetConvMSG("¤ª»Ùʧ´üÆü", date("Yǯm·îdÆü", strtotime($arrRes[0]['payment_limit_date'])));
472        // ¼õÃí¥Æ¡¼¥Ö¥ë¤ËÊݸ
473        $arrVal["memo02"] = serialize($arrMemo);
474        // ½é´ü¥¹¥Æ¡¼¥¿¥¹¤òÀßÄꤹ¤ë¡£
475        $arrVal["status"] = $arrInitStatus[PAYGENT_ATM];       
476        break;
477    // ¶ä¹Ô¥Í¥Ã¥È¤Î¾ì¹ç
478    case PAYGENT_BANK:
479        // ½é´ü¥¹¥Æ¡¼¥¿¥¹¤òÀßÄꤹ¤ë¡£
480        $arrVal["status"] = $arrInitStatus[PAYGENT_BANK];
481        // ¶õ¤ÎÇÛÎó¤ò³ÊǼ¤·¤Æ¤ª¤¯
482        $arrVal["memo02"] = serialize(array());
483        break;
484    default:
485        break;
486    }
487   
488    // ¼õÃí¥Æ¡¼¥Ö¥ë¤Ëµ­Ï¿¤¹¤ë
489    $arrVal["memo01"] = MDL_PAYGENT_ID;     // ½èÍý·ë²Ì
490       
491    // memo02¤Ï¡¢»Ùʧ¾ðÊó¤ò³ÊǼ¤¹¤ë¡£
492    $arrVal["memo03"] = $resultStatus;      // ½èÍý·ë²Ì
493    $arrVal["memo04"] = $responseCode;      // ¥ì¥¹¥Ý¥ó¥¹¥³¡¼¥É
494    $arrVal["memo05"] = $responseDetail;    // ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
495    $arrVal["memo06"] = $arrRes[0]['payment_id'];       // ¾µÇ§ÈÖ¹æ
496    $arrVal["memo07"] = "";                 // ¥¹¥Æ¡¼¥¿¥¹¼èÆÀ¤Ç»ÈÍÑ
497    $arrVal["memo08"] = $telegram_kind;
498    $arrVal["memo09"] = "";                 // ¥«¡¼¥É·èºÑÏ¢·È¤Ç»ÈÍÑ
499   
500    // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Ë¹¹¿·
501    sfRegistTempOrder($uniqid, $arrVal);
502   
503    // ¾µÇ§ÈÖ¹æ¤È¥á¥Ã¥»¡¼¥¸¤òÊÖ¤¹
504    return $arrRes[0];
505}
506
507/**************************************************************************************************************
508 * ´Ø¿ô̾   ¡§sfSetConvMSG
509 * ½èÍýÆâÍÆ ¡§¥³¥ó¥Ó¥Ë¾ðÊóɽ¼¨ÍÑ
510 * °ú¿ô1    ¡§
511 * °ú¿ô2    ¡§
512 * °ú¿ô3    ¡§
513 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
514 **************************************************************************************************************/
515function sfSetConvMSG($name, $value){
516    return array("name" => $name, "value" => $value);
517}
518
519/**************************************************************************************************************
520 * ´Ø¿ô̾   ¡§sfPaygentDisp
521 * ½èÍýÆâÍÆ ¡§¶¦Ä̤Îɽ¼¨½èÍý
522 * °ú¿ô1    ¡§
523 * °ú¿ô2    ¡§
524 * °ú¿ô3    ¡§
525 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
526 **************************************************************************************************************/
527function sfPaygentDisp($objPage, $payment_id) {
528    $objQuery = new SC_Query();
529    // »Ùʧ¤¤ÊýË¡¤ÎÀâÌÀ²èÁü¤ò¼èÆÀ¤¹¤ë¡£
530    $arrRet = $objQuery->select("payment_method, payment_image", "dtb_payment", "payment_id = ?", array($payment_id));
531    $objPage->tpl_payment_method = $arrRet[0]['payment_method'];
532    $objPage->tpl_payment_image = $arrRet[0]['payment_image'];
533    return $objPage;
534}
535
536/**************************************************************************************************************
537 * ´Ø¿ô̾   ¡§sfGetPaymentDB
538 * ½èÍýÆâÍÆ ¡§É¬Íפʥǡ¼¥¿¤ò¼èÆÀ¤¹¤ë¡£
539 * °ú¿ô1    ¡§
540 * °ú¿ô2    ¡§
541 * °ú¿ô3    ¡§
542 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
543 **************************************************************************************************************/
544function sfGetPaymentDB($module_id, $where = "", $arrWhereVal = array()){
545    $objQuery = new SC_Query();
546       
547    $arrVal = array($module_id);
548    $arrVal = array_merge($arrVal, $arrWhereVal);
549   
550    $arrRet = array();
551    $sql = "SELECT
552                module_id,
553                memo01 as merchant_id,
554                memo02 as connect_id,
555                memo03 as payment,
556                memo04 as connect_password,
557                memo05 as other_param
558            FROM dtb_payment WHERE module_id = ? " . $where;
559    $arrRet = $objQuery->getall($sql, $arrVal);
560
561    return $arrRet;
562}
563
564/**************************************************************************************************************
565 * ´Ø¿ô̾   ¡§sfPaygentBatch
566 * ½èÍýÆâÍÆ ¡§Æþ¶â¥¹¥Æ¡¼¥¿¥¹³Îǧ¥Ð¥Ã¥Á
567 * °ú¿ô1    ¡§
568 * °ú¿ô2    ¡§
569 * °ú¿ô3    ¡§
570 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
571 **************************************************************************************************************/
572function sfPaygentBatch() {
573    $objQuery = new SC_Query();
574   
575    // Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
576    $objPaygent = new PaygentB2BModule();
577    $objPaygent->init();
578   
579    //¡¡ÀßÄê¥Ñ¥é¥á¡¼¥¿¤Î¼èÆÀ
580    $arrPaymentDB = sfGetPaymentDB(MDL_PAYGENT_ID);
581
582    $where = "memo01 = ? AND status = ?";
583    $arrOrder = $objQuery->select("order_id", "dtb_order", $where, array(MDL_PAYGENT_ID, ORDER_PAY_WAIT));
584   
585    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
586    $arrSend = sfGetPaygentShare(PAYGENT_REF, 0, $arrPaymentDB[0]);
587   
588    for($i = 0; $i < count($arrOrder); $i++) {
589        sfUpdatePaymentStatus($objPaygent, $arrOrder[$i]['order_id'], $arrSend);
590    }
591}
592
593/**************************************************************************************************************
594 * ´Ø¿ô̾   ¡§sfPaygentTest
595 * ½èÍýÆâÍÆ ¡§Àܳ¥Æ¥¹¥È
596 * °ú¿ô1    ¡§
597 * °ú¿ô2    ¡§
598 * °ú¿ô3    ¡§
599 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
600 **************************************************************************************************************/
601function sfPaygentTest($arrParam) {
602    $objQuery = new SC_Query();
603   
604    // Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
605    $objPaygent = new PaygentB2BModule();
606    $objPaygent->init();
607       
608    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
609    $arrSend = sfGetPaygentShare(PAYGENT_REF, '0', $arrParam);
610
611    // ÅÅʸ¤ÎÁ÷ÉÕ
612    foreach($arrSend as $key => $val) {
613        $objPaygent->reqPut($key, $val);
614    }
615    // ÅÅʸ¤ÎÁ÷¿®
616    $objPaygent->post();
617   
618    // ½èÍý·ë²Ì¼èÆÀ¡Ê¶¦ÄÌ¡Ë
619    $resultStatus = $objPaygent->getResultStatus(); # ½èÍý·ë²Ì 0=Àµ¾ï½ªÎ», 1=°Û¾ï½ªÎ»
620           
621    if($resultStatus == 0) {
622        return true;
623    } else {
624        return false;
625    }
626}
627
628/**************************************************************************************************************
629 * ´Ø¿ô̾   ¡§sfUpdatePaymentStatus
630 * ½èÍýÆâÍÆ ¡§Æþ¶â¥¹¥Æ¡¼¥¿¥¹³Îǧ¥Ð¥Ã¥Á
631 * °ú¿ô1    ¡§
632 * °ú¿ô2    ¡§
633 * °ú¿ô3    ¡§
634 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
635 **************************************************************************************************************/
636function sfUpdatePaymentStatus($objPaygent, $order_id, $arrSend) {
637    // ¥¹¥Æ¡¼¥¿¥¹¤Î¼èÆÀ
638    $payment_status = sfGetPaymentStatus($objPaygent, $order_id, $arrSend);
639       
640    if($payment_status != "") {
641        gfPrintLog("¼õÃíÈÖ¹æ:" . $order_id . " »Ùʧ¥¹¥Æ¡¼¥¿¥¹:" . $payment_status);
642    } else {
643        gfPrintLog("¼õÃíÈÖ¹æ:" . $order_id . " »Ùʧ¥¹¥Æ¡¼¥¿¥¹:¼èÆÀ¤Ê¤·");   
644    }
645   
646    // »Ùʧ¥¹¥Æ¡¼¥¿¥¹¤Î¹¹¿·
647    /*
648     * 10:¿½¹þºÑ
649     * 12:»Ùʧ´ü¸ÂÀÚ¤ì
650     * 15:¿½¹þÃæÃÇ
651     * 40:¾Ã¹þºÑ
652     * 43:®Êó¸¡ÃκÑ
653     * 61:®Êó¼è¾ÃºÑ
654     * etc
655     */
656    if($payment_status == '40') {
657        // Æþ¶âºÑ¤ß¤ËÊѹ¹¤¹¤ë¡£
658        $arrVal['status'] = ORDER_PRE_END;
659    }
660       
661    $arrVal['memo07'] = $arrRes[0]['payment_status'];
662    $objQuery->update("dtb_order", $arrVal, "order_id = ?", array($order_id));
663}
664/**************************************************************************************************************
665 * ´Ø¿ô̾   ¡§sfGetPaymentStatus
666 * ½èÍýÆâÍÆ ¡§Æþ¶â¥¹¥Æ¡¼¥¿¥¹³Îǧ¥Ð¥Ã¥Á
667 * °ú¿ô1    ¡§
668 * °ú¿ô2    ¡§
669 * °ú¿ô3    ¡§
670 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
671 **************************************************************************************************************/
672function sfGetPaymentStatus($objPaygent, $order_id, $arrSend) {
673    $objQuery = new SC_Query();
674       
675    // ¥Þ¡¼¥Á¥ã¥ó¥È¼è°úID¤ÎÆþ¤ìÂؤ¨
676    $arrSend['trading_id'] = $order_id;
677   
678    // ÅÅʸ¤ÎÁ÷ÉÕ
679    foreach($arrSend as $key => $val) {
680        $objPaygent->reqPut($key, $val);
681    }
682    // ÅÅʸ¤ÎÁ÷¿®
683    $objPaygent->post();
684   
685    // ¥ì¥¹¥Ý¥ó¥¹¤Î¼èÆÀ
686    while($objPaygent->hasResNext()) {
687        # ¥Ç¡¼¥¿¤¬Â¸ºß¤¹¤ë¸Â¤ê¡¢¼èÆÀ
688        $arrRes[] = $objPaygent->resNext(); # Í×µá·ë²Ì¼èÆÀ
689    }
690       
691    foreach($arrRes[0] as $key => $val) {
692        // Shift-JIS¤Ç±þÅú¤¬¤¢¤ë¤Î¤Ç¡¢¥¨¥ó¥³¡¼¥É¤¹¤ë¡£
693        $arrRes[0][$key] = mb_convert_encoding($val, CHAR_CODE, "Shift-JIS");
694        gfPrintLog($key."->".$arrRes[0][$key]);
695    }
696    return $arrRes[0]['payment_status'];
697}
698
699/**************************************************************************************************************
700 * ´Ø¿ô̾   ¡§sfPaygentOrder($paygent_type)
701 * ½èÍýÆâÍÆ ¡§¼õÃíÏ¢·È
702 * °ú¿ô1    ¡§
703 * °ú¿ô2    ¡§
704 * °ú¿ô3    ¡§
705 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
706 **************************************************************************************************************/
707function sfPaygentOrder($paygent_type, $order_id) {
708    global $arrDispKind;
709   
710    // Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
711    $objPaygent = new PaygentB2BModule();
712    $objPaygent->init();
713   
714    //¡¡ÀßÄê¥Ñ¥é¥á¡¼¥¿¤Î¼èÆÀ
715    $arrPaymentDB = sfGetPaymentDB(MDL_PAYGENT_ID);
716   
717    switch($paygent_type) {
718    case 'auth_cancel':
719        $kind = PAYGENT_AUTH_CANCEL;
720        break;
721    case 'card_commit':
722        $kind = PAYGENT_CARD_COMMIT;
723        break;
724    case 'card_commit_cancel':
725        $kind = PAYGENT_CARD_COMMIT_CANCEL;
726        break;
727    }
728    $arrSend = sfGetPaygentShare($kind, $order_id, $arrPaymentDB[0]);
729   
730    // ÅÅʸ¤ÎÁ÷ÉÕ
731    foreach($arrSend as $key => $val) {
732        $objPaygent->reqPut($key, $val);
733    }
734    // ÅÅʸ¤ÎÁ÷¿®
735    $objPaygent->post();
736
737    // ¥ì¥¹¥Ý¥ó¥¹¤Î¼èÆÀ
738    while($objPaygent->hasResNext()) {
739        # ¥Ç¡¼¥¿¤¬Â¸ºß¤¹¤ë¸Â¤ê¡¢¼èÆÀ
740        $arrRes[] = $objPaygent->resNext(); # Í×µá·ë²Ì¼èÆÀ
741    }
742
743    $resultStatus = $objPaygent->getResultStatus(); # ½èÍý·ë²Ì 0=Àµ¾ï½ªÎ», 1=°Û¾ï½ªÎ»
744    gfPrintLog('result'."->".$resultStatus);
745   
746    foreach($arrRes[0] as $key => $val) {
747        // Shift-JIS¤Ç±þÅú¤¬¤¢¤ë¤Î¤Ç¡¢¥¨¥ó¥³¡¼¥É¤¹¤ë¡£
748        $arrRes[0][$key] = mb_convert_encoding($val, CHAR_CODE, "Shift-JIS");
749        gfPrintLog($key."->".$arrRes[0][$key]);
750    }
751   
752    // Àµ¾ï½ªÎ»
753    if($resultStatus == '0') {
754        $objQuery = new SC_Query();
755        $arrVal['memo09'] = $kind;
756        $objQuery->update("dtb_order", $arrVal, "order_id = ?", array($order_id));
757        $arrReturn['return'] = true;   
758    } else {
759        $arrReturn['return'] = false;
760    }
761    $arrReturn['kind'] = $kind;
762    return $arrReturn;
763}
764
765/**************************************************************************************************************
766 * ´Ø¿ô̾   ¡§sfPaygentOrderPage($objPage)
767 * ½èÍýÆâÍÆ ¡§É½¼¨Íѥѥ顼¥á¡¼¥¿¤òÄɲ乤롣
768 * °ú¿ô1    ¡§
769 * °ú¿ô2    ¡§
770 * °ú¿ô3    ¡§
771 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
772 **************************************************************************************************************/
773function sfPaygentOrderPage($objPage) {
774    global $arrDispKind;
775    $objPage->arrDispKind = $arrDispKind;
776    return $objPage;
777}
778?>
Note: See TracBrowser for help on using the repository browser.