paymod_id = 'paypal_cp';
$this->pay_method = array(
'acting_paypal_cp',
'acting_paypal_card',
);
$this->acting_name = 'PayPal(CP)';
$this->acting_formal_name = 'PayPal Commerce Platform';
$this->initialize_data();
add_action( 'init', array( $this, 'init' ), 20 );
add_filter( 'http_headers_useragent', array( $this, 'http_headers_useragent' ), 10, 2 );
if ( $this->is_validity_acting() ) {
add_action( 'template_redirect', array( $this, 'respond_to_ipn' ), 1 );
}
if ( is_admin() ) {
add_action( 'wp_ajax_onboarded', array( $this, 'onboarded' ) );
add_action( 'usces_action_admin_ajax', array( $this, 'admin_ajax' ) );
add_action( 'admin_print_footer_scripts', array( $this, 'admin_scripts' ) );
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( 'wp_ajax_create_billing_agreement', array( $this, 'create_billing_agreement' ) );
add_action( 'wp_ajax_nopriv_create_billing_agreement', array( $this, 'create_billing_agreement' ) );
add_action( 'wp_ajax_create_order', array( $this, 'create_order' ) );
add_action( 'wp_ajax_nopriv_create_order', array( $this, 'create_order' ) );
if ( $this->is_validity_acting( 'card' ) ) {
add_action( 'wp_ajax_create_order_card', array( $this, 'create_order_card' ) );
add_action( 'wp_ajax_nopriv_create_order_card', array( $this, 'create_order_card' ) );
add_action( 'wp_ajax_create_order_member', array( $this, 'create_order_member' ) );
add_action( 'wp_ajax_nopriv_create_order_member', array( $this, 'create_order_member' ) );
add_action( 'wp_ajax_show_order_details_card', array( $this, 'show_order_details_card' ) );
add_action( 'wp_ajax_nopriv_show_order_details_card', array( $this, 'show_order_details_card' ) );
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_delivery_secure_form_loop', array( $this, 'delivery_secure_form_loop' ), 10, 2 );
add_filter( 'usces_filter_delivery_check', array( $this, 'delivery_check' ), 15 );
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_filter( 'usces_filter_get_error_settlement', array( $this, 'error_page_message' ) );
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 );
add_action( 'usces_action_pre_delete_memberdata', array( $this, 'delete_member' ) );
}
add_filter( 'usces_filter_confirm_inform', array( $this, 'confirm_inform' ), 10, 5 );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'wp_print_footer_scripts', array( $this, 'footer_scripts' ) );
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_action( 'usces_action_reg_orderdata', array( $this, 'register_orderdata' ) );
add_filter( 'usces_filter_is_complete_settlement', array( $this, 'is_complete_settlement' ), 10, 3 );
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 );
if ( is_admin() ) {
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_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_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_action_reg_continuationdata', array( $this, 'register_continuationdata' ) );
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_memberlist_column', array( $this, 'continue_memberlist_column' ), 10, 2 );
add_filter( 'dlseller_filter_continue_memberlist_sql_jointable', array( $this, 'continue_memberlist_sql_jointable' ), 10, 2 );
add_filter( 'dlseller_filter_continue_memberlist_sql_select', array( $this, 'continue_memberlist_sql_select' ), 10, 3 );
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 );
add_filter( 'usces_filter_order_confirm_mail_payment', array( $this, 'continue_order_mail_payment' ), 11, 4 );
add_filter( 'usces_filter_send_order_mail_payment', array( $this, 'continue_order_mail_payment' ), 11, 4 );
}
/* WCEX Auto Delivery */
if ( defined( 'WCEX_AUTO_DELIVERY' ) ) {
add_filter( 'wcad_action_reg_regulardata', array( $this, 'register_regulardata' ) );
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' ) );
add_filter( 'wcad_filter_send_settlement_error_mail_message_head', array( $this, 'settlement_error_mail_message_header' ), 10, 2 );
if ( version_compare( WCEX_AUTO_DELIVERY_VERSION, '1.2.5', '>=' ) ) {
add_filter( 'wcad_filter_send_settlement_error_mail_message', array( $this, 'settlement_error_mail_message' ), 10, 3 );
}
add_action( 'wcad_action_regular_information_edit_form', array( $this, 'regular_information_edit_form' ) );
add_filter( 'usces_filter_order_confirm_mail_payment', array( $this, 'regular_order_mail_payment' ), 11, 4 );
add_filter( 'usces_filter_send_order_mail_payment', array( $this, 'regular_order_mail_payment' ), 11, 4 );
add_filter( 'wcad_filter_order_confirm_mail_payment', array( $this, 'regular_order_mail_payment' ), 11, 4 );
}
}
}
/**
* 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']['paypal_cp']['activate'] = ( isset( $options['acting_settings']['paypal_cp']['activate'] ) ) ? $options['acting_settings']['paypal_cp']['activate'] : 'off';
$options['acting_settings']['paypal_cp']['cp_activate'] = ( isset( $options['acting_settings']['paypal_cp']['cp_activate'] ) ) ? $options['acting_settings']['paypal_cp']['cp_activate'] : 'off';
$options['acting_settings']['paypal_cp']['card_activate'] = ( isset( $options['acting_settings']['paypal_cp']['card_activate'] ) ) ? $options['acting_settings']['paypal_cp']['card_activate'] : 'off';
$options['acting_settings']['paypal_cp']['card_vault'] = ( isset( $options['acting_settings']['paypal_cp']['card_vault'] ) ) ? $options['acting_settings']['paypal_cp']['card_vault'] : 'off';
$options['acting_settings']['paypal_cp']['card_prefix'] = ( isset( $options['acting_settings']['paypal_cp']['card_prefix'] ) ) ? $options['acting_settings']['paypal_cp']['card_prefix'] : '';
$options['acting_settings']['paypal_cp']['card_3ds'] = ( isset( $options['acting_settings']['paypal_cp']['card_3ds'] ) ) ? $options['acting_settings']['paypal_cp']['card_3ds'] : 'off';
$options['acting_settings']['paypal_cp']['environment'] = ( isset( $options['acting_settings']['paypal_cp']['environment'] ) ) ? $options['acting_settings']['paypal_cp']['environment'] : 'live';
$options['acting_settings']['paypal_cp']['bncode'] = ( isset( $options['acting_settings']['paypal_cp']['bncode'] ) ) ? $options['acting_settings']['paypal_cp']['bncode'] : '';
$options['acting_settings']['paypal_cp']['client_id'] = ( isset( $options['acting_settings']['paypal_cp']['client_id'] ) ) ? $options['acting_settings']['paypal_cp']['client_id'] : '';
$options['acting_settings']['paypal_cp']['secret'] = ( isset( $options['acting_settings']['paypal_cp']['secret'] ) ) ? $options['acting_settings']['paypal_cp']['secret'] : '';
$options['acting_settings']['paypal_cp']['intent'] = ( isset( $options['acting_settings']['paypal_cp']['intent'] ) ) ? $options['acting_settings']['paypal_cp']['intent'] : 'CAPTURE';
$options['acting_settings']['paypal_cp']['autobilling_intent'] = ( isset( $options['acting_settings']['paypal_cp']['autobilling_intent'] ) ) ? $options['acting_settings']['paypal_cp']['autobilling_intent'] : 'CAPTURE';
$options['acting_settings']['paypal_cp']['autobilling_email'] = ( isset( $options['acting_settings']['paypal_cp']['autobilling_email'] ) ) ? $options['acting_settings']['paypal_cp']['autobilling_email'] : 'off';
$options['acting_settings']['paypal_cp']['button_layout'] = ( isset( $options['acting_settings']['paypal_cp']['button_layout'] ) ) ? $options['acting_settings']['paypal_cp']['button_layout'] : 'vertical';
$options['acting_settings']['paypal_cp']['button_color'] = ( isset( $options['acting_settings']['paypal_cp']['button_color'] ) ) ? $options['acting_settings']['paypal_cp']['button_color'] : 'gold';
$options['acting_settings']['paypal_cp']['button_shape'] = ( isset( $options['acting_settings']['paypal_cp']['button_shape'] ) ) ? $options['acting_settings']['paypal_cp']['button_shape'] : 'rect';
$options['acting_settings']['paypal_cp']['button_label'] = ( isset( $options['acting_settings']['paypal_cp']['button_label'] ) ) ? $options['acting_settings']['paypal_cp']['button_label'] : 'paypal';
$options['acting_settings']['paypal_cp']['agree'] = ( isset( $options['acting_settings']['paypal_cp']['agree'] ) ) ? $options['acting_settings']['paypal_cp']['agree'] : '';
update_option( 'usces', $options );
$available_settlement = get_option( 'usces_available_settlement', array() );
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_paypal_ec', 'acting_paypal_wpp' );
}
/**
* 決済有効判定
* 支払方法で使用している場合に 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 'cp':
foreach ( $payment_method as $payment ) {
if ( 'acting_paypal_cp' === $payment['settlement'] && 'activate' === $payment['use'] ) {
$method = true;
break;
}
}
if ( $method && $this->is_activate_paypal_cp() ) {
return true;
} else {
return false;
}
case 'card':
foreach ( $payment_method as $payment ) {
if ( 'acting_paypal_card' === $payment['settlement'] && 'activate' === $payment['use'] ) {
$method = true;
break;
}
}
if ( $method && $this->is_activate_paypal_card() ) {
return true;
} else {
return false;
}
break;
default:
if ( 'on' === $acting_opts['activate'] ) {
return true;
} else {
return false;
}
}
}
/**
* 決済利用判定
* PayPal CP を「利用する」のとき true
*
* @return boolean
*/
public function is_activate_paypal_cp() {
$acting_opts = $this->get_acting_settings();
if ( ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) &&
( isset( $acting_opts['cp_activate'] ) && 'on' === $acting_opts['cp_activate'] ) ) {
$res = true;
} else {
$res = false;
}
return $res;
}
/**
* 決済利用判定
* PayPal カード決済を「利用する」のとき true
*
* @return boolean
*/
public function is_activate_paypal_card() {
$acting_opts = $this->get_acting_settings();
if ( ( isset( $acting_opts['activate'] ) && 'on' === $acting_opts['activate'] ) &&
( isset( $acting_opts['card_activate'] ) && 'on' === $acting_opts['card_activate'] ) ) {
$res = true;
} else {
$res = false;
}
return $res;
}
/**
* Resolve conflicts.
* init
*/
public function init() {
global $usces;
$payment_method = usces_get_system_option( 'usces_payment_method', 'sort' );
foreach ( $payment_method as $payment ) {
if ( 'acting_paypal_ec' === $payment['settlement'] && 'activate' === $payment['use'] ) {
$payment['use'] = 'deactivate';
usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
} elseif ( 'acting_paypal_wpp' === $payment['settlement'] && 'activate' === $payment['use'] ) {
$payment['use'] = 'deactivate';
usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
}
}
}
/**
* Respond to PayPal IPN with HTTP 200.
*
* Billing Agreements created before the notify_url removal
* still trigger IPN on each recurring payment. Since PayPal CP
* does not use IPN, simply return HTTP 200 to stop failure alerts.
*
* @return void
*/
public function respond_to_ipn() {
if ( 'POST' !== $_SERVER['REQUEST_METHOD'] ) {
return;
}
if ( ! isset( $_POST['ipn_track_id'] ) || ! isset( $_POST['txn_type'] ) ) {
return;
}
status_header( 200 );
exit;
}
/**
* Filters the user agent value sent with an HTTP request.
* http_headers_useragent
*
* @param string $user_agent WordPress user agent string.
* @param string $url The request URL.
*/
public function http_headers_useragent( $user_agent, $url ) {
if ( false !== strpos( $url, self::API_URL ) || false !== strpos( $url, self::API_SANDBOX_URL ) ) {
$user_agent = 'Welcart/' . USCES_VERSION . '; ' . get_bloginfo( 'url' );
}
return $user_agent;
}
/**
* 管理画面スクリプト
* admin_print_footer_scripts
*/
public function admin_scripts() {
global $usces, $usces_settings;
$admin_page = ( isset( $_GET['page'] ) ) ? wp_unslash( $_GET['page'] ) : '';
switch ( $admin_page ) :
/* クレジット決済設定画面 */
case 'usces_settlement':
$settlement_selected = get_option( 'usces_settlement_selected', array() );
if ( in_array( $this->paymod_id, (array) $settlement_selected ) ) :
$acting_opts = $this->get_acting_settings();
$cp_activate = ( isset( $acting_opts['cp_activate'] ) ) ? $acting_opts['cp_activate'] : 'off';
$card_activate = ( isset( $acting_opts['card_activate'] ) ) ? $acting_opts['card_activate'] : 'off';
$cp_environment = ( isset( $acting_opts['environment'] ) ) ? $acting_opts['environment'] : 'live';
?>
get_order_acting_flg( $order_id );
}
}
if ( in_array( $acting_flg, $this->pay_method ) ) :
$args = compact( 'order_id', 'acting_flg', 'admin_page' );
$cr = $usces->options['system']['currency'];
if ( isset( $usces_settings['currency'][ $cr ] ) ) {
list( $crcode, $decimal, $point, $seperator, $symbol ) = $usces_settings['currency'][ $cr ];
if ( 'JPY' === $crcode ) {
$currency = __( $crcode, 'usces' );
} else {
$currency = ( usces_is_entity( $symbol ) ) ? mb_convert_encoding( $symbol, 'UTF-8', 'HTML-ENTITIES' ) : $symbol;
}
} else {
$currency = '';
}
if ( defined( 'WCEX_AUTO_DELIVERY' ) && 'acting_paypal_cp' === $acting_flg ) {
$reg_id = $this->get_regular_id( $order_id );
} else {
$reg_id = '';
}
?>
paymod_id != wp_unslash( $_POST['acting'] ) ) {
return;
}
$this->error_mes = '';
$options = get_option( 'usces', array() );
$payment_method = usces_get_system_option( 'usces_payment_method', 'settlement' );
$post_data = wp_unslash( $_POST );
unset( $options['acting_settings']['paypal_cp'] );
$options['acting_settings']['paypal_cp']['cp_activate'] = ( isset( $post_data['cp_activate'] ) ) ? $post_data['cp_activate'] : 'off';
$options['acting_settings']['paypal_cp']['card_activate'] = ( isset( $post_data['card_activate'] ) ) ? $post_data['card_activate'] : 'off';
$options['acting_settings']['paypal_cp']['card_vault'] = ( isset( $post_data['card_vault'] ) ) ? $post_data['card_vault'] : 'off';
$options['acting_settings']['paypal_cp']['card_prefix'] = ( isset( $post_data['card_prefix'] ) ) ? $post_data['card_prefix'] : '';
$options['acting_settings']['paypal_cp']['card_3ds'] = ( isset( $post_data['card_3ds'] ) ) ? $post_data['card_3ds'] : 'off';
$options['acting_settings']['paypal_cp']['environment'] = ( isset( $post_data['cp_environment'] ) ) ? $post_data['cp_environment'] : 'live';
$options['acting_settings']['paypal_cp']['client_id'] = ( isset( $post_data['cp_client_id'] ) ) ? trim( $post_data['cp_client_id'] ) : '';
$options['acting_settings']['paypal_cp']['secret'] = ( isset( $post_data['cp_secret'] ) ) ? trim( $post_data['cp_secret'] ) : '';
$options['acting_settings']['paypal_cp']['intent'] = ( isset( $post_data['cp_intent'] ) ) ? $post_data['cp_intent'] : 'CAPTURE';
$options['acting_settings']['paypal_cp']['autobilling_intent'] = ( isset( $post_data['cp_autobilling_intent'] ) ) ? $post_data['cp_autobilling_intent'] : 'CAPTURE';
$options['acting_settings']['paypal_cp']['autobilling_email'] = ( isset( $post_data['cp_autobilling_email'] ) ) ? $post_data['cp_autobilling_email'] : 'off';
$options['acting_settings']['paypal_cp']['button_layout'] = ( isset( $post_data['cp_button_layout'] ) ) ? $post_data['cp_button_layout'] : 'vertical';
$options['acting_settings']['paypal_cp']['button_color'] = ( isset( $post_data['cp_button_color'] ) ) ? $post_data['cp_button_color'] : 'gold';
$options['acting_settings']['paypal_cp']['button_shape'] = ( isset( $post_data['cp_button_shape'] ) ) ? $post_data['cp_button_shape'] : 'rect';
$options['acting_settings']['paypal_cp']['button_label'] = ( isset( $post_data['cp_button_label'] ) ) ? $post_data['cp_button_label'] : 'paypal';
$options['acting_settings']['paypal_cp']['agree'] = ( isset( $post_data['cp_agree'] ) ) ? $post_data['cp_agree'] : '';
if ( 'on' === $options['acting_settings']['paypal_cp']['cp_activate'] || 'on' === $options['acting_settings']['paypal_cp']['card_activate'] ) {
$unavailable_activate = false;
foreach ( $payment_method as $settlement => $payment ) {
if ( in_array( $settlement, $this->unavailable_method ) && 'deactivate' !== $payment['use'] ) {
$unavailable_activate = true;
break;
}
}
if ( $unavailable_activate ) {
$this->error_mes .= __( '* Settlement that can not be used together is activated.', 'usces' ) . '
';
} else {
if ( WCUtils::is_blank( $post_data['cp_client_id'] ) ) {
$this->error_mes .= __( '* Enter Client ID.', 'usces' ) . '
';
}
if ( WCUtils::is_blank( $post_data['cp_secret'] ) ) {
$this->error_mes .= __( '* Enter Secret.', 'usces' ) . '
';
}
if ( 'on' === $options['acting_settings']['paypal_cp']['card_activate'] && 'on' === $options['acting_settings']['paypal_cp']['card_vault'] ) {
if ( ! $this->check_prefix( $options['acting_settings']['paypal_cp']['card_prefix'] ) ) {
$this->error_mes .= __( '* The prefix must be at least one and no more than four single-byte uppercase alphabetic characters.', 'usces' ) . '
';
}
}
if ( empty( $options['acting_settings']['paypal_cp']['agree'] ) ) {
$this->error_mes .= __( '* There was no agreement on terms of use.', 'usces' ) . '
';
}
}
}
if ( '' === $this->error_mes ) {
$usces->action_status = 'success';
$usces->action_message = __( 'Options are updated.', 'usces' );
if ( 'on' === $options['acting_settings']['paypal_cp']['cp_activate'] || 'on' === $options['acting_settings']['paypal_cp']['card_activate'] ) {
$options['acting_settings']['paypal_cp']['activate'] = 'on';
if ( 'live' === $options['acting_settings']['paypal_cp']['environment'] ) {
$options['acting_settings']['paypal_cp']['api_request_url'] = self::API_URL;
} else {
$options['acting_settings']['paypal_cp']['api_request_url'] = self::API_SANDBOX_URL;
}
$toactive = array();
if ( 'on' === $options['acting_settings']['paypal_cp']['cp_activate'] ) {
$usces->payment_structure['acting_paypal_cp'] = $this->acting_name;
foreach ( $payment_method as $settlement => $payment ) {
if ( 'acting_paypal_cp' === $settlement && 'activate' !== $payment['use'] ) {
$toactive[] = $payment['name'];
}
}
}
if ( 'on' === $options['acting_settings']['paypal_cp']['card_activate'] ) {
$usces->payment_structure['acting_paypal_card'] = __( 'PayPal(CreditCard)', 'usces' );
foreach ( $payment_method as $settlement => $payment ) {
if ( 'acting_paypal_card' === $settlement && 'activate' !== $payment['use'] ) {
$toactive[] = $payment['name'];
}
}
}
if ( 0 < count( $toactive ) ) {
$usces->action_message .= __( 'Please update the payment method to "Activate". General Setting > Payment Methods', 'usces' );
}
usces_admin_orderlist_show_wc_trans_id();
$this->setting_update_notification( $options );
} else {
$options['acting_settings']['paypal_cp']['activate'] = 'off';
unset( $usces->payment_structure['acting_paypal_cp'] );
unset( $usces->payment_structure['acting_paypal_card'] );
$deactivate = array();
foreach ( $payment_method as $settlement => $payment ) {
if ( ! array_key_exists( $settlement, $usces->payment_structure ) ) {
if ( 'deactivate' !== $payment['use'] ) {
$payment['use'] = 'deactivate';
$deactivate[] = $payment['name'];
usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
}
}
}
if ( 0 < count( $deactivate ) ) {
$deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) );
$usces->action_message .= $deactivate_message;
}
}
} else {
$usces->action_status = 'error';
$usces->action_message = __( 'Data have deficiency.', 'usces' );
$options = get_option( 'usces', array() );
$options['acting_settings']['paypal_cp']['activate'] = 'off';
$options['acting_settings']['paypal_cp']['agree'] = '';
unset( $usces->payment_structure['acting_paypal_cp'] );
unset( $usces->payment_structure['acting_paypal_card'] );
$deactivate = array();
foreach ( $payment_method as $settlement => $payment ) {
if ( in_array( $settlement, $this->pay_method ) ) {
if ( 'deactivate' !== $payment['use'] ) {
$payment['use'] = 'deactivate';
$deactivate[] = $payment['name'];
usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
}
}
}
if ( 0 < count( $deactivate ) ) {
$deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) );
$usces->action_message .= $deactivate_message . __( 'Please complete the setup and update the payment method to "Activate".', 'usces' );
}
}
ksort( $usces->payment_structure );
update_option( 'usces', $options );
update_option( 'usces_payment_structure', $usces->payment_structure );
}
/**
* 決済設定通知
*
* @param array $options Setting values.
*/
private function setting_update_notification( $options ) {
$message = 'サイト名/屋号:' . html_entity_decode( get_option( 'blogname' ) ) . "\n" .
'サイトURL:' . esc_url( home_url( '/' ) ) . "\n" .
'Eメールアドレス:' . get_option( 'admin_email' ) . "\n" .
'動作環境:' . $options['acting_settings']['paypal_cp']['environment'] . "\n";
$sendmail_params = array(
'to_name' => 'PayPal',
'to_address' => 'welcart-setting-update@paypal.com',
'from_name' => get_option( 'blogname' ),
'from_address' => get_option( 'admin_email' ),
'reply_name' => get_option( 'blogname' ),
'reply_to' => usces_get_first_order_mail(),
'return_path' => get_option( 'admin_email' ),
'subject' => '[Welcart]PayPal決済設定通知',
'message' => do_shortcode( $message ),
);
usces_send_mail( $sendmail_params );
}
/**
* クレジット決済設定画面タブ
* usces_action_settlement_tab_title
*/
public function settlement_tab_title() {
$settlement_selected = get_option( 'usces_settlement_selected', array() );
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', array() );
if ( in_array( $this->paymod_id, (array) $settlement_selected ) ) :
$cp_activate = ( isset( $acting_opts['cp_activate'] ) && 'on' === $acting_opts['cp_activate'] ) ? 'on' : 'off';
$card_activate = ( isset( $acting_opts['card_activate'] ) && 'on' === $acting_opts['card_activate'] ) ? 'on' : 'off';
$card_vault = ( isset( $acting_opts['card_vault'] ) && 'on' === $acting_opts['card_vault'] ) ? 'on' : 'off';
$card_prefix = ( isset( $acting_opts['card_prefix'] ) ) ? $acting_opts['card_prefix'] : '';
$card_3ds = ( isset( $acting_opts['card_3ds'] ) && 'on' === $acting_opts['card_3ds'] ) ? 'on' : 'off';
$cp_environment = ( isset( $acting_opts['environment'] ) && 'live' === $acting_opts['environment'] ) ? 'live' : 'sandbox';
$cp_client_id = ( isset( $acting_opts['client_id'] ) ) ? $acting_opts['client_id'] : '';
$cp_secret = ( isset( $acting_opts['secret'] ) ) ? $acting_opts['secret'] : '';
$cp_intent = ( isset( $acting_opts['intent'] ) ) ? $acting_opts['intent'] : '';
if ( defined( 'WCEX_DLSELLER' ) ) {
$cp_autobilling_intent = ( isset( $acting_opts['autobilling_intent'] ) ) ? $acting_opts['autobilling_intent'] : '';
$cp_autobilling_email = ( isset( $acting_opts['autobilling_email'] ) && 'on' === $acting_opts['autobilling_email'] ) ? 'on' : 'off';
}
$cp_button_layout = ( isset( $acting_opts['button_layout'] ) && 'horizontal' === $acting_opts['button_layout'] ) ? 'horizontal' : 'vertical';
$class_button_color = '';
$cp_button_color_gold = '';
$cp_button_color_blue = '';
$cp_button_color_silver = '';
$cp_button_color_white = '';
$cp_button_color_black = '';
if ( isset( $acting_opts['button_color'] ) && 'blue' === $acting_opts['button_color'] ) {
$cp_button_color_blue = ' checked="checked"';
$class_button_color = ' color-blue';
} elseif ( isset( $acting_opts['button_color'] ) && 'silver' === $acting_opts['button_color'] ) {
$cp_button_color_silver = ' checked="checked"';
$class_button_color = ' color-silver';
} elseif ( isset( $acting_opts['button_color'] ) && 'white' === $acting_opts['button_color'] ) {
$cp_button_color_white = ' checked="checked"';
$class_button_color = ' color-white';
} elseif ( isset( $acting_opts['button_color'] ) && 'black' === $acting_opts['button_color'] ) {
$cp_button_color_black = ' checked="checked"';
$class_button_color = ' color-black';
} else {
$cp_button_color_gold = ' checked="checked"'; /* default */
$class_button_color = ' color-gold';
}
$class_button_shape = '';
$cp_button_shape_rect = '';
$cp_button_shape_pill = '';
if ( isset( $acting_opts['button_shape'] ) && 'pill' === $acting_opts['button_shape'] ) {
$cp_button_shape_pill = ' checked="checked"';
$class_button_shape = ' shape-pill';
} else {
$cp_button_shape_rect = ' checked="checked"'; /* default */
$class_button_shape = ' shape-rect';
}
$class_button_label = '';
$cp_button_label_paypal = '';
$cp_button_label_checkout = '';
$cp_button_label_buynow = '';
$cp_button_label_pay = '';
if ( isset( $acting_opts['button_label'] ) && 'checkout' === $acting_opts['button_label'] ) {
$cp_button_label_checkout = ' checked="checked"';
$class_button_label = ' label-checkout';
} elseif ( isset( $acting_opts['button_label'] ) && 'buynow' === $acting_opts['button_label'] ) {
$cp_button_label_buynow = ' checked="checked"';
$class_button_label = ' label-buynow';
} elseif ( isset( $acting_opts['button_label'] ) && 'pay' === $acting_opts['button_label'] ) {
$cp_button_label_pay = ' checked="checked"';
$class_button_label = ' label-pay';
} else {
$cp_button_label_paypal = ' checked="checked"'; /* default */
$class_button_label = ' label-paypal';
}
$cp_agree = ( isset( $acting_opts['agree'] ) && 'agree' === $acting_opts['agree'] ) ? 'agree' : '';
?>
paymod_id === wp_unslash( $_POST['acting'] ) ) :
if ( ! empty( $this->error_mes ) ) :
?>
error_mes ); ?>
問い合わせ先
新規ビジネス・サービス導入・お申込専用ライン
Tel:03-6739-7135 9:30~17:30(土日祝休)※通話料がかかります
すでにペイパルアカウントをお持ちの方(カスタマーサービス)
Tel:0120-271-888 または 03-6739-7360(携帯電話と海外からはこちら)※通話料がかかります
9:00~18:00(土日休)
WEBでのお問い合わせ
を行う場合は、ペイパルへの「従量課金」の利用申請・審査が必要となります。
利用申請については、こちらからお問い合わせください。
※上記の問い合わせページで「その他のお問い合わせ方法」の下にある「メッセージを送る」を選択ください。
※メッセージボックスに、「Welcart にて Reference Transaction を利用するための審査・設定をしてほしい」旨をご記入ください。
クレジットカード決済のご利用には別途ペイパルへのお申込みと審査が必要です。
クレジットカード決済の申込みはこちらから行えます。
get_acting_settings();
$card_vault = 'off';
$payment_token_id = '';
$payment_token_last_digits = '';
$payment_token_brand = '';
if ( usces_is_member_system() && usces_is_login() ) {
$card_vault = ( isset( $acting_opts['card_vault'] ) ) ? $acting_opts['card_vault'] : 'off';
if ( 'on' === $card_vault ) {
$member = $usces->get_member();
/* Get Access Token */
$access_token = $this->get_access_token();
$payment_tokens = $this->api_get_payment_tokens( $access_token, $member['ID'] );
if ( ! empty( $payment_tokens['payment_tokens'] ) && is_array( $payment_tokens['payment_tokens'] ) ) {
$tokens_count = count( $payment_tokens['payment_tokens'] );
if ( 1 === $tokens_count ) {
$payment_token = current( $payment_tokens['payment_tokens'] );
$payment_token_id = $payment_token['id'];
$payment_token_last_digits = $payment_token['source']['card']['last_digits'];
$payment_token_brand = $payment_token['source']['card']['brand'];
} else {
foreach ( $payment_tokens['payment_tokens'] as $payment_token ) {
$delete_status = $this->api_delete_payment_tokens( $access_token, $payment_token['id'] );
}
}
}
}
}
$tracking_id = usces_acting_key();
ob_start();
?>
';
} else {
if ( ! wel_check_credit_security() ) {
$mes .= __( 'Update has been locked. Please contact the store administrator.', 'usces' ) . '
';
}
}
}
}
return $mes;
}
/**
* 内容確認ページ ポイントフォーム
* usces_action_confirm_page_point_inform
*/
public function e_point_inform() {
$html = $this->point_inform( '' );
wel_esc_script_e( $html );
}
/**
* 内容確認ページ ポイントフォーム
* usces_filter_confirm_point_inform
*
* @param string $html Input point form.
* @return string
*/
public function point_inform( $html ) {
global $usces;
$entry = $usces->cart->get_entry();
$payment = usces_get_payments_by_name( $entry['order']['payment_name'] );
if ( isset( $payment['settlement'] ) && 'acting_paypal_card' === $payment['settlement'] ) {
if ( isset( $_POST['paypal_tracking_id'] ) ) {
$html .= '';
}
if ( isset( $_POST['paypal_resource_id'] ) ) {
$html .= '';
}
if ( isset( $_POST['paypal_payment_card'] ) ) {
$html .= '';
}
if ( isset( $_POST['paypal_payment_token_id'] ) ) {
$html .= '';
}
if ( isset( $_POST['paypal_vault'] ) ) {
$html .= '';
}
if ( isset( $_POST['paypal_f'] ) ) {
$html .= '';
}
if ( isset( $_POST['paypal_liability_shift'] ) ) {
$html .= '';
}
if ( isset( $_POST['paypal_enrollment_status'] ) ) {
$html .= '';
}
if ( isset( $_POST['paypal_authentication_status'] ) ) {
$html .= '';
}
}
return $html;
}
/**
* 内容確認ページ [注文する] ボタン
* usces_filter_confirm_inform
*
* @param string $form Purchase post form.
* @param array $payment Payment method info.
* @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, $payment, $acting_flg, $rand, $purchase_disabled ) {
global $usces;
$entry = $usces->cart->get_entry();
$cart = $usces->cart->get_cart();
if ( empty( $entry ) || empty( $cart ) ) {
return $form;
}
if ( empty( $entry['order']['total_full_price'] ) ) {
return $form;
}
if ( 'acting_paypal_cp' === $acting_flg ) {
usces_save_order_acting_data( $rand );
$form = '