paymod_id = 'anotherlane';
$this->pay_method = array(
'acting_anotherlane_card',
);
$this->acting_name = 'アナザーレーン';
$this->acting_formal_name = 'アナザーレーン';
$this->acting_company_url = 'https://www.alij.ne.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' ) );
}
}
/**
* 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']['anotherlane'] ) ) {
$options['acting_settings']['anotherlane']['siteid'] = '';
$options['acting_settings']['anotherlane']['sitepass'] = '';
$options['acting_settings']['anotherlane']['ope'] = '';
$options['acting_settings']['anotherlane']['quickcharge'] = '';
$options['acting_settings']['anotherlane']['card_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_anotherlane_card' == $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;
}
/**
* 決済オプション登録・更新
* 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']['anotherlane'] );
$options['acting_settings']['anotherlane']['siteid'] = ( isset( $_POST['siteid'] ) ) ? trim( $_POST['siteid'] ) : '';
$options['acting_settings']['anotherlane']['sitepass'] = ( isset( $_POST['sitepass'] ) ) ? trim( $_POST['sitepass'] ) : '';
$options['acting_settings']['anotherlane']['ope'] = ( isset( $_POST['ope'] ) ) ? $_POST['ope'] : '';
$options['acting_settings']['anotherlane']['quickcharge'] = ( isset( $_POST['quickcharge'] ) ) ? $_POST['quickcharge'] : '';
$options['acting_settings']['anotherlane']['card_activate'] = ( isset( $_POST['card_activate'] ) ) ? $_POST['card_activate'] : 'off';
if ( 'on' == $options['acting_settings']['anotherlane']['card_activate'] ) {
if ( WCUtils::is_blank( $_POST['siteid'] ) ) {
$this->error_mes .= '※サイトIDを入力してください
';
}
if ( WCUtils::is_blank( $_POST['sitepass'] ) ) {
$this->error_mes .= '※サイトパスワードを入力してください
';
}
if ( WCUtils::is_blank( $options['acting_settings']['anotherlane']['ope'] ) ) {
$this->error_mes .= '※稼働環境を選択してください
';
}
}
if ( '' == $this->error_mes ) {
$usces->action_status = 'success';
$usces->action_message = __( 'Options are updated.', 'usces' );
if ( 'on' == $options['acting_settings']['anotherlane']['card_activate'] ) {
$options['acting_settings']['anotherlane']['activate'] = 'on';
if ( 'public' == $options['acting_settings']['anotherlane']['ope'] ) {
$options['acting_settings']['anotherlane']['send_url'] = 'https://payment.alij.ne.jp/service/credit';
} else {
$options['acting_settings']['anotherlane']['send_url'] = 'https://test-payment.alij.ne.jp/service/credit';
}
$usces->payment_structure['acting_anotherlane_card'] = 'カード決済(' . $this->acting_name . ')';
usces_admin_orderlist_show_wc_trans_id();
$toactive = array();
foreach ( $payment_method as $settlement => $payment ) {
if ( 'acting_anotherlane_card' == $settlement && 'deactivate' == $payment['use'] ) {
$toactive[] = $payment['name'];
}
}
if ( 0 < count( $toactive ) ) {
$usces->action_message .= __( "Please update the payment method to \"Activate\". General Setting > Payment Methods", 'usces' );
}
} else {
$options['acting_settings']['anotherlane']['activate'] = 'off';
unset( $usces->payment_structure['acting_anotherlane_card'] );
$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']['anotherlane']['activate'] = 'off';
unset( $usces->payment_structure['acting_anotherlane_card'] );
$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 ); ?>の詳細はこちら 》
この決済は「外部リンク型」の決済システムです。
「外部リンク型」とは、決済会社のページへ遷移してカード情報を入力する決済システムです。