Plugin Directory

Changeset 1875347


Ignore:
Timestamp:
05/16/2018 10:39:30 AM (8 years ago)
Author:
kagla
Message:

1.3.0 update

Location:
gnupay-kcp/trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • gnupay-kcp/trunk/classes/admin_metabox.class.php

    r1403518 r1875347  
    4242        $pay_ids = gnupay_kcp_get_settings('pay_ids');
    4343
    44         if( !empty($order->payment_method) && in_array($order->payment_method, $pay_ids) ){
    45             $config = gnupay_kcp_get_config_payment( $order->id );
     44        if( !empty($order->get_payment_method()) && in_array($order->get_payment_method(), $pay_ids) ){
     45            $order_id = $order->get_order_number();
     46            $config = gnupay_kcp_get_config_payment( $order_id );
    4647
    47             $payment_method = $order->payment_method;
     48            $payment_method = $order->get_payment_method();
    4849            $pg_url  = 'http://admin8.kcp.co.kr';
    4950            $pg_test = 'KCP';
    5051
    51             $od_pg = get_post_meta($order->id, '_od_pg', true);   //결제 pg사를 저장
    52             $od_pay_method = get_post_meta($order->id, '_od_pay_method', true);   //결제 pg사를 저장
    53             $od_tno = get_post_meta($order->id, '_od_tno', true);   //결제 pg사를 주문번호
    54             $od_app_no = get_post_meta($order->id, '_od_app_no', true);   //결제 승인 번호
    55             $od_receipt_price = get_post_meta($order->id, '_od_receipt_price', true);   //결제 금액
    56             $od_test = get_post_meta($order->id, '_od_test', true);   //테스트체크
    57             $od_escrow = get_post_meta($order->id, '_od_escrow', true);   //에스크로
     52            $od_pg = get_post_meta($order_id, '_od_pg', true);   //결제 pg사를 저장
     53            $od_pay_method = get_post_meta($order_id, '_od_pay_method', true);   //결제 pg사를 저장
     54            $od_tno = get_post_meta($order_id, '_od_tno', true);   //결제 pg사를 주문번호
     55            $od_app_no = get_post_meta($order_id, '_od_app_no', true);   //결제 승인 번호
     56            $od_receipt_price = get_post_meta($order_id, '_od_receipt_price', true);   //결제 금액
     57            $od_test = get_post_meta($order_id, '_od_test', true);   //테스트체크
     58            $od_escrow = get_post_meta($order_id, '_od_escrow', true);   //에스크로
    5859        ?>
    5960        <div>
  • gnupay-kcp/trunk/classes/kcp_ajax.class.php

    r1439770 r1875347  
    6868
    6969        }
    70 
     70       
    7171        echo json_encode($res);
    7272        exit;
  • gnupay-kcp/trunk/classes/kcp_card_gateway.class.php

    r1830610 r1875347  
    119119        if( $result ){
    120120            if( $this->id == $this->gnupay_kcp_card ){     //카드일때만 실행;
    121                 $options = apply_filters( 'woocommerce_settings_api_sanitized_fields_' . $this->id, $this->setttings );
     121                $options = apply_filters( 'woocommerce_settings_api_sanitized_fields_' . $this->id, $this->settings );
    122122               
    123123                $pay_ids = gnupay_kcp_get_settings('pay_ids');
     
    307307            }
    308308
    309             include_once(GNUPAY_KCP_PATH.'kcp/settle_kcp.inc.php');
    310 
    311             // locale ko_KR.euc-kr 로 설정
    312             setlocale(LC_CTYPE, 'ko_KR.euc-kr');
    313 
    314             // 부분취소 실행
    315             $g_conf_site_cd   = $config['de_kcp_mid'];
    316             $g_conf_site_key  = $config['de_kcp_site_key'];
    317             $g_conf_home_dir  = GNUPAY_KCP_PATH.'/kcp';
    318             $g_conf_key_dir   = '';
    319             $g_conf_log_dir   = '';
    320 
    321             if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
    322             {
    323                 $g_conf_log_dir   = sir_get_upload_path().'/log/refund';
    324                 $g_conf_key_dir   = GNUPAY_KCP_PATH.'kcp/bin/pub.key';
    325             }
    326 
    327             if (preg_match("/^T000/", $g_conf_site_cd) || $config['de_card_test']) {
    328                 $g_conf_gw_url  = "testpaygw.kcp.co.kr";
    329             }
    330             else {
    331                 $g_conf_gw_url  = "paygw.kcp.co.kr";
    332                 if (!preg_match("/^SR/", $g_conf_site_cd)) {
    333                     return new WP_Error('kcp_refund_error', __("SR 로 시작하지 않는 KCP SITE CODE 는 지원하지 않습니다.", GNUPAY_NAME));
    334                 }
    335             }
    336 
    337             include_once(GNUPAY_KCP_PATH.'kcp/pp_cli_hub_lib.php');
    338 
    339             $tno            = get_post_meta( $order_id, '_od_tno', true );
    340             $req_tx         = 'mod';
    341             $mod_desc       = gp_iconv_euckr($mod_memo);
    342             $cust_ip        = getenv('REMOTE_ADDR');
    343             //$rem_mny        = $order->get_remaining_refund_amount();  // 취소 가능 잔액 ( 이렇게 하면 안됨 )
    344             $rem_mny        = $order->get_total() - $order->get_total_refunded() + (int) $amount;  // 취소 가능 잔액
    345             $mod_mny        = (int)$tax_mny;
    346             $mod_free_mny   = (int)$free_mny;
    347             $mod_type       = 'RN07';
    348 
    349             if( $payment_method == $pay_ids['bank'] )   //계좌이체
    350                 $mod_type   = 'STPA';
    351 
    352             if($od_tax_flag) {
    353                 $mod_mny = $tax_mny + $free_mny;
    354             }
    355 
    356             $c_PayPlus  = new C_PAYPLUS_CLI;
    357             $c_PayPlus->mf_clear();
    358 
    359 
    360             if ( $req_tx == "mod" )
    361             {
    362                 $tran_cd = "00200000";
    363 
    364                 $c_PayPlus->mf_set_modx_data( "tno"          , $tno                  );  // KCP 원거래 거래번호
    365                 $c_PayPlus->mf_set_modx_data( "mod_type"     , $mod_type             );  // 원거래 변경 요청 종류
    366                 $c_PayPlus->mf_set_modx_data( "mod_ip"       , $cust_ip              );  // 변경 요청자 IP
    367                 $c_PayPlus->mf_set_modx_data( "mod_desc"     , $mod_desc             );  // 변경 사유
    368                 $c_PayPlus->mf_set_modx_data( "rem_mny"      , strval($rem_mny)      );  // 취소 가능 잔액
    369                 $c_PayPlus->mf_set_modx_data( "mod_mny"      , strval($mod_mny)      );  // 취소 요청 금액
    370 
    371                 if($od_tax_flag)
     309            $is_refund_success = false;     // 환불 성공/실패 플래그 변수 초기화
     310
     311            // 환불할 금액이 주문금액과 같고, 취소하면 남은잔액이 0원이면
     312            if( $order->get_total() && (int) $amount === (int) $order->get_total() && (int) $order->get_remaining_refund_amount() === 0 ){
     313
     314                // 전액 환불 처리합니다.
     315                $is_refund_success = $this->order_kcp_refund($order->get_id(), $amount, $reason);
     316
     317            } else {    // 부분환불 처리
     318
     319                include_once(GNUPAY_KCP_PATH.'kcp/settle_kcp.inc.php');
     320
     321                // locale ko_KR.euc-kr 로 설정
     322                setlocale(LC_CTYPE, 'ko_KR.euc-kr');
     323
     324                // 부분취소 실행
     325                $g_conf_site_cd   = $config['de_kcp_mid'];
     326                $g_conf_site_key  = $config['de_kcp_site_key'];
     327                $g_conf_home_dir  = GNUPAY_KCP_PATH.'/kcp';
     328                $g_conf_key_dir   = '';
     329                $g_conf_log_dir   = '';
     330
     331                if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
    372332                {
    373                     $mod_tax_mny = round((int)$tax_mny / 1.1);
    374                     $mod_vat_mny = (int)$tax_mny - $mod_tax_mny;
    375 
    376                     $c_PayPlus->mf_set_modx_data( "tax_flag"     , "TG03"                );  // 복합과세 구분
    377                     $c_PayPlus->mf_set_modx_data( "mod_tax_mny"  , strval($mod_tax_mny)  );  // 공급가 부분 취소 요청 금액
    378                     $c_PayPlus->mf_set_modx_data( "mod_vat_mny"  , strval($mod_vat_mny)  );  // 부과세 부분 취소 요청 금액
    379                     $c_PayPlus->mf_set_modx_data( "mod_free_mny" , strval($mod_free_mny) );  // 비관세 부분 취소 요청 금액
    380                 }
    381             }
    382 
    383             if ( $tran_cd != "" )
    384             {
    385             $c_PayPlus->mf_do_tx( "",                $g_conf_home_dir, $g_conf_site_cd,
    386                               $g_conf_site_key,  $tran_cd,         "",
    387                               $g_conf_gw_url,    $g_conf_gw_port,  "payplus_cli_slib",
    388                               isset($ordr_idxx) ? $ordr_idxx : '',        $cust_ip,         $g_conf_log_level,
    389                               "",                0,                $g_conf_key_dir,
    390                               $g_conf_log_dir );
    391 
    392             $res_cd  = $c_PayPlus->m_res_cd;  // 결과 코드
    393             $res_msg = $c_PayPlus->m_res_msg; // 결과 메시지
    394             /* $res_en_msg = $c_PayPlus->mf_get_res_data( "res_en_msg" );  // 결과 영문 메세지 */
    395             }
    396             else
    397             {
    398                 $c_PayPlus->m_res_cd  = "9562";
    399                 $c_PayPlus->m_res_msg = __("연동 오류|Payplus Plugin이 설치되지 않았거나 tran_cd값이 설정되지 않았습니다.", GNUPAY_NAME);
    400             }
    401 
    402             if ($res_cd != '0000')
    403             {
    404                 $res_msg = iconv("euc-kr", "utf-8", $res_msg);
    405 
    406                 return new WP_Error('kcp_refund_error', "$res_cd : $res_msg" );
    407             }
    408 
    409             /* ============================================================================== */
    410             /* =       취소 결과 처리                                                       = */
    411             /* = -------------------------------------------------------------------------- = */
    412             if ( $req_tx == "mod" )
    413             {
    414                 if ( $res_cd == "0000" )
     333                    $g_conf_log_dir   = sir_get_upload_path().'/log/refund';
     334                    $g_conf_key_dir   = GNUPAY_KCP_PATH.'kcp/bin/pub.key';
     335                }
     336
     337                if (preg_match("/^T000/", $g_conf_site_cd) || $config['de_card_test']) {
     338                    $g_conf_gw_url  = "testpaygw.kcp.co.kr";
     339                }
     340                else {
     341                    $g_conf_gw_url  = "paygw.kcp.co.kr";
     342                    if (!preg_match("/^SR/", $g_conf_site_cd)) {
     343                        return new WP_Error('kcp_refund_error', __("SR 로 시작하지 않는 KCP SITE CODE 는 지원하지 않습니다.", GNUPAY_NAME));
     344                    }
     345                }
     346
     347                include_once(GNUPAY_KCP_PATH.'kcp/pp_cli_hub_lib.php');
     348
     349                $tno            = get_post_meta( $order_id, '_od_tno', true );
     350                $req_tx         = 'mod';
     351                $mod_desc       = gp_iconv_euckr($mod_memo);
     352                $cust_ip        = getenv('REMOTE_ADDR');
     353                //$rem_mny        = $order->get_remaining_refund_amount();  // 취소 가능 잔액 ( 이렇게 하면 안됨 )
     354                $rem_mny        = $order->get_total() - $order->get_total_refunded() + (int) $amount;  // 취소 가능 잔액
     355                $mod_mny        = (int)$tax_mny;
     356                $mod_free_mny   = (int)$free_mny;
     357                $mod_type       = 'RN07';
     358
     359                if( $payment_method == $pay_ids['bank'] )   //계좌이체
     360                    $mod_type   = 'STPA';
     361
     362                if($od_tax_flag) {
     363                    $mod_mny = $tax_mny + $free_mny;
     364                }
     365
     366                $c_PayPlus  = new C_PAYPLUS_CLI;
     367                $c_PayPlus->mf_clear();
     368
     369
     370                if ( $req_tx == "mod" )
    415371                {
    416                 $tno = $c_PayPlus->mf_get_res_data( "tno" );  // KCP 거래 고유 번호
    417                 $amount  = $c_PayPlus->mf_get_res_data( "amount"       ); // 원 거래금액
    418                 $mod_mny = $c_PayPlus->mf_get_res_data( "panc_mod_mny" ); // 취소요청된 금액
    419                 $rem_mny = $c_PayPlus->mf_get_res_data( "panc_rem_mny" ); // 취소요청후 잔액
    420 
    421                 // 환불금액기록
    422 
    423                 $payment_gateways = gnupay_kcp_get_gateways();
    424 
    425                 $current_user = wp_get_current_user();
    426                 $order->add_order_note( sprintf(__( '%s 님이 %s, ( %s ) 이유로 가격 %s 를 취소하셨습니다.', GNUPAY_NAME ),
    427                     $current_user->user_login.' ( '.$current_user->ID.' ) ',
    428                     isset( $payment_gateways[ $payment_method ] ) ? esc_html( $payment_gateways[ $payment_method ]->get_title() ) : esc_html( $payment_method ),
    429                     $reason,
    430                     wc_price($mod_mny)
    431                 ) );
    432 
    433                 // 미수금 등의 정보 업데이트
    434 
    435                 } // End of [res_cd = "0000"]
    436 
    437                 /* = -------------------------------------------------------------------------- = */
    438                 /* =       취소 실패 결과 처리                                                  = */
    439                 /* = -------------------------------------------------------------------------- = */
     372                    $tran_cd = "00200000";
     373
     374                    $c_PayPlus->mf_set_modx_data( "tno"          , $tno                  );  // KCP 원거래 거래번호
     375                    $c_PayPlus->mf_set_modx_data( "mod_type"     , $mod_type             );  // 원거래 변경 요청 종류
     376                    $c_PayPlus->mf_set_modx_data( "mod_ip"       , $cust_ip              );  // 변경 요청자 IP
     377                    $c_PayPlus->mf_set_modx_data( "mod_desc"     , $mod_desc             );  // 변경 사유
     378                    $c_PayPlus->mf_set_modx_data( "rem_mny"      , strval($rem_mny)      );  // 취소 가능 잔액
     379                    $c_PayPlus->mf_set_modx_data( "mod_mny"      , strval($mod_mny)      );  // 취소 요청 금액
     380
     381                    if($od_tax_flag)
     382                    {
     383                        $mod_tax_mny = round((int)$tax_mny / 1.1);
     384                        $mod_vat_mny = (int)$tax_mny - $mod_tax_mny;
     385
     386                        $c_PayPlus->mf_set_modx_data( "tax_flag"     , "TG03"                );  // 복합과세 구분
     387                        $c_PayPlus->mf_set_modx_data( "mod_tax_mny"  , strval($mod_tax_mny)  );  // 공급가 부분 취소 요청 금액
     388                        $c_PayPlus->mf_set_modx_data( "mod_vat_mny"  , strval($mod_vat_mny)  );  // 부과세 부분 취소 요청 금액
     389                        $c_PayPlus->mf_set_modx_data( "mod_free_mny" , strval($mod_free_mny) );  // 비관세 부분 취소 요청 금액
     390                    }
     391                }
     392
     393                if ( $tran_cd != "" )
     394                {
     395                $c_PayPlus->mf_do_tx( "",                $g_conf_home_dir, $g_conf_site_cd,
     396                                  $g_conf_site_key,  $tran_cd,         "",
     397                                  $g_conf_gw_url,    $g_conf_gw_port,  "payplus_cli_slib",
     398                                  isset($ordr_idxx) ? $ordr_idxx : '',        $cust_ip,         $g_conf_log_level,
     399                                  "",                0,                $g_conf_key_dir,
     400                                  $g_conf_log_dir );
     401
     402                $res_cd  = $c_PayPlus->m_res_cd;  // 결과 코드
     403                $res_msg = $c_PayPlus->m_res_msg; // 결과 메시지
     404                /* $res_en_msg = $c_PayPlus->mf_get_res_data( "res_en_msg" );  // 결과 영문 메세지 */
     405                }
    440406                else
    441407                {
    442                     return new WP_Error('kcp_refund_error', __("알수 없는 이유로 환불 할수 없습니다.", GNUPAY_NAME) );
    443                 }
    444             }
    445 
    446             // locale 설정 초기화
    447             setlocale(LC_CTYPE, '');
     408                    $c_PayPlus->m_res_cd  = "9562";
     409                    $c_PayPlus->m_res_msg = __("연동 오류|Payplus Plugin이 설치되지 않았거나 tran_cd값이 설정되지 않았습니다.", GNUPAY_NAME);
     410                }
     411
     412                if ($res_cd != '0000')
     413                {
     414                    $res_msg = iconv("euc-kr", "utf-8", $res_msg);
     415
     416                    return new WP_Error('kcp_refund_error', "$res_cd : $res_msg" );
     417                }
     418
     419                /* ============================================================================== */
     420                /* =       취소 결과 처리                                                       = */
     421                /* = -------------------------------------------------------------------------- = */
     422                if ( $req_tx == "mod" )
     423                {
     424                    if ( $res_cd == "0000" )
     425                    {
     426                    $tno = $c_PayPlus->mf_get_res_data( "tno" );  // KCP 거래 고유 번호
     427                    $amount  = $c_PayPlus->mf_get_res_data( "amount"       ); // 원 거래금액
     428                    $mod_mny = $c_PayPlus->mf_get_res_data( "panc_mod_mny" ); // 취소요청된 금액
     429                    $rem_mny = $c_PayPlus->mf_get_res_data( "panc_rem_mny" ); // 취소요청후 잔액
     430
     431                    // 환불금액기록
     432
     433                    $payment_gateways = gnupay_kcp_get_gateways();
     434
     435                    $current_user = wp_get_current_user();
     436                    $order->add_order_note( sprintf(__( '%s 님이 %s, ( %s ) 이유로 가격 %s 를 취소하셨습니다.', GNUPAY_NAME ),
     437                        $current_user->user_login.' ( '.$current_user->ID.' ) ',
     438                        isset( $payment_gateways[ $payment_method ] ) ? esc_html( $payment_gateways[ $payment_method ]->get_title() ) : esc_html( $payment_method ),
     439                        $reason,
     440                        wc_price($mod_mny)
     441                    ) );
     442
     443                    $is_refund_success = true;      // 부분환불 성공시
     444
     445                    // 미수금 등의 정보 업데이트
     446
     447                    } // End of [res_cd = "0000"]
     448
     449                    /* = -------------------------------------------------------------------------- = */
     450                    /* =       취소 실패 결과 처리                                                  = */
     451                    /* = -------------------------------------------------------------------------- = */
     452                    else
     453                    {
     454                        return new WP_Error('kcp_refund_error', __("알수 없는 이유로 환불 할수 없습니다.", GNUPAY_NAME) );
     455                    }
     456                }
     457
     458                // locale 설정 초기화
     459                setlocale(LC_CTYPE, '');
     460
     461            }   //end if
     462           
     463            if ( is_wp_error( $is_refund_success ) ) {
     464                return $is_refund_success;
     465            }
     466
     467            if( !$is_refund_success ){
     468                return new WP_Error('kcp_refund_error', __( '환불에 실패하였습니다.', GNUPAY_INICIS ) );
     469            }
     470
    448471            return true;
    449472
     
    529552            }
    530553
     554            $is_position = is_admin() ? __('쇼핑몰 운영자 페이지') : __('사용자 페이지');
     555
    531556            $current_user = wp_get_current_user();
    532557            $order->add_order_note( sprintf(__( '%s 님의 요청으로 인해 %s 이 환불되었습니다.', GNUPAY_NAME ),
    533                 $current_user->user_login.' ( '.$current_user->ID.' ) ',
     558                $is_position.' '.$current_user->user_login.' ( '.$current_user->ID.' ) ',
    534559                wc_price($amount)
    535560            ) );
     
    554579
    555580    public function kcp_pay_check(){
    556 
     581       
    557582        //체크아웃일때만 작동
    558583        if( !is_checkout() )
     
    560585
    561586        //요청이 있을때 동작합니다.
    562         if( isset($_REQUEST['checkout_nonce']) && wp_verify_nonce( $_REQUEST['checkout_nonce'], 'kcp_form_nonce' ) ){
    563 
     587        if( isset($_REQUEST['checkout_nonce']) && gp_ft_nonce_is_valid( $_REQUEST['checkout_nonce'], 'kcp_form_nonce' ) ){
    564588
    565589            $pay_ids = gnupay_kcp_get_settings('pay_ids');
     
    11391163        $res = wp_parse_args(array(
    11401164            'result'    => 'success',
    1141             'order_id'  =>  $order->id,
    1142             'order_key' =>  $order->order_key,
     1165            'order_id'  =>  $order->get_order_number(),
     1166            'order_key' =>  $order->get_order_key(),
    11431167            'redirect'  => $this->get_return_url( $order )
    11441168        ), gnupay_kcp_process_payment($order, $this->config));
  • gnupay-kcp/trunk/classes/kcp_pay_gateway.class.php

    r1403518 r1875347  
    6363        return array(
    6464            'result'    => 'success',
    65             'order_id'  =>  $order->id,
     65            'order_id'  =>  $order->get_order_number(),
    6666            'order_key' =>  $order->order_key,
    6767            'redirect'  => $this->get_return_url( $order )
  • gnupay-kcp/trunk/classes/kcp_user_cancel.class.php

    r1439770 r1875347  
    3535        $payment_gateways = $this->get_gateways();
    3636
    37         $payment_method = get_post_meta( $order->id, '_payment_method', true );
     37        $payment_method = get_post_meta( $order->get_order_number(), '_payment_method', true );
    3838
    3939        $file_path = plugin_dir_path( __FILE__ ).'classes/kcp_card_gateway.class.php';
     
    8888        $payment_gateways = $this->get_gateways();
    8989
    90         $payment_method = get_post_meta( $order->id, '_payment_method', true );
     90        $payment_method = get_post_meta( $order->get_order_number(), '_payment_method', true );
    9191
    9292        if( !in_array($payment_method, gnupay_kcp_get_settings('pay_ids')) ){
  • gnupay-kcp/trunk/classes/kcp_user_order_details.class.php

    r1403518 r1875347  
    1313    public function order_table($order){
    1414
    15         $order_id = $order->id;
     15        $order_id = $order->get_order_number();
    1616
    1717        if( ! gp_kcp_order_can_view($order_id) ){   //볼수 있는 권한이 없으면
  • gnupay-kcp/trunk/classes/kcp_virtualaccount.class.php

    r1568404 r1875347  
    213213                $order_tno = get_post_meta( $order_id, '_od_tno', true );
    214214                $pay_options = get_option( $this->plugin_id . $this->id . '_settings' );
    215                 if( !isset($order->id) || empty($order->id) ){
     215                if( ! $order->get_order_number() ){
    216216                    return;
    217217                }
     
    298298   
    299299        if( $result ){
    300             $options = apply_filters( 'woocommerce_settings_api_sanitized_fields_' . $this->id, $this->setttings );
     300            $options = apply_filters( 'woocommerce_settings_api_sanitized_fields_' . $this->id, $this->settings );
    301301
    302302            $kcp_options = get_option( $this->plugin_id . $this->gnupay_kcp_card . '_settings' );
  • gnupay-kcp/trunk/config.php

    r1830610 r1875347  
    44Class GNUPAY_KCP_WOO_CONSTANTS {
    55    public function __construct() {
    6         define( 'GNUPAY_VERSION', '1.2.3' );
     6        define( 'GNUPAY_VERSION', '1.3.0' );
    77        define( 'GNUPAY_NAME', 'gnupay-kcp' );
    88        define( 'GNUPAY_KCP_ORDER_TMP', '_order_tmp_kcp' );
  • gnupay-kcp/trunk/gnupay-kcp.php

    r1830610 r1875347  
    66 *  Author: SIR Soft
    77 *  Author URI: http://sir.kr
    8  *  Version: 1.2.3
    9  *  Tested up to: 4.5
     8 *  Version: 1.3.0
     9 *  Tested up to: 4.9.5
    1010 *  Text Domain: gnupay-kcp
    1111 */
  • gnupay-kcp/trunk/js/kcp_pay.js

    r1439770 r1875347  
    207207        },
    208208        kcp_pay_submit: function(f, json){
    209 
    210209            // 금액체크
    211210           
  • gnupay-kcp/trunk/kcp/m_order_approval_form.php

    r1568404 r1875347  
    77//$return_url = add_query_arg( array('kcppay'=>'return'), $checkout_url);
    88
    9 $return_url = wp_nonce_url(add_query_arg( array('kcppay'=>'return'), $checkout_url), 'kcp_form_nonce', 'checkout_nonce');
     9$return_url = add_query_arg( array('kcppay'=>'return', 'checkout_nonce'=>gp_ft_nonce_create('kcp_form_nonce')), $checkout_url);
    1010
    1111    /* ============================================================================== */
     
    235235
    236236    echo gc_make_order_field($data, $exclude);
    237     wp_nonce_field( 'kcp_form_nonce', 'checkout_nonce' );
     237    echo '<input type="hidden" name="checkout_nonce" value="'.gp_ft_nonce_create('kcp_form_nonce').'">'.PHP_EOL;
    238238    foreach($_POST as $key=>$value) {
    239239        echo '<input type="hidden" name="'.$key.'" value="'.$value.'">'.PHP_EOL;
     
    245245
    246246<form name="gnupay_kcp_form" method="POST" accept-charset="euc-kr">
    247 <?php wp_nonce_field( 'kcp_form_nonce', 'checkout_nonce' ); ?>
     247<input type="hidden" name="checkout_nonce" value="<?php echo gp_ft_nonce_create('kcp_form_nonce');?>">
    248248<input type="hidden" name="good_name" value="<?php echo sanitize_title(esc_attr($good_name)); ?>">
    249249<input type="hidden" name="good_mny"  value="<?php echo esc_attr($good_mny); ?>" >
  • gnupay-kcp/trunk/kcp/m_orderform.2.php

    r1403518 r1875347  
    1818<div style="display:none">
    1919<form name="gnupay_kcp_form" id="gnupay_kcp_form" method="POST">
    20 <?php wp_nonce_field( 'kcp_form_nonce', 'checkout_nonce' ); ?>
     20<input type="hidden" name="checkout_nonce" value="<?php echo gp_ft_nonce_create('kcp_form_nonce');?>">
    2121<input type="hidden" name="kcppay" value="return">
    2222<input type="hidden" name="good_name"     value="<?php echo $goods; ?>">
  • gnupay-kcp/trunk/kcp/orderform.2.php

    r1403518 r1875347  
    2020    <div style="display:none">
    2121    <form name="gnupay_kcp_form" id="gnupay_kcp_form" method="POST" accept-charset="UTF-8">
    22     <?php wp_nonce_field( 'kcp_form_nonce', 'checkout_nonce' ); ?>
     22    <input type="hidden" name="checkout_nonce" value="<?php echo gp_ft_nonce_create('kcp_form_nonce');?>">
    2323    <?php
    2424        /* ============================================================================== */
  • gnupay-kcp/trunk/kcp/pp_ax_hub_lib.php

    r1403518 r1875347  
    285285      $exec_cmd = array_shift( $arg );
    286286
    287       while ( list(,$i) = each($arg) )
    288       {
    289         $exec_cmd .= " " . escapeshellarg( $i );
     287      foreach( $arg as $i ){
     288          $exec_cmd .= " " . escapeshellarg( $i );
    290289      }
    291290
  • gnupay-kcp/trunk/lib/functions.php

    r1568404 r1875347  
    11<?php
    22if( ! defined( 'GNUPAY_NAME' ) ) exit; // 개별 페이지 접근 불가
     3
     4if(!function_exists('gp_ft_get_secret_key')){
     5    function gp_ft_get_secret_key($secret){
     6        return md5(NONCE_SALT.DB_PASSWORD.session_id().$secret);
     7    }
     8}
     9
     10// This method creates an nonce. It should be called by one of the previous two functions.
     11if(!function_exists('gp_ft_nonce_create')){
     12    function gp_ft_nonce_create( $action = '',$user='', $timeoutSeconds=3600 ){
     13
     14        $secret = gp_ft_get_secret_key($action.$user);
     15
     16        $salt = gp_ft_nonce_generate_hash();
     17        $time = time();
     18        $maxTime = $time + $timeoutSeconds;
     19        $nonce = $salt . "|" . $maxTime . "|" . sha1( $salt . $secret . $maxTime );
     20        return $nonce;
     21
     22    }
     23}
     24
     25// This method validates an nonce
     26if(!function_exists('gp_ft_nonce_is_valid')){
     27    function gp_ft_nonce_is_valid( $nonce, $action = '', $user='' ){
     28
     29        $secret = gp_ft_get_secret_key($action.$user);
     30
     31        if (is_string($nonce) == false) {
     32            return false;
     33        }
     34        $a = explode('|', $nonce);
     35        if (count($a) != 3) {
     36            return false;
     37        }
     38        $salt = $a[0];
     39        $maxTime = intval($a[1]);
     40        $hash = $a[2];
     41        $back = sha1( $salt . $secret . $maxTime );
     42        if ($back != $hash) {
     43            return false;
     44        }
     45        if (time() > $maxTime) {
     46            return false;
     47        }
     48        return true;
     49    }
     50}
     51
     52// This method generates the nonce timestamp
     53if(!function_exists('ft_nonce_generate_hash')){
     54    function gp_ft_nonce_generate_hash(){
     55        $length = 10;
     56        $chars='1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM';
     57        $ll = strlen($chars)-1;
     58        $o = '';
     59        while (strlen($o) < $length) {
     60            $o .= $chars[ rand(0, $ll) ];
     61        }
     62        return $o;
     63    }
     64}
    365
    466if( ! function_exists('gp_get_stype_names') ){
     
    261323    function gnupay_kcp_process_payment($order, $config){
    262324
    263         $res = array();
    264         $crr = array(
    265                 'order_key',
    266                 'payment_method',
    267                 'payment_method_title',
    268                 'billing_last_name',
    269                 'billing_first_name',
    270                 'billing_company',
    271                 'billing_address_1',
    272                 'billing_address_2',
    273                 'billing_city',
    274                 'billing_state',
    275                 'billing_postcode',
    276                 'billing_country',
    277                 'billing_email',
    278                 'billing_phone',
    279                 'shipping_last_name',
    280                 'shipping_first_name',
    281                 'shipping_company',
    282                 'shipping_address_1',
    283                 'shipping_address_2',
    284                 'shipping_city',
    285                 'shipping_state',
    286                 'shipping_postcode',
    287                 'shipping_country',
    288                 'shipping_email',
    289                 'shipping_phone',
     325        $res = array(
     326                'order_key' => $order->get_order_key(),
     327                'payment_method' => $order->get_payment_method(),
     328                'payment_method_title' => $order->get_payment_method_title(),
     329                'billing_last_name' => $order->get_billing_last_name(),
     330                'billing_first_name' => $order->get_billing_first_name(),
     331                'billing_company' => $order->get_billing_company(),
     332                'billing_address_1' => $order->get_billing_address_1(),
     333                'billing_address_2' => $order->get_billing_address_2(),
     334                'billing_city' => $order->get_billing_city(),
     335                'billing_state' => $order->get_billing_state(),
     336                'billing_postcode' => $order->get_billing_postcode(),
     337                'billing_country' => $order->get_billing_country(),
     338                'billing_email' => $order->get_billing_email(),
     339                'billing_phone' => $order->get_billing_phone(),
     340                'shipping_last_name' => $order->get_shipping_last_name(),
     341                'shipping_first_name' => $order->get_shipping_first_name(),
     342                'shipping_company' => $order->get_shipping_company(),
     343                'shipping_address_1' => $order->get_shipping_address_1(),
     344                'shipping_address_2' => $order->get_shipping_address_2(),
     345                'shipping_city' => $order->get_shipping_city(),
     346                'shipping_state' => $order->get_shipping_state(),
     347                'shipping_postcode' => $order->get_shipping_postcode(),
     348                'shipping_country' => $order->get_shipping_country(),
     349                'shipping_email' => '',
     350                'shipping_phone' => '',
    290351            );
    291 
    292         foreach($crr as $v){
    293             $res[$v] = isset($order->$v) ? $order->$v : '';
    294         }
    295352       
    296         $res['order_id'] = $order->id;
     353        $res['order_id'] = $order->get_order_number();
    297354
    298355        $goods = '';
  • gnupay-kcp/trunk/readme.txt

    r1830610 r1875347  
    55Tags: woocommerce, payment, kcp, nhn-kcp, nhnkcp, sirsoft, card, bank, korea, korean, kagla
    66Requires at least: 4.0
    7 Tested up to: 4.5
    8 Stable tag: 1.2.3
     7Tested up to: 4.9.5
     8Stable tag: 1.3.0
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset for help on using the changeset viewer.