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

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