paymod_id = 'mizuho'; // $this->pay_method = array( // 'acting_mizuho_card', // 'acting_mizuho_conv1', // 'acting_mizuho_conv2', // ); $this->pay_method = array( 'acting_mizuho_card', ); $this->acting_name = 'みずほファクター'; $this->acting_formal_name = 'みずほファクター'; $this->acting_company_url = 'https://www.mizuho-factor.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' ) ); } } /** * 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']['mizuho'] ) ) { $options['acting_settings']['mizuho']['shopid'] = ''; $options['acting_settings']['mizuho']['cshopid'] = ''; $options['acting_settings']['mizuho']['hash_pass'] = ''; $options['acting_settings']['mizuho']['ope'] = ''; $options['acting_settings']['mizuho']['send_url'] = ''; $options['acting_settings']['mizuho']['send_url_mbl'] = ''; $options['acting_settings']['mizuho']['card_activate'] = 'off'; $options['acting_settings']['mizuho']['conv1_activate'] = 'off'; $options['acting_settings']['mizuho']['conv2_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_mizuho_card' == $payment['settlement'] && 'activate' == $payment['use'] ) { $method = true; break; } } if( $method && $this->is_activate_card() ) { return true; } else { return false; } break; case 'conv': foreach ( $payment_method as $payment ) { if ( 'acting_mizuho_conv1' == $payment['settlement'] && 'activate' == $payment['use'] ) { $method = true; break; } elseif ( 'acting_mizuho_conv2' == $payment['settlement'] && 'activate' == $payment['use'] ) { $method = true; break; } } if ( $method && $this->is_activate_conv1() ) { return true; } elseif ( $method && $this->is_activate_conv2() ) { 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; } /** * コンビニ・ウェルネット決済有効判定 * * @return boolean $res */ public function is_activate_conv1() { $acting_opts = $this->get_acting_settings(); if ( ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) && ( isset( $acting_opts['conv1_activate'] ) && 'on' == $acting_opts['conv1_activate'] ) ) { $res = true; } else { $res = false; } return $res; } /** * コンビニ・セブンイレブン決済有効判定 * * @return boolean $res */ public function is_activate_conv2() { $acting_opts = $this->get_acting_settings(); if ( ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) && ( isset( $acting_opts['conv2_activate'] ) && 'on' == $acting_opts['conv2_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']['mizuho'] ); $options['acting_settings']['mizuho']['shopid'] = ( isset( $_POST['shopid'] ) ) ? trim( $_POST['shopid'] ) : ''; $options['acting_settings']['mizuho']['cshopid'] = ( isset( $_POST['cshopid'] ) ) ? trim( $_POST['cshopid'] ) : ''; $options['acting_settings']['mizuho']['hash_pass'] = ( isset( $_POST['hash_pass'] ) ) ? trim( $_POST['hash_pass'] ) : ''; $options['acting_settings']['mizuho']['ope'] = ( isset( $_POST['ope'] ) ) ? $_POST['ope'] : ''; $options['acting_settings']['mizuho']['send_url'] = ( isset( $_POST['send_url'] ) ) ? trim( $_POST['send_url'] ) : ''; $options['acting_settings']['mizuho']['send_url_mbl'] = ( isset( $_POST['send_url_mbl'] ) ) ? trim( $_POST['send_url_mbl'] ) : ''; $options['acting_settings']['mizuho']['card_activate'] = ( isset( $_POST['card_activate'] ) ) ? $_POST['card_activate'] : 'off'; $options['acting_settings']['mizuho']['conv1_activate'] = ( isset( $_POST['conv1_activate'] ) ) ? $_POST['conv1_activate'] : 'off'; $options['acting_settings']['mizuho']['conv2_activate'] = ( isset( $_POST['conv2_activate'] ) ) ? $_POST['conv2_activate'] : 'off'; if ( WCUtils::is_blank( $_POST['shopid'] ) ) { $this->error_mes .= '※加盟店コードを入力してください
'; } if ( WCUtils::is_blank( $_POST['cshopid'] ) ) { $this->error_mes .= '※加盟店サブコードを入力してください
'; } if ( WCUtils::is_blank( $_POST['hash_pass'] ) ) { $this->error_mes .= '※ハッシュ用パスワードを入力してください
'; } if ( isset( $_POST['ope'] ) && 'public' == $_POST['ope'] && WCUtils::is_blank( $_POST['send_url'] ) ) { $this->error_mes .= '※本番URLを入力してください
'; } if ( defined( 'WCEX_MOBILE' ) && isset( $_POST['ope'] ) && 'public' == $_POST['ope'] && WCUtils::is_blank( $_POST['send_url_mbl'] ) ) { $this->error_mes .= '※本番URL(携帯)を入力してください
'; } if ( '' == $this->error_mes ) { $usces->action_status = 'success'; $usces->action_message = __( 'Options are updated.', 'usces' ); if ( 'on' == $options['acting_settings']['mizuho']['card_activate'] || 'on' == $options['acting_settings']['mizuho']['conv1_activate'] || 'on' == $options['acting_settings']['mizuho']['conv2_activate'] ) { $options['acting_settings']['mizuho']['activate'] = 'on'; $options['acting_settings']['mizuho']['send_url_test'] = 'https://tst.kessai-navi.jp/mltbank/MBWebFrontPayment'; if ( defined( 'WCEX_MOBILE' ) ) { $options['acting_settings']['mizuho']['send_url_mbl_test'] = 'https://tst.kessai-navi.jp/mltbank/iMBWebFrontPayment'; } $toactive = array(); if ( 'on' == $options['acting_settings']['mizuho']['card_activate'] ) { $usces->payment_structure['acting_mizuho_card'] = 'カード決済(' . $this->acting_name . ')'; foreach ( $payment_method as $settlement => $payment ) { if ( 'acting_mizuho_card' == $settlement && 'deactivate' == $payment['use'] ) { $toactive[] = $payment['name']; } } } else { unset( $usces->payment_structure['acting_mizuho_card'] ); } if ( 'on' == $options['acting_settings']['mizuho']['conv1_activate'] ) { $usces->payment_structure['acting_mizuho_conv1'] = 'コンビニ・ウェルネット決済(' . $this->acting_name . ')'; foreach ( $payment_method as $settlement => $payment ) { if ( 'acting_mizuho_conv1' == $settlement && 'deactivate' == $payment['use'] ) { $toactive[] = $payment['name']; } } } else { unset( $usces->payment_structure['acting_mizuho_conv1'] ); } if ( 'on' == $options['acting_settings']['mizuho']['conv2_activate'] ) { $usces->payment_structure['acting_mizuho_conv2'] = 'コンビニ・セブンイレブン決済(' . $this->acting_name . ')'; foreach ( $payment_method as $settlement => $payment ) { if ( 'acting_mizuho_conv2' == $settlement && 'deactivate' == $payment['use'] ) { $toactive[] = $payment['name']; } } } else { unset( $usces->payment_structure['acting_mizuho_conv2'] ); } 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']['mizuho']['activate'] = 'off'; unset( $usces->payment_structure['acting_mizuho_card'] ); unset( $usces->payment_structure['acting_mizuho_conv1'] ); unset( $usces->payment_structure['acting_mizuho_conv2'] ); } $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']['mizuho']['activate'] = 'off'; unset( $usces->payment_structure['acting_mizuho_card'] ); unset( $usces->payment_structure['acting_mizuho_conv1'] ); unset( $usces->payment_structure['acting_mizuho_conv2'] ); $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 ); ?>
    十分にテストを行ってから運用してください。
    加盟店コード
    契約時にacting_name ); ?>から発行される加盟店コード(半角数字6桁)
    加盟店サブコード
    契約時にacting_name ); ?>から発行される加盟店サブコード(半角数字5桁)
    ハッシュ用パスワード
    契約時にacting_name ); ?>から発行されるハッシュ用パスワード(半角英数字)

    動作環境を切り替えます。
    本番URL
    本番環境で接続するURLを設定します。決済インタフェース「接続先URL(画面連携型)PC」に示されるURLを入力してください。
    本番URL(携帯)
    本番環境で接続するURLを設定します。決済インタフェース「接続先URL(画面連携型)MB」に示されるURLを入力してください。
    クレジットカード決済

    acting_formal_name ); ?>

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

     

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

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

    pay_method ) ) { return; } if ( ! $entry['order']['total_full_price'] ) { return; } if ( isset( $_REQUEST['acting'] ) && 'mizuho_card' == $_REQUEST['acting'] ) { $data['stran'] = esc_sql( $_REQUEST['stran'] ); $data['mbtran'] = esc_sql( $_REQUEST['mbtran'] ); $usces->set_order_meta_value( 'acting_' . $_REQUEST['acting'], serialize( $data ), $order_id ); $usces->set_order_meta_value( 'wc_trans_id', $_REQUEST['stran'], $order_id ); } elseif ( isset( $_REQUEST['acting'] ) && 'mizuho_conv' == $_REQUEST['acting'] ) { $data['stran'] = esc_sql( $_REQUEST['stran'] ); $data['mbtran'] = esc_sql( $_REQUEST['mbtran'] ); $data['bktrans'] = esc_sql( $_REQUEST['bktrans'] ); $data['tranid'] = esc_sql( $_REQUEST['tranid'] ); $usces->set_order_meta_value( 'stran', $data['stran'], $order_id ); $usces->set_order_meta_value( 'acting_' . $_REQUEST['acting'], serialize( $data ), $order_id ); $usces->set_order_meta_value( 'wc_trans_id', $data['stran'], $order_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; } }