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

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