T

payment 플러그인 화

벌써 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개

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

프로그램

8,188건
+
제목 글쓴이 날짜 조회
15-12-13 조회 2,524
15-12-13 조회 2,936
15-12-11 조회 2,597
15-12-11 조회 2,560
15-12-11 조회 2,561
15-12-10 조회 2,514
15-12-10 조회 2,582
15-12-10 조회 2,550
15-12-03 조회 3,194
15-12-03 조회 2,715
15-11-25 조회 2,795
15-11-09 조회 3,130
15-11-04 조회 2,957
15-06-09 조회 4,083
15-05-06 조회 5,082
15-03-28 조회 4,558
14-12-05 조회 4,985
14-10-25 조회 5,046
14-10-13 조회 4,263
14-10-03 조회 6,201
14-09-19 조회 4,957
14-09-18 조회 4,044
14-09-13 조회 4,602
14-09-03 조회 5,593
14-08-26 조회 4,200
14-08-26 조회 3,996
14-08-26 조회 3,972
14-08-11 조회 6,448
14-08-06 조회 4,118
14-08-06 조회 3,716
14-08-06 조회 3,924
14-08-01 조회 6,284
14-08-01 조회 3,836
14-07-30 조회 4,431
14-06-28 조회 5,157
14-06-28 조회 4,432
14-05-11 조회 4,582
14-05-09 조회 4,935
14-05-09 조회 7,695
14-04-30 조회 4,307
14-04-27 조회 4,181
14-04-25 조회 4,889
14-04-21 조회 3,872
14-04-21 조회 4,996
14-04-10 조회 4,595
14-04-01 조회 6,151
14-03-03 조회 3,527
14-02-25 조회 5,912
14-02-14 조회 5,192
14-02-13 조회 4,947
14-01-03 조회 4,436
13-12-06 조회 3,761
13-11-22 조회 5,517
13-11-18 조회 4,018
13-10-02 조회 4,438
13-10-02 조회 3,690
13-10-02 조회 3,953
13-10-02 조회 3,811
13-10-02 조회 4,178
13-09-16 조회 8,023
13-09-16 조회 5,388
13-08-18 조회 5,399
13-07-11 조회 4,051
13-07-10 조회 4,688
13-07-09 조회 4,724
13-07-09 조회 4,971
13-07-04 조회 4,479
13-07-04 조회 4,117
13-07-04 조회 4,234
13-07-01 조회 4,716
13-07-01 조회 4,543
13-07-01 조회 6,797
13-06-23 조회 4,371
13-06-05 조회 3,621
13-05-29 조회 4,865
13-05-10 조회 4,271
13-04-05 조회 4,883
13-04-05 조회 6,574
13-04-05 조회 1.1만
13-04-05 조회 7,167
13-04-05 조회 6,559
13-03-31 조회 5,829
13-03-31 조회 4,153
13-03-28 조회 4,514
13-03-28 조회 6,712
13-03-28 조회 9,194
13-03-28 조회 4,327
13-03-24 조회 3,941
13-03-21 조회 4,611
13-03-21 조회 1.8만
13-03-14 조회 3,924
13-03-10 조회 4,742
13-03-10 조회 4,495
13-03-10 조회 4,194
13-03-08 조회 5,254
13-03-08 조회 4,364
13-03-03 조회 5,014
13-03-03 조회 7,460
13-03-03 조회 4,213
13-03-03 조회 1.1만