T

payment 플러그인 화

· 2014-10-31 (금) 11:35:23 · 3660 · 5

벌써 payment 작업만 20번이 넘어 가네요.

조금씩 수정 하며 공용으로 사용 할 수 있는 플러그인화 작업도 진화 되고 있습니다.

 

참고 하시라고 소스를 첨부 합니다.

payment.class.php

[code]

<?php

class TBpayment {

 

# 기본환경 설정

public function set($Payment, $code='', $key='', $mode='real') {

 

global $config;

 

/*

$code: payment에서 발급되는 아이디 혹은 코드

$key: payment에서 발급되는 키

*/

# 필수값 확인

if($mode == 'real')

if(!$Payment || !$code || !$key) die('환경설정 부에 누락 된 값이 있습니다.');

 

# 경로 설정 (경로를 잡으면서 윈도우 \를 변환)

$RootDir = str_replace(chr(92), '/', $_SERVER['DOCUMENT_ROOT']);

$ModulePath =  str_replace(chr(92), '/', dirname(__FILE__));

 

# 모듈 경로의 URL을 생성

$http = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']!='off')?'https://':'http://';

$ModuleDir = str_replace($RootDir, '', $ModulePath);

$ModuleDir = rtrim($ModuleDir, '/');

$ModuleUrl = $http.$_SERVER['HTTP_HOST'].$ModuleDir;

 

# 정보를 배열에 담는다.

$this->config['module_path'] = $ModulePath;

$this->config['module_url'] = $ModuleUrl;

$this->config['payment'] = $Payment;

$this->config['mode'] = $mode;

$this->config['path'] = $ModulePath.'/'.$Payment;

$this->config['url'] = $ModuleUrl.'/'.$Payment;

$this->config['code'] = $code;

$this->config['key'] = $key;

 

if(file_exists($this->config['path'].'/config.php'))

include_once($this->config['path'].'/config.php');

else die('payment config file not exists!!');

}

 

 

# 환경설정 확인

public function config() {

 

return $this->config;

}

} 

[/code]

 

 

 

 

./module/payment/kcp/config.php

[code]

<?php

# BIN 절대 경로 입력 (bin전까지 설정

$GLOBALS['g_conf_home_dir'] = $this->config['path'].'/';

 

 

# log 경로 지정

$GLOBALS['g_conf_log_path'] = $GLOBALS['g_conf_home_dir'].'log';

 

 

# g_conf_gw_url 설정

if($mode == 'test') $GLOBALS['g_conf_gw_url'] = 'testpaygw.kcp.co.kr';

else $GLOBALS['g_conf_gw_url'] = 'paygw.kcp.co.kr';

 

 

# g_conf_js_url 설정

if($mode == 'test') {

 

if((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']!='off')) {

 

$GLOBALS['g_conf_js_url'] = 'https://pay.kcp.co.kr/plugin/payplus_test_un.js';

}

else {

 

$GLOBALS['g_conf_js_url'] = 'http://pay.kcp.co.kr/plugin/payplus_test_un.js';

}

}

else {

 

if((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']!='off')) {

 

$GLOBALS['g_conf_js_url'] = 'https://pay.kcp.co.kr/plugin/payplus_un.js';

}

else {

 

$GLOBALS['g_conf_js_url'] = 'http://pay.kcp.co.kr/plugin/payplus_un.js';

}

}

 

 

#스마트폰 SOAP 통신 설정

if($mode == 'test') $GLOBALS['g_wsdl'] = "KCPPaymentService.wsdl";

else $GLOBALS['g_wsdl'] = "real_KCPPaymentService.wsdl";

 

 

# g_conf_site_cd, g_conf_site_key 설정

if($mode == 'test') {

 

$GLOBALS['g_conf_site_cd'] = "T0000"; // T0007 은 결제 테스트 안됨

$GLOBALS['g_conf_site_key'] = "3grptw1.zW0GSo4PQdaGvsF__"; // 4Ho4YsuOZlLXUZUdOxM1Q7X__ 은 결제 테스트 안됨

}

else {

 

$GLOBALS['g_conf_site_cd']   = $this->config['code'];

    $GLOBALS['g_conf_site_key']  = $this->config['key'];

}

 

 

# g_conf_site_name 설정

if($mode == 'test') $GLOBALS['g_conf_site_name'] = $config['cf_title']." Test";

else $GLOBALS['g_conf_site_name'] = $config['cf_title'];

 

 

# 지불 데이터 셋업 (변경 불가) 

$GLOBALS['g_conf_log_level'] = "3";

$GLOBALS['g_conf_gw_port'] = "8090";        // 포트번호(변경불가)

$GLOBALS['module_type'] = "01";          // 변경불가 

[/code]

 

 

 

호출과 사용

[code]

include_once(realpath(__DIR__).'/payment.class.php');

 

$PayMode = 'test'; // real or test

$tbPay = new TBpayment;

$tbPay->set('kcp', '아이디 또는 코드값', '키값', $PayMode);

$PayConfig = $tbPay->config(); 

[/code]

|

댓글 5개

2014-11-11 (화) 09:45:11
빨리나왔으면 좋겠어요.ㄳ
비공개 작품이구요.
방법을 제시 하는 글입니다 ㅎㅎㅎ
2014-11-11 (화) 10:25:14
앗 ㅎㅎㅎ 프로그램 까막눈이라. 네~
ㅎㅎㅎㅎㅎ
ㅇㅎㅎㅎㅎㅎ
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,188건
+
제목 글쓴이 날짜 조회
12-08-29 조회 4,006
12-08-07 조회 3,675
12-08-03 조회 3,518
12-07-31 조회 3,626
12-07-30 조회 3,589
12-07-16 조회 3,797
12-07-15 조회 3,567
12-07-07 조회 3,498
12-07-06 조회 3,685
12-07-03 조회 3,659
12-06-29 조회 3,235
12-06-22 조회 3,606
12-06-17 조회 3,766
12-05-21 조회 3,787
12-05-02 조회 3,365
12-05-02 조회 4,162
12-05-02 조회 3,274
12-04-30 조회 3,447
12-04-30 조회 3,140
12-03-17 조회 3,990
12-03-10 조회 3,351
12-03-08 조회 3,847
12-03-03 조회 3,529
12-02-27 조회 4,955
12-02-17 조회 4,296
12-02-16 조회 4,534
12-02-03 조회 3,269
12-01-31 조회 3,070
12-01-24 조회 3,094
12-01-17 조회 3,843
12-01-05 조회 3,399
11-12-30 조회 3,056
11-12-23 조회 4,684
11-12-08 조회 3,398
11-12-07 조회 4,371
11-11-27 조회 3,791
11-11-25 조회 4,137
11-11-23 조회 3,560
11-11-22 조회 3,461
11-11-09 조회 3,191
11-10-23 조회 3,096
11-10-19 조회 3,068
11-10-08 조회 2,771
11-10-04 조회 2,780
11-10-04 조회 5,224
11-09-01 조회 4,283
11-08-13 조회 2,458
11-08-06 조회 3,152
11-07-11 조회 3,550
11-06-27 조회 2,923
11-06-21 조회 2,595
11-06-13 조회 2,375
11-06-07 조회 2,384
11-05-26 조회 2,379
11-04-20 조회 2,687
11-03-21 조회 2,774
11-03-18 조회 2,467
11-03-11 조회 2,512
11-02-07 조회 2,332
11-01-18 조회 2,646
11-01-12 조회 2,376
11-01-06 조회 2,486
10-12-10 조회 2,748
10-12-09 조회 2,463
10-12-08 조회 4,999
10-11-29 조회 2,574
10-11-28 조회 2,766
10-11-28 조회 2,608
10-11-19 조회 2,788
10-11-04 조회 2,681
10-10-21 조회 2,393
10-10-19 조회 3,343
10-10-12 조회 2,665
10-10-07 조회 2,496
10-09-30 조회 3,451
10-09-17 조회 3,847
10-09-17 조회 3,823
10-05-31 조회 3,484
09-12-31 조회 3,636
09-07-23 조회 4,951
08-09-16 조회 3,182
08-09-06 조회 2,916
08-09-04 조회 3,339
08-08-16 조회 4,392
08-08-15 조회 3,259
08-08-14 조회 4,468
08-08-12 조회 3,871
08-07-23 조회 2,768
08-07-10 조회 3,699
08-07-04 조회 2,921
08-06-27 조회 7,573
08-06-19 조회 4,862
08-05-27 조회 5,480
08-05-25 조회 5,310
08-05-23 조회 3,379
08-05-23 조회 4,519
08-05-21 조회 4,898
08-05-20 조회 4,021
08-05-20 조회 3,258
08-04-18 조회 4,294