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 '
acting_formal_name ); ?>
acting_name ); ?>の詳細はこちら 》
この決済は「外部リンク型」の決済システムです。
「外部リンク型」とは、決済会社のページへ遷移してカード情報を入力する決済システムです。