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

Revision 15265, 19.7 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    // ¥³¥Ô¡¼¥é¥¤¥È
347    $arrSend['copy_right'] = $arrOtherParam['copy_right'];
348    // ¼«Í³¥á¥âÍó
349    $arrSend['free_memo'] = $arrOtherParam['free_memo'];
350    // »Ùʧ´ü´Ö(0DDhhmm)
351    $arrSend['asp_payment_term'] = sprintf("0%02d0000", $arrOtherParam['asp_payment_term']);
352   
353    // ÅÅʸ¤ÎÁ÷ÉÕ
354    foreach($arrSend as $key => $val) {
355        // Shift-JIS¤Ë¥¨¥ó¥³¡¼¥É¤¹¤ëɬÍפ¢¤ê
356        $enc_val = mb_convert_encoding($val, "Shift-JIS", CHAR_CODE);
357        $p->reqPut($key, $enc_val);
358    }
359   
360    // ÅÅʸ¤ÎÁ÷¿®
361    $p->post();
362   
363    // ±þÅú¤ò½èÍý
364    $arrRet = sfPaygentResponse(PAYGENT_BANK, $p, $uniqid);
365   
366    return $arrRet;
367}
368
369/**************************************************************************************************************
370 * ´Ø¿ô̾   ¡§sfPaygentResponse
371 * ½èÍýÆâÍÆ ¡§±þÅú¤ò½èÍý¤¹¤ë
372 * °ú¿ô1    ¡§
373 * °ú¿ô2    ¡§
374 * °ú¿ô3    ¡§
375 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
376 **************************************************************************************************************/
377
378function sfPaygentResponse($telegram_kind, $objPaygent, $uniqid) {
379    global $arrConvenience;
380   
381    // ½èÍý·ë²Ì¼èÆÀ¡Ê¶¦ÄÌ¡Ë
382    $resultStatus = $objPaygent->getResultStatus(); # ½èÍý·ë²Ì 0=Àµ¾ï½ªÎ», 1=°Û¾ï½ªÎ»
383    $responseCode = $objPaygent->getResponseCode(); # °Û¾ï½ªÎ»»þ¡¢¥ì¥¹¥Ý¥ó¥¹¥³¡¼¥É¤¬¼èÆÀ¤Ç¤­¤ë
384    $responseDetail = $objPaygent->getResponseDetail(); # °Û¾ï½ªÎ»»þ¡¢¥ì¥¹¥Ý¥ó¥¹¾ÜºÙ¤¬¼èÆÀ¤Ç¤­¤ë
385
386    // Shift-JIS¤Ç±þÅú¤¬¤¢¤ë¤Î¤Ç¡¢¥¨¥ó¥³¡¼¥É¤¹¤ë¡£
387    $responseDetail = mb_convert_encoding($responseDetail, CHAR_CODE, "Shift-JIS");
388       
389   
390    // ¥ì¥¹¥Ý¥ó¥¹¤Î¼èÆÀ
391    while($objPaygent->hasResNext()) {
392        # ¥Ç¡¼¥¿¤¬Â¸ºß¤¹¤ë¸Â¤ê¡¢¼èÆÀ
393        $arrRes[] = $objPaygent->resNext(); # Í×µá·ë²Ì¼èÆÀ
394    }
395   
396    // ·èºÑËè¤Ë°Û¤Ê¤ë½èÍý
397    switch($telegram_kind) {
398    // ¥¯¥ì¥¸¥Ã¥È·èºÑ¤Î¾ì¹ç
399    case PAYGENT_CREDIT:
400        // ¥¹¥Æ¡¼¥¿¥¹¤ò¿·µ¬¼õÉդˤ¹¤ë¡£
401        $arrVal["status"] = ORDER_NEW;
402        // ¶õ¤ÎÇÛÎó¤ò³ÊǼ¤·¤Æ¤ª¤¯
403        $arrVal["memo02"] = serialize(array());     
404        break;
405    // ¥³¥ó¥Ó¥Ë·èºÑ¤Î¾ì¹ç
406    case PAYGENT_CONVENI:       
407        // ¥¿¥¤¥È¥ë¤òÀßÄꤹ¤ë
408        $arrMemo['title'] = sfSetConvMSG("¥³¥ó¥Ó¥Ë¤ª»Ùʧ¾ðÊó", true);   
409        //ʧ¹þɼURL(PC)
410        if($arrRes[0]['receipt_print_url'] != "") {
411            $arrMemo['receipt_print_url'] = sfSetConvMSG("ʧ¹þɼURL", $arrRes[0]['receipt_print_url']);
412        }
413        //ʧ¹þɼÈÖ¹æ
414        $arrMemo['receipt_number'] = sfSetConvMSG("ʧ¹þɼÈÖ¹æ", $arrRes[0]['receipt_number']);
415        $arrCVS = split("-", $arrRes[0]['usable_cvs_company_id']);
416        foreach($arrCVS as $val) {
417            if($cvsLine != "") {
418                $cvsLine.= ",".$arrConvenience[$val];               
419            } else {
420                $cvsLine = $arrConvenience[$val];
421            }
422        }
423        //Âоݥ³¥ó¥Ó¥Ë
424        $arrMemo['usable_cvs_company_id'] = sfSetConvMSG("¤ª»Ùʧ²Äǽ¤Ê¥³¥ó¥Ó¥Ë", $cvsLine);         
425        // »Ùʧ´üÆü
426        $arrMemo['payment_limit_date'] = sfSetConvMSG("¤ª»Ùʧ´üÆü", date("Yǯm·îdÆü", strtotime($arrRes[0]['payment_limit_date'])));
427        // ¼õÃí¥Æ¡¼¥Ö¥ë¤ËÊݸ
428        $arrVal["memo02"] = serialize($arrMemo);
429        // ¥¹¥Æ¡¼¥¿¥¹¤òÆþ¶âÂÔ¤Á¤Ë¤¹¤ë¡£
430        $arrVal["status"] = ORDER_PAY_WAIT;     
431        break;
432    // ATM·èºÑ¤Î¾ì¹ç
433    case PAYGENT_ATM:
434        // ¥¿¥¤¥È¥ë¤òÀßÄꤹ¤ë
435        $arrMemo['title'] = sfSetConvMSG("ATM¤ª»Ùʧ¾ðÊó", true);   
436        $arrMemo['pay_center_number'] = sfSetConvMSG("¼ýǼµ¡´ØÈÖ¹æ", $arrRes[0]['pay_center_number']);
437        $arrMemo['customer_number'] = sfSetConvMSG("¤ªµÒÍÍÈÖ¹æ", $arrRes[0]['customer_number']);
438        $arrMemo['conf_number'] = sfSetConvMSG("³ÎǧÈÖ¹æ", $arrRes[0]['pay_center_number']);
439        // »Ùʧ´üÆü
440        $arrMemo['payment_limit_date'] = sfSetConvMSG("¤ª»Ùʧ´üÆü", date("Yǯm·îdÆü", strtotime($arrRes[0]['payment_limit_date'])));
441        // ¼õÃí¥Æ¡¼¥Ö¥ë¤ËÊݸ
442        $arrVal["memo02"] = serialize($arrMemo);
443        // ¥¹¥Æ¡¼¥¿¥¹¤òÆþ¶âÂÔ¤Á¤Ë¤¹¤ë¡£
444        $arrVal["status"] = ORDER_PAY_WAIT;     
445        break;
446    // ¶ä¹Ô¥Í¥Ã¥È¤Î¾ì¹ç
447    case PAYGENT_BANK:
448        // ¥¹¥Æ¡¼¥¿¥¹¤ò¿·µ¬¼õÉդˤ¹¤ë¡£
449        $arrVal["status"] = ORDER_NEW;
450        // ¶õ¤ÎÇÛÎó¤ò³ÊǼ¤·¤Æ¤ª¤¯
451        $arrVal["memo02"] = serialize(array());
452        break;
453    default:
454        break;
455    }
456   
457    // ¼õÃí¥Æ¡¼¥Ö¥ë¤Ëµ­Ï¿¤¹¤ë
458    $arrVal["memo01"] = MDL_PAYGENT_ID;     // ½èÍý·ë²Ì
459       
460    // memo02¤Ï¡¢»Ùʧ¾ðÊó¤ò³ÊǼ¤¹¤ë¡£
461    $arrVal["memo03"] = $resultStatus;      // ½èÍý·ë²Ì
462    $arrVal["memo04"] = $responseCode;      // ¥ì¥¹¥Ý¥ó¥¹¥³¡¼¥É
463    $arrVal["memo05"] = $responseDetail;    // ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
464    $arrVal["memo06"] = $arrRes[0]['payment_id'];       // ¾µÇ§ÈÖ¹æ
465
466    // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Ë¹¹¿·
467    sfRegistTempOrder($uniqid, $arrVal);
468   
469    // ¾µÇ§ÈÖ¹æ¤È¥á¥Ã¥»¡¼¥¸¤òÊÖ¤¹
470    return $arrRes[0];
471}
472
473/**************************************************************************************************************
474 * ´Ø¿ô̾   ¡§sfSetConvMSG
475 * ½èÍýÆâÍÆ ¡§¥³¥ó¥Ó¥Ë¾ðÊóɽ¼¨ÍÑ
476 * °ú¿ô1    ¡§
477 * °ú¿ô2    ¡§
478 * °ú¿ô3    ¡§
479 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
480 **************************************************************************************************************/
481function sfSetConvMSG($name, $value){
482    return array("name" => $name, "value" => $value);
483}
484
485/**************************************************************************************************************
486 * ´Ø¿ô̾   ¡§sfPaygentDisp
487 * ½èÍýÆâÍÆ ¡§¶¦Ä̤Îɽ¼¨½èÍý
488 * °ú¿ô1    ¡§
489 * °ú¿ô2    ¡§
490 * °ú¿ô3    ¡§
491 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
492 **************************************************************************************************************/
493function sfPaygentDisp($objPage, $payment_id) {
494    $objQuery = new SC_Query();
495    // »Ùʧ¤¤ÊýË¡¤ÎÀâÌÀ²èÁü¤ò¼èÆÀ¤¹¤ë¡£
496    $arrRet = $objQuery->select("payment_method, payment_image", "dtb_payment", "payment_id = ?", array($payment_id));
497    $objPage->tpl_payment_method = $arrRet[0]['payment_method'];
498    $objPage->tpl_payment_image = $arrRet[0]['payment_image'];
499    return $objPage;
500}
501
502/**************************************************************************************************************
503 * ´Ø¿ô̾   ¡§sfGetPaymentDB
504 * ½èÍýÆâÍÆ ¡§É¬Íפʥǡ¼¥¿¤ò¼èÆÀ¤¹¤ë¡£
505 * °ú¿ô1    ¡§
506 * °ú¿ô2    ¡§
507 * °ú¿ô3    ¡§
508 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
509 **************************************************************************************************************/
510function sfGetPaymentDB($module_id, $where = "", $arrWhereVal = array()){
511    $objQuery = new SC_Query();
512       
513    $arrVal = array($module_id);
514    $arrVal = array_merge($arrVal, $arrWhereVal);
515   
516    $arrRet = array();
517    $sql = "SELECT
518                module_id,
519                memo01 as merchant_id,
520                memo02 as connect_id,
521                memo03 as payment,
522                memo04 as connect_password,
523                memo05 as other_param
524            FROM dtb_payment WHERE module_id = ? " . $where;
525    $arrRet = $objQuery->getall($sql, $arrVal);
526
527    return $arrRet;
528}
529
530/**************************************************************************************************************
531 * ´Ø¿ô̾   ¡§sfPaygentBatch
532 * ½èÍýÆâÍÆ ¡§Æþ¶â¥¹¥Æ¡¼¥¿¥¹³Îǧ¥Ð¥Ã¥Á
533 * °ú¿ô1    ¡§
534 * °ú¿ô2    ¡§
535 * °ú¿ô3    ¡§
536 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
537 **************************************************************************************************************/
538function sfPaygentBatch() {
539    $objQuery = new SC_Query();
540   
541    // Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
542    $objPaygent = new PaygentB2BModule();
543    $objPaygent->init();
544   
545    //¡¡ÀßÄê¥Ñ¥é¥á¡¼¥¿¤Î¼èÆÀ
546    $arrPaymentDB = sfGetPaymentDB(MDL_PAYGENT_ID);
547
548    $where = "memo01 = ? AND status = ?";
549    $arrOrder = $objQuery->select("order_id", "dtb_order", $where, array(MDL_PAYGENT_ID, ORDER_PAY_WAIT));
550   
551    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
552    $arrSend = sfGetPaygentShare(PAYGENT_REF, 0, $arrPaymentDB[0]);
553   
554    for($i = 0; $i < count($arrOrder); $i++) {
555        $arrRet = sfUpdatePaymentStatus($objPaygent, $arrOrder[$i]['order_id'], $arrSend);
556    }
557       
558    return $arrRet;
559}
560
561/**************************************************************************************************************
562 * ´Ø¿ô̾   ¡§sfPaygentTest
563 * ½èÍýÆâÍÆ ¡§Àܳ¥Æ¥¹¥È
564 * °ú¿ô1    ¡§
565 * °ú¿ô2    ¡§
566 * °ú¿ô3    ¡§
567 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
568 **************************************************************************************************************/
569function sfPaygentTest($arrParam) {
570    $objQuery = new SC_Query();
571   
572    // Àܳ¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¼èÆÀ (¥³¥ó¥¹¥È¥é¥¯¥¿)¤È½é´ü²½
573    $objPaygent = new PaygentB2BModule();
574    $objPaygent->init();
575       
576    // ¶¦Ḁ̈ǡ¼¥¿¤Î¼èÆÀ
577    $arrSend = sfGetPaygentShare(PAYGENT_REF, '0', $arrParam);
578
579    // ÅÅʸ¤ÎÁ÷ÉÕ
580    foreach($arrSend as $key => $val) {
581        $objPaygent->reqPut($key, $val);
582    }
583    // ÅÅʸ¤ÎÁ÷¿®
584    $objPaygent->post();
585   
586    // ½èÍý·ë²Ì¼èÆÀ¡Ê¶¦ÄÌ¡Ë
587    $resultStatus = $objPaygent->getResultStatus(); # ½èÍý·ë²Ì 0=Àµ¾ï½ªÎ», 1=°Û¾ï½ªÎ»
588           
589    if($resultStatus == 0) {
590        return true;
591    } else {
592        return false;
593    }
594}
595
596/**************************************************************************************************************
597 * ´Ø¿ô̾   ¡§sfCheckPaymentStatus
598 * ½èÍýÆâÍÆ ¡§Æþ¶â¥¹¥Æ¡¼¥¿¥¹³Îǧ¥Ð¥Ã¥Á
599 * °ú¿ô1    ¡§
600 * °ú¿ô2    ¡§
601 * °ú¿ô3    ¡§
602 * Ìá¤êÃÍ   ¡§¼èÆÀ·ë²Ì
603 **************************************************************************************************************/
604function sfUpdatePaymentStatus($objPaygent, $order_id, $arrSend) {
605    $objQuery = new SC_Query();
606       
607    // ¥Þ¡¼¥Á¥ã¥ó¥È¼è°úID¤ÎÆþ¤ìÂؤ¨
608    $arrSend['trading_id'] = $order_id;
609   
610    // ÅÅʸ¤ÎÁ÷ÉÕ
611    foreach($arrSend as $key => $val) {
612        $objPaygent->reqPut($key, $val);
613    }
614    // ÅÅʸ¤ÎÁ÷¿®
615    $objPaygent->post();
616   
617    // ¥ì¥¹¥Ý¥ó¥¹¤Î¼èÆÀ
618    while($objPaygent->hasResNext()) {
619        # ¥Ç¡¼¥¿¤¬Â¸ºß¤¹¤ë¸Â¤ê¡¢¼èÆÀ
620        $arrRes[] = $objPaygent->resNext(); # Í×µá·ë²Ì¼èÆÀ
621    }
622   
623    foreach($arrRes[0] as $key => $val) {
624        // Shift-JIS¤Ç±þÅú¤¬¤¢¤ë¤Î¤Ç¡¢¥¨¥ó¥³¡¼¥É¤¹¤ë¡£
625        $arrRes[0][$key] = mb_convert_encoding($val, CHAR_CODE, "Shift-JIS");   
626    }
627   
628    // »Ùʧ¥¹¥Æ¡¼¥¿¥¹¤Î¹¹¿·
629    /*
630     * 10:¿½¹þºÑ
631     * 12:»Ùʧ´ü¸ÂÀÚ¤ì
632     * 15:¿½¹þÃæÃÇ
633     * 40:¾Ã¹þºÑ
634     * 43:®Êó¸¡ÃκÑ
635     * 61:®Êó¼è¾ÃºÑ
636     * etc
637     */
638    if($arrRes[0][payment_status] == '40') {
639        $arrVal['status'] = ORDER_PRE_END;
640    }
641   
642    $arrVal['memo07'] = $arrRes[0][payment_status];
643    $objQuery->update("dtb_order", $arrVal, "order_id = ?", array($order_id));
644   
645    return $arrRes[0];
646}
647
648?>
Note: See TracBrowser for help on using the repository browser.