paymod_id = 'telecom'; $this->pay_method = array( 'acting_telecom_card', 'acting_telecom_edy', ); $this->acting_name = 'テレコムクレジット'; $this->acting_formal_name = 'テレコムクレジット'; $this->acting_company_url = 'https://www.telecomcredit.co.jp/'; $this->initialize_data(); if ( is_admin() ) { add_action( 'usces_action_admin_settlement_update', array( $this, 'settlement_update' ) ); add_action( 'usces_action_settlement_tab_title', array( $this, 'settlement_tab_title' ) ); add_action( 'usces_action_settlement_tab_body', array( $this, 'settlement_tab_body' ) ); } if ( $this->is_activate_card() ) { add_action( 'usces_action_reg_orderdata', array( $this, 'register_orderdata' ) ); } if ( $this->is_validity_acting( 'card' ) ) { if ( is_admin() ) { add_action( 'usces_action_admin_member_info', array( $this, 'member_settlement_info' ), 10, 3 ); add_action( 'usces_action_post_update_memberdata', array( $this, 'member_edit_post' ), 10, 2 ); } } } /** * Return an instance of this class. */ public static function get_instance() { if ( is_null( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } /** * Initialize */ public function initialize_data() { $options = get_option( 'usces', array() ); if ( ! isset( $options['acting_settings'] ) || ! isset( $options['acting_settings']['telecom'] ) ) { $options['acting_settings']['telecom']['clientip'] = ''; $options['acting_settings']['telecom']['stype'] = ''; $options['acting_settings']['telecom']['card_activate'] = 'off'; $options['acting_settings']['telecom']['oneclick'] = ''; $options['acting_settings']['telecom']['edy_activate'] = 'off'; update_option( 'usces', $options ); } } /** * 決済有効判定 * 引数が指定されたとき、支払方法で使用している場合に「有効」とする * * @param string $type Module type. * @return boolean */ public function is_validity_acting( $type = '' ) { $acting_opts = $this->get_acting_settings(); if ( empty( $acting_opts ) ) { return false; } $payment_method = usces_get_system_option( 'usces_payment_method', 'sort' ); $method = false; switch ( $type ) { case 'card': foreach ( $payment_method as $payment ) { if ( 'acting_telecom_card' == $payment['settlement'] && 'activate' == $payment['use'] ) { $method = true; break; } } if ( $method && $this->is_activate_card() ) { return true; } else { return false; } break; case 'edy': foreach ( $payment_method as $payment ) { if ( 'acting_telecom_edy' == $payment['settlement'] && 'activate' == $payment['use'] ) { $method = true; break; } } if ( $method && $this->is_activate_card() ) { return true; } else { return false; } break; default: if ( 'on' == $acting_opts['activate'] ) { return true; } else { return false; } } } /** * クレジットカード決済有効判定 * * @return boolean $res */ public function is_activate_card() { $acting_opts = $this->get_acting_settings(); if ( ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) && ( isset( $acting_opts['card_activate'] ) && ( 'on' == $acting_opts['card_activate'] ) ) ) { $res = true; } else { $res = false; } return $res; } /** * Edy 決済有効判定 * * @return boolean $res */ public function is_activate_edy() { $acting_opts = $this->get_acting_settings(); if ( ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) && ( isset( $acting_opts['edy_activate'] ) && ( 'on' == $acting_opts['edy_activate'] ) ) ) { $res = true; } else { $res = false; } return $res; } /** * 決済オプション登録・更新 * usces_action_admin_settlement_update */ public function settlement_update() { global $usces; if ( $this->paymod_id != $_POST['acting'] ) { return; } $this->error_mes = ''; $options = get_option( 'usces', array() ); $payment_method = usces_get_system_option( 'usces_payment_method', 'settlement' ); unset( $options['acting_settings']['telecom'] ); $options['acting_settings']['telecom']['clientip'] = ( isset( $_POST['clientip'] ) ) ? $_POST['clientip'] : ''; $options['acting_settings']['telecom']['stype'] = ( isset( $_POST['stype'] ) ) ? $_POST['stype'] : ''; $options['acting_settings']['telecom']['card_activate'] = ( isset( $_POST['card_activate'] ) ) ? $_POST['card_activate'] : 'off'; $options['acting_settings']['telecom']['oneclick'] = ( isset( $_POST['oneclick'] ) ) ? $_POST['oneclick'] : ''; // $options['acting_settings']['telecom']['edy_activate'] = ( isset( $_POST['edy_activate'] ) ) ? $_POST['edy_activate'] : 'off'; $options['acting_settings']['telecom']['edy_activate'] = 'off'; if ( WCUtils::is_blank( $_POST['clientip'] ) ) { $this->error_mes .= '※クライアントIPを入力してください
'; } if ( WCUtils::is_blank( $_POST['stype'] ) ) { $this->error_mes .= '※決済タイプを入力してください
'; } if ( '' == $this->error_mes ) { $usces->action_status = 'success'; $usces->action_message = __( 'Options are updated.', 'usces' ); if ( 'on' == $options['acting_settings']['telecom']['card_activate'] || 'on' == $options['acting_settings']['telecom']['edy_activate'] ) { $options['acting_settings']['telecom']['activate'] = 'on'; $toactive = array(); if ( 'on' == $options['acting_settings']['telecom']['card_activate'] ) { if ( 'EP' == $options['acting_settings']['telecom']['stype'] ) { $options['acting_settings']['telecom']['send_url'] = 'https://settle.saa-s.com/inetcredit/secure/order.pl'; if ( 'on' == $options['acting_settings']['telecom']['oneclick'] ) { $options['acting_settings']['telecom']['oneclick_send_url'] = 'https://settle.saa-s.com/inetcredit/secure/one-click-order.pl'; } } else { if ( 'E' == $options['acting_settings']['telecom']['stype'][0] ) { $options['acting_settings']['telecom']['send_url'] = 'https://www.credit-cgiserver.com/inetcredit/secure/order.pl'; } else { $options['acting_settings']['telecom']['send_url'] = 'https://secure.telecomcredit.co.jp/inetcredit/secure/order.pl'; } if ( 'on' == $options['acting_settings']['telecom']['oneclick'] ) { $options['acting_settings']['telecom']['oneclick_send_url'] = 'https://secure.telecomcredit.co.jp/inetcredit/secure/one-click-order.pl'; } } $usces->payment_structure['acting_telecom_card'] = 'カード決済(' . $this->acting_name . ')'; foreach ( $payment_method as $settlement => $payment ) { if ( 'acting_telecom_card' == $settlement && 'deactivate' == $payment['use'] ) { $toactive[] = $payment['name']; } } } else { unset( $usces->payment_structure['acting_telecom_card'] ); } if ( 'on' == $options['acting_settings']['telecom']['edy_activate'] ) { $options['acting_settings']['telecom']['send_url_edy'] = 'https://secure.telecomcredit.co.jp/payment/edy/order.pl'; $usces->payment_structure['acting_telecom_edy'] = 'Edy決済(' . $this->acting_name . ')'; foreach ( $payment_method as $settlement => $payment ) { if ( 'acting_telecom_edy' == $settlement && 'deactivate' == $payment['use'] ) { $toactive[] = $payment['name']; } } } else { unset( $usces->payment_structure['acting_telecom_edy'] ); } usces_admin_orderlist_show_wc_trans_id(); if ( 0 < count( $toactive ) ) { $usces->action_message .= __( "Please update the payment method to \"Activate\". General Setting > Payment Methods", 'usces' ); } } else { $options['acting_settings']['telecom']['activate'] = 'off'; unset( $usces->payment_structure['acting_telecom_card'] ); unset( $usces->payment_structure['acting_telecom_edy'] ); } if ( 'on' != $options['acting_settings']['telecom']['oneclick'] || 'off' == $options['acting_settings']['telecom']['activate'] ) { usces_clear_quickcharge( 'telecom_oneclick' ); } $deactivate = array(); foreach ( $payment_method as $settlement => $payment ) { if ( ! array_key_exists( $settlement, $usces->payment_structure ) ) { if ( 'deactivate' != $payment['use'] ) { $payment['use'] = 'deactivate'; $deactivate[] = $payment['name']; usces_update_system_option( 'usces_payment_method', $payment['id'], $payment ); } } } if ( 0 < count( $deactivate ) ) { $deactivate_message = sprintf( __( "\"Deactivate\" %s of payment method.", 'usces' ), implode( ',', $deactivate ) ); $usces->action_message .= $deactivate_message; } } else { $usces->action_status = 'error'; $usces->action_message = __( 'Data have deficiency.', 'usces' ); $options['acting_settings']['telecom']['activate'] = 'off'; unset( $usces->payment_structure['acting_telecom_card'] ); unset( $usces->payment_structure['acting_telecom_edy'] ); $deactivate = array(); foreach ( $payment_method as $settlement => $payment ) { if ( in_array( $settlement, $this->pay_method ) ) { if ( 'deactivate' != $payment['use'] ) { $payment['use'] = 'deactivate'; $deactivate[] = $payment['name']; usces_update_system_option( 'usces_payment_method', $payment['id'], $payment ); } } } if ( 0 < count( $deactivate ) ) { $deactivate_message = sprintf( __( "\"Deactivate\" %s of payment method.", 'usces' ), implode( ',', $deactivate ) ); $usces->action_message .= $deactivate_message . __( "Please complete the setup and update the payment method to \"Activate\".", 'usces' ); } } ksort( $usces->payment_structure ); update_option( 'usces', $options ); update_option( 'usces_payment_structure', $usces->payment_structure ); } /** * クレジット決済設定画面タブ * usces_action_settlement_tab_title */ public function settlement_tab_title() { $settlement_selected = get_option( 'usces_settlement_selected' ); if ( in_array( $this->paymod_id, (array) $settlement_selected ) ) { echo '
  • ' . $this->acting_name . '
  • '; } } /** * クレジット決済設定画面フォーム * usces_action_settlement_tab_body */ public function settlement_tab_body() { global $usces; $acting_opts = $this->get_acting_settings(); $settlement_selected = get_option( 'usces_settlement_selected' ); if ( in_array( $this->paymod_id, (array) $settlement_selected ) ) : ?>
    acting_formal_name ); ?>
    error_mes ) : ?>
    error_mes ); ?>
    十分にテストを行ってから運用してください。
    クライアントIP
    契約時にacting_name ); ?>から発行されるクライアントIP(半角数字)
    決済タイプ
    設定依頼書に記載されている決済タイプ
    クレジットカード決済
    スピード決済
    2回目以降の利用はカード番号を入力しなくても決済可能となります。

    acting_formal_name ); ?>

    acting_name ); ?>の詳細はこちら 》

     

    この決済は「外部リンク型」の決済システムです。

    「外部リンク型」とは、決済会社のページへ遷移してカード情報を入力する決済システムです。

    pay_method ) ) { return; } if ( ! $entry['order']['total_full_price'] ) { return; } if ( isset( $_REQUEST['acting'] ) && 'telecom_card' == $_REQUEST['acting'] && isset( $_REQUEST['acting_return'] ) && isset( $_REQUEST['option'] ) ) { if ( empty( $data ) ) { $data = array(); } $data['option'] = esc_sql( $_REQUEST['option'] ); $usces->set_order_meta_value( 'acting_telecom_card', serialize( $data ), $order_id ); $usces->set_order_meta_value( 'wc_trans_id', $_REQUEST['option'], $order_id ); $usces->set_order_meta_value( 'trans_id', $_REQUEST['option'], $order_id ); $acting_opts = $usces->options['acting_settings']['telecom']; if ( 'on' == $acting_opts['oneclick'] ) { $usces->set_member_meta_value( 'telecom_oneclick', $member_id ); } } } /** * 会員データ編集画面 スピード決済登録情報 * usces_action_admin_member_info * * @param array $member_data Member data. * @param array $member_meta_data Member meta data. * @param array $member_history Member history data. */ public function member_settlement_info( $member_data, $member_meta_data, $member_history ) { if ( 0 < count( $member_meta_data ) ) : $cardinfo = array(); foreach ( $member_meta_data as $value ) { if ( in_array( $value['meta_key'], array( 'telecom_oneclick' ) ) ) { $cardinfo[ $value['meta_key'] ] = $value['meta_value']; } } if ( 0 < count( $cardinfo ) ) : if ( array_key_exists( 'telecom_oneclick', $cardinfo ) ) : ?> スピード決済
    登録あり
    del_member_meta( 'telecom_oneclick', $member_id ); } } /** * 決済オプション取得 * * @return array $acting_settings */ protected function get_acting_settings() { global $usces; $acting_settings = ( isset( $usces->options['acting_settings'][ $this->paymod_id ] ) ) ? $usces->options['acting_settings'][ $this->paymod_id ] : array(); return $acting_settings; } }