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

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