'01',
CODE_LOWSON => '02',
CODE_MINISTOP => '02',
CODE_YAMAZAKI => '02',
CODE_SEVENELEVEN => '03',
CODE_FAMILYMART => '04',
);
/**
* コンビニ接続タイプA(企業コード:コンビニ)
*
* @var array
*/
protected $cvs_company_a = array(
CODE_SEICOMART => 'セイコーマート',
CODE_LOWSON => 'ローソン',
CODE_MINISTOP => 'ミニストップ',
CODE_YAMAZAKI => 'デイリーヤマザキ',
CODE_SEVENELEVEN => 'セブンイレブン',
CODE_FAMILYMART => 'ファミリーマート',
);
/**
* 銀行ネット決済支払期間
*
* @var array
*/
protected $asp_payment_term = array(
'0000030' => '即日購入後 30分以内',
'0000060' => '即日購入後 1時間以内',
'0000120' => '即日購入後 2時間以内',
'0000180' => '即日購入後 3時間以内',
'0000360' => '即日購入後 6時間以内',
'0010000' => '購入後 24時間以内',
'0020000' => '購入後 2日以内',
'0030000' => '購入後 3日以内',
'0050000' => '購入後 5日以内',
'0070000' => '購入後 7日以内',
'0140000' => '購入後 14日以内',
);
/**
* Construct.
*/
public function __construct() {
$this->paymod_id = 'paygent';
$this->pay_method = array(
'acting_paygent_card',
'acting_paygent_conv',
'acting_paygent_atm',
'acting_paygent_bank',
'acting_paygent_paidy',
);
$this->acting_name = 'ペイジェント';
$this->acting_formal_name = 'ペイジェント';
$this->acting_company_url = 'https://www.paygent.co.jp/';
$this->initialize_data();
if ( is_admin() ) {
add_action( 'admin_print_footer_scripts', array( $this, 'admin_scripts' ) );
add_action( 'wp_ajax_check_file_path', array( $this, 'check_file_path' ) );
add_action( 'wp_ajax_upload_certificate_file', array( $this, 'upload_certificate_file' ) );
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_validity_acting() ) {
add_action( 'usces_after_cart_instant', array( $this, 'acting_transaction' ), 11 );
add_filter( 'usces_filter_is_complete_settlement', array( $this, 'is_complete_settlement' ), 10, 3 );
if ( is_admin() ) {
add_action( 'usces_action_admin_ajax', array( $this, 'admin_ajax' ) );
add_filter( 'usces_filter_orderlist_detail_value', array( $this, 'orderlist_settlement_status' ), 10, 4 );
add_action( 'usces_action_order_edit_form_status_block_middle', array( $this, 'settlement_status' ), 10, 3 );
add_action( 'usces_action_order_edit_form_settle_info', array( $this, 'settlement_information' ), 10, 2 );
add_action( 'usces_action_endof_order_edit_form', array( $this, 'settlement_dialog' ), 10, 2 );
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' ), 10, 2 );
add_filter( 'usces_filter_settle_info_field_value', array( $this, 'settlement_info_field_value' ), 10, 3 );
add_filter( 'usces_filter_order_confirm_mail_payment', array( $this, 'order_confirm_mail_payment' ), 10, 5 );
add_filter( 'usces_filter_get_link_key', array( $this, 'get_link_key' ), 10, 2 );
add_action( 'usces_action_revival_order_data', array( $this, 'revival_orderdata' ), 10, 3 );
} else {
add_filter( 'usces_filter_payment_detail', array( $this, 'payment_detail' ), 10, 2 );
add_filter( 'usces_filter_payments_str', array( $this, 'payments_str' ), 10, 2 );
add_filter( 'usces_filter_payments_arr', array( $this, 'payments_arr' ), 10, 2 );
add_filter( 'usces_filter_confirm_inform', array( $this, 'confirm_inform' ), 10, 5 );
add_action( 'usces_action_confirm_page_point_inform', array( $this, 'e_point_inform' ), 10, 5 );
add_filter( 'usces_filter_confirm_point_inform', array( $this, 'point_inform' ), 10, 5 );
if ( defined( 'WCEX_COUPON' ) ) {
add_filter( 'wccp_filter_coupon_inform', array( $this, 'point_inform' ), 10, 5 );
}
add_action( 'usces_pre_purchase', array( $this, 'pre_purchase' ), 1 );
add_action( 'usces_action_acting_processing', array( $this, 'acting_processing' ), 10, 2 );
add_filter( 'usces_filter_check_acting_return_results', array( $this, 'acting_return' ) );
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' ) );
add_filter( 'usces_filter_get_error_settlement', array( $this, 'error_page_message' ) );
add_filter( 'usces_filter_send_order_mail_payment', array( $this, 'order_mail_payment' ), 10, 6 );
}
if ( $this->is_validity_acting( 'card' ) ) {
// if ( $this->is_activate_card( 'module' ) ) {
add_action( 'init', array( $this, 'done_3ds_auth' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'wp_print_footer_scripts', array( $this, 'footer_scripts' ), 9 );
add_filter( 'usces_filter_uscesL10n', array( $this, 'set_uscesL10n' ), 12, 2 );
add_filter( 'usces_filter_delivery_check', array( $this, 'delivery_check' ), 15 );
add_filter( 'usces_filter_delivery_secure_form_loop', array( $this, 'delivery_secure_form_loop' ), 10, 2 );
add_filter( 'usces_filter_save_order_acting_data', array( $this, 'save_order_acting_data' ) );
add_filter( 'usces_filter_delete_member_check', array( $this, 'delete_member_check' ), 10, 2 );
add_filter( 'usces_filter_delete_member_check_front', array( $this, 'delete_member_check' ), 10, 2 );
add_action( 'usces_action_pre_delete_memberdata', array( $this, 'delete_member' ) );
// }
add_filter( 'usces_filter_template_redirect', array( $this, 'member_update_settlement' ), 1 );
add_action( 'usces_action_member_submenu_list', array( $this, 'e_update_settlement' ) );
add_filter( 'usces_filter_member_submenu_list', array( $this, 'update_settlement' ), 10, 2 );
if ( is_admin() ) {
add_action( 'usces_action_admin_member_info', array( $this, 'admin_member_info' ), 10, 3 );
add_action( 'usces_action_post_update_memberdata', array( $this, 'admin_update_memberdata' ), 10, 2 );
}
/* WCEX DL Seller */
if ( defined( 'WCEX_DLSELLER' ) ) {
add_filter( 'usces_filter_the_continue_payment_method', array( $this, 'continuation_payment_method' ) );
add_filter( 'dlseller_filter_first_charging', array( $this, 'first_charging_date' ), 9, 5 );
add_filter( 'dlseller_filter_the_payment_method_restriction', array( $this, 'payment_method_restriction' ), 10, 2 );
add_filter( 'dlseller_filter_continue_member_list_condition', array( $this, 'continue_member_list_condition' ), 10, 4 );
add_action( 'dlseller_action_continue_member_list_page', array( $this, 'continue_member_list_page' ) );
add_action( 'dlseller_action_do_continuation_charging', array( $this, 'auto_continuation_charging' ), 10, 4 );
add_action( 'dlseller_action_do_continuation', array( $this, 'do_auto_continuation' ), 10, 2 );
add_filter( 'dlseller_filter_reminder_mail_body', array( $this, 'reminder_mail_body' ), 10, 3 );
add_filter( 'dlseller_filter_contract_renewal_mail_body', array( $this, 'contract_renewal_mail_body' ), 10, 3 );
}
/* WCEX Auto Delivery */
if ( defined( 'WCEX_AUTO_DELIVERY' ) ) {
if ( is_admin() && version_compare( WCEX_AUTO_DELIVERY_VERSION, '1.2.3', '<' ) ) {
add_filter( 'wcad_filter_admin_notices', array( $this, 'admin_notices_autodelivery' ), 11 );
}
add_filter( 'wcad_filter_shippinglist_acting', array( $this, 'set_shippinglist_acting' ) );
add_filter( 'wcad_filter_available_regular_payment_method', array( $this, 'available_regular_payment_method' ) );
add_filter( 'wcad_filter_the_payment_method_restriction', array( $this, 'payment_method_restriction' ), 10, 2 );
add_action( 'wcad_action_reg_auto_orderdata', array( $this, 'register_auto_orderdata' ) );
}
}
if ( $this->is_validity_acting( 'conv' ) ) {
add_filter( 'usces_filter_noreceipt_status', array( $this, 'noreceipt_status' ) );
if ( $this->is_activate_conv( 'module' ) ) {
add_action( 'wp_print_footer_scripts', array( $this, 'footer_scripts' ), 9 );
add_filter( 'usces_filter_delivery_check', array( $this, 'delivery_check' ), 15 );
add_filter( 'usces_filter_delivery_secure_form_loop', array( $this, 'delivery_secure_form_loop' ), 10, 2 );
add_filter( 'usces_filter_completion_settlement_message', array( $this, 'completion_settlement_message' ), 10, 2 );
}
}
if ( $this->is_validity_acting( 'atm' ) ) {
add_filter( 'usces_filter_noreceipt_status', array( $this, 'noreceipt_status' ) );
if ( $this->is_activate_atm() ) {
add_filter( 'usces_filter_delivery_check', array( $this, 'delivery_check' ), 15 );
add_filter( 'usces_filter_delivery_secure_form_loop', array( $this, 'delivery_secure_form_loop' ), 10, 2 );
add_filter( 'usces_filter_completion_settlement_message', array( $this, 'completion_settlement_message' ), 10, 2 );
}
}
if ( $this->is_validity_acting( 'bank' ) ) {
add_filter( 'usces_filter_noreceipt_status', array( $this, 'noreceipt_status' ) );
if ( $this->is_activate_bank() ) {
add_filter( 'usces_filter_delivery_check', array( $this, 'delivery_check' ), 15 );
add_filter( 'usces_filter_delivery_secure_form_loop', array( $this, 'delivery_secure_form_loop' ), 10, 2 );
}
}
if ( $this->is_validity_acting( 'paidy' ) ) {
if ( $this->is_activate_paidy() ) {
add_action( 'wp_print_footer_scripts', array( $this, 'footer_scripts' ), 9 );
}
}
}
}
/**
* 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() );
$options['acting_settings']['paygent']['activate'] = ( isset( $options['acting_settings']['paygent']['activate'] ) ) ? $options['acting_settings']['paygent']['activate'] : 'off';
$options['acting_settings']['paygent']['seq_merchant_id'] = ( isset( $options['acting_settings']['paygent']['seq_merchant_id'] ) ) ? $options['acting_settings']['paygent']['seq_merchant_id'] : '';
$options['acting_settings']['paygent']['connect_id'] = ( isset( $options['acting_settings']['paygent']['connect_id'] ) ) ? $options['acting_settings']['paygent']['connect_id'] : '';
$options['acting_settings']['paygent']['connect_password'] = ( isset( $options['acting_settings']['paygent']['connect_password'] ) ) ? $options['acting_settings']['paygent']['connect_password'] : '';
$options['acting_settings']['paygent']['telegram_version'] = TELEGRAM_VERSION;
$options['acting_settings']['paygent']['hc'] = ( isset( $options['acting_settings']['paygent']['hc'] ) ) ? $options['acting_settings']['paygent']['hc'] : '';
$options['acting_settings']['paygent']['conv_hc'] = ( isset( $options['acting_settings']['paygent']['conv_hc'] ) ) ? $options['acting_settings']['paygent']['conv_hc'] : '';
$options['acting_settings']['paygent']['ope'] = ( isset( $options['acting_settings']['paygent']['ope'] ) ) ? $options['acting_settings']['paygent']['ope'] : '';
$options['acting_settings']['paygent']['card_activate'] = ( isset( $options['acting_settings']['paygent']['card_activate'] ) ) ? $options['acting_settings']['paygent']['card_activate'] : 'off';
$options['acting_settings']['paygent']['token_key'] = ( isset( $options['acting_settings']['paygent']['token_key'] ) ) ? $options['acting_settings']['paygent']['token_key'] : '';
$options['acting_settings']['paygent']['token_hc'] = ( isset( $options['acting_settings']['paygent']['token_hc'] ) ) ? $options['acting_settings']['paygent']['token_hc'] : '';
$options['acting_settings']['paygent']['certificate_path'] = ( isset( $options['acting_settings']['paygent']['certificate_path'] ) ) ? $options['acting_settings']['paygent']['certificate_path'] : '';
$options['acting_settings']['paygent']['client_file'] = ( isset( $options['acting_settings']['paygent']['client_file'] ) ) ? $options['acting_settings']['paygent']['client_file'] : '';
$options['acting_settings']['paygent']['ca_file'] = ( isset( $options['acting_settings']['paygent']['ca_file'] ) ) ? $options['acting_settings']['paygent']['ca_file'] : '';
$options['acting_settings']['paygent']['payment_class'] = ( isset( $options['acting_settings']['paygent']['payment_class'] ) ) ? $options['acting_settings']['paygent']['payment_class'] : '';
$options['acting_settings']['paygent']['use_card_conf_number'] = ( isset( $options['acting_settings']['paygent']['use_card_conf_number'] ) ) ? $options['acting_settings']['paygent']['use_card_conf_number'] : '';
$options['acting_settings']['paygent']['stock_card_mode'] = ( isset( $options['acting_settings']['paygent']['stock_card_mode'] ) ) ? $options['acting_settings']['paygent']['stock_card_mode'] : '';
$options['acting_settings']['paygent']['sales_mode'] = ( isset( $options['acting_settings']['paygent']['sales_mode'] ) ) ? $options['acting_settings']['paygent']['sales_mode'] : '0';
$options['acting_settings']['paygent']['sales_mode_dlseller'] = ( isset( $options['acting_settings']['paygent']['sales_mode_dlseller'] ) ) ? $options['acting_settings']['paygent']['sales_mode_dlseller'] : '0';
$options['acting_settings']['paygent']['auto_settlement_mail'] = ( isset( $options['acting_settings']['paygent']['auto_settlement_mail'] ) ) ? $options['acting_settings']['paygent']['auto_settlement_mail'] : 'off';
$options['acting_settings']['paygent']['threedsecure_ryaku'] = ( isset( $options['acting_settings']['paygent']['threedsecure_ryaku'] ) ) ? $options['acting_settings']['paygent']['threedsecure_ryaku'] : 'off';
$options['acting_settings']['paygent']['threedsecure_hc'] = ( isset( $options['acting_settings']['paygent']['threedsecure_hc'] ) ) ? $options['acting_settings']['paygent']['threedsecure_hc'] : '';
$options['acting_settings']['paygent']['attempt'] = ( isset( $options['acting_settings']['paygent']['attempt'] ) ) ? $options['acting_settings']['paygent']['attempt'] : 'on';
$options['acting_settings']['paygent']['conv_activate'] = ( isset( $options['acting_settings']['paygent']['conv_activate'] ) ) ? $options['acting_settings']['paygent']['conv_activate'] : 'off';
$options['acting_settings']['paygent']['payment_term_day'] = ( isset( $options['acting_settings']['paygent']['payment_term_day'] ) ) ? $options['acting_settings']['paygent']['payment_term_day'] : '';
$options['acting_settings']['paygent']['payment_term_min'] = ( isset( $options['acting_settings']['paygent']['payment_term_min'] ) ) ? $options['acting_settings']['paygent']['payment_term_min'] : '';
$options['acting_settings']['paygent']['sales_type'] = ( isset( $options['acting_settings']['paygent']['sales_type'] ) ) ? $options['acting_settings']['paygent']['sales_type'] : '1';
$options['acting_settings']['paygent']['cvs_type'] = ( ! empty( $options['acting_settings']['paygent']['cvs_type'] ) ) ? $options['acting_settings']['paygent']['cvs_type'] : array( '01', '02', '03', '04' );
$options['acting_settings']['paygent']['atm_activate'] = ( isset( $options['acting_settings']['paygent']['atm_activate'] ) ) ? $options['acting_settings']['paygent']['atm_activate'] : 'off';
$options['acting_settings']['paygent']['payment_limit_date'] = ( isset( $options['acting_settings']['paygent']['payment_limit_date'] ) ) ? $options['acting_settings']['paygent']['payment_limit_date'] : '';
$options['acting_settings']['paygent']['bank_activate'] = ( isset( $options['acting_settings']['paygent']['bank_activate'] ) ) ? $options['acting_settings']['paygent']['bank_activate'] : 'off';
$options['acting_settings']['paygent']['asp_payment_term'] = ( isset( $options['acting_settings']['paygent']['asp_payment_term'] ) ) ? $options['acting_settings']['paygent']['asp_payment_term'] : '0050000';
$options['acting_settings']['paygent']['paidy_activate'] = ( isset( $options['acting_settings']['paygent']['paidy_activate'] ) ) ? $options['acting_settings']['paygent']['paidy_activate'] : 'off';
$options['acting_settings']['paygent']['paidy_public_key'] = ( isset( $options['acting_settings']['paygent']['paidy_public_key'] ) ) ? $options['acting_settings']['paygent']['paidy_public_key'] : '';
if ( empty( $options['acting_settings']['paygent']['certificate_path'] ) ) {
$upload_dir = wp_upload_dir();
$dir = $this->create_certificate_path();
$options['acting_settings']['paygent']['certificate_path'] = $upload_dir['basedir'] . $dir;
}
update_option( 'usces', $options );
$available_settlement = get_option( 'usces_available_settlement' );
if ( ! in_array( $this->paymod_id, $available_settlement ) ) {
$available_settlement[ $this->paymod_id ] = $this->acting_formal_name;
update_option( 'usces_available_settlement', $available_settlement );
}
$this->unavailable_method = array( 'acting_paidy' );
}
/**
* 証明書ファイルパス名生成
*
* @return string
*/
private function create_certificate_path() {
$dir = '/p' . substr( str_shuffle( '1234567890abcdefghijklmnopqrstuvwxyz' ), 0, 12 );
return $dir;
}
/**
* 証明書ディレクトリに公開遮断ファイルを設置する
*
* 秘密鍵を含む証明書が HTTP で配信される領域に保存されている場合に備え、
* ディレクトリ名の推測困難性だけに頼らず Web サーバー側でも遮断する.
* 効果があるのは .htaccess を読む Apache のみ. nginx では無効.
*
* 証明書が実際に置かれているディレクトリのときにのみ設置する.
* 証明書ファイルパスは管理画面で任意のディレクトリに変更できるため、
* 証明書と無関係なディレクトリには触れないようにする.
*
* 呼び出し元はディレクトリ作成時・証明書アップロード時・管理画面の読み込み時の3箇所.
*
* @param string $dir Certificate directory path.
* @return bool True if the directory has the blocking file.
*/
private function protect_certificate_dir( $dir ) {
if ( WCUtils::is_blank( $dir ) || ! is_dir( $dir ) ) {
return false;
}
$htaccess = $dir . '/.htaccess';
if ( file_exists( $htaccess ) ) {
return true;
}
if ( ! is_writable( $dir ) || ! $this->has_certificate_file( $dir ) ) {
return false;
}
$content = "\n\tRequire all denied\n\n";
$content .= "\n\tOrder deny,allow\n\tDeny from all\n\n";
return ( false !== file_put_contents( $htaccess, $content ) );
}
/**
* 証明書が置かれているディレクトリかを判定する
*
* クライアント証明書(.pem)かCAファイル(.crt)が1つでもあれば true.
* 拡張子はアップロード時の検証と揃えてある.
* 証明書が無いディレクトリでは決済設定画面の表示ごとにこの判定が走るため、
* ファイル名を配列に溜めずに1件ずつ調べ、見つかった時点で打ち切る.
*
* @param string $dir Certificate directory path.
* @return bool True if the directory holds a certificate file.
*/
private function has_certificate_file( $dir ) {
$handle = opendir( $dir );
if ( false === $handle ) {
return false;
}
$extensions = array( 'pem', 'crt' );
$found = false;
while ( false !== ( $entry = readdir( $handle ) ) ) {
if ( in_array( strtolower( pathinfo( $entry, PATHINFO_EXTENSION ) ), $extensions, true ) ) {
$found = true;
break;
}
}
closedir( $handle );
return $found;
}
/**
* 決済有効判定
* 支払方法で使用している場合に 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_paygent_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_paygent_conv' == $payment['settlement'] && 'activate' == $payment['use'] ) {
$method = true;
break;
}
}
if ( $method && $this->is_activate_conv() ) {
return true;
} else {
return false;
}
break;
case 'atm':
foreach ( $payment_method as $payment ) {
if ( 'acting_paygent_atm' == $payment['settlement'] && 'activate' == $payment['use'] ) {
$method = true;
break;
}
}
if ( $method && $this->is_activate_atm() ) {
return true;
} else {
return false;
}
break;
case 'bank':
foreach ( $payment_method as $payment ) {
if ( 'acting_paygent_bank' == $payment['settlement'] && 'activate' == $payment['use'] ) {
$method = true;
break;
}
}
if ( $method && $this->is_activate_bank() ) {
return true;
} else {
return false;
}
break;
case 'paidy':
foreach ( $payment_method as $payment ) {
if ( 'acting_paygent_paidy' == $payment['settlement'] && 'activate' == $payment['use'] ) {
$method = true;
break;
}
}
if ( $method && $this->is_activate_paidy() ) {
return true;
} else {
return false;
}
break;
default:
if ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) {
return true;
} else {
return false;
}
}
}
/**
* クレジットカード決済有効判定
*
* @param string $type 'link'|'module'.
* @return boolean
*/
public function is_activate_card( $type = '' ) {
$acting_opts = $this->get_acting_settings();
if ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) {
if ( empty( $type ) ) {
if ( isset( $acting_opts['card_activate'] ) && ( 'off' != $acting_opts['card_activate'] ) ) {
$res = true;
} else {
$res = false;
}
} elseif ( 'link' == $type ) {
if ( isset( $acting_opts['card_activate'] ) && ( 'on' == $acting_opts['card_activate'] ) ) {
$res = true;
} else {
$res = false;
}
} elseif ( 'module' == $type ) {
if ( isset( $acting_opts['card_activate'] ) && ( 'module' == $acting_opts['card_activate'] ) ) {
$res = true;
} else {
$res = false;
}
} else {
$res = false;
}
} else {
$res = false;
}
return $res;
}
/**
* コンビニ決済有効判定
*
* @param string $type 'link'|'module'.
* @return boolean
*/
public function is_activate_conv( $type = '' ) {
$acting_opts = $this->get_acting_settings();
if ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) {
if ( empty( $type ) ) {
if ( isset( $acting_opts['conv_activate'] ) && ( 'off' != $acting_opts['conv_activate'] ) ) {
$res = true;
} else {
$res = false;
}
} elseif ( 'link' == $type ) {
if ( isset( $acting_opts['conv_activate'] ) && ( 'on' == $acting_opts['conv_activate'] ) ) {
$res = true;
} else {
$res = false;
}
} elseif ( 'module' == $type ) {
if ( isset( $acting_opts['conv_activate'] ) && ( 'module' == $acting_opts['conv_activate'] ) ) {
$res = true;
} else {
$res = false;
}
} else {
$res = false;
}
} else {
$res = false;
}
return $res;
}
/**
* ATM決済(Pay-easy)有効判定
*
* @return boolean
*/
public function is_activate_atm() {
$acting_opts = $this->get_acting_settings();
if ( ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) &&
( isset( $acting_opts['atm_activate'] ) && 'module' == $acting_opts['atm_activate'] ) ) {
$res = true;
} else {
$res = false;
}
return $res;
}
/**
* 銀行ネット決済有効判定
*
* @return boolean
*/
public function is_activate_bank() {
$acting_opts = $this->get_acting_settings();
if ( ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) &&
( isset( $acting_opts['bank_activate'] ) && 'module' == $acting_opts['bank_activate'] ) ) {
$res = true;
} else {
$res = false;
}
return $res;
}
/**
* Paidy決済有効判定
*
* @return boolean
*/
public function is_activate_paidy() {
$acting_opts = $this->get_acting_settings();
if ( ( isset( $acting_opts['activate'] ) && 'on' == $acting_opts['activate'] ) &&
( isset( $acting_opts['paidy_activate'] ) && 'module' == $acting_opts['paidy_activate'] ) ) {
$res = true;
} else {
$res = false;
}
return $res;
}
/**
* 未入金ステータス
* usces_filter_noreceipt_status
*
* @param array $noreceipt_status Receive payment notification.
* @return array
*/
public function noreceipt_status( $noreceipt_status ) {
if ( ! in_array( 'acting_paygent_conv', $noreceipt_status ) || ! in_array( 'acting_paygent_atm', $noreceipt_status ) || ! in_array( 'acting_paygent_bank', $noreceipt_status ) ) {
$noreceipt_status[] = 'acting_paygent_conv';
$noreceipt_status[] = 'acting_paygent_atm';
$noreceipt_status[] = 'acting_paygent_bank';
$noreceipt_status = array_unique( $noreceipt_status );
update_option( 'usces_noreceipt_status', $noreceipt_status );
}
return $noreceipt_status;
}
/**
* 管理画面スクリプト
* admin_print_footer_scripts
*/
public function admin_scripts() {
$admin_page = ( isset( $_GET['page'] ) ) ? wp_unslash( $_GET['page'] ) : '';
switch ( $admin_page ) :
/* クレジット決済設定画面 */
case 'usces_settlement':
$settlement_selected = get_option( 'usces_settlement_selected' );
if ( in_array( $this->paymod_id, (array) $settlement_selected ) ) :
$acting_opts = $this->get_acting_settings();
?>
get_order_acting_flg( $order_id );
}
}
if ( in_array( $acting_flg, $this->pay_method ) ) :
?>
'Forbidden' ), 403 );
}
check_admin_referer( 'admin_settlement', 'wc_nonce' );
$post_data = wp_unslash( $_POST );
$certificate_path = ( isset( $post_data['path'] ) ) ? rtrim( $post_data['path'], '/' ) : '';
$invalid_wrappers = array( 'phar://', 'php://', 'data://', 'zip://', 'rar://' );
foreach ( $invalid_wrappers as $wrapper ) {
if ( strpos( $certificate_path, $wrapper ) === 0 ) {
$data['status'] = '無効なファイルパスです';
wp_send_json( $data );
return;
}
}
if ( empty( $certificate_path ) ) {
$data['status'] = '証明書ファイルパスが指定されていません';
} else {
if ( ! is_dir( $certificate_path ) ) {
wp_mkdir_p( $certificate_path );
}
$this->protect_certificate_dir( $certificate_path );
if ( ! empty( $post_data['file'] ) ) {
$full_path = $certificate_path . '/' . $post_data['file'];
foreach ( $invalid_wrappers as $wrapper ) {
if ( strpos( $full_path, $wrapper ) !== false ) {
$data['status'] = '無効なファイルパスです';
wp_send_json( $data );
return;
}
}
if ( file_exists( $full_path ) ) {
$data['file_exists'] = 1;
}
}
$data['status'] = ( is_writable( $certificate_path ) ) ? 'OK' : '証明書ファイルパスのディレクトリに書き込み権限がありません';
}
wp_send_json( $data );
}
/**
* Upload paygent certificate file.
*/
public function upload_certificate_file() {
if ( ! current_user_can( 'wel_manage_setting' ) ) {
wp_send_json_error( array( 'message' => 'Forbidden' ), 403 );
}
check_admin_referer( 'admin_settlement', 'wc_nonce' );
$upfile = $_FILES['upfile'];
$acting_opts = $this->get_acting_settings();
$data = array( 'status' => '' );
$filename = $upfile['name'];
if ( strrpos( $filename, '.' ) === false ) {
$data['status'] = 'NG';
wp_send_json( $data );
return;
}
$ext = strtolower( pathinfo( $filename, PATHINFO_EXTENSION ) );
$type = ( isset( $_POST['upfile_type'] ) ) ? ( $_POST['upfile_type'] ) : '';
if ( 'client_file' === $type ) {
if ( 'pem' !== $ext ) {
$data['status'] = 'NG';
}
} elseif ( 'ca_file' === $type ) {
if ( 'crt' !== $ext ) {
$data['status'] = 'NG';
}
} else {
$data['status'] = 'NG';
}
if ( 'NG' != $data['status'] ) {
if ( 0 < $upfile['error'] ) {
$data['status'] = $upfile['error'];
} else {
$this->protect_certificate_dir( $acting_opts['certificate_path'] );
$filename = sanitize_file_name( $upfile['name'] );
$res = move_uploaded_file( $upfile['tmp_name'], $acting_opts['certificate_path'] . '/' . $filename );
if ( $res ) {
$data['status'] = 'OK';
} else {
$data['status'] = 'NG';
}
}
}
wp_send_json( $data );
}
/**
* 決済オプション登録・更新
* usces_action_admin_settlement_update
*/
public function settlement_update() {
global $usces;
if ( $this->paymod_id != wp_unslash( $_POST['acting'] ) ) {
return;
}
$this->error_mes = '';
$payment_method = usces_get_system_option( 'usces_payment_method', 'settlement' );
$options = get_option( 'usces', array() );
$certificate_path = $options['acting_settings']['paygent']['certificate_path'];
$post_data = wp_unslash( $_POST );
unset( $options['acting_settings']['paygent'] );
$options['acting_settings']['paygent']['seq_merchant_id'] = ( isset( $post_data['seq_merchant_id'] ) ) ? trim( $post_data['seq_merchant_id'] ) : '';
$options['acting_settings']['paygent']['connect_id'] = ( isset( $post_data['connect_id'] ) ) ? trim( $post_data['connect_id'] ) : '';
$options['acting_settings']['paygent']['connect_password'] = ( isset( $post_data['connect_password'] ) ) ? trim( $post_data['connect_password'] ) : '';
$options['acting_settings']['paygent']['telegram_version'] = TELEGRAM_VERSION;
$options['acting_settings']['paygent']['hc'] = ( isset( $post_data['hc'] ) ) ? trim( $post_data['hc'] ) : '';
$options['acting_settings']['paygent']['conv_hc'] = ( isset( $post_data['conv_hc'] ) ) ? trim( $post_data['conv_hc'] ) : '';
$options['acting_settings']['paygent']['ope'] = ( isset( $post_data['ope'] ) ) ? $post_data['ope'] : '';
$options['acting_settings']['paygent']['card_activate'] = ( isset( $post_data['card_activate'] ) ) ? $post_data['card_activate'] : 'off';
$options['acting_settings']['paygent']['token_key'] = ( isset( $post_data['token_key'] ) ) ? trim( $post_data['token_key'] ) : '';
$options['acting_settings']['paygent']['token_hc'] = ( isset( $post_data['token_hc'] ) ) ? trim( $post_data['token_hc'] ) : '';
$options['acting_settings']['paygent']['client_file'] = ( isset( $post_data['client_file'] ) ) ? trim( $post_data['client_file'] ) : '';
$options['acting_settings']['paygent']['ca_file'] = ( isset( $post_data['ca_file'] ) ) ? trim( $post_data['ca_file'] ) : '';
$options['acting_settings']['paygent']['payment_class'] = ( isset( $post_data['payment_class'] ) ) ? $post_data['payment_class'] : '0';
$options['acting_settings']['paygent']['use_card_conf_number'] = ( isset( $post_data['use_card_conf_number'] ) ) ? $post_data['use_card_conf_number'] : 'off';
$options['acting_settings']['paygent']['stock_card_mode'] = ( isset( $post_data['stock_card_mode'] ) ) ? $post_data['stock_card_mode'] : 'off';
$options['acting_settings']['paygent']['sales_mode'] = ( isset( $post_data['sales_mode'] ) ) ? $post_data['sales_mode'] : '0';
$options['acting_settings']['paygent']['sales_mode_dlseller'] = ( isset( $post_data['sales_mode_dlseller'] ) ) ? $post_data['sales_mode_dlseller'] : '0';
$options['acting_settings']['paygent']['auto_settlement_mail'] = ( isset( $post_data['auto_settlement_mail'] ) ) ? $post_data['auto_settlement_mail'] : 'off';
$options['acting_settings']['paygent']['threedsecure_ryaku'] = ( isset( $post_data['threedsecure_ryaku'] ) ) ? $post_data['threedsecure_ryaku'] : 'off';
$options['acting_settings']['paygent']['threedsecure_hc'] = ( isset( $post_data['threedsecure_hc'] ) ) ? trim( $post_data['threedsecure_hc'] ) : '';
$options['acting_settings']['paygent']['attempt'] = ( isset( $post_data['attempt'] ) ) ? $post_data['attempt'] : 'on';
$options['acting_settings']['paygent']['conv_activate'] = ( isset( $post_data['conv_activate'] ) ) ? $post_data['conv_activate'] : 'off';
$options['acting_settings']['paygent']['payment_term_day'] = ( isset( $post_data['payment_term_day'] ) ) ? $post_data['payment_term_day'] : '5';
$options['acting_settings']['paygent']['payment_term_min'] = ( isset( $post_data['payment_term_min'] ) ) ? $post_data['payment_term_min'] : '';
$options['acting_settings']['paygent']['sales_type'] = ( isset( $post_data['sales_type'] ) ) ? $post_data['sales_type'] : '1';
$options['acting_settings']['paygent']['cvs_type'] = ( isset( $post_data['cvs_type'] ) ) ? $post_data['cvs_type'] : array( '01', '02', '03', '04' );
$options['acting_settings']['paygent']['atm_activate'] = ( isset( $post_data['atm_activate'] ) ) ? $post_data['atm_activate'] : 'off';
$options['acting_settings']['paygent']['payment_limit_date'] = ( isset( $post_data['payment_limit_date'] ) ) ? $post_data['payment_limit_date'] : '';
$options['acting_settings']['paygent']['bank_activate'] = ( isset( $post_data['bank_activate'] ) ) ? $post_data['bank_activate'] : 'off';
$options['acting_settings']['paygent']['asp_payment_term'] = ( isset( $post_data['asp_payment_term'] ) ) ? $post_data['asp_payment_term'] : '0050000';
$options['acting_settings']['paygent']['paidy_activate'] = ( isset( $post_data['paidy_activate'] ) ) ? $post_data['paidy_activate'] : 'off';
$options['acting_settings']['paygent']['paidy_public_key'] = ( isset( $post_data['paidy_public_key'] ) ) ? $post_data['paidy_public_key'] : '';
if ( ! isset( $post_data['certificate_path'] ) || WCUtils::is_blank( $post_data['certificate_path'] ) ) {
$certificate_path_before = ( isset( $post_data['certificate_path_before'] ) ) ? $post_data['certificate_path_before'] : '';
if ( empty( $certificate_path ) || $certificate_path_before != $certificate_path ) {
$upload_dir = wp_upload_dir();
$dir = $this->create_certificate_path();
$options['acting_settings']['paygent']['certificate_path'] = $upload_dir['basedir'] . $dir;
} else {
$options['acting_settings']['paygent']['certificate_path'] = $certificate_path;
}
} else {
$options['acting_settings']['paygent']['certificate_path'] = rtrim( trim( $post_data['certificate_path'] ), '/' );
}
if ( WCUtils::is_blank( $options['acting_settings']['paygent']['seq_merchant_id'] ) ) {
$this->error_mes .= '※マーチャントIDを入力してください
';
}
if ( 'on' == $options['acting_settings']['paygent']['card_activate'] || 'on' == $options['acting_settings']['paygent']['conv_activate'] ) {
if ( WCUtils::is_blank( $options['acting_settings']['paygent']['hc'] ) ) {
$this->error_mes .= '※ハッシュ値生成キーを入力してください
';
}
} elseif ( 'module' == $options['acting_settings']['paygent']['card_activate'] || 'module' == $options['acting_settings']['paygent']['conv_activate'] ) {
if ( '' == $options['acting_settings']['paygent']['connect_id'] ) {
$this->error_mes .= '※接続IDを入力してください
';
}
if ( '' == $options['acting_settings']['paygent']['connect_password'] ) {
$this->error_mes .= '※接続パスワードを入力してください
';
}
if ( '' != $options['acting_settings']['paygent']['client_file'] ) {
if ( ! file_exists( $options['acting_settings']['paygent']['certificate_path'] . '/' . $options['acting_settings']['paygent']['client_file'] ) ) {
$this->error_mes .= '※クライアント証明書ファイルがアップロードされていません
';
}
}
if ( '' != $options['acting_settings']['paygent']['ca_file'] ) {
if ( ! file_exists( $options['acting_settings']['paygent']['certificate_path'] . '/' . $options['acting_settings']['paygent']['ca_file'] ) ) {
$this->error_mes .= '※CAファイルがアップロードされていません
';
}
}
}
if ( WCUtils::is_blank( $options['acting_settings']['paygent']['ope'] ) ) {
$this->error_mes .= '※稼働環境を選択してください
';
}
if ( WCUtils::is_blank( $options['acting_settings']['paygent']['conv_hc'] ) ) {
$this->error_mes .= '※差分通知ハッシュ値生成キーを入力してください
';
}
if ( 'on' == $options['acting_settings']['paygent']['conv_activate'] ) {
if ( '' == $options['acting_settings']['paygent']['payment_term_day'] && '' == $options['acting_settings']['paygent']['payment_term_min'] ) {
} elseif ( '' != $options['acting_settings']['paygent']['payment_term_day'] && '' != $options['acting_settings']['paygent']['payment_term_min'] ) {
$this->error_mes .= '※「支払期間(日指定)」と「支払期間(分指定)」の両方を指定することはできません
';
} elseif ( '' != $options['acting_settings']['paygent']['payment_term_day'] ) {
$term_day = (int) $options['acting_settings']['paygent']['payment_term_day'];
if ( 2 > $term_day || 60 < $term_day ) {
$this->error_mes .= '※「支払期間(日指定)」が指定できる範囲を超えています
';
}
} elseif ( '' != $options['acting_settings']['paygent']['payment_term_min'] ) {
$term_min = (int) $options['acting_settings']['paygent']['payment_term_min'];
if ( 5 > $term_min || 2880 < $term_min ) {
$this->error_mes .= '※「支払期間(分指定)」が指定できる範囲を超えています
';
}
}
} elseif ( 'module' == $options['acting_settings']['paygent']['conv_activate'] ) {
if ( empty( $options['acting_settings']['paygent']['cvs_type'] ) ) {
$this->error_mes .= '※申込コンビニを選択してください
';
}
}
if ( 'module' == $options['acting_settings']['paygent']['paidy_activate'] ) {
if ( WCUtils::is_blank( $options['acting_settings']['paygent']['paidy_public_key'] ) ) {
$this->error_mes .= '※パブリックキーを入力してください
';
}
}
if ( '' == $this->error_mes ) {
$usces->action_status = 'success';
$usces->action_message = __( 'Options are updated.', 'usces' );
$toactive = array();
if ( 'on' == $options['acting_settings']['paygent']['card_activate'] || 'module' == $options['acting_settings']['paygent']['card_activate'] ) {
$usces->payment_structure['acting_paygent_card'] = 'カード決済(' . $this->acting_name . ')';
if ( '' == $options['acting_settings']['paygent']['payment_class'] ) {
$options['acting_settings']['paygent']['payment_class'] = '0';
}
if ( '' == $options['acting_settings']['paygent']['use_card_conf_number'] ) {
$options['acting_settings']['paygent']['use_card_conf_number'] = 'off';
}
if ( '' == $options['acting_settings']['paygent']['stock_card_mode'] ) {
$options['acting_settings']['paygent']['stock_card_mode'] = 'off';
}
if ( '' == $options['acting_settings']['paygent']['threedsecure_ryaku'] ) {
$options['acting_settings']['paygent']['threedsecure_ryaku'] = 'off';
}
foreach ( $payment_method as $settlement => $payment ) {
if ( 'acting_paygent_card' == $settlement && 'deactivate' == $payment['use'] ) {
$toactive[] = $payment['name'];
}
}
} else {
unset( $usces->payment_structure['acting_paygent_card'] );
}
if ( 'on' == $options['acting_settings']['paygent']['conv_activate'] || 'module' == $options['acting_settings']['paygent']['conv_activate'] ) {
$usces->payment_structure['acting_paygent_conv'] = 'コンビニ決済(' . $this->acting_name . ')';
if ( '' == $options['acting_settings']['paygent']['payment_term_day'] && '' == $options['acting_settings']['paygent']['payment_term_min'] ) {
$options['acting_settings']['paygent']['payment_term_day'] = 5;
}
foreach ( $payment_method as $settlement => $payment ) {
if ( 'acting_paygent_conv' == $settlement && 'deactivate' == $payment['use'] ) {
$toactive[] = $payment['name'];
}
}
} else {
unset( $usces->payment_structure['acting_paygent_conv'] );
}
if ( 'module' == $options['acting_settings']['paygent']['atm_activate'] ) {
$usces->payment_structure['acting_paygent_atm'] = 'ATM決済(' . $this->acting_name . ')';
foreach ( $payment_method as $settlement => $payment ) {
if ( 'acting_paygent_atm' == $settlement && 'deactivate' == $payment['use'] ) {
$toactive[] = $payment['name'];
}
}
} else {
unset( $usces->payment_structure['acting_paygent_atm'] );
}
if ( 'module' == $options['acting_settings']['paygent']['bank_activate'] ) {
$usces->payment_structure['acting_paygent_bank'] = '銀行ネット決済(' . $this->acting_name . ')';
foreach ( $payment_method as $settlement => $payment ) {
if ( 'acting_paygent_bank' == $settlement && 'deactivate' == $payment['use'] ) {
$toactive[] = $payment['name'];
}
}
} else {
unset( $usces->payment_structure['acting_paygent_bank'] );
}
if ( 'module' == $options['acting_settings']['paygent']['paidy_activate'] ) {
$usces->payment_structure['acting_paygent_paidy'] = 'Paidy(' . $this->acting_name . ')';
foreach ( $payment_method as $settlement => $payment ) {
if ( 'acting_paygent_paidy' == $settlement && 'deactivate' == $payment['use'] ) {
$toactive[] = $payment['name'];
}
}
} else {
unset( $usces->payment_structure['acting_paygent_paidy'] );
}
if ( ( 'on' == $options['acting_settings']['paygent']['card_activate'] || 'module' == $options['acting_settings']['paygent']['card_activate'] ) ||
( 'on' == $options['acting_settings']['paygent']['conv_activate'] || 'module' == $options['acting_settings']['paygent']['conv_activate'] ) ||
'module' == $options['acting_settings']['paygent']['atm_activate'] ||
'module' == $options['acting_settings']['paygent']['bank_activate'] ||
'module' == $options['acting_settings']['paygent']['paidy_activate'] ) {
$options['acting_settings']['paygent']['activate'] = 'on';
if ( 'public' == $options['acting_settings']['paygent']['ope'] ) {
$options['acting_settings']['paygent']['send_url'] = 'https://link.paygent.co.jp/v/u/request';
$options['acting_settings']['paygent']['token_url'] = 'https://token.paygent.co.jp/js/PaygentToken.js';
} else {
$options['acting_settings']['paygent']['send_url'] = 'https://sandbox.paygent.co.jp/v/u/request';
$options['acting_settings']['paygent']['token_url'] = 'https://sandbox.paygent.co.jp/js/PaygentToken.js';
}
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']['paygent']['activate'] = 'off';
unset( $usces->payment_structure['acting_paygent_card'] );
unset( $usces->payment_structure['acting_paygent_conv'] );
unset( $usces->payment_structure['acting_paygent_atm'] );
unset( $usces->payment_structure['acting_paygent_bank'] );
unset( $usces->payment_structure['acting_paygent_paidy'] );
}
$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']['paygent']['activate'] = 'off';
unset( $usces->payment_structure['acting_paygent_card'] );
unset( $usces->payment_structure['acting_paygent_conv'] );
unset( $usces->payment_structure['acting_paygent_atm'] );
unset( $usces->payment_structure['acting_paygent_bank'] );
unset( $usces->payment_structure['acting_paygent_paidy'] );
$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 ) ) :
/* 証明書ディレクトリの遮断ファイルを点検する. */
$this->protect_certificate_dir( ( isset( $acting_opts['certificate_path'] ) ) ? $acting_opts['certificate_path'] : '' );
$seq_merchant_id = ( isset( $acting_opts['seq_merchant_id'] ) ) ? $acting_opts['seq_merchant_id'] : '';
$connect_id = ( isset( $acting_opts['connect_id'] ) ) ? $acting_opts['connect_id'] : '';
$connect_password = ( isset( $acting_opts['connect_password'] ) ) ? $acting_opts['connect_password'] : '';
$hc = ( isset( $acting_opts['hc'] ) ) ? $acting_opts['hc'] : '';
$conv_hc = ( isset( $acting_opts['conv_hc'] ) ) ? $acting_opts['conv_hc'] : '';
$ope_test = '';
$ope_public = '';
if ( isset( $acting_opts['ope'] ) && 'public' == $acting_opts['ope'] ) {
$ope_public = ' checked="checked"';
} else {
$ope_test = ' checked="checked"'; /* default */
}
$card_activate_link = '';
$card_activate_module = '';
$card_activate_off = '';
if ( isset( $acting_opts['card_activate'] ) && 'on' == $acting_opts['card_activate'] ) {
$card_activate_link = ' checked="checked"';
} elseif ( isset( $acting_opts['card_activate'] ) && 'module' == $acting_opts['card_activate'] ) {
$card_activate_module = ' checked="checked"';
} else {
$card_activate_off = ' checked="checked"';
}
$token_key = ( isset( $acting_opts['token_key'] ) ) ? $acting_opts['token_key'] : '';
$token_hc = ( isset( $acting_opts['token_hc'] ) ) ? $acting_opts['token_hc'] : '';
$certificate_path = ( isset( $acting_opts['certificate_path'] ) ) ? $acting_opts['certificate_path'] : '';
$client_file = ( isset( $acting_opts['client_file'] ) ) ? $acting_opts['client_file'] : '';
$ca_file = ( isset( $acting_opts['ca_file'] ) ) ? $acting_opts['ca_file'] : '';
$client_file_disabled = '';
$ca_file_disabled = '';
$payment_class_0 = '';
$payment_class_1 = '';
$payment_class_2 = '';
if ( isset( $acting_opts['payment_class'] ) && '1' == $acting_opts['payment_class'] ) {
$payment_class_1 = ' checked="checked"';
} elseif ( isset( $acting_opts['payment_class'] ) && '2' == $acting_opts['payment_class'] ) {
$payment_class_2 = ' checked="checked"';
} else {
$payment_class_0 = ' checked="checked"'; /* default */
}
$use_card_conf_number_on = '';
$use_card_conf_number_off = '';
if ( isset( $acting_opts['use_card_conf_number'] ) && 'on' == $acting_opts['use_card_conf_number'] ) {
$use_card_conf_number_on = ' checked="checked"';
} else {
$use_card_conf_number_off = ' checked="checked"';
}
$stock_card_mode_on = '';
$stock_card_mode_off = '';
if ( isset( $acting_opts['stock_card_mode'] ) && 'on' == $acting_opts['stock_card_mode'] ) {
$stock_card_mode_on = ' checked="checked"';
} else {
$stock_card_mode_off = ' checked="checked"';
}
$stock_card_mode_msg = '';
if ( defined( 'WCEX_DLSELLER' ) ) {
$stock_card_mode_msg = '自動継続課金をご利用の場合は「利用する」を選択してください。';
} elseif ( defined( 'WCEX_AUTO_DELIVERY' ) ) {
$stock_card_mode_msg = '定期購入をご利用の場合は「利用する」を選択してください。';
}
$sales_mode_on = '';
$sales_mode_off = '';
if ( isset( $acting_opts['sales_mode'] ) && '1' == $acting_opts['sales_mode'] ) {
$sales_mode_on = ' checked="checked"';
} else {
$sales_mode_off = ' checked="checked"';
}
$sales_mode_dlseller_on = '';
$sales_mode_dlseller_off = '';
if ( isset( $acting_opts['sales_mode_dlseller'] ) && '1' == $acting_opts['sales_mode_dlseller'] ) {
$sales_mode_dlseller_on = ' checked="checked"';
} else {
$sales_mode_dlseller_off = ' checked="checked"';
}
$auto_settlement_mail_on = '';
$auto_settlement_mail_off = '';
if ( isset( $acting_opts['auto_settlement_mail'] ) && 'on' == $acting_opts['auto_settlement_mail'] ) {
$auto_settlement_mail_on = ' checked="checked"';
} else {
$auto_settlement_mail_off = ' checked="checked"';
}
$threedsecure_on = '';
$threedsecure_off = '';
if ( isset( $acting_opts['threedsecure_ryaku'] ) && 'on' == $acting_opts['threedsecure_ryaku'] ) {
$threedsecure_on = ' checked="checked"';
} else {
$threedsecure_off = ' checked="checked"';
}
$threedsecure_hc = ( isset( $acting_opts['threedsecure_hc'] ) ) ? $acting_opts['threedsecure_hc'] : '';
$attempt_on = '';
$attempt_off = '';
if ( isset( $acting_opts['attempt'] ) && 'on' == $acting_opts['attempt'] ) {
$attempt_on = ' checked="checked"';
} else {
$attempt_off = ' checked="checked"';
}
$conv_activate_link = '';
$conv_activate_module = '';
$conv_activate_off = '';
if ( isset( $acting_opts['conv_activate'] ) && 'on' == $acting_opts['conv_activate'] ) {
$conv_activate_link = ' checked="checked"';
} elseif ( isset( $acting_opts['conv_activate'] ) && 'module' == $acting_opts['conv_activate'] ) {
$conv_activate_module = ' checked="checked"';
} else {
$conv_activate_off = ' checked="checked"';
}
$payment_term_day = ( isset( $acting_opts['payment_term_day'] ) ) ? $acting_opts['payment_term_day'] : '5';
$payment_term_min = ( isset( $acting_opts['payment_term_min'] ) ) ? $acting_opts['payment_term_min'] : '';
$sales_type_1 = '';
$sales_type_3 = '';
if ( isset( $acting_opts['sales_type'] ) && '3' == $acting_opts['sales_type'] ) {
$sales_type_3 = ' checked="checked"';
} else {
$sales_type_1 = ' checked="checked"';
}
$cvs_type_01 = '';
$cvs_type_02 = '';
$cvs_type_03 = '';
$cvs_type_04 = '';
if ( isset( $acting_opts['cvs_type'] ) ) {
if ( in_array( '01', $acting_opts['cvs_type'] ) ) {
$cvs_type_01 = ' checked="checked"';
}
if ( in_array( '02', $acting_opts['cvs_type'] ) ) {
$cvs_type_02 = ' checked="checked"';
}
if ( in_array( '03', $acting_opts['cvs_type'] ) ) {
$cvs_type_03 = ' checked="checked"';
}
if ( in_array( '04', $acting_opts['cvs_type'] ) ) {
$cvs_type_04 = ' checked="checked"';
}
}
$atm_activate_link = '';
$atm_activate_module = '';
$atm_activate_off = '';
if ( isset( $acting_opts['atm_activate'] ) && 'module' == $acting_opts['atm_activate'] ) {
$atm_activate_module = ' checked="checked"';
} else {
$atm_activate_off = ' checked="checked"';
}
$payment_limit_date = ( isset( $acting_opts['payment_limit_date'] ) ) ? $acting_opts['payment_limit_date'] : '';
$bank_activate_link = '';
$bank_activate_module = '';
$bank_activate_off = '';
if ( isset( $acting_opts['bank_activate'] ) && 'module' == $acting_opts['bank_activate'] ) {
$bank_activate_module = ' checked="checked"';
} else {
$bank_activate_off = ' checked="checked"';
}
$asp_payment_term = ( isset( $acting_opts['asp_payment_term'] ) ) ? $acting_opts['asp_payment_term'] : '0050000';
$paidy_activate_module = '';
$paidy_activate_off = '';
if ( isset( $acting_opts['paidy_activate'] ) && 'module' == $acting_opts['paidy_activate'] ) {
$paidy_activate_module = ' checked="checked"';
} else {
$paidy_activate_off = ' checked="checked"';
}
$paidy_public_key = ( isset( $acting_opts['paidy_public_key'] ) ) ? $acting_opts['paidy_public_key'] : '';
?>
acting_formal_name ); ?>
paymod_id == wp_unslash( $_POST['acting'] ) ) : ?>
error_mes ) : ?>
error_mes ); ?>
十分にテストを行ってから運用してください。
acting_formal_name ); ?>
acting_name ); ?>の詳細はこちら 》
この決済は「外部リンク型(リンクタイプ)」と「非通過型(モジュールタイプ)」が選択できます。
リンクタイプでもペイジェントの決済システムと Welcart の決済データの連携機能を利用したい場合は、「クライアント証明書ファイル」と「CAファイル」をサーバーに設置する必要があります。また、ペイジェントの申込サービスタイプは「リンク+モジュール」モジュール使用は「同意済」になっている必要があります。詳細は「ペイジェント決済導入マニュアル」を参照してください。
決済通知ステータスの申請は「任意」となっていますが、以下のように申請してください。リンクタイプで利用する場合は※印のステータス通知は必須となります。
【クレジット決済】
■ 申込済※
■ オーソリNG
■ 3Dセキュア中断(3Dセキュア契約時のみ)
■ オーソリOK
■ オーソリ取消済
■ オーソリ期限切
■ 消込済
■ 消込済(売上取消期限切)
■ 売上取消済
【コンビニ決済】
■ 申込済※
■ 支払期限切
■ 消込済※
■ 速報検知済※
■ 速報取消済
【ATM決済】
■ 支払期限切
■ 消込済※
【銀行ネット決済】
■ 申込中断
■ 消込済※
【Paidy】
■ オーソリNG
■ オーソリOK
■ オーソリ取消済
■ オーソリ期限切
■ 消込済
■ 消込済(売上取消期限切)
■ 売上取消済
get_acting_settings();
$original_string = trim( $post_data['payment_notice_id'] ) . trim( $post_data['payment_id'] ) . trim( $post_data['trading_id'] ) . trim( $post_data['payment_type'] ) . trim( $post_data['payment_amount'] ) . trim( $acting_opts['conv_hc'] );
$hased_string = hash( 'sha256', $original_string );
if ( isset( $post_data['hc'] ) && $hased_string === $post_data['hc'] ) {
$payment_type = ( isset( $post_data['payment_type'] ) ) ? $post_data['payment_type'] : '';
$payment_status = $post_data['payment_status'];
switch ( $payment_type ) {
/* カード決済 */
case PAYMENT_TYPE_CREDIT:
switch ( $payment_status ) {
case STATUS_REQUESTED: /* 申込済 */
if ( ! empty( $post_data['trading_id'] ) ) {
$order_id = $this->get_order_id( $post_data['trading_id'] );
if ( ! $order_id ) {
if ( $this->is_activate_card( 'link' ) ) {
$order_data = usces_restore_order_acting_data( $post_data['trading_id'] );
if ( $order_data ) {
$res = $usces->order_processing( $post_data );
if ( 'ordercompletion' == $res ) {
if ( 'on' == $acting_opts['stock_card_mode'] ) {
if ( isset( $post_data['customer_id'] ) && isset( $post_data['customer_card_id'] ) ) {
$usces->set_member_meta_value( 'paygent_customer_card_id', $post_data['customer_card_id'], $post_data['customer_id'] );
}
}
$usces->cart->crear_cart();
} else {
$log = array(
'acting' => 'paygent_card',
'key' => $post_data['trading_id'],
'result' => 'ORDER DATA REGISTERED ERROR',
'data' => $post_data,
);
usces_save_order_acting_error( $log );
}
$order_id = $this->get_order_id( $post_data['trading_id'] );
if ( $order_id ) {
$post_data = apply_filters( 'usces_filter_paygent_card_acting_transaction_log', $post_data, $order_id, $post_data['trading_id'] );
$this->save_acting_log( $post_data, 'paygent_card', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
}
}
}
} else {
$post_data = apply_filters( 'usces_filter_paygent_card_acting_transaction_log', $post_data, $order_id, $post_data['trading_id'] );
$this->save_acting_log( $post_data, 'paygent_card', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
}
}
break;
case STATUS_AUTHORIZE_NG: /* オーソリNG */
case STATUS_AUTHORIZE_OK: /* オーソリOK */
case STATUS_AUTHORIZE_CANCELED: /* オーソリ取消済 */
case STATUS_AUTHORIZE_EXPIRED: /* オーソリ期限切 */
case STATUS_CLEARED: /* 消込済 */
case STATUS_CLEARED_SALES_CANCEL_INVALIDITY: /* 消込済(売上取消期限切) */
case STATUS_SALES_CANCELED: /* 売上取消済 */
case STATUS_3DSECURE_INTERRUPTION: /* 3Dセキュア中断 */
case STATUS_3DSECURE_CERTIFICATION: /* 3Dセキュア認証 */
$order_id = $this->get_order_id( $post_data['trading_id'] );
if ( $order_id ) {
$post_data = apply_filters( 'usces_filter_paygent_card_acting_transaction_log', $post_data, $order_id, $post_data['trading_id'] );
$this->save_acting_log( $post_data, 'paygent_card', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
}
break;
case STATUS_SALES_CANCELING: /* 売上取消中 */
case STATUS_SALES_CANCELING_TALLY: /* 売上取消集計中 */
$order_id = $this->get_order_id( $post_data['trading_id'] );
if ( $order_id ) {
$post_data = apply_filters( 'usces_filter_paygent_card_acting_transaction_log', $post_data, $order_id, $post_data['trading_id'] );
$this->save_acting_log( $post_data, 'paygent_card', $payment_status, RESULT_STATUS_ERROR, $order_id, $post_data['trading_id'] );
}
break;
}
break;
/* コンビニ決済 */
case PAYMENT_TYPE_CONVENI_NUM:
switch ( $payment_status ) {
case STATUS_REQUESTED: /* 申込済 */
if ( ! empty( $post_data['trading_id'] ) ) {
$order_id = $this->get_order_id( $post_data['trading_id'] );
if ( ! $order_id ) {
if ( $this->is_activate_conv( 'link' ) ) {
$order_data = usces_restore_order_acting_data( $post_data['trading_id'] );
if ( $order_data ) {
$res = $usces->order_processing( $post_data );
if ( 'ordercompletion' == $res ) {
$usces->cart->crear_cart();
} else {
$log = array(
'acting' => 'paygent_conv',
'key' => $post_data['trading_id'],
'result' => 'ORDER DATA REGISTERED ERROR',
'data' => $post_data,
);
usces_save_order_acting_error( $log );
}
$order_id = $this->get_order_id( $post_data['trading_id'] );
if ( $order_id ) {
$this->save_acting_log( $post_data, 'paygent_conv', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
}
}
}
} else {
$this->save_acting_log( $post_data, 'paygent_conv', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
}
}
break;
case STATUS_PRELIMINARY_DETECTED: /* 速報検地済 */
case STATUS_CLEARED: /* 消込済 */
$order_id = $this->get_order_id( $post_data['trading_id'] );
if ( $order_id ) {
$this->save_acting_log( $post_data, 'paygent_conv', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
$order_status = $this->get_order_status( $order_id );
if ( 0 == $order_status ) {
$res = usces_change_order_receipt( $order_id, 'receipted' );
if ( false === $res ) {
$log = array(
'acting' => 'paygent_conv',
'key' => $post_data['trading_id'],
'result' => 'ORDER DATA UPDATE ERROR',
'data' => $post_data,
);
usces_save_order_acting_error( $log );
} else {
usces_action_acting_getpoint( $order_id );
$usces->set_order_meta_value( 'acting_paygent_conv', usces_serialize( $post_data ), $order_id );
if ( STATUS_CLEARED === $payment_status ) {
do_action( 'usces_action_paygent_conv_payment_completion', $post_data, $order_id );
}
}
}
}
break;
case STATUS_PRELIMINARY_CANCELED: /* 速報取消済 */
$order_id = $this->get_order_id( $post_data['trading_id'] );
if ( $order_id ) {
$this->save_acting_log( $post_data, 'paygent_conv', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
$order_status = $this->get_order_status( $order_id );
if ( 0 < $order_status ) {
$res = usces_change_order_receipt( $order_id, 'noreceipt' );
if ( false === $res ) {
$log = array(
'acting' => 'paygent_conv',
'key' => $post_data['trading_id'],
'result' => 'ORDER DATA UPDATE ERROR',
'data' => $post_data,
);
usces_save_order_acting_error( $log );
} else {
usces_action_acting_getpoint( $order_id, false );
}
}
}
break;
case STATUS_PAYMENT_EXPIRED: /* 支払期限切 */
$order_id = $this->get_order_id( $post_data['trading_id'] );
if ( $order_id ) {
$this->save_acting_log( $post_data, 'paygent_conv', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
}
break;
}
break;
/* ATM決済 */
case PAYMENT_TYPE_ATM:
switch ( $payment_status ) {
case STATUS_PAYMENT_EXPIRED: /* 支払期限切 */
$order_id = $this->get_order_id( $post_data['trading_id'] );
if ( $order_id ) {
$this->save_acting_log( $post_data, 'paygent_atm', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
}
break;
case STATUS_CLEARED: /* 消込済 */
$order_id = $this->get_order_id( $post_data['trading_id'] );
if ( $order_id ) {
$this->save_acting_log( $post_data, 'paygent_atm', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
$order_status = $this->get_order_status( $order_id );
if ( 0 == $order_status ) {
$res = usces_change_order_receipt( $order_id, 'receipted' );
if ( false === $res ) {
$log = array(
'acting' => 'paygent_atm',
'key' => $post_data['trading_id'],
'result' => 'ORDER DATA UPDATE ERROR',
'data' => $post_data,
);
usces_save_order_acting_error( $log );
} else {
usces_action_acting_getpoint( $order_id );
$usces->set_order_meta_value( 'acting_paygent_atm', usces_serialize( $post_data ), $order_id );
do_action( 'usces_action_paygent_atm_payment_completion', $post_data, $order_id );
}
}
}
break;
}
break;
/* 銀行ネット決済 */
case PAYMENT_TYPE_BANK:
switch ( $payment_status ) {
case STATUS_REGISTRATION_SUSPENDED: /* 申込中断 */
$order_id = $this->get_order_id( $post_data['trading_id'] );
if ( $order_id ) {
$this->save_acting_log( $post_data, 'paygent_bank', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
}
break;
case STATUS_CLEARED: /* 消込済 */
$order_id = $this->get_order_id( $post_data['trading_id'] );
if ( $order_id ) {
$this->save_acting_log( $post_data, 'paygent_bank', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
$order_status = $this->get_order_status( $order_id );
if ( 0 == $order_status ) {
$res = usces_change_order_receipt( $order_id, 'receipted' );
if ( false === $res ) {
$log = array(
'acting' => 'paygent_bank',
'key' => $post_data['trading_id'],
'result' => 'ORDER DATA UPDATE ERROR',
'data' => $post_data,
);
usces_save_order_acting_error( $log );
} else {
usces_action_acting_getpoint( $order_id );
$usces->set_order_meta_value( 'acting_paygent_bank', usces_serialize( $post_data ), $order_id );
do_action( 'usces_action_paygent_bank_payment_completion', $post_data, $order_id );
}
}
}
break;
}
break;
/* Paidy */
case PAYMENT_TYPE_PAIDY:
switch ( $payment_status ) {
case STATUS_AUTHORIZE_NG: /* オーソリNG */
case STATUS_AUTHORIZE_OK: /* オーソリOK */
case STATUS_AUTHORIZE_CANCELED: /* オーソリ取消済 */
case STATUS_AUTHORIZE_EXPIRED: /* オーソリ期限切 */
case STATUS_CLEARED: /* 消込済 */
case STATUS_CLEARED_SALES_CANCEL_INVALIDITY: /* 消込済(売上取消期限切) */
case STATUS_SALES_CANCELED: /* 売上取消済 */
$order_id = $this->get_order_id( $post_data['trading_id'] );
if ( $order_id ) {
$this->save_acting_log( $post_data, 'paygent_paidy', $payment_status, RESULT_STATUS_NORMAL, $order_id, $post_data['trading_id'] );
}
break;
}
break;
}
}
die( 'result=0' );
}
}
/**
* ポイント即時付与
* usces_filter_is_complete_settlement
*
* @param boolean $complete Complete the payment.
* @param string $payment_name Payment name.
* @param string $status Payment status.
* @return boolean
*/
public function is_complete_settlement( $complete, $payment_name, $status ) {
$payment = usces_get_payments_by_name( $payment_name );
if ( isset( $payment['settlement'] ) && ( 'acting_paygent_card' == $payment['settlement'] || 'acting_paygent_paidy' == $payment['settlement'] ) ) {
$complete = true;
}
return $complete;
}
/**
* 管理画面決済処理
* usces_action_admin_ajax
*/
public function admin_ajax() {
global $usces;
$post_data = wp_unslash( $_POST );
$mode = sanitize_title( $post_data['mode'] );
$data = array();
switch ( $mode ) {
/* クレジットカード参照 */
case 'get_paygent_card':
check_admin_referer( 'order_edit', 'wc_nonce' );
$order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
$trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
$member_id = ( isset( $post_data['member_id'] ) ) ? $post_data['member_id'] : '';
if ( empty( $order_id ) || empty( $trading_id ) ) {
$data['status'] = 'reference_error';
wp_send_json( $data );
break;
}
$latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
$payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
$data = $this->settlement_reference_card( $order_id, $trading_id, $payment_id, $member_id );
wp_send_json( $data );
break;
/* クレジットカード売上処理 */
case 'sales_paygent_card':
check_admin_referer( 'order_edit', 'wc_nonce' );
$order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
$trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
if ( empty( $order_id ) || empty( $trading_id ) ) {
$data['status'] = 'reference_error';
wp_send_json( $data );
break;
}
$result = '';
$status = '';
$latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
$payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
$telegram_kind = PAYGENT_CARD_COMMIT;
$settlement = $this->settlement_request( $telegram_kind, $trading_id, $payment_id );
$settlement = apply_filters( 'usces_filter_paygent_card_acting_sales_log', $settlement, $order_id, $trading_id );
if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
$this->save_acting_log( $settlement, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
$status = 'payment_error';
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
$result .= '';
$result .= $this->settlement_history( $order_id, $trading_id );
$data['result'] = $result;
$data['status'] = $status;
} else {
$this->save_acting_log( $settlement, 'paygent_card', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
$data = $this->settlement_reference_card( $order_id, $trading_id, $payment_id );
}
$this->save_admin_log( $order_id, $trading_id );
wp_send_json( $data );
break;
/* クレジットカードオーソリ取消 */
case 'auth_cancel_paygent_card':
check_admin_referer( 'order_edit', 'wc_nonce' );
$order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
$trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
if ( empty( $order_id ) || empty( $trading_id ) ) {
$data['status'] = 'reference_error';
wp_send_json( $data );
break;
}
$result = '';
$status = '';
$latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
$payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
$telegram_kind = PAYGENT_AUTH_CANCEL;
$settlement = $this->settlement_request( $telegram_kind, $trading_id, $payment_id );
$settlement = apply_filters( 'usces_filter_paygent_card_acting_auth_cancel_log', $settlement, $order_id, $trading_id );
if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
$this->save_acting_log( $settlement, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
$status = 'payment_error';
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
$result .= '';
$result .= $this->settlement_history( $order_id, $trading_id );
$data['result'] = $result;
$data['status'] = $status;
} else {
$this->save_acting_log( $settlement, 'paygent_card', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
$data = $this->settlement_reference_card( $order_id, $trading_id, $payment_id );
}
$this->save_admin_log( $order_id, $trading_id );
wp_send_json( $data );
break;
/* クレジットカードオーソリ変更 */
case 'auth_revise_paygent_card':
check_admin_referer( 'order_edit', 'wc_nonce' );
$order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
$trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
$amount = ( isset( $post_data['amount'] ) ) ? $post_data['amount'] : '';
if ( empty( $order_id ) || empty( $trading_id ) || empty( $amount ) ) {
$data['status'] = 'reference_error';
wp_send_json( $data );
break;
}
$result = '';
$status = '';
$latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
$payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
$telegram_kind = PAYGENT_CARD_COMMIT_AUTH_REVISE;
$settlement = $this->settlement_request_revise( $telegram_kind, $trading_id, $payment_id, $amount );
$settlement = apply_filters( 'usces_filter_paygent_card_acting_auth_revise_log', $settlement, $order_id, $trading_id );
if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
$this->save_acting_log( $settlement, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
$status = 'payment_error';
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
$result .= '';
$result .= $this->settlement_history( $order_id, $trading_id );
$data['result'] = $result;
$data['status'] = $status;
} else {
$this->save_acting_log( $settlement, 'paygent_card', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
$data = $this->settlement_reference_card( $order_id, $trading_id, $payment_id );
}
$this->save_admin_log( $order_id, $trading_id );
wp_send_json( $data );
break;
/* クレジットカード売上取消(キャンセル処理) */
case 'sales_cancel_paygent_card':
check_admin_referer( 'order_edit', 'wc_nonce' );
$order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
$trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
if ( empty( $order_id ) || empty( $trading_id ) ) {
$data['status'] = 'reference_error';
wp_send_json( $data );
break;
}
$result = '';
$status = '';
$latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
$payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
$telegram_kind = PAYGENT_CARD_COMMIT_CANCEL;
$settlement = $this->settlement_request( $telegram_kind, $trading_id, $payment_id );
$settlement = apply_filters( 'usces_filter_paygent_card_acting_sales_cancel_log', $settlement, $order_id, $trading_id );
if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
$this->save_acting_log( $settlement, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
$status = 'payment_error';
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
$result .= '';
$result .= $this->settlement_history( $order_id, $trading_id );
$data['result'] = $result;
$data['status'] = $status;
} else {
$this->save_acting_log( $settlement, 'paygent_card', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
$data = $this->settlement_reference_card( $order_id, $trading_id, $payment_id );
}
$this->save_admin_log( $order_id, $trading_id );
wp_send_json( $data );
break;
/* クレジットカード売上金額変更(売上変更) */
case 'sales_revise_paygent_card':
check_admin_referer( 'order_edit', 'wc_nonce' );
$order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
$trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
$amount = ( isset( $post_data['amount'] ) ) ? $post_data['amount'] : '';
if ( empty( $order_id ) || empty( $trading_id ) || empty( $amount ) ) {
$data['status'] = 'reference_error';
wp_send_json( $data );
break;
}
$result = '';
$status = '';
$latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
$payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
$telegram_kind = PAYGENT_CARD_COMMIT_REVISE;
$settlement = $this->settlement_request_revise( $telegram_kind, $trading_id, $payment_id, $amount );
$settlement = apply_filters( 'usces_filter_paygent_card_acting_sales_revise_log', $settlement, $order_id, $trading_id );
if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
$this->save_acting_log( $settlement, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
$status = 'payment_error';
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
$result .= '';
$result .= $this->settlement_history( $order_id, $trading_id );
$data['result'] = $result;
$data['status'] = $status;
} else {
$this->save_acting_log( $settlement, 'paygent_card', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
$data = $this->settlement_reference_card( $order_id, $trading_id, $payment_id );
}
$this->save_admin_log( $order_id, $trading_id );
wp_send_json( $data );
break;
/* クレジットカード新規オーソリ */
case 'auth_paygent_card':
check_admin_referer( 'order_edit', 'wc_nonce' );
$order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
$trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
$member_id = ( isset( $post_data['member_id'] ) ) ? $post_data['member_id'] : '';
$amount = ( isset( $post_data['amount'] ) ) ? $post_data['amount'] : '';
if ( empty( $order_id ) || empty( $trading_id ) || empty( $amount ) ) {
$data['status'] = 'reference_error';
wp_send_json( $data );
break;
}
$result = '';
$status = '';
// $trading_id = usces_acting_key();
$customer = $this->customer_ref( $member_id );
if ( isset( $customer['customer_id'] ) && $customer['customer_id'] == $member_id && isset( $customer['customer_card_id'] ) ) {
$telegram_kind = PAYGENT_CREDIT;
$pm = Paygent_Module::get_instance();
$pm->init();
$pm->req_put( 'trading_id', $trading_id );
$pm->req_put( 'payment_amount', $amount );
$pm->req_put( 'payment_class', '10' );
$pm->req_put( '3dsecure_ryaku', '1' );
$pm->req_put( 'stock_card_mode', '1' );
$pm->req_put( 'customer_id', $member_id );
$pm->req_put( 'customer_card_id', $customer['customer_card_id'] );
$pm->req_put( 'sales_mode', '0' ); /* Auth */
$result_post = $pm->post( $telegram_kind );
$result_status = $pm->get_result_status();
if ( ! ( true === $result_post ) || RESULT_STATUS_NORMAL != $result_status ) {
$response_data = array(
'result' => $result_post,
'result_status' => $result_status,
'response_code' => $pm->get_response_code(),
'response_detail' => $pm->get_response_detail(),
'result_message' => $pm->get_result_message(),
);
$this->save_acting_log( $response_data, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
$status = 'payment_error';
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
$result .= '';
$result .= $this->settlement_history( $order_id, $trading_id );
$data['result'] = $result;
$data['status'] = $status;
} else {
$response_data = $pm->get_response_data();
if ( ! isset( $response_data['payment_type'] ) ) {
$response_data['payment_type'] = PAYMENT_TYPE_CREDIT;
}
$this->save_acting_log( $response_data, 'paygent_card', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
$usces->set_order_meta_value( 'acting_paygent_card', usces_serialize( $response_data ), $order_id );
$payment_id = ( isset( $response_data['payment_id'] ) ) ? $response_data['payment_id'] : '';
$data = $this->settlement_reference_card( $order_id, $trading_id, $payment_id );
}
$this->save_admin_log( $order_id, $trading_id );
} else {
if ( ! isset( $customer['payment_type'] ) ) {
$customer['payment_type'] = PAYMENT_TYPE_CREDIT;
}
$this->save_acting_log( $customer, 'paygent_card', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
$status = 'payment_error';
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
$result .= '';
$result .= $this->settlement_history( $order_id, $trading_id );
$data['result'] = $result;
$data['status'] = $status;
$this->save_admin_log( $order_id, $trading_id );
}
wp_send_json( $data );
break;
/* コンビニ参照 */
case 'get_paygent_conv':
check_admin_referer( 'order_edit', 'wc_nonce' );
$order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
$trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
if ( empty( $order_id ) || empty( $trading_id ) ) {
$data['status'] = 'reference_error';
wp_send_json( $data );
break;
}
$result = '';
$status = '';
$latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
$payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
$settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
if ( isset( $settlement_ref['result_status'] ) && RESULT_STATUS_ERROR == $settlement_ref['result_status'] ) {
$status = 'reference_error';
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
} else {
$payment_status = ( isset( $settlement_ref['payment_status'] ) ) ? $settlement_ref['payment_status'] : '';
$status = $this->get_status( $payment_status );
$class = ' conv-' . $status;
$status_name = $this->get_status_name( $payment_status );
$result .= '' . $status_name . '
';
}
$result .= '';
$result .= $this->settlement_history( $order_id, $trading_id );
$data['result'] = $result;
$data['status'] = $status;
wp_send_json( $data );
break;
/* ATM参照 */
case 'get_paygent_atm':
check_admin_referer( 'order_edit', 'wc_nonce' );
$order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
$trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
if ( empty( $order_id ) || empty( $trading_id ) ) {
$data['status'] = 'reference_error';
wp_send_json( $data );
break;
}
$result = '';
$status = '';
$latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
$payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
$settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
if ( isset( $settlement_ref['result_status'] ) && RESULT_STATUS_ERROR == $settlement_ref['result_status'] ) {
$status = 'reference_error';
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
} else {
$payment_status = ( isset( $settlement_ref['payment_status'] ) ) ? $settlement_ref['payment_status'] : '';
$status = $this->get_status( $payment_status );
$class = ' atm-' . $status;
$status_name = $this->get_status_name( $payment_status );
$result .= '' . $status_name . '
';
}
$result .= '';
$result .= $this->settlement_history( $order_id, $trading_id );
$data['result'] = $result;
$data['status'] = $status;
wp_send_json( $data );
break;
/* 銀行ネット決済参照 */
case 'get_paygent_bank':
check_admin_referer( 'order_edit', 'wc_nonce' );
$order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
$trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
if ( empty( $order_id ) || empty( $trading_id ) ) {
$data['status'] = 'reference_error';
wp_send_json( $data );
break;
}
$result = '';
$status = '';
$acting_status = '';
$latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
$payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
$settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
if ( isset( $settlement_ref['result_status'] ) && RESULT_STATUS_ERROR == $settlement_ref['result_status'] ) {
if ( 'bank_applying' == $latest_log['status'] ) {
$status = 'bank_applying';
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
} else {
$status = 'reference_error';
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
}
} else {
$payment_status = ( isset( $settlement_ref['payment_status'] ) ) ? $settlement_ref['payment_status'] : '';
$status = $this->get_status( $payment_status );
$class = ' bank-' . $status;
$status_name = $this->get_status_name( $payment_status );
$result .= '' . $status_name . '
';
if ( 'bank_applying' == $latest_log['status'] && STATUS_REQUESTED == $payment_status ) {
$this->save_acting_log( $settlement_ref, 'paygent_bank', $payment_status, RESULT_STATUS_NORMAL, $order_id, $trading_id );
$acting_status = '' . $status_name . '';
}
}
$result .= '';
$result .= $this->settlement_history( $order_id, $trading_id );
$data['result'] = $result;
$data['status'] = $status;
$data['acting_status'] = $acting_status;
wp_send_json( $data );
break;
/* Paidy 参照 */
case 'get_paygent_paidy':
check_admin_referer( 'order_edit', 'wc_nonce' );
$order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
$trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
if ( empty( $order_id ) || empty( $trading_id ) ) {
$data['status'] = 'reference_error';
wp_send_json( $data );
break;
}
$latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
$payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
$data = $this->settlement_reference_paidy( $order_id, $trading_id, $payment_id );
wp_send_json( $data );
break;
/* Paidy オーソリキャンセル */
case 'cancel_paygent_paidy':
check_admin_referer( 'order_edit', 'wc_nonce' );
$order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
$trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
if ( empty( $order_id ) || empty( $trading_id ) ) {
$data['status'] = 'reference_error';
wp_send_json( $data );
break;
}
$result = '';
$status = '';
$latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
$payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
$telegram_kind = PAYGENT_PAIDY_AUTH_CANCEL;
$settlement = $this->settlement_request_paidy( $telegram_kind, $trading_id, $payment_id );
if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
$this->save_acting_log( $settlement, 'paygent_paidy', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
$status = 'payment_error';
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
$result .= '';
$result .= $this->settlement_history( $order_id, $trading_id );
$data['result'] = $result;
$data['status'] = $status;
} else {
$this->save_acting_log( $settlement, 'paygent_paidy', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
$data = $this->settlement_reference_paidy( $order_id, $trading_id );
}
wp_send_json( $data );
break;
/* Paidy 売上 */
case 'capture_paygent_paidy':
check_admin_referer( 'order_edit', 'wc_nonce' );
$order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
$trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
if ( empty( $order_id ) || empty( $trading_id ) ) {
$data['status'] = 'reference_error';
wp_send_json( $data );
break;
}
$result = '';
$status = '';
$latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
$payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
$telegram_kind = PAYGENT_PAIDY_CAPTURE;
$settlement = $this->settlement_request_paidy( $telegram_kind, $trading_id, $payment_id );
if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
$this->save_acting_log( $settlement, 'paygent_paidy', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
$status = 'payment_error';
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
$result .= '';
$result .= $this->settlement_history( $order_id, $trading_id );
$data['result'] = $result;
$data['status'] = $status;
} else {
$this->save_acting_log( $settlement, 'paygent_paidy', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
$data = $this->settlement_reference_paidy( $order_id, $trading_id );
}
wp_send_json( $data );
break;
/* Paidy 返金 */
case 'refund_paygent_paidy':
check_admin_referer( 'order_edit', 'wc_nonce' );
$order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
$trading_id = ( isset( $post_data['trading_id'] ) ) ? $post_data['trading_id'] : '';
$amount = ( isset( $post_data['amount'] ) ) ? $post_data['amount'] : '';
if ( empty( $order_id ) || empty( $trading_id ) || empty( $amount ) ) {
$data['status'] = 'reference_error';
wp_send_json( $data );
break;
}
$result = '';
$status = '';
$latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
$payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
$telegram_kind = PAYGENT_PAIDY_REFUND;
$settlement = $this->settlement_request_paidy_refund( $telegram_kind, $trading_id, $amount, $payment_id );
if ( isset( $settlement['result_status'] ) && RESULT_STATUS_ERROR == $settlement['result_status'] ) {
$this->save_acting_log( $settlement, 'paygent_paidy', 'payment_error', RESULT_STATUS_ERROR, $order_id, $trading_id );
$status = 'payment_error';
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
$result .= '';
$result .= $this->settlement_history( $order_id, $trading_id );
$data['result'] = $result;
$data['status'] = $status;
} else {
$this->save_acting_log( $settlement, 'paygent_paidy', $telegram_kind, RESULT_STATUS_NORMAL, $order_id, $trading_id );
$data = $this->settlement_reference_paidy( $order_id, $trading_id );
}
wp_send_json( $data );
break;
/* 継続課金情報更新 */
case 'continuation_update':
check_admin_referer( 'order_edit', 'wc_nonce' );
$order_id = ( isset( $post_data['order_id'] ) ) ? $post_data['order_id'] : '';
$member_id = ( isset( $post_data['member_id'] ) ) ? $post_data['member_id'] : '';
$contracted_year = ( isset( $post_data['contracted_year'] ) ) ? $post_data['contracted_year'] : '';
$contracted_month = ( isset( $post_data['contracted_month'] ) ) ? $post_data['contracted_month'] : '';
$contracted_day = ( isset( $post_data['contracted_day'] ) ) ? $post_data['contracted_day'] : '';
$charged_year = ( isset( $post_data['charged_year'] ) ) ? $post_data['charged_year'] : '';
$charged_month = ( isset( $post_data['charged_month'] ) ) ? $post_data['charged_month'] : '';
$charged_day = ( isset( $post_data['charged_day'] ) ) ? $post_data['charged_day'] : '';
$price = ( isset( $post_data['price'] ) ) ? $post_data['price'] : 0;
$status = ( isset( $post_data['status'] ) ) ? $post_data['status'] : '';
$continue_data = $this->get_continuation_data( $member_id, $order_id );
if ( ! $continue_data ) {
$data['status'] = 'NG';
wp_send_json( $data );
break;
}
/* 継続中→停止 */
if ( 'continuation' == $continue_data['status'] && 'cancellation' == $status ) {
$this->update_continuation_data( $member_id, $order_id, $continue_data, true );
} else {
if ( ! empty( $contracted_year ) && ! empty( $contracted_month ) && ! empty( $contracted_day ) ) {
$contracted_date = ( empty( $continue_data['contractedday'] ) ) ? dlseller_next_contracting( $order_id ) : $continue_data['contractedday'];
if ( $contracted_date ) {
$new_contracted_date = $contracted_year . '-' . $contracted_month . '-' . $contracted_day;
if ( ! $this->isdate( $new_contracted_date ) ) {
$data['status'] = 'NG';
$data['message'] = __( 'Next contract renewal date is incorrect.', 'dlseller' );
wp_send_json( $data );
}
}
} else {
$new_contracted_date = '';
}
$new_charged_date = $charged_year . '-' . $charged_month . '-' . $charged_day;
if ( ! $this->isdate( $new_charged_date ) ) {
$data['status'] = 'NG';
$data['message'] = __( 'Next settlement date is incorrect.', 'dlseller' );
wp_send_json( $data );
}
$tomorrow = date_i18n( 'Y-m-d', strtotime( '+1 day' ) );
if ( $new_charged_date < $tomorrow ) {
$data['status'] = 'NG';
$data['message'] = sprintf( __( 'The next settlement date must be after %s.', 'dlseller' ), $tomorrow );
wp_send_json( $data );
}
$continue_data['contractedday'] = $new_contracted_date;
$continue_data['chargedday'] = $new_charged_date;
$continue_data['price'] = usces_crform( $price, false, false, 'return', false );
$continue_data['status'] = $status;
$this->update_continuation_data( $member_id, $order_id, $continue_data );
}
$data['status'] = 'OK';
wp_send_json( $data );
break;
}
}
/**
* クレジットカード決済履歴
*
* @param int $order_id Order number.
* @param string $trading_id Trading ID.
* @param string $payment_id Payment ID.
* @param int $member_id Member ID.
* @return array
*/
private function settlement_reference_card( $order_id, $trading_id, $payment_id, $member_id = '' ) {
global $usces;
$data = array();
$result = '';
$status = '';
$acting_status = '';
if ( empty( $payment_id ) ) {
$latest_log = $this->get_acting_latest_log( $order_id, $trading_id, RESULT_STATUS_ALL );
if ( isset( $latest_log['status'] ) && ( 'payment_error' == $latest_log['status'] || 'customer_error' == $latest_log['status'] ) ) {
$customer = $this->customer_ref( $member_id );
if ( isset( $customer['customer_id'] ) && $customer['customer_id'] == $member_id ) {
$order_data = $usces->get_order_data( $order_id, 'direct' );
$amount = $order_data['order_item_total_price'] - $order_data['order_usedpoint'] + $order_data['order_discount'] + $order_data['order_shipping_charge'] + $order_data['order_cod_fee'] + $order_data['order_tax'];
$result .= '';
$result .= '';
$result .= '';
$result .= '';
$result .= '
';
} else {
$status = 'error';
$result .= '' . __( 'Credit card information not registered', 'usces' ) . '
';
$result .= '';
}
} else {
$status = 'error';
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
$result .= '';
}
} else {
$settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
if ( isset( $settlement_ref['result_status'] ) && RESULT_STATUS_ERROR == $settlement_ref['result_status'] ) {
$status = 'reference_error';
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
$result .= '';
} elseif ( isset( $settlement_ref['payment_status'] ) ) {
$payment_status = $settlement_ref['payment_status'];
$status = $this->get_status( $payment_status );
$class = ' card-' . $status;
$status_name = $this->get_status_name( $payment_status );
$amount = $settlement_ref['payment_amount'];
$result .= '' . $status_name . '
';
switch ( $payment_status ) {
case STATUS_AUTHORIZE_EXPIRED: /* オーソリ期限切 */
case STATUS_AUTHORIZE_CANCELED: /* オーソリ取消済 */
$result .= '';
$result .= '';
$result .= '';
$result .= '';
$result .= '
';
break;
case STATUS_AUTHORIZE_OK: /* オーソリOK */
$result .= '';
$result .= '';
$result .= '';
$result .= '';
$result .= '';
$result .= '';
$result .= '
';
break;
case STATUS_AUTHORIZE_CANCELING: /* オーソリ取消中 */
$result .= '';
$result .= '';
$result .= '';
$result .= '
';
break;
case STATUS_SALES_REQUEST_PENDING: /* 売上要求中 */
$result .= '';
$result .= '';
$result .= '';
$result .= '
';
break;
case STATUS_CLEARED: /* 消込済 */
$result .= '';
$result .= '';
$result .= '';
$result .= '';
$result .= '';
$result .= '
';
break;
case STATUS_SALES_CANCELING: /* 売上取消中 */
case STATUS_SALES_CANCELING_TALLY: /* 売上取消集計中 */
$result .= '';
$result .= '';
$result .= '';
$result .= '
';
break;
default:
$result .= '';
}
$acting_status = '' . $status_name . '';
} else {
$status = 'error';
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
$result .= '';
}
}
$result .= $this->settlement_history( $order_id, $trading_id );
$data['result'] = $result;
$data['status'] = $status;
$data['acting_status'] = $acting_status;
return $data;
}
/**
* Paidy 決済履歴
*
* @param int $order_id Order number.
* @param string $trading_id Trading ID.
* @param string $payment_id Payment ID.
* @return array
*/
private function settlement_reference_paidy( $order_id, $trading_id, $payment_id = '' ) {
$data = array();
$result = '';
$status = '';
$acting_status = '';
$settlement_ref = $this->settlement_ref( $order_id, $trading_id, $payment_id );
if ( isset( $settlement_ref['result_status'] ) && RESULT_STATUS_ERROR == $settlement_ref['result_status'] ) {
$status = 'reference_error';
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
$result .= '';
} elseif ( isset( $settlement_ref['payment_status'] ) ) {
$payment_status = $settlement_ref['payment_status'];
$status = $this->get_status( $payment_status );
$class = ' paidy-' . $status;
$status_name = $this->get_status_name( $payment_status );
$amount = $settlement_ref['payment_amount'];
$result .= '' . $status_name . '
';
switch ( $payment_status ) {
case STATUS_AUTHORIZE_OK: /* オーソリOK */
$result .= '';
$result .= '';
$result .= '';
$result .= '';
$result .= '';
$result .= '
';
break;
case STATUS_CLEARED: /* 消込済 */
$result .= '';
$result .= '';
$result .= '';
$result .= '';
$result .= '
';
break;
default:
$result .= '';
}
$acting_status = '' . $status_name . '';
} else {
$status = 'error';
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
$result .= '';
}
$result .= $this->settlement_history( $order_id, $trading_id );
$data['result'] = $result;
$data['status'] = $status;
$data['acting_status'] = $acting_status;
return $data;
}
/**
* 決済履歴
*
* @param int $order_id Order number.
* @param string $trading_id Trading ID.
* @return string
*/
private function settlement_history( $order_id, $trading_id ) {
$history = '';
$log_data = $this->get_acting_log( $order_id, $trading_id, RESULT_STATUS_ALL );
if ( $log_data ) {
$num = count( $log_data );
$history = '';
$history .= '';
$history .= ' | ' . __( 'Processing date', 'usces' ) . ' | 決済ID | マーチャント取引ID | ' . __( 'Processing classification', 'usces' ) . ' | ' . __( 'Amount', 'usces' ) . ' | ' . __( 'Result', 'usces' ) . ' |
';
$history .= '';
$history .= '';
foreach ( (array) $log_data as $data ) {
$log = usces_unserialize( $data['log'] );
$payment_id = ( isset( $log['payment_id'] ) ) ? $log['payment_id'] : '';
if ( empty( $payment_id ) && isset( $log['paidy_id'] ) ) {
$payment_id = $log['paidy_id'];
}
$status_name = ( isset( $data['status'] ) ) ? $this->get_status_name( $data['status'] ) : '';
$err_code = '';
$class = '';
if ( 2 == strlen( $data['status'] ) || 0 < $data['amount'] ) {
$amount = usces_crform( $data['amount'], false, true, 'return', true );
} else {
$amount = '';
}
if ( RESULT_STATUS_NORMAL != $data['result'] ) {
$err_code = ( isset( $log['result_message'] ) ) ? $log['result_message'] : '';
$class = ' error';
}
$history .= '';
$history .= '| ' . $num . ' | ';
$history .= '' . $data['datetime'] . ' | ';
$history .= '' . $payment_id . ' | ';
$history .= '' . $trading_id . ' | ';
$history .= '' . $status_name . ' | ';
$history .= '' . $amount . ' | ';
$history .= '' . $err_code . ' | ';
$history .= '
';
$num--;
}
$history .= '';
$history .= '
';
}
return $history;
}
/**
* 決済状況
* usces_filter_orderlist_detail_value
*
* @param string $detail HTML.
* @param string $value Settlement info key.
* @param string $key Settlement info value.
* @param int $order_id Order number.
* @return array
*/
public function orderlist_settlement_status( $detail, $value, $key, $order_id ) {
global $usces;
if ( 'wc_trans_id' != $key || empty( $value ) ) {
return $detail;
}
$acting_flg = $this->get_order_acting_flg( $order_id );
if ( in_array( $acting_flg, $this->pay_method ) ) {
$class = '';
$status_name = '';
$trading_id = $this->get_trading_id( $order_id );
$payment_status = $this->get_payment_status( $order_id, $trading_id );
if ( ! empty( $payment_status ) ) {
switch ( $acting_flg ) {
case 'acting_paygent_card':
$class = ' card-' . $this->get_status( $payment_status );
$status_name = $this->get_status_name( $payment_status );
break;
case 'acting_paygent_conv':
$class = ' conv-' . $this->get_status( $payment_status );
$status_name = $this->get_status_name( $payment_status );
break;
case 'acting_paygent_atm':
$class = ' atm-' . $this->get_status( $payment_status );
$status_name = $this->get_status_name( $payment_status );
break;
case 'acting_paygent_bank':
$class = ' bank-' . $this->get_status( $payment_status );
$status_name = $this->get_status_name( $payment_status );
break;
case 'acting_paygent_paidy':
$class = ' paidy-' . $this->get_status( $payment_status );
$status_name = $this->get_status_name( $payment_status );
break;
}
}
if ( ! empty( $class ) && ! empty( $status_name ) ) {
$detail = '' . esc_html( $value ) . '' . esc_html( $status_name ) . ' | ';
}
}
return $detail;
}
/**
* 受注編集画面【ステータス】
* usces_action_order_edit_form_status_block_middle
*
* @param array $data Order data.
* @param array $cscs_meta Custom field data.
* @param array $action_args Compact array( 'order_action', 'order_id', 'cart' ).
*/
public function settlement_status( $data, $cscs_meta, $action_args ) {
global $usces;
extract( $action_args );
if ( 'new' != $order_action && ! empty( $order_id ) ) {
$payment = usces_get_payments_by_name( $data['order_payment_name'] );
$acting_flg = ( isset( $payment['settlement'] ) ) ? $payment['settlement'] : '';
if ( in_array( $acting_flg, $this->pay_method ) ) {
$trading_id = $this->get_trading_id( $order_id );
$payment_status = $this->get_payment_status( $order_id, $trading_id );
if ( ! empty( $payment_status ) ) {
$class = '';
$status_name = '';
switch ( $acting_flg ) {
case 'acting_paygent_card':
$class = ' card-' . $this->get_status( $payment_status );
$status_name = $this->get_status_name( $payment_status );
break;
case 'acting_paygent_conv':
$class = ' conv-' . $this->get_status( $payment_status );
$status_name = $this->get_status_name( $payment_status );
break;
case 'acting_paygent_atm':
$class = ' atm-' . $this->get_status( $payment_status );
$status_name = $this->get_status_name( $payment_status );
break;
case 'acting_paygent_bank':
$class = ' bank-' . $this->get_status( $payment_status );
$status_name = $this->get_status_name( $payment_status );
break;
case 'acting_paygent_paidy':
$class = ' paidy-' . $this->get_status( $payment_status );
$status_name = $this->get_status_name( $payment_status );
break;
}
if ( ! empty( $status_name ) ) {
echo '
| ' . esc_html__( 'Settlement status', 'usces' ) . ' |
' . esc_html( $status_name ) . ' |
';
}
}
}
}
}
/**
* 受注編集画面【支払情報】
* usces_action_order_edit_form_settle_info
*
* @param array $data Order data.
* @param array $action_args Compact array( 'order_action', 'order_id', 'cart' ).
*/
public function settlement_information( $data, $action_args ) {
global $usces;
extract( $action_args );
if ( 'new' != $order_action && ! empty( $order_id ) ) {
$payment = usces_get_payments_by_name( $data['order_payment_name'] );
if ( isset( $payment['settlement'] ) && in_array( $payment['settlement'], $this->pay_method ) ) {
$acting_data = usces_unserialize( $usces->get_order_meta_value( $payment['settlement'], $order_id ) );
$trading_id = ( isset( $acting_data['trading_id'] ) ) ? $acting_data['trading_id'] : '9999999999';
if ( ! empty( $trading_id ) ) {
echo '';
}
}
}
}
/**
* 決済情報ダイアログ
* usces_action_endof_order_edit_form
*
* @param array $data Order data.
* @param array $action_args Compact array( 'order_action', 'order_id', 'cart' ).
*/
public function settlement_dialog( $data, $action_args ) {
global $usces;
extract( $action_args );
if ( 'new' != $order_action && ! empty( $order_id ) ) :
$payment = usces_get_payments_by_name( $data['order_payment_name'] );
if ( isset( $payment['settlement'] ) && in_array( $payment['settlement'], $this->pay_method ) ) :
?>
acting_name . ' カード決済';
break;
case PAYMENT_TYPE_CONVENI_NUM:
$value = $this->acting_name . ' コンビニ決済';
break;
case PAYMENT_TYPE_ATM:
$value = $this->acting_name . ' ATM決済';
break;
case PAYMENT_TYPE_BANK:
$value = $this->acting_name . ' 銀行ネット決済';
break;
case PAYMENT_TYPE_PAIDY:
$value = $this->acting_name . ' Paidy';
break;
}
break;
case 'split_count':
switch ( $value ) {
case '01':
$value = __( 'One time payment', 'usces' );
break;
case '02':
case '03':
case '05':
case '06':
case '10':
case '12':
case '15':
case '18':
case '20':
case '24':
$times = (int) $value;
$value = $times . __( '-time payment', 'usces' );
break;
case '23':
$value = __( 'Bonus lump-sum payment', 'usces' );
break;
case '80':
$value = __( 'Libor Funding pay', 'usces' );
break;
}
}
return $value;
}
/**
* 管理画面送信メール
* 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 $order_data Order data.
* @return string
*/
public function order_confirm_mail_payment( $msg_payment, $order_id, $payment, $cart, $order_data ) {
global $usces;
switch ( $payment['settlement'] ) {
case 'acting_paygent_card':
$acting_opts = $this->get_acting_settings();
if ( 0 !== (int) $acting_opts['payment_class'] ) {
$trading_id = $this->get_trading_id( $order_id );
$latest_log = $this->get_acting_latest_log( $order_id, $trading_id );
if ( isset( $latest_log['log']['split_count'] ) && isset( $latest_log['log']['payment_class'] ) ) {
switch ( $latest_log['log']['payment_class'] ) {
case '10':
$split_count = __( '(', 'usces' ) . __( 'One time payment', 'usces' ) . __( ')', 'usces' );
break;
case '23':
$split_count = __( '(', 'usces' ) . __( 'Bonus lump-sum payment', 'usces' ) . __( ')', 'usces' );
break;
case '80':
$split_count = __( '(', 'usces' ) . __( 'Libor Funding pay', 'usces' ) . __( ')', 'usces' );
break;
default:
$times = (int) $latest_log['log']['split_count'];
if ( 0 < $times ) {
$split_count = __( '(', 'usces' ) . $times . __( '-time payment', 'usces' ) . __( ')', 'usces' );
}
}
if ( ! empty( $split_count ) ) {
if ( usces_is_html_mail() ) {
$msg_payment = '| ';
$msg_payment .= $payment['name'] . $split_count;
$msg_payment .= ' |
';
} else {
$msg_payment = __( '** Payment method **', 'usces' ) . "\r\n";
$msg_payment .= usces_mail_line( 1, $order_data['order_email'] );
$msg_payment .= $payment['name'] . $split_count;
$msg_payment .= "\r\n\r\n";
}
}
}
}
break;
case 'acting_paygent_conv':
$mode = ( isset( $_POST['mode'] ) ) ? wp_unslash( $_POST['mode'] ) : '';
if ( 'orderConfirmMail' == $mode || 'changeConfirmMail' == $mode ) {
$acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_paygent_conv', $order_id ) );
$usable_cvs_company_id = ( isset( $acting_data['usable_cvs_company_id'] ) ) ? $acting_data['usable_cvs_company_id'] : '';
$receipt_number = ( isset( $acting_data['receipt_number'] ) ) ? $acting_data['receipt_number'] : '';
if ( usces_is_html_mail() ) {
$msg_payment = '';
$msg_payment .= $payment['name'] . '
';
$lb = ' ';
} else {
$lb = "\r\n";
}
if ( ! empty( $receipt_number ) ) {
if ( false !== strpos( $usable_cvs_company_id, CODE_SEICOMART ) ) {
$msg_payment .= $this->cvs_company_a[ CODE_SEICOMART ] . 'でのお支払い' . $lb;
$msg_payment .= '受付番号:' . $receipt_number . $lb;
}
if ( false !== strpos( $usable_cvs_company_id, CODE_SEVENELEVEN ) ) {
$msg_payment .= $this->cvs_company_a[ CODE_SEVENELEVEN ] . 'でのお支払い' . $lb;
$msg_payment .= '払込票番号:' . $receipt_number . $lb;
}
if ( false !== strpos( $usable_cvs_company_id, CODE_LOWSON ) ) {
$msg_payment .= $this->cvs_company_a[ CODE_LOWSON ] . 'でのお支払い' . $lb;
$msg_payment .= 'お客様番号:' . $receipt_number . $lb;
$msg_payment .= '確認番号:' . CONVENI_CONFIRMATION_NUMBER . $lb;
}
if ( false !== strpos( $usable_cvs_company_id, CODE_MINISTOP ) ) {
$msg_payment .= $this->cvs_company_a[ CODE_MINISTOP ] . 'でのお支払い' . $lb;
$msg_payment .= 'お客様番号:' . $receipt_number . $lb;
$msg_payment .= '確認番号:' . CONVENI_CONFIRMATION_NUMBER . $lb;
}
if ( false !== strpos( $usable_cvs_company_id, CODE_FAMILYMART ) ) {
$msg_payment .= $this->cvs_company_a[ CODE_FAMILYMART ] . 'でのお支払い' . $lb;
$msg_payment .= '収納番号:' . $receipt_number . $lb;
}
if ( false !== strpos( $usable_cvs_company_id, CODE_YAMAZAKI ) ) {
$msg_payment .= $this->cvs_company_a[ CODE_YAMAZAKI ] . 'でのお支払い' . $lb;
$msg_payment .= '決済番号:' . $receipt_number . $lb;
}
}
if ( ! empty( $acting_data['receipt_print_url'] ) ) {
$receipt_print_url = ( usces_is_html_mail() ) ? '' . esc_url( $acting_data['receipt_print_url'] ) . '' : $acting_data['receipt_print_url'];
if ( false !== strpos( $usable_cvs_company_id, CODE_SEICOMART ) || false !== strpos( $usable_cvs_company_id, CODE_SEVENELEVEN ) ) {
$msg_payment .= '払込票URL:' . $receipt_print_url . $lb;
} else {
$msg_payment .= '支払参照URL:' . $receipt_print_url . $lb;
}
}
if ( ! empty( $acting_data['payment_limit_date'] ) ) {
$msg_payment .= 'お支払い期限日:' . date( __( 'Y/m/d' ), strtotime( $acting_data['payment_limit_date'] ) ) . $lb;
}
if ( usces_is_html_mail() ) {
$msg_payment .= ' |
';
}
}
break;
case 'acting_paygent_atm':
$mode = ( isset( $_POST['mode'] ) ) ? wp_unslash( $_POST['mode'] ) : '';
if ( 'orderConfirmMail' == $mode || 'changeConfirmMail' == $mode ) {
$acting_data = usces_unserialize( $usces->get_order_meta_value( 'acting_paygent_atm', $order_id ) );
$lb = ( usces_is_html_mail() ) ? '
' : "\r\n";
if ( isset( $acting_data['pay_center_number'] ) ) {
$msg_payment .= '収納機関番号:' . $acting_data['pay_center_number'] . $lb;
}
if ( isset( $acting_data['customer_number'] ) ) {
$msg_payment .= 'お客様番号:' . $acting_data['customer_number'] . $lb;
}
if ( isset( $acting_data['conf_number'] ) ) {
$msg_payment .= '確認番号:' . $acting_data['conf_number'] . $lb;
}
if ( isset( $acting_data['payment_limit_date'] ) ) {
$msg_payment .= 'お支払い期限日:' . date( __( 'Y/m/d' ), strtotime( $acting_data['payment_limit_date'] ) ) . $lb;
}
}
break;
case 'acting_paygent_bank':
break;
case 'acting_paygent_paidy':
break;
}
return $msg_payment;
}
/**
* 決済リンクキー
* usces_filter_get_link_key
*
* @param string $linkkey Settlement link key.
* @param array $results Response data.
* @return string
*/
public function get_link_key( $linkkey, $results ) {
if ( isset( $results['trading_id'] ) ) {
$linkkey = $results['trading_id'];
}
return $linkkey;
}
/**
* 受注データ復旧処理
* usces_action_revival_order_data
*
* @param int $order_id Order number.
* @param string $log_key Link key.
* @param string $acting_flg Payment type.
*/
public function revival_orderdata( $order_id, $log_key, $acting_flg ) {
global $usces;
switch ( $acting_flg ) {
case 'acting_paygent_card':
$data = array(
'trading_id' => $log_key,
'payment_type' => PAYMENT_TYPE_CREDIT,
);
$usces->set_order_meta_value( $acting_flg, usces_serialize( $data ), $order_id );
$usces->set_order_meta_value( 'trading_id', $log_key, $order_id );
break;
case 'acting_paygent_conv':
$data = array(
'trading_id' => $log_key,
'payment_type' => PAYMENT_TYPE_CONVENI_NUM,
);
$usces->set_order_meta_value( $acting_flg, usces_serialize( $data ), $order_id );
$usces->set_order_meta_value( 'trading_id', $log_key, $order_id );
break;
case 'acting_paygent_atm':
$data = array(
'trading_id' => $log_key,
'payment_type' => PAYMENT_TYPE_ATM,
);
$usces->set_order_meta_value( $acting_flg, usces_serialize( $data ), $order_id );
$usces->set_order_meta_value( 'trading_id', $log_key, $order_id );
break;
case 'acting_paygent_bank':
$data = array(
'trading_id' => $log_key,
'payment_type' => PAYMENT_TYPE_BANK,
);
$usces->set_order_meta_value( $acting_flg, usces_serialize( $data ), $order_id );
$usces->set_order_meta_value( 'trading_id', $log_key, $order_id );
break;
case 'acting_paygent_paidy':
$data = array(
'trading_id' => $log_key,
'payment_type' => PAYMENT_TYPE_PAIDY,
);
$usces->set_order_meta_value( $acting_flg, usces_serialize( $data ), $order_id );
$usces->set_order_meta_value( 'trading_id', $log_key, $order_id );
break;
}
}
/**
* 支払方法説明
* 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_paygent_card' == $payment['settlement'] ) {
$acting_opts = $this->get_acting_settings();
if ( 0 !== (int) $acting_opts['payment_class'] ) {
$split_count = ( isset( $_POST['split_count'] ) ) ? wp_unslash( $_POST['split_count'] ) : '01';
switch ( $split_count ) {
case '01':
$str = __( '(', 'usces' ) . __( 'One time payment', 'usces' ) . __( ')', 'usces' );
break;
case '02':
case '03':
case '05':
case '06':
case '10':
case '12':
case '15':
case '18':
case '20':
case '24':
$times = (int) $split_count;
$str = __( '(', 'usces' ) . $times . __( '-time payment', 'usces' ) . __( ')', 'usces' );
break;
case '23':
$str = __( '(', 'usces' ) . __( 'Bonus lump-sum payment', 'usces' ) . __( ')', 'usces' );
break;
case '80':
$str = __( '(', 'usces' ) . __( 'Libor Funding pay', 'usces' ) . __( ')', 'usces' );
break;
default:
$str = __( '(', 'usces' ) . __( 'One time payment', 'usces' ) . __( ')', 'usces' );
}
}
} elseif ( isset( $payment['settlement'] ) && 'acting_paygent_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['payment_term_day'] ) . __( ')', 'usces' );
$str = apply_filters( 'usces_filter_paygent_payment_limit_conv', $payment_detail, $acting_opts['payment_term_day'] );
} elseif ( isset( $payment['settlement'] ) && 'acting_paygent_atm' == $payment['settlement'] ) {
$acting_opts = $this->get_acting_settings();
$payment_limit_date = ( WCUtils::is_blank( $acting_opts['payment_limit_date'] ) ) ? 30 : (int) $acting_opts['payment_limit_date'];
if ( 0 < $payment_limit_date ) {
$payment_detail = __( '(', 'usces' ) . sprintf( __( 'Payment is valid for %s days from the date of order.', 'usces' ), $payment_limit_date ) . __( ')', 'usces' );
} else {
$payment_detail = __( '(', 'usces' ) . '本日中にお支払いを完了してください。' . __( ')', 'usces' );
}
$str = apply_filters( 'usces_filter_paygent_payment_limit_atm', $payment_detail, $acting_opts['payment_limit_date'] );
} elseif ( isset( $payment['settlement'] ) && 'acting_paygent_bank' == $payment['settlement'] ) {
$acting_opts = $this->get_acting_settings();
$asp_payment_term = $this->asp_payment_term[ $acting_opts['asp_payment_term'] ];
$payment_detail = __( '(', 'usces' ) . sprintf( '%sにお支払いを完了してください。', $asp_payment_term ) . __( ')', 'usces' );
$str = apply_filters( 'usces_filter_paygent_payment_limit_bank', $payment_detail, $acting_opts['asp_payment_term'] );
}
return $str;
}
/**
* 支払方法 JavaScript 用決済名追加
* usces_filter_payments_str
*
* @param string $payments_str Payments.
* @param array $payment Selected payment.
* @return string
*/
public function payments_str( $payments_str, $payment ) {
switch ( $payment['settlement'] ) {
case 'acting_paygent_card':
if ( $this->is_activate_card( 'module' ) ) {
$payments_str .= "'" . $payment['name'] . "': 'paygent_card_form', ";
}
break;
case 'acting_paygent_conv':
if ( $this->is_activate_conv( 'module' ) ) {
$payments_str .= "'" . $payment['name'] . "': 'paygent_conv_form', ";
}
break;
case 'acting_paygent_atm':
if ( $this->is_activate_atm() ) {
$payments_str .= "'" . $payment['name'] . "': 'paygent_atm_form', ";
}
break;
case 'acting_paygent_bank':
if ( $this->is_activate_bank() ) {
$payments_str .= "'" . $payment['name'] . "': 'paygent_bank_form', ";
}
break;
}
return $payments_str;
}
/**
* 支払方法 JavaScript 用決済追加
* usces_filter_payments_arr
*
* @param array $payments_arr Payments.
* @param array $payment Selected payment.
* @return array
*/
public function payments_arr( $payments_arr, $payment ) {
switch ( $payment['settlement'] ) {
case 'acting_paygent_card':
if ( $this->is_activate_card( 'module' ) ) {
$payments_arr[] = 'paygent_card_form';
}
break;
case 'acting_paygent_conv':
if ( $this->is_activate_conv( 'module' ) ) {
$payments_arr[] = 'paygent_conv_form';
}
break;
case 'acting_paygent_atm':
if ( $this->is_activate_atm() ) {
$payments_arr[] = 'paygent_atm_form';
}
break;
case 'acting_paygent_bank':
if ( $this->is_activate_bank() ) {
$payments_arr[] = 'paygent_bank_form';
}
break;
}
return $payments_arr;
}
/**
* 内容確認ページ [注文する] ボタン
* usces_filter_confirm_inform
*
* @param string $form Purchase post form.
* @param array $payments Payment data.
* @param string $acting_flg Payment type.
* @param string $rand Welcart transaction key.
* @param string $purchase_disabled Disable purchase button.
* @return string
*/
public function confirm_inform( $form, $payments, $acting_flg, $rand, $purchase_disabled ) {
global $usces;
if ( ! in_array( $acting_flg, $this->pay_method ) ) {
return $form;
}
$entry = $usces->cart->get_entry();
$cart = $usces->cart->get_cart();
if ( ! $entry || ! $cart ) {
return $form;
}
if ( ! $entry['order']['total_full_price'] ) {
return $form;
}
$acting_opts = $this->get_acting_settings();
switch ( $acting_flg ) {
/* カード決済 */
case 'acting_paygent_card':
usces_save_order_acting_data( $rand );
if ( 'module' == $acting_opts['card_activate'] ) {
$token = ( isset( $_POST['token'] ) ) ? wp_unslash( $_POST['token'] ) : '';
$masked_card_number = ( isset( $_POST['masked_card_number'] ) ) ? wp_unslash( $_POST['masked_card_number'] ) : '';
$valid_until = ( isset( $_POST['valid_until'] ) ) ? wp_unslash( $_POST['valid_until'] ) : '';
$fingerprint = ( isset( $_POST['fingerprint'] ) ) ? wp_unslash( $_POST['fingerprint'] ) : '';
$hc = ( isset( $_POST['hc'] ) ) ? wp_unslash( $_POST['hc'] ) : '';
$stock_card = ( isset( $_POST['stock_card'] ) ) ? wp_unslash( $_POST['stock_card'] ) : '';
$stock_card_mode = ( isset( $_POST['stock_card_mode'] ) ) ? wp_unslash( $_POST['stock_card_mode'] ) : '';
$split_count = ( isset( $_POST['split_count'] ) ) ? wp_unslash( $_POST['split_count'] ) : '';
$form = '';
$form .= '';
$form .= '