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

Revision 16577, 23.7 KB checked in by naka, 15 years ago (diff)

ペイジェント決済ログ出力

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