paymod_id = 'digitalcheck'; $this->pay_method = array( 'acting_digitalcheck_card', 'acting_digitalcheck_conv', ); $this->acting_name = 'ペイメントフォー'; $this->acting_formal_name = 'ペイメントフォー'; $this->acting_company_url = 'https://www.paymentfor.com/'; $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() || $this->is_activate_conv() ) { add_filter( 'usces_filter_settle_info_field_meta_keys', array( $this, 'settlement_info_field_meta_keys' ) ); add_filter( 'usces_filter_settle_info_field_keys', array( $this, 'settlement_info_field_keys' ) ); add_filter( 'usces_filter_check_acting_return_duplicate', array( $this, 'check_acting_return_duplicate' ), 10, 2 ); add_action( 'usces_action_reg_orderdata', array( $this, 'register_orderdata' ) ); } if ( $this->is_activate_conv() ) { add_filter( 'usces_filter_payment_detail', array( $this, 'payment_detail' ), 10, 2 ); add_filter( 'usces_filter_send_order_mail_payment', array( $this, 'order_mail_payment' ), 10, 6 ); add_filter( 'usces_filter_order_confirm_mail_payment', array( $this, 'order_confirm_mail_payment' ), 10, 5 ); } 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']['digitalcheck'] ) ) { $options['acting_settings']['digitalcheck']['card_activate'] = 'off'; $options['acting_settings']['digitalcheck']['card_ip'] = ''; $options['acting_settings']['digitalcheck']['card_pass'] = ''; $options['acting_settings']['digitalcheck']['card_kakutei'] = ''; $options['acting_settings']['digitalcheck']['card_user_id'] = ''; $options['acting_settings']['digitalcheck']['conv_activate'] = 'off'; $options['acting_settings']['digitalcheck']['conv_ip'] = ''; $options['acting_settings']['digitalcheck']['conv_store'] = array(); $options['acting_settings']['digitalcheck']['conv_kigen'] = '14'; update_option( 'usces', $options ); } else { $options['acting_settings']['digitalcheck']['card_activate'] = ( isset( $options['acting_settings']['digitalcheck']['card_activate'] ) ) ? $options['acting_settings']['digitalcheck']['card_activate'] : 'off'; $options['acting_settings']['digitalcheck']['conv_activate'] = ( isset( $options['acting_settings']['digitalcheck']['conv_activate'] ) ) ? $options['acting_settings']['digitalcheck']['conv_activate'] : 'off'; if ( 'on' === $options['acting_settings']['digitalcheck']['card_activate'] || 'on' === $options['acting_settings']['digitalcheck']['card_activate'] ) { $options['acting_settings']['digitalcheck']['card_ip'] = ( isset( $options['acting_settings']['digitalcheck']['card_ip'] ) ) ? $options['acting_settings']['digitalcheck']['card_ip'] : ''; $options['acting_settings']['digitalcheck']['card_pass'] = ( isset( $options['acting_settings']['digitalcheck']['card_pass'] ) ) ? $options['acting_settings']['digitalcheck']['card_pass'] : ''; $options['acting_settings']['digitalcheck']['card_kakutei'] = ( isset( $options['acting_settings']['digitalcheck']['card_kakutei'] ) ) ? $options['acting_settings']['digitalcheck']['card_kakutei'] : '0'; $options['acting_settings']['digitalcheck']['card_user_id'] = ( isset( $options['acting_settings']['digitalcheck']['card_user_id'] ) ) ? $options['acting_settings']['digitalcheck']['card_user_id'] : 'off'; $options['acting_settings']['digitalcheck']['send_url_card'] = 'https://www.paydesign.jp/settle/settle3/bp3.dll'; $options['acting_settings']['digitalcheck']['send_url_user_id'] = 'https://www.paydesign.jp/settle/settlex/credit2.dll'; $options['acting_settings']['digitalcheck']['conv_ip'] = ( isset( $options['acting_settings']['digitalcheck']['conv_ip'] ) ) ? $options['acting_settings']['digitalcheck']['conv_ip'] : ''; $options['acting_settings']['digitalcheck']['conv_store'] = ( isset( $options['acting_settings']['digitalcheck']['conv_store'] ) ) ? $options['acting_settings']['digitalcheck']['conv_store'] : array(); $options['acting_settings']['digitalcheck']['conv_kigen'] = ( isset( $options['acting_settings']['digitalcheck']['conv_kigen'] ) ) ? $options['acting_settings']['digitalcheck']['conv_kigen'] : '14'; $options['acting_settings']['digitalcheck']['send_url_conv'] = 'https://www.paydesign.jp/settle/settle3/bp3.dll'; update_option( 'usces', $options ); } } } /** * 決済有効判定 * 支払方法で使用している場合に true * * @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_digitalcheck_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_digitalcheck_conv' == $payment['settlement'] && 'activate' == $payment['use'] ) { $method = true; break; } } if ( $method && $this->is_activate_conv() ) { return true; } else { return false; } break; default: if ( 'on' == $acting_opts['activate'] ) { return true; } else { return false; } } } /** * クレジットカード決済有効判定 * * @return boolean */ 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 */ public function is_activate_conv() { $acting_opts = $this->get_acting_settings(); if ( ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) && ( isset( $acting_opts['conv_activate'] ) && 'on' == $acting_opts['conv_activate'] ) ) { $res = true; } else { $res = false; } return $res; } /** * 決済オプション登録・更新 * usces_action_admin_settlement_update */ public function settlement_update() { global $usces; if ( $this->paymod_id != wp_unslash( $_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']['digitalcheck'] ); $options['acting_settings']['digitalcheck']['card_activate'] = ( isset( $_POST['card_activate'] ) ) ? $_POST['card_activate'] : 'off'; $options['acting_settings']['digitalcheck']['card_ip'] = ( isset( $_POST['card_ip'] ) ) ? $_POST['card_ip'] : ''; $options['acting_settings']['digitalcheck']['card_pass'] = ( isset( $_POST['card_pass'] ) ) ? $_POST['card_pass'] : ''; $options['acting_settings']['digitalcheck']['card_kakutei'] = ( isset( $_POST['card_kakutei'] ) ) ? $_POST['card_kakutei'] : '0'; $options['acting_settings']['digitalcheck']['card_user_id'] = ( isset( $_POST['card_user_id'] ) ) ? $_POST['card_user_id'] : 'off'; $options['acting_settings']['digitalcheck']['conv_activate'] = ( isset( $_POST['conv_activate'] ) ) ? $_POST['conv_activate'] : 'off'; $options['acting_settings']['digitalcheck']['conv_ip'] = ( isset( $_POST['conv_ip'] ) ) ? $_POST['conv_ip'] : ''; $options['acting_settings']['digitalcheck']['conv_store'] = ( isset( $_POST['conv_store'] ) ) ? $_POST['conv_store'] : array(); $options['acting_settings']['digitalcheck']['conv_kigen'] = ( isset( $_POST['conv_kigen'] ) ) ? $_POST['conv_kigen'] : '14'; if ( 'on' == $options['acting_settings']['digitalcheck']['card_activate'] ) { if ( WCUtils::is_blank( $_POST['card_ip'] ) ) { $this->error_mes .= '※加盟店コードを入力してください
'; } if ( 'on' == $options['acting_settings']['digitalcheck']['card_user_id'] ) { if ( WCUtils::is_blank( $_POST['card_pass'] ) ) { $this->error_mes .= '※加盟店パスワードを入力してください
'; } } } if ( 'on' == $options['acting_settings']['digitalcheck']['conv_activate'] ) { if ( WCUtils::is_blank( $_POST['conv_ip'] ) ) { $this->error_mes .= '※加盟店コードを入力してください
'; } if ( empty( $_POST['conv_store'] ) ) { $this->error_mes .= '※利用コンビニを選択してください
'; } } if ( '' == $this->error_mes ) { $usces->action_status = 'success'; $usces->action_message = __( 'Options are updated.', 'usces' ); if ( 'on' == $options['acting_settings']['digitalcheck']['card_activate'] || 'on' == $options['acting_settings']['digitalcheck']['conv_activate'] ) { $options['acting_settings']['digitalcheck']['activate'] = 'on'; $toactive = array(); if ( 'on' == $options['acting_settings']['digitalcheck']['card_activate'] ) { $options['acting_settings']['digitalcheck']['send_url_card'] = 'https://www.paydesign.jp/settle/settle3/bp3.dll'; if ( 'on' == $options['acting_settings']['digitalcheck']['card_user_id'] ) { $options['acting_settings']['digitalcheck']['send_url_user_id'] = 'https://www.paydesign.jp/settle/settlex/credit2.dll'; } else { $options['acting_settings']['digitalcheck']['send_url_user_id'] = ''; } $usces->payment_structure['acting_digitalcheck_card'] = 'カード決済(' . $this->acting_name . ')'; foreach ( $payment_method as $settlement => $payment ) { if ( 'acting_digitalcheck_card' == $settlement && 'deactivate' == $payment['use'] ) { $toactive[] = $payment['name']; } } } else { unset( $usces->payment_structure['acting_digitalcheck_card'] ); } if ( 'on' == $options['acting_settings']['digitalcheck']['conv_activate'] ) { $options['acting_settings']['digitalcheck']['send_url_conv'] = 'https://www.paydesign.jp/settle/settle3/bp3.dll'; $usces->payment_structure['acting_digitalcheck_conv'] = 'コンビニ決済(' . $this->acting_name . ')'; foreach ( $payment_method as $settlement => $payment ) { if ( 'acting_digitalcheck_conv' == $settlement && 'deactivate' == $payment['use'] ) { $toactive[] = $payment['name']; } } } else { unset( $usces->payment_structure['acting_digitalcheck_conv'] ); } 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']['digitalcheck']['activate'] = 'off'; unset( $usces->payment_structure['acting_digitalcheck_card'] ); unset( $usces->payment_structure['acting_digitalcheck_conv'] ); } if ( 'on' != $options['acting_settings']['digitalcheck']['card_user_id'] || 'off' == $options['acting_settings']['digitalcheck']['activate'] ) { usces_clear_quickcharge( 'digitalcheck_ip_user_id' ); } $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']['digitalcheck']['activate'] = 'off'; unset( $usces->payment_structure['acting_digitalcheck_card'] ); unset( $usces->payment_structure['acting_digitalcheck_conv'] ); $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 '
  • ' . esc_html( $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 ) ) : $card_activate = ( isset( $acting_opts['card_activate'] ) && 'on' == $acting_opts['card_activate'] ) ? 'on' : 'off'; $card_ip = ( isset( $acting_opts['card_ip'] ) ) ? $acting_opts['card_ip'] : ''; $card_pass = ( isset( $acting_opts['card_pass'] ) ) ? $acting_opts['card_pass'] : ''; $card_kakutei = ( isset( $acting_opts['card_kakutei'] ) ) ? $acting_opts['card_kakutei'] : '0'; $card_user_id = ( isset( $acting_opts['card_user_id'] ) && 'on' == $acting_opts['card_user_id'] ) ? 'on' : 'off'; $conv_activate = ( isset( $acting_opts['conv_activate'] ) && 'on' == $acting_opts['conv_activate'] ) ? 'on' : 'off'; $conv_ip = ( isset( $acting_opts['conv_ip'] ) ) ? $acting_opts['conv_ip'] : ''; $conv_store = ( isset( $acting_opts['conv_store'] ) && is_array( $acting_opts['conv_store'] ) ) ? $acting_opts['conv_store'] : array(); ?>
    acting_formal_name ); ?>
    paymod_id == $_POST['acting'] ) : if ( '' != $this->error_mes ) : ?>
    error_mes ); ?>
    十分にテストを行ってから運用してください。
    クレジットカード決済
    加盟店コード
    契約時にacting_name ); ?>から発行される加盟店コード(半角英数字)
    加盟店パスワード
    契約時にacting_name ); ?>から発行される加盟店パスワード(半角英数字)
    ユーザID決済をご利用の場合は、必須となります。
    決済自動確定
    注文の際にクレジットの与信のみを行ないます。
    実際の売上として計上するには確定処理が必要となります。省略時は「売上確定(確定まで同時に行う)」です。
    ユーザID決済
    過去にクレジットカードでのお取引があるユーザは、次回からカード情報の入力を省略することが可能となります。
    コンビニ決済
    加盟店コード
    契約時にacting_name ); ?>から発行される加盟店コード(半角英数字)
    利用コンビニ
    収納先のコンビニを選択します。コンビニ毎の審査が必要となり、審査通過後にご利用可能となります。
    支払期限 (日数)
    コンビニ店頭でお支払いいただける期限となります。

    acting_formal_name ); ?>

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

     

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

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

    pay_method ) ) { return; } if ( ! $entry['order']['total_full_price'] ) { return; } if ( isset( $_REQUEST['SID'] ) && isset( $_REQUEST['FUKA'] ) ) { $fuka = substr( wp_unslash( $_REQUEST['FUKA'] ), 0, 24 ); if ( 'acting_digitalcheck_card' == $fuka ) { $data = array(); foreach ( $_REQUEST as $key => $value ) { $data[ $key ] = $value; } $usces->set_order_meta_value( 'acting_digitalcheck_card', serialize( $data ), $order_id ); } if ( 'acting_digitalcheck_conv' == $fuka ) { $data = array(); $data['SID'] = wp_unslash( $_REQUEST['SID'] ); if ( ! empty( $_REQUEST['CVS'] ) ) { $data['CVS'] = wp_unslash( $_REQUEST['CVS'] ); } if ( ! empty( $_REQUEST['SHNO'] ) ) { $data['SHNO'] = wp_unslash( $_REQUEST['SHNO'] ); } if ( ! empty( $_REQUEST['FURL'] ) ) { $data['FURL'] = wp_unslash( $_REQUEST['FURL'] ); } $usces->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id ); } $usces->set_order_meta_value( 'SID', wp_unslash( $_REQUEST['SID'] ), $order_id ); $usces->set_order_meta_value( 'wc_trans_id', wp_unslash( $_REQUEST['SID'] ), $order_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( 'digitalcheck_ip_user_id' ) ) ) { $cardinfo[ $value['meta_key'] ] = $value['meta_value']; } } if ( 0 < count( $cardinfo ) ) : foreach ( $cardinfo as $key => $value ) : if ( 'digitalcheck_ip_user_id' != $key ) : ?>
    ユーザID決済
    登録あり
    del_member_meta( 'digitalcheck_ip_user_id', $member_id ); } } /** * 支払方法説明 * usces_filter_payment_detail * * @param string $str Payment method description. * @param array $entry Entry data. * @return string */ public function payment_detail( $str, $entry ) { $payment = usces_get_payments_by_name( $entry['order']['payment_name'] ); if ( isset( $payment['settlement'] ) && 'acting_digitalcheck_conv' == $payment['settlement'] ) { $acting_opts = $this->get_acting_settings(); $payment_detail = __( '(', 'usces' ) . sprintf( __( 'Payment is valid for %s days from the date of order.', 'usces' ), $acting_opts['conv_kigen'] ) . __( ')', 'usces' ); $str = apply_filters( 'usces_filter_digitalcheck_payment_limit_conv', $payment_detail, $acting_opts['conv_kigen'] ); } return $str; } /** * サンキューメール * usces_filter_send_order_mail_payment * * @param string $msg_payment Payment method message. * @param int $order_id Order number. * @param array $payment Payment data. * @param array $cart Cart data. * @param array $entry Entry data. * @param array $data Order data. * @return string */ public function order_mail_payment( $msg_payment, $order_id, $payment, $cart, $entry, $data ) { global $usces; if ( 'acting_digitalcheck_conv' != $payment['settlement'] ) { return $msg_payment; } $args = wel_safe_maybe_unserialize( $usces->get_order_meta_value( $payment['settlement'], $order_id ) ); if ( isset( $args['CVS'] ) ) { $msg_payment .= '支払先 : ' . $this->get_conv_name( $args['CVS'] ) . "\r\n"; } if ( isset( $args['SHNO'] ) ) { $msg_payment .= '支払番号 : ' . $args['SHNO'] . "\r\n"; } if ( isset( $args['FURL'] ) ) { $msg_payment .= '支払情報URL : ' . $args['FURL'] . "\r\n"; } return $msg_payment; } /** * 管理画面送信メール * usces_filter_order_confirm_mail_payment * * @param string $msg_payment Payment information message. * @param int $order_id Order number. * @param array $payment Payment data. * @param array $cart Cart data. * @param array $data Order data. * @return string */ public function order_confirm_mail_payment( $msg_payment, $order_id, $payment, $cart, $data ) { global $usces; if ( 'acting_digitalcheck_conv' != $payment['settlement'] ) { return $msg_payment; } if ( 'orderConfirmMail' == $_POST['mode'] ) { $args = wel_safe_maybe_unserialize( $usces->get_order_meta_value( $payment['settlement'], $order_id ) ); if ( isset( $args['CVS'] ) ) { $msg_payment .= '支払先 : ' . $this->get_conv_name( $args['CVS'] ) . "\r\n"; } if ( isset( $args['SHNO'] ) ) { $msg_payment .= '支払番号 : ' . $args['SHNO'] . "\r\n"; } if ( isset( $args['FURL'] ) ) { $msg_payment .= '支払情報URL : ' . $args['FURL'] . "\r\n"; } } return $msg_payment; } /** * コンビニ名称取得 * * @param string $code CVS code. * @return string */ protected function get_conv_name( $code ) { switch ( $code ) { case 'SEVEN': $name = 'セブン-イレブン'; break; case 'loppi': $name = 'ローソン/ミニストップ/セイコーマート'; break; case 'famima': $name = 'ファミリーマート'; break; case 'wellnet': $name = 'デイリーヤマザキ/ヤマザキデイリーストア'; break; default: $name = $code; } return $name; } /** * 決済結果通知の送信元IPを検証する * * 許可IP以外からのリクエストはエラーログを残して処理を終了する * 入金状態を変更するサーバー間通知でのみ呼び出すこと * ブラウザ戻りを伴う結果戻りでは呼び出さない * * @param array $data Notification data. * @return void */ public function acting_notice_ip_guard( $data ) { $remote_addr = ( isset( $_SERVER['REMOTE_ADDR'] ) ) ? wp_unslash( $_SERVER['REMOTE_ADDR'] ) : ''; if ( usces_acting_notice_ip_allowed( $remote_addr, self::ACTING_NOTICE_IPADDRS ) ) { return; } $log = array( 'acting' => 'digitalcheck_conv', 'key' => ( isset( $data['SID'] ) ) ? $data['SID'] : '', 'result' => 'IP ADDRESS NOT ALLOWED: ' . $remote_addr, 'data' => $data, ); usces_save_order_acting_error( $log ); usces_log( 'digitalcheck notice denied ip : ' . $remote_addr, 'acting_transaction.log' ); header( 'Content-Type: text/plain; charset=Shift_JIS' ); die( "9\r\n" ); } /** * 決済オプション取得 * * @return array */ 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; } }