From 68205a8d5f1e45d9dd308b1b41822c5b17ec6fc9 Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Tue, 21 Jul 2020 13:18:39 +0530 Subject: [PATCH 1/4] PHP error Call to a member function get() on null, PFW-664 --- .../angelleye-conditional-functions.php | 2 +- .../angelleye-session-functions.php | 34 +++++++ .../class-angelleye-cartflow-pro-helper.php | 2 +- ...eway-paypal-express-function-angelleye.php | 4 +- ...ateway-paypal-express-helper-angelleye.php | 22 ++--- ...teway-paypal-express-request-angelleye.php | 58 ++++++------ classes/wc-gateway-braintree-angelleye.php | 2 +- .../wc-gateway-paypal-express-angelleye.php | 70 +++++++------- classes/wc-gateway-paypal-pro-angelleye.php | 64 ++++++------- ...c-gateway-paypal-pro-payflow-angelleye.php | 94 +++++++++---------- paypal-for-woocommerce.php | 6 +- 11 files changed, 197 insertions(+), 161 deletions(-) create mode 100644 angelleye-includes/angelleye-session-functions.php diff --git a/angelleye-includes/angelleye-conditional-functions.php b/angelleye-includes/angelleye-conditional-functions.php index 358ff7fee..a04055f0a 100644 --- a/angelleye-includes/angelleye-conditional-functions.php +++ b/angelleye-includes/angelleye-conditional-functions.php @@ -13,7 +13,7 @@ function is_angelleye_ec_review_page() { if (!class_exists('WooCommerce') || WC()->session == null) { return false; } - $paypal_express_checkout = WC()->session->get('paypal_express_checkout'); + $paypal_express_checkout = angelleye_get_session('paypal_express_checkout'); if (isset($paypal_express_checkout['token']) && !empty($paypal_express_checkout['token']) && isset($paypal_express_checkout['payer_id']) && !empty($paypal_express_checkout['payer_id'])) { return true; } else { diff --git a/angelleye-includes/angelleye-session-functions.php b/angelleye-includes/angelleye-session-functions.php new file mode 100644 index 000000000..7a0e11a83 --- /dev/null +++ b/angelleye-includes/angelleye-session-functions.php @@ -0,0 +1,34 @@ +session == null) { + return false; + } + WC()->session->set($key, $value); + } + +} +if (!function_exists('angelleye_get_session')) { + + function angelleye_get_session($key) { + if (!class_exists('WooCommerce') || WC()->session == null) { + return false; + } + $angelleye_session = WC()->session->get($key); + return $angelleye_session; + } + +} +if (!function_exists('angelleye_unset_session')) { + + function angelleye_unset_session($key) { + if (!class_exists('WooCommerce') || WC()->session == null) { + return false; + } + WC()->session->__unset($key); + unset(WC()->session->$key); + } + +} \ No newline at end of file diff --git a/angelleye-includes/cartflows-pro/class-angelleye-cartflow-pro-helper.php b/angelleye-includes/cartflows-pro/class-angelleye-cartflow-pro-helper.php index 926d308ea..e42921ccb 100644 --- a/angelleye-includes/cartflows-pro/class-angelleye-cartflow-pro-helper.php +++ b/angelleye-includes/cartflows-pro/class-angelleye-cartflow-pro-helper.php @@ -74,7 +74,7 @@ function maybe_handle_paypal_express_api_call() { } function angelleye_express_checkout_cartflow($bool) { - $post_data = WC()->session->get('post_data'); + $post_data = angelleye_get_session('post_data'); if (!empty($post_data)) { if (!empty($post_data['_wcf_flow_id'])) { $order_bump = get_post_meta($post_data['_wcf_checkout_id'], 'wcf-pre-checkout-offer', true); diff --git a/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-function-angelleye.php b/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-function-angelleye.php index 42531cf37..01d338ea4 100644 --- a/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-function-angelleye.php +++ b/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-function-angelleye.php @@ -40,7 +40,7 @@ public function ec_is_express_checkout() { if ( ! class_exists( 'WooCommerce' ) || WC()->session == null ) { return false; } - $paypal_express_checkout = WC()->session->get( 'paypal_express_checkout' ); + $paypal_express_checkout = angelleye_get_session( 'paypal_express_checkout' ); if( isset($paypal_express_checkout['token']) && !empty($paypal_express_checkout['token']) && isset($paypal_express_checkout['payer_id']) && !empty($paypal_express_checkout['payer_id']) ) { return true; } else { @@ -63,7 +63,7 @@ public function ec_redirect_after_checkout() { 'redirect' => $this->ec_get_checkout_url('set_express_checkout'), ); if ((isset($_POST['terms']) || isset($_POST['legal'])) && wc_get_page_id('terms') > 0) { - WC()->session->set( 'paypal_express_terms', 1); + angelleye_set_session( 'paypal_express_terms', 1); } if (is_ajax()) { if ($this->ec_is_version_gte_2_4()) { diff --git a/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-helper-angelleye.php b/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-helper-angelleye.php index 5ed9ae67e..8146dce14 100644 --- a/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-helper-angelleye.php +++ b/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-helper-angelleye.php @@ -340,7 +340,7 @@ public function add_to_cart_redirect($url = null) { if (isset($_REQUEST['express_checkout']) || isset($_REQUEST['express_checkout_x'])) { wc_clear_notices(); if ((isset($_POST['wc-paypal_express-new-payment-method']) && $_POST['wc-paypal_express-new-payment-method'] == 'true') || ( isset($_GET['ec_save_to_account']) && $_GET['ec_save_to_account'] == true)) { - WC()->session->set('ec_save_to_account', 'on'); + angelleye_set_session('ec_save_to_account', 'on'); } else { unset(WC()->session->ec_save_to_account); } @@ -357,7 +357,7 @@ public function ec_get_session_data($key = '') { if (!class_exists('WooCommerce') || WC()->session == null) { return false; } - $session_data = WC()->session->get('paypal_express_checkout'); + $session_data = angelleye_get_session('paypal_express_checkout'); if (isset($session_data[$key])) { $session_data = $session_data[$key]; } @@ -380,7 +380,7 @@ public function ec_set_checkout_post_data() { if (!$this->function_helper->ec_is_express_checkout() || !$this->ec_get_session_data('shipping_details')) { return; } - $post_data = WC()->session->get('post_data'); + $post_data = angelleye_get_session('post_data'); foreach ($this->ec_get_session_data('shipping_details') as $field => $value) { if (!empty($value)) { if ('state' == $field) { @@ -534,7 +534,7 @@ public function ec_add_body_class($classes) { if (!class_exists('WooCommerce') || WC()->session == null) { return $classes; } - $paypal_express_terms = WC()->session->get('paypal_express_terms'); + $paypal_express_terms = angelleye_get_session('paypal_express_terms'); if ($this->ec_is_checkout() && $this->function_helper->ec_is_express_checkout()) { $classes[] = 'express-checkout'; if ($this->show_on_checkout && isset($paypal_express_terms)) { @@ -560,7 +560,7 @@ public function ec_terms_express_checkout($checked_default) { if (!$this->ec_is_available() || !$this->function_helper->ec_is_express_checkout()) { return $checked_default; } - $paypal_express_terms = WC()->session->get('paypal_express_terms'); + $paypal_express_terms = angelleye_get_session('paypal_express_terms'); if ($this->show_on_checkout && isset($paypal_express_terms)) { $checked_default = true; } @@ -583,7 +583,7 @@ public function ec_is_checkout() { } public function ec_order_received_text($text, $order) { - $held_order_received_text = WC()->session->get('held_order_received_text'); + $held_order_received_text = angelleye_get_session('held_order_received_text'); if ($order && $order->has_status('on-hold') && isset($held_order_received_text)) { $text = $held_order_received_text; unset(WC()->session->held_order_received_text); @@ -957,7 +957,7 @@ public function angelleye_ship_to_different_address_checked($bool) { if (!class_exists('WooCommerce') || WC()->session == null) { return $bool; } - $post_data = WC()->session->get('post_data'); + $post_data = angelleye_get_session('post_data'); if (!empty($post_data['ship_to_different_address']) && $post_data['ship_to_different_address'] == '1') { return 1; } @@ -1048,7 +1048,7 @@ public function wc_ajax_update_shipping_costs() { WC()->shipping->reset_shipping(); WC()->cart->calculate_totals(); if ((isset($_POST['wc-paypal_express-new-payment-method']) && $_POST['wc-paypal_express-new-payment-method'] == 'true') || ( isset($_GET['ec_save_to_account']) && $_GET['ec_save_to_account'] == true)) { - WC()->session->set('ec_save_to_account', 'on'); + angelleye_set_session('ec_save_to_account', 'on'); } else { unset(WC()->session->ec_save_to_account); } @@ -1068,7 +1068,7 @@ public function angelleye_ajax_generate_cart() { $url = add_query_arg('ec_save_to_account', 'true', $url); } if ((isset($_POST['wc-paypal_express-new-payment-method']) && $_POST['wc-paypal_express-new-payment-method'] == 'true') || ( isset($_GET['ec_save_to_account']) && $_GET['ec_save_to_account'] == true)) { - WC()->session->set( 'ec_save_to_account', 'on' ); + angelleye_set_session( 'ec_save_to_account', 'on' ); $url = add_query_arg('ec_save_to_account', 'true', $url); } else { unset(WC()->session->ec_save_to_account); @@ -1155,7 +1155,7 @@ public function angelleye_paypal_for_woocommerce_page_title($page_title) { if (!class_exists('WooCommerce') || WC()->session == null) { return $page_title; } - $paypal_express_checkout = WC()->session->get('paypal_express_checkout'); + $paypal_express_checkout = angelleye_get_session('paypal_express_checkout'); if (!is_admin() && is_main_query() && in_the_loop() && is_page() && is_checkout() && !empty($paypal_express_checkout)) { remove_filter('the_title', array($this, 'angelleye_paypal_for_woocommerce_page_title')); return $this->review_title_page; @@ -1382,7 +1382,7 @@ public function angelleye_ec_force_to_display_checkout_page_js() { if (AngellEYE_Utility::is_cart_contains_subscription() == true) { return apply_filters('angelleye_ec_force_to_display_checkout_page', true); } - $paypal_express_terms = WC()->session->get('paypal_express_terms'); + $paypal_express_terms = angelleye_get_session('paypal_express_terms'); if (wc_get_page_id('terms') > 0 && apply_filters('woocommerce_checkout_show_terms', true)) { if ($this->disable_term) { return apply_filters('angelleye_ec_force_to_display_checkout_page', false); diff --git a/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-request-angelleye.php b/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-request-angelleye.php index 546478ac7..0c75d3b6b 100644 --- a/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-request-angelleye.php +++ b/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-request-angelleye.php @@ -71,7 +71,7 @@ public function __construct($gateway) { } public function angelleye_redirect() { - $post_data = WC()->session->get('post_data'); + $post_data = angelleye_get_session('post_data'); if( !empty($post_data) ) { if( !empty($post_data['_wcf_checkout_id'])) { $return_url = get_permalink($post_data['_wcf_checkout_id']); @@ -80,11 +80,11 @@ public function angelleye_redirect() { if(empty($return_url)) { $return_url = wc_get_cart_url(); } - $paypal_express_checkout = WC()->session->get('paypal_express_checkout'); + $paypal_express_checkout = angelleye_get_session('paypal_express_checkout'); $payPalURL = $this->PAYPAL_URL . $paypal_express_checkout['token']; if (!empty($this->paypal_response['L_ERRORCODE0']) && $this->paypal_response['L_ERRORCODE0'] == '10486') { if (!empty($paypal_express_checkout['token'])) { - WC()->session->set('is_smart_button_popup_closed', 'yes'); + angelleye_set_session('is_smart_button_popup_closed', 'yes'); wc_clear_notices(); if (!empty($_REQUEST['request_from']) && $_REQUEST['request_from'] == 'JSv4') { if (ob_get_length()) { @@ -211,8 +211,8 @@ public function angelleye_set_express_checkout() { $this->angelleye_set_express_checkout_request(); // @note set token in session so return can be matched - Skylar if (!empty($this->paypal_response['TOKEN'])) { - if (null === ($paypalSession = WC()->session->get('paypal_express_checkout')) || empty($paypalSession['token']) || $paypalSession['token'] != $this->paypal_response['TOKEN']) { // only set if not present or mismatched - WC()->session->set('paypal_express_checkout', ['token' => $this->paypal_response['TOKEN']]); + if (null === ($paypalSession = angelleye_get_session('paypal_express_checkout')) || empty($paypalSession['token']) || $paypalSession['token'] != $this->paypal_response['TOKEN']) { // only set if not present or mismatched + angelleye_set_session('paypal_express_checkout', ['token' => $this->paypal_response['TOKEN']]); } } if ($this->response_helper->ec_is_response_success($this->paypal_response)) { @@ -238,7 +238,7 @@ public function angelleye_set_express_checkout() { public function angelleye_get_express_checkout_details() { try { // @note make sure token matches set express checkout response token - Skylar L - if (!isset($_GET['token']) || null === ($paypalSession = WC()->session->get('paypal_express_checkout')) || empty($paypalSession['token']) || $paypalSession['token'] != $_GET['token']) { + if (!isset($_GET['token']) || null === ($paypalSession = angelleye_get_session('paypal_express_checkout')) || empty($paypalSession['token']) || $paypalSession['token'] != $_GET['token']) { $this->function_helper->ec_clear_session_data(); wc_clear_notices(); wc_add_notice(__('Your PayPal session has expired', 'paypal-for-woocommerce'), 'error'); @@ -267,11 +267,11 @@ public function angelleye_get_express_checkout_details() { 'payer_id' => $this->response_helper->ec_get_payer_id($this->paypal_response), 'ExpresscheckoutDetails' => $this->paypal_response ); - WC()->session->set('paypal_express_checkout', $paypal_express_checkout); - WC()->session->set('shiptoname', $this->paypal_response['FIRSTNAME'] . ' ' . $this->paypal_response['LASTNAME']); - WC()->session->set('payeremail', $this->paypal_response['EMAIL']); - WC()->session->set('chosen_payment_method', $this->gateway->id); - $post_data = WC()->session->get('post_data'); + angelleye_set_session('paypal_express_checkout', $paypal_express_checkout); + angelleye_set_session('shiptoname', $this->paypal_response['FIRSTNAME'] . ' ' . $this->paypal_response['LASTNAME']); + angelleye_set_session('payeremail', $this->paypal_response['EMAIL']); + angelleye_set_session('chosen_payment_method', $this->gateway->id); + $post_data = angelleye_get_session('post_data'); if (empty($post_data)) { $this->angelleye_ec_load_customer_data_using_ec_details(); } @@ -289,7 +289,7 @@ public function angelleye_get_express_checkout_details() { } if ($this->angelleye_ec_force_to_display_checkout_page()) { if (!empty($_GET['pay_for_order']) && $_GET['pay_for_order'] == true && !empty($_GET['key'])) { - WC()->session->set('order_awaiting_payment', absint( wp_unslash( $_GET['order_id'] ) ) ) ; + angelleye_set_session('order_awaiting_payment', absint( wp_unslash( $_GET['order_id'] ) ) ) ; } else { $this->angelleye_wp_safe_redirect(wc_get_checkout_url(), 'get_express_checkout_details'); } @@ -317,7 +317,7 @@ public function angelleye_do_express_checkout_payment() { } elseif (!in_array(WC()->customer->get_shipping_country(), array_keys(WC()->countries->get_shipping_countries()))) { $errors->add('shipping', sprintf(__('Unfortunately we do not ship %s. Please enter an alternative shipping address.', 'paypal-for-woocommerce'), WC()->countries->shipping_to_prefix() . ' ' . WC()->customer->get_shipping_country())); } else { - $chosen_shipping_methods = WC()->session->get('chosen_shipping_methods'); + $chosen_shipping_methods = angelleye_get_session('chosen_shipping_methods'); foreach (WC()->shipping->get_packages() as $i => $package) { if (!isset($chosen_shipping_methods[$i], $package['rates'][$chosen_shipping_methods[$i]])) { $errors->add('shipping', __('No shipping method has been selected. Please double check your address, or contact us if you need any help.', 'paypal-for-woocommerce')); @@ -346,7 +346,7 @@ public function angelleye_do_express_checkout_payment() { if ($order->get_total() > 0) { $this->angelleye_do_express_checkout_payment_request(); } else { - $paypal_express_checkout = WC()->session->get('paypal_express_checkout'); + $paypal_express_checkout = angelleye_get_session('paypal_express_checkout'); if (empty($paypal_express_checkout['token'])) { $this->angelleye_redirect(); } @@ -385,7 +385,7 @@ public function angelleye_do_express_checkout_payment() { $subject .= __('Order #', 'paypal-for-woocommerce') . $order_id; $message = 'We\'re sorry, but something went wrong with your order. Someone from our service department will contact you about this soon.'; $message = $mailer->wrap_message($subject, $message); - $payeremail = WC()->session->get('payeremail'); + $payeremail = angelleye_get_session('payeremail'); if( !empty($payeremail) ) { $mailer->send($payeremail, strip_tags($subject), $message); } @@ -406,7 +406,7 @@ public function angelleye_do_express_checkout_payment() { $this->update_payment_status_by_paypal_responce($this->confirm_order_id, $this->paypal_response); $order->set_transaction_id(isset($this->paypal_response['PAYMENTINFO_0_TRANSACTIONID']) ? $this->paypal_response['PAYMENTINFO_0_TRANSACTIONID'] : ''); } - $payeremail = WC()->session->get('payeremail'); + $payeremail = angelleye_get_session('payeremail'); if ($old_wc) { update_post_meta($order_id, '_express_chekout_transactionid', isset($this->paypal_response['PAYMENTINFO_0_TRANSACTIONID']) ? $this->paypal_response['PAYMENTINFO_0_TRANSACTIONID'] : ''); update_post_meta($order_id, 'paypal_email', $payeremail); @@ -516,7 +516,7 @@ public function angelleye_do_express_checkout_payment_request() { $this->order_param = array('is_calculation_mismatch' => true); } $this->angelleye_load_paypal_class($this->gateway, $this, $this->confirm_order_id); - $paypal_express_checkout = WC()->session->get('paypal_express_checkout'); + $paypal_express_checkout = angelleye_get_session('paypal_express_checkout'); if (empty($paypal_express_checkout['token'])) { $this->angelleye_redirect(); } @@ -701,7 +701,7 @@ public function angelleye_set_express_checkout_request() { 'utm_nooverride' => 1 ), WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE'))); } - WC()->session->set('order_awaiting_payment', absint( wp_unslash( $order_id) ) ); + angelleye_set_session('order_awaiting_payment', absint( wp_unslash( $order_id) ) ); } else { if( $this->send_items ) { $this->cart_param = $this->gateway_calculation->cart_calculation(); @@ -777,7 +777,7 @@ public function angelleye_set_express_checkout_request() { if (empty($_GET['pay_for_order'])) { - $post_data = WC()->session->get('post_data'); + $post_data = angelleye_get_session('post_data'); if (!empty($post_data)) { $SECFields['addroverride'] = 1; if (!empty($post_data['ship_to_different_address'])) { @@ -922,7 +922,7 @@ public function angelleye_add_billing_agreement_param($PayPalRequestData, $token foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) { $product_id = apply_filters('woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key); $_paypal_billing_agreement = get_post_meta($product_id, '_paypal_billing_agreement', true); - $ec_save_to_account = WC()->session->get('ec_save_to_account'); + $ec_save_to_account = angelleye_get_session('ec_save_to_account'); if ($_paypal_billing_agreement == 'yes' || ( isset($ec_save_to_account) && $ec_save_to_account == 'on') || AngellEYE_Utility::angelleye_paypal_for_woo_wc_autoship_cart_has_autoship_item() || AngellEYE_Utility::is_cart_contains_subscription() == true || AngellEYE_Utility::is_subs_change_payment() == true) { $BillingAgreements = array(); $Item = array( @@ -1071,7 +1071,7 @@ public function angelleye_add_extra_order_meta($order) { if ( ! class_exists( 'WooCommerce' ) || WC()->session == null ) { $payment_order_meta = array('_payment_action' => $this->gateway->payment_action, '_first_transaction_id' => isset($this->paypal_response['PAYMENTINFO_0_TRANSACTIONID']) ? $this->paypal_response['PAYMENTINFO_0_TRANSACTIONID'] : $this->paypal_response['TRANSACTIONID']); } else { - $paypal_express_checkout = WC()->session->get('paypal_express_checkout'); + $paypal_express_checkout = angelleye_get_session('paypal_express_checkout'); $payment_order_meta = array('_payment_action' => $this->gateway->payment_action, '_express_checkout_token' => $paypal_express_checkout['token'], '_first_transaction_id' => isset($this->paypal_response['PAYMENTINFO_0_TRANSACTIONID']) ? $this->paypal_response['PAYMENTINFO_0_TRANSACTIONID'] : $this->paypal_response['TRANSACTIONID']); } $order->set_transaction_id(isset($this->paypal_response['PAYMENTINFO_0_TRANSACTIONID']) ? $this->paypal_response['PAYMENTINFO_0_TRANSACTIONID'] : ''); @@ -1080,7 +1080,7 @@ public function angelleye_add_extra_order_meta($order) { } public function angelleye_add_order_note($order) { - $paypal_express_checkout = WC()->session->get('paypal_express_checkout'); + $paypal_express_checkout = angelleye_get_session('paypal_express_checkout'); if (!empty($paypal_express_checkout['ExpresscheckoutDetails']['PAYERSTATUS'])) { $order->add_order_note(sprintf(__('Payer Status: %s', 'paypal-for-woocommerce'), '' . $paypal_express_checkout['ExpresscheckoutDetails']['PAYERSTATUS'] . '')); } @@ -1501,7 +1501,7 @@ public function angelleye_ec_force_to_display_checkout_page() { if (AngellEYE_Utility::is_cart_contains_subscription() == true) { return apply_filters('angelleye_ec_force_to_display_checkout_page', true); } - $paypal_express_terms = WC()->session->get('paypal_express_terms'); + $paypal_express_terms = angelleye_get_session('paypal_express_terms'); if (wc_get_page_id('terms') > 0 && apply_filters('woocommerce_checkout_show_terms', true)) { if ($this->disable_term) { return apply_filters('angelleye_ec_force_to_display_checkout_page', false); @@ -1591,8 +1591,8 @@ public function angelleye_process_refund($order_id, $amount = null, $reason = '' } public function angelleye_process_customer($order_id) { - $post_data = WC()->session->get('post_data'); - $paypal_express_checkout = WC()->session->get('paypal_express_checkout'); + $post_data = angelleye_get_session('post_data'); + $paypal_express_checkout = angelleye_get_session('paypal_express_checkout'); if (!empty($post_data) && !empty($post_data['billing_first_name']) && !empty($post_data['billing_last_name']) && !empty($post_data['billing_email'])) { $first_name = !empty($post_data['billing_first_name']) ? $post_data['billing_first_name'] : ''; $last_name = !empty($post_data['billing_last_name']) ? $post_data['billing_last_name'] : ''; @@ -1620,7 +1620,7 @@ public function angelleye_process_customer($order_id) { } else { $password = wp_generate_password(); } - WC()->session->set('before_wc_create_new_customer', true); + angelleye_set_session('before_wc_create_new_customer', true); $new_customer = wc_create_new_customer($email, $username, $password); if (is_wp_error($new_customer)) { throw new Exception($new_customer->get_error_message()); @@ -1630,7 +1630,7 @@ public function angelleye_process_customer($order_id) { } } wc_set_customer_auth_cookie($customer_id); - WC()->session->set('reload_checkout', true); + angelleye_set_session('reload_checkout', true); if ($first_name && apply_filters('woocommerce_checkout_update_customer_data', true, WC()->customer)) { $userdata = array( 'ID' => $customer_id, @@ -1646,7 +1646,7 @@ public function angelleye_process_customer($order_id) { } public function angelleye_wp_safe_redirect($url, $action = null) { - $is_smart_button_popup_closed = WC()->session->get('is_smart_button_popup_closed'); + $is_smart_button_popup_closed = angelleye_get_session('is_smart_button_popup_closed'); if(!empty($is_smart_button_popup_closed) && $is_smart_button_popup_closed == 'yes') { unset(WC()->session->is_smart_button_popup_closed); wp_safe_redirect($url); @@ -1668,7 +1668,7 @@ public function angelleye_wp_safe_redirect($url, $action = null) { } public function is_angelleye_baid_required() { - $ec_save_to_account = WC()->session->get('ec_save_to_account'); + $ec_save_to_account = angelleye_get_session('ec_save_to_account'); if ( ( isset($ec_save_to_account) && $ec_save_to_account == 'on') || AngellEYE_Utility::angelleye_paypal_for_woo_wc_autoship_cart_has_autoship_item() || AngellEYE_Utility::is_cart_contains_subscription() == true || AngellEYE_Utility::is_subs_change_payment() == true) { return true; } diff --git a/classes/wc-gateway-braintree-angelleye.php b/classes/wc-gateway-braintree-angelleye.php index c71e2ff48..36f600fe6 100644 --- a/classes/wc-gateway-braintree-angelleye.php +++ b/classes/wc-gateway-braintree-angelleye.php @@ -2799,7 +2799,7 @@ public function subscription_change_payment($order_id) { ); } else { - WC()->session->set('reload_checkout', true); + angelleye_set_session('reload_checkout', true); return array( 'result' => 'fail', 'redirect' => '' diff --git a/classes/wc-gateway-paypal-express-angelleye.php b/classes/wc-gateway-paypal-express-angelleye.php index 8781b49f8..8c50fdcea 100644 --- a/classes/wc-gateway-paypal-express-angelleye.php +++ b/classes/wc-gateway-paypal-express-angelleye.php @@ -2139,15 +2139,15 @@ public function process_payment($order_id) { if( is_user_logged_in() && !empty($_POST['ship_to_different_address']) && $_POST['ship_to_different_address'] == '1') { } else { if( empty($_POST['shipping_country'] ) ) { - $paypal_express_checkout = WC()->session->get( 'paypal_express_checkout' ); + $paypal_express_checkout = angelleye_get_session( 'paypal_express_checkout' ); $shipping_details = isset($paypal_express_checkout['shipping_details']) ? wp_unslash($paypal_express_checkout['shipping_details']) : array(); AngellEYE_Utility::angelleye_set_address($order_id, $shipping_details, 'shipping'); } } - $post_data = WC()->session->get('post_data'); + $post_data = angelleye_get_session('post_data'); if ($this->billing_address && empty($post_data)) { if( empty($_POST['billing_country'] ) ) { - $paypal_express_checkout = WC()->session->get( 'paypal_express_checkout' ); + $paypal_express_checkout = angelleye_get_session( 'paypal_express_checkout' ); $shipping_details = isset($paypal_express_checkout['shipping_details']) ? wp_unslash($paypal_express_checkout['shipping_details']) : array(); AngellEYE_Utility::angelleye_set_address($order_id, $shipping_details, 'billing'); } @@ -2157,7 +2157,7 @@ public function process_payment($order_id) { 'redirect' => $return_url, ); if (isset($_POST['terms']) && wc_get_page_id('terms') > 0) { - WC()->session->set( 'paypal_express_terms', true ); + angelleye_set_session( 'paypal_express_terms', true ); } if (is_ajax()) { if ($this->function_helper->ec_is_version_gte_2_4()) { @@ -2173,7 +2173,7 @@ public function process_payment($order_id) { require_once( PAYPAL_FOR_WOOCOMMERCE_PLUGIN_DIR . '/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-request-angelleye.php' ); $paypal_express_request = new WC_Gateway_PayPal_Express_Request_AngellEYE($this); if ((isset($_POST['wc-paypal_express-new-payment-method']) && $_POST['wc-paypal_express-new-payment-method'] == 'true') || ( isset($_GET['ec_save_to_account']) && $_GET['ec_save_to_account'] == true)) { - WC()->session->set( 'ec_save_to_account', 'on' ); + angelleye_set_session( 'ec_save_to_account', 'on' ); } else { unset(WC()->session->ec_save_to_account); } @@ -2181,9 +2181,9 @@ public function process_payment($order_id) { $paypal_express_request->angelleye_set_express_checkout(); } if (isset($_POST['terms']) && wc_get_page_id('terms') > 0) { - WC()->session->set( 'paypal_express_terms', true ); + angelleye_set_session( 'paypal_express_terms', true ); } - WC()->session->set( 'post_data', wp_unslash($_POST)); + angelleye_set_session( 'post_data', wp_unslash($_POST)); $_GET['pp_action'] = 'set_express_checkout'; $this->handle_wc_api(); } @@ -2274,7 +2274,7 @@ public function handle_wc_api() { exit; case 'set_express_checkout': if ((isset($_POST['wc-paypal_express-new-payment-method']) && $_POST['wc-paypal_express-new-payment-method'] == 'true') || ( isset($_GET['ec_save_to_account']) && $_GET['ec_save_to_account'] == true)) { - WC()->session->set( 'ec_save_to_account', 'on' ); + angelleye_set_session( 'ec_save_to_account', 'on' ); } else { unset(WC()->session->ec_save_to_account); } @@ -2282,28 +2282,28 @@ public function handle_wc_api() { break; case 'get_express_checkout_details': $paypal_express_request->angelleye_get_express_checkout_details(); - $order_id = absint(WC()->session->get('order_awaiting_payment')); + $order_id = absint(angelleye_get_session('order_awaiting_payment')); if( !empty($_GET['pay_for_order']) && $_GET['pay_for_order'] == true ) { } else { if ( $order_id > 0 && ( $order = wc_get_order( $order_id ) ) && $order->has_status( array( 'pending', 'failed' ) ) ) { - $_POST = WC()->session->get( 'post_data' ); - $_POST['post_data'] = WC()->session->get( 'post_data' ); - $this->posted = WC()->session->get( 'post_data' ); - $chosen_shipping_methods = WC()->session->get('chosen_shipping_methods'); + $_POST = angelleye_get_session( 'post_data' ); + $_POST['post_data'] = angelleye_get_session( 'post_data' ); + $this->posted = angelleye_get_session( 'post_data' ); + $chosen_shipping_methods = angelleye_get_session('chosen_shipping_methods'); if (isset($_POST['shipping_method']) && is_array($_POST['shipping_method'])) foreach ($_POST['shipping_method'] as $i => $value) { $chosen_shipping_methods[$i] = wc_clean($value); } - WC()->session->set('chosen_shipping_methods', $chosen_shipping_methods); + angelleye_set_session('chosen_shipping_methods', $chosen_shipping_methods); if (WC()->cart->needs_shipping()) { // Validate Shipping Methods WC()->shipping->get_shipping_methods(); $packages = WC()->shipping->get_packages(); - WC()->checkout()->shipping_methods = WC()->session->get('chosen_shipping_methods'); + WC()->checkout()->shipping_methods = angelleye_get_session('chosen_shipping_methods'); } if (empty($this->posted)) { $this->posted = array(); - $paypal_express_checkout = WC()->session->get( 'paypal_express_checkout' ); + $paypal_express_checkout = angelleye_get_session( 'paypal_express_checkout' ); if( !empty($paypal_express_checkout['shipping_details']['email'])) { $this->posted['billing_email'] = $paypal_express_checkout['shipping_details']['email']; } @@ -2319,7 +2319,7 @@ public function handle_wc_api() { $this->angelleye_check_cart_items(); - $validate_data = WC()->session->get( 'validate_data' ); + $validate_data = angelleye_get_session( 'validate_data' ); if( !empty($validate_data) ) { $order_id = WC()->checkout()->create_order($validate_data); @@ -2339,28 +2339,28 @@ public function handle_wc_api() { } do_action('woocommerce_checkout_order_processed', $order_id, $this->posted, $order); } else { - $_POST = WC()->session->get( 'post_data' ); - $_POST['post_data'] = WC()->session->get( 'post_data' ); - $this->posted = WC()->session->get( 'post_data' ); + $_POST = angelleye_get_session( 'post_data' ); + $_POST['post_data'] = angelleye_get_session( 'post_data' ); + $this->posted = angelleye_get_session( 'post_data' ); } if ( $order_id == 0 ) { - $_POST = WC()->session->get( 'post_data' ); - $_POST['post_data'] = WC()->session->get( 'post_data' ); - $this->posted = WC()->session->get( 'post_data' ); - $chosen_shipping_methods = WC()->session->get('chosen_shipping_methods'); + $_POST = angelleye_get_session( 'post_data' ); + $_POST['post_data'] = angelleye_get_session( 'post_data' ); + $this->posted = angelleye_get_session( 'post_data' ); + $chosen_shipping_methods = angelleye_get_session('chosen_shipping_methods'); if (isset($_POST['shipping_method']) && is_array($_POST['shipping_method'])) foreach ($_POST['shipping_method'] as $i => $value) $chosen_shipping_methods[$i] = wc_clean($value); - WC()->session->set('chosen_shipping_methods', $chosen_shipping_methods); + angelleye_set_session('chosen_shipping_methods', $chosen_shipping_methods); if (WC()->cart->needs_shipping()) { // Validate Shipping Methods WC()->shipping->get_shipping_methods(); $packages = WC()->shipping->get_packages(); - WC()->checkout()->shipping_methods = WC()->session->get('chosen_shipping_methods'); + WC()->checkout()->shipping_methods = angelleye_get_session('chosen_shipping_methods'); } if (empty($this->posted)) { $this->posted = array(); - $paypal_express_checkout = WC()->session->get( 'paypal_express_checkout' ); + $paypal_express_checkout = angelleye_get_session( 'paypal_express_checkout' ); if( !empty($paypal_express_checkout['shipping_details']['email'])) { $this->posted['billing_email'] = $paypal_express_checkout['shipping_details']['email']; } elseif( !empty ($paypal_express_checkout['ExpresscheckoutDetails']['EMAIL'])) { @@ -2380,7 +2380,7 @@ public function handle_wc_api() { } $this->angelleye_check_cart_items(); - $validate_data = WC()->session->get( 'validate_data' ); + $validate_data = angelleye_get_session( 'validate_data' ); if( !empty($validate_data) ) { $order_id = WC()->checkout()->create_order($validate_data); @@ -2403,9 +2403,9 @@ public function handle_wc_api() { if(!$order instanceof WC_Order) { $order = wc_get_order($order_id); } - $post_data = WC()->session->get('post_data'); + $post_data = angelleye_get_session('post_data'); if ($this->billing_address && empty($post_data)) { - $paypal_express_checkout = WC()->session->get( 'paypal_express_checkout' ); + $paypal_express_checkout = angelleye_get_session( 'paypal_express_checkout' ); $shipping_details = isset($paypal_express_checkout['shipping_details']) ? $paypal_express_checkout['shipping_details'] : array(); AngellEYE_Utility::angelleye_set_address($order_id, $shipping_details, 'billing'); } else { @@ -2419,7 +2419,7 @@ public function handle_wc_api() { } AngellEYE_Utility::angelleye_set_address($order_id, $billing_address, 'billing'); } - $paypal_express_checkout = WC()->session->get( 'paypal_express_checkout' ); + $paypal_express_checkout = angelleye_get_session( 'paypal_express_checkout' ); $shipping_details = isset($paypal_express_checkout['shipping_details']) ? wp_unslash($paypal_express_checkout['shipping_details']) : array(); AngellEYE_Utility::angelleye_set_address($order_id, $shipping_details, 'shipping'); $order_id = version_compare(WC_VERSION, '3.0', '<') ? $order->id : $order->get_id(); @@ -2431,7 +2431,7 @@ public function handle_wc_api() { $order->set_payment_method($this); update_post_meta($order->get_id(), '_customer_user', get_current_user_id()); } - $post_data = WC()->session->get( 'post_data' ); + $post_data = angelleye_get_session( 'post_data' ); if (!empty($post_data['billing_phone'])) { if ($old_wc) { update_post_meta($order_id, '_billing_phone', $post_data['billing_phone']); @@ -2855,11 +2855,11 @@ public function angelleye_paypal_express_checkout_redirect_to_paypal($data, $err $paypal_express_request = new WC_Gateway_PayPal_Express_Request_AngellEYE($this); if (empty($_POST['woocommerce_checkout_update_totals']) && 0 === $notice_count) { try { - WC()->session->set('post_data', wp_slash($_POST)); - WC()->session->set('validate_data', $data); + angelleye_set_session('post_data', wp_slash($_POST)); + angelleye_set_session('validate_data', $data); if ( isset( $_POST['from_checkout'] ) && 'yes' === $_POST['from_checkout'] ) { if ((isset($_POST['wc-paypal_express-new-payment-method']) && $_POST['wc-paypal_express-new-payment-method'] == 'true') || ( isset($_GET['ec_save_to_account']) && $_GET['ec_save_to_account'] == true)) { - WC()->session->set( 'ec_save_to_account', 'on' ); + angelleye_set_session( 'ec_save_to_account', 'on' ); } else { unset(WC()->session->ec_save_to_account); } diff --git a/classes/wc-gateway-paypal-pro-angelleye.php b/classes/wc-gateway-paypal-pro-angelleye.php index 0a2511d59..e7048c561 100644 --- a/classes/wc-gateway-paypal-pro-angelleye.php +++ b/classes/wc-gateway-paypal-pro-angelleye.php @@ -800,13 +800,13 @@ public function process_payment($order_id) { $this->centinel_client->add('TransactionMode', 'S'); $this->centinel_client->add('ProductCode', 'PHY'); $this->centinel_client->add('CardNumber', $card->number); - WC()->session->set('CardNumber', $card->number); + angelleye_set_session('CardNumber', $card->number); $this->centinel_client->add('CardExpMonth', $card->exp_month); - WC()->session->set('CardExpMonth', $card->exp_month); + angelleye_set_session('CardExpMonth', $card->exp_month); $this->centinel_client->add('CardExpYear', $card->exp_year); - WC()->session->set('CardExpYear', $card->exp_year); + angelleye_set_session('CardExpYear', $card->exp_year); $this->centinel_client->add('CardCode', $card->cvc); - WC()->session->set('CardCode', $card->cvc); + angelleye_set_session('CardCode', $card->cvc); $billing_first_name = version_compare( WC_VERSION, '3.0', '<' ) ? $order->billing_first_name : $order->get_billing_first_name(); $billing_last_name = version_compare( WC_VERSION, '3.0', '<' ) ? $order->billing_last_name : $order->get_billing_last_name(); @@ -856,16 +856,16 @@ public function process_payment($order_id) { // Save response in session - WC()->session->set('Centinel_ErrorNo', $this->get_centinel_value("ErrorNo")); - WC()->session->set('Centinel_ErrorDesc', $this->get_centinel_value("ErrorDesc")); - WC()->session->set('Centinel_TransactionId', $this->get_centinel_value("TransactionId")); - WC()->session->set('Centinel_OrderId', $this->get_centinel_value("OrderId")); - WC()->session->set('Centinel_Enrolled', $this->get_centinel_value("Enrolled")); - WC()->session->set('Centinel_ACSUrl', $this->get_centinel_value("ACSUrl")); - WC()->session->set('Centinel_Payload', $this->get_centinel_value("Payload")); - WC()->session->set('Centinel_EciFlag', $this->get_centinel_value("EciFlag")); - WC()->session->set('Centinel_card_start_month', $card->start_month); - WC()->session->set('Centinel_card_start_year', $card->start_year); + angelleye_set_session('Centinel_ErrorNo', $this->get_centinel_value("ErrorNo")); + angelleye_set_session('Centinel_ErrorDesc', $this->get_centinel_value("ErrorDesc")); + angelleye_set_session('Centinel_TransactionId', $this->get_centinel_value("TransactionId")); + angelleye_set_session('Centinel_OrderId', $this->get_centinel_value("OrderId")); + angelleye_set_session('Centinel_Enrolled', $this->get_centinel_value("Enrolled")); + angelleye_set_session('Centinel_ACSUrl', $this->get_centinel_value("ACSUrl")); + angelleye_set_session('Centinel_Payload', $this->get_centinel_value("Payload")); + angelleye_set_session('Centinel_EciFlag', $this->get_centinel_value("EciFlag")); + angelleye_set_session('Centinel_card_start_month', $card->start_month); + angelleye_set_session('Centinel_card_start_year', $card->start_year); if ($this->get_centinel_value("ErrorNo")) { @@ -899,8 +899,8 @@ public function process_payment($order_id) { public function handle_3dsecure() { if (!empty($_GET['acs'])) { $order_id = wc_clean($_GET['acs']); - $acsurl = WC()->session->get('Centinel_ACSUrl'); - $payload = WC()->session->get('Centinel_Payload'); + $acsurl = angelleye_get_session('Centinel_ACSUrl'); + $payload = angelleye_get_session('Centinel_Payload'); ?> @@ -958,14 +958,14 @@ function authorise_3dsecure() { $this->centinel_client->add("MerchantId", $this->centinel_mid); $this->centinel_client->add("TransactionPwd", $this->centinel_pwd); $this->centinel_client->add("TransactionType", 'C'); - $this->centinel_client->add('TransactionId', WC()->session->get('Centinel_TransactionId')); + $this->centinel_client->add('TransactionId', angelleye_get_session('Centinel_TransactionId')); $this->centinel_client->add('PAResPayload', $pares); $this->centinel_client->sendHttp($this->centinel_url, "5000", "15000"); $response_to_log = $this->centinel_client->response; $response_to_log['CardNumber'] = 'XXX'; $response_to_log['CardCode'] = 'XXX'; - $this->log('Centinal transaction ID ' . WC()->session->get('Centinel_TransactionId')); + $this->log('Centinal transaction ID ' . angelleye_get_session('Centinel_TransactionId')); $this->log('Centinal client request : ' . print_r($this->centinel_client->request, true)); $this->log('Centinal client response: ' . print_r($response_to_log, true)); $this->log('3dsecure pa_res_status: ' . $this->get_centinel_value("PAResStatus")); @@ -987,15 +987,15 @@ function authorise_3dsecure() { $card->cvc = $this->get_centinel_value("CardCode"); $card->exp_month = $this->get_centinel_value("CardExpMonth"); $card->exp_year = $this->get_centinel_value("CardExpYear"); - $card->start_month = WC()->session->get('Centinel_card_start_month'); - $card->start_year = WC()->session->get('Centinel_card_start_year'); + $card->start_month = angelleye_get_session('Centinel_card_start_month'); + $card->start_year = angelleye_get_session('Centinel_card_start_year'); $centinel = new stdClass(); $centinel->paresstatus = $this->get_centinel_value("PAResStatus"); $centinel->xid = $this->get_centinel_value("Xid"); $centinel->cavv = $this->get_centinel_value("Cavv"); $centinel->eciflag = $this->get_centinel_value("EciFlag"); - $centinel->enrolled = WC()->session->get('Centinel_Enrolled'); + $centinel->enrolled = angelleye_get_session('Centinel_Enrolled'); $this->do_payment($order, $card->number, $card->type, $card->exp_month, $card->exp_year, $card->cvc, $centinel->paresstatus, "Y", $centinel->cavv, $centinel->eciflag, $centinel->xid, $card->start_month, $card->start_year); $this->clear_centinel_session(); wp_safe_redirect($redirect_url); @@ -1435,16 +1435,16 @@ function do_payment($order, $card_number, $card_type, $card_exp_month, $card_exp * @return void */ function clear_centinel_session() { - WC()->session->set('Centinel_ErrorNo', null); - WC()->session->set('Centinel_ErrorDesc', null); - WC()->session->set('Centinel_TransactionId', null); - WC()->session->set('Centinel_OrderId', null); - WC()->session->set('Centinel_Enrolled', null); - WC()->session->set('Centinel_ACSUrl', null); - WC()->session->set('Centinel_Payload', null); - WC()->session->set('Centinel_EciFlag', null); - WC()->session->set('Centinel_card_start_month', null); - WC()->session->set('Centinel_card_start_year', null); + angelleye_set_session('Centinel_ErrorNo', null); + angelleye_set_session('Centinel_ErrorDesc', null); + angelleye_set_session('Centinel_TransactionId', null); + angelleye_set_session('Centinel_OrderId', null); + angelleye_set_session('Centinel_Enrolled', null); + angelleye_set_session('Centinel_ACSUrl', null); + angelleye_set_session('Centinel_Payload', null); + angelleye_set_session('Centinel_EciFlag', null); + angelleye_set_session('Centinel_card_start_month', null); + angelleye_set_session('Centinel_card_start_year', null); } /** @@ -1545,7 +1545,7 @@ public function angelleye_woocommerce_credit_card_form_start($current_id) { public function get_centinel_value($key) { $value = $this->centinel_client->getValue($key); if (empty($value)) { - $value = WC()->session->get($key); + $value = angelleye_get_session($key); } $value = wc_clean($value); return $value; diff --git a/classes/wc-gateway-paypal-pro-payflow-angelleye.php b/classes/wc-gateway-paypal-pro-payflow-angelleye.php index c5c2c0245..92cb061f2 100644 --- a/classes/wc-gateway-paypal-pro-payflow-angelleye.php +++ b/classes/wc-gateway-paypal-pro-payflow-angelleye.php @@ -705,18 +705,18 @@ function process_payment($order_id) { $this->centinel_client->add('TransactionMode', 'S'); $this->centinel_client->add('ProductCode', 'PHY'); $this->centinel_client->add('CardNumber', $card->number); - WC()->session->set('CardNumber', $card->number); + angelleye_set_session('CardNumber', $card->number); $this->centinel_client->add('CardExpMonth', $card->exp_month); - WC()->session->set('CardExpMonth', $card->exp_month); + angelleye_set_session('CardExpMonth', $card->exp_month); if (strlen($card->exp_year) == 2) { $card_exp_year_full += 2000; } else { $card_exp_year_full = $card->exp_year; } $this->centinel_client->add('CardExpYear', $card_exp_year_full); - WC()->session->set('CardExpYear', $card_exp_year_full); + angelleye_set_session('CardExpYear', $card_exp_year_full); $this->centinel_client->add('CardCode', $card->cvc); - WC()->session->set('CardCode', $card->cvc); + angelleye_set_session('CardCode', $card->cvc); $billing_first_name = version_compare(WC_VERSION, '3.0', '<') ? $order->billing_first_name : $order->get_billing_first_name(); $billing_last_name = version_compare(WC_VERSION, '3.0', '<') ? $order->billing_last_name : $order->get_billing_last_name(); @@ -766,16 +766,16 @@ function process_payment($order_id) { // Save response in session - WC()->session->set('Centinel_ErrorNo', $this->get_centinel_value("ErrorNo")); - WC()->session->set('Centinel_ErrorDesc', $this->get_centinel_value("ErrorDesc")); - WC()->session->set('Centinel_TransactionId', $this->get_centinel_value("TransactionId")); - WC()->session->set('Centinel_OrderId', $this->get_centinel_value("OrderId")); - WC()->session->set('Centinel_Enrolled', $this->get_centinel_value("Enrolled")); - WC()->session->set('Centinel_ACSUrl', $this->get_centinel_value("ACSUrl")); - WC()->session->set('Centinel_Payload', $this->get_centinel_value("Payload")); - WC()->session->set('Centinel_EciFlag', $this->get_centinel_value("EciFlag")); - WC()->session->set('Centinel_card_start_month', $card->start_month); - WC()->session->set('Centinel_card_start_year', $card->start_year); + angelleye_set_session('Centinel_ErrorNo', $this->get_centinel_value("ErrorNo")); + angelleye_set_session('Centinel_ErrorDesc', $this->get_centinel_value("ErrorDesc")); + angelleye_set_session('Centinel_TransactionId', $this->get_centinel_value("TransactionId")); + angelleye_set_session('Centinel_OrderId', $this->get_centinel_value("OrderId")); + angelleye_set_session('Centinel_Enrolled', $this->get_centinel_value("Enrolled")); + angelleye_set_session('Centinel_ACSUrl', $this->get_centinel_value("ACSUrl")); + angelleye_set_session('Centinel_Payload', $this->get_centinel_value("Payload")); + angelleye_set_session('Centinel_EciFlag', $this->get_centinel_value("EciFlag")); + angelleye_set_session('Centinel_card_start_month', $card->start_month); + angelleye_set_session('Centinel_card_start_year', $card->start_year); if ($this->get_centinel_value("ErrorNo")) { @@ -804,10 +804,10 @@ function process_payment($order_id) { $order_amt = '0.00'; } $redirect_url = $this->get_return_url($order); - WC()->session->set('acct', $card->number); - WC()->session->set('exp_month', $card->exp_month); - WC()->session->set('exp_year', $card->exp_year); - WC()->session->set('cvv2', $card->cvc); + angelleye_set_session('acct', $card->number); + angelleye_set_session('exp_month', $card->exp_month); + angelleye_set_session('exp_year', $card->exp_year); + angelleye_set_session('cvv2', $card->cvc); $PayPalRequestData = array( 'trxtype' => 'E', @@ -857,19 +857,19 @@ function process_payment($order_id) { if (isset($PayPalResult['AUTHENTICATION_ID']) && $PayPalResult['RESULT'] == 0) { if (!empty($PayPalResult['AUTHENTICATION_ID'])) { - WC()->session->set('AUTHENTICATION_ID', $PayPalResult['AUTHENTICATION_ID']); + angelleye_set_session('AUTHENTICATION_ID', $PayPalResult['AUTHENTICATION_ID']); } if (!empty($PayPalResult['AUTHENTICATION_STATUS'])) { - WC()->session->set('AUTHENTICATION_STATUS', $PayPalResult['AUTHENTICATION_STATUS']); + angelleye_set_session('AUTHENTICATION_STATUS', $PayPalResult['AUTHENTICATION_STATUS']); } if (!empty($PayPalResult['ACSURL'])) { - WC()->session->set('ACSURL', $PayPalResult['ACSURL']); + angelleye_set_session('ACSURL', $PayPalResult['ACSURL']); } if (!empty($PayPalResult['PAREQ'])) { - WC()->session->set('PAREQ', $PayPalResult['PAREQ']); + angelleye_set_session('PAREQ', $PayPalResult['PAREQ']); } if (!empty($PayPalResult['ECI'])) { - WC()->session->set('ECI', $PayPalResult['ECI']); + angelleye_set_session('ECI', $PayPalResult['ECI']); } if (isset($PayPalResult['AUTHENTICATION_STATUS']) && 'E' === $PayPalResult['AUTHENTICATION_STATUS']) { $this->add_log('Doing 3dsecure payment authorization'); @@ -932,11 +932,11 @@ public function handle_3dsecure() { if (!empty($_GET['acs'])) { $order_id = wc_clean($_GET['acs']); if ($this->threedsecure_type == 'cardinalcommerce') { - $acsurl = WC()->session->get('Centinel_ACSUrl'); - $payload = WC()->session->get('Centinel_Payload'); + $acsurl = angelleye_get_session('Centinel_ACSUrl'); + $payload = angelleye_get_session('Centinel_Payload'); } else { - $acsurl = WC()->session->get('ACSUrl'); - $payload = WC()->session->get('PAREQ'); + $acsurl = angelleye_get_session('ACSUrl'); + $payload = angelleye_get_session('PAREQ'); } ?> @@ -995,14 +995,14 @@ function authorise_3dsecure() { $this->centinel_client->add("MerchantId", $this->centinel_mid); $this->centinel_client->add("TransactionPwd", $this->centinel_pwd); $this->centinel_client->add("TransactionType", 'C'); - $this->centinel_client->add('TransactionId', WC()->session->get('Centinel_TransactionId')); + $this->centinel_client->add('TransactionId', angelleye_get_session('Centinel_TransactionId')); $this->centinel_client->add('PAResPayload', $pares); $this->centinel_client->sendHttp($this->centinel_url, "5000", "15000"); $response_to_log = $this->centinel_client->response; $response_to_log['CardNumber'] = 'XXX'; $response_to_log['CardCode'] = 'XXX'; - $this->add_log('Centinal transaction ID ' . WC()->session->get('Centinel_TransactionId')); + $this->add_log('Centinal transaction ID ' . angelleye_get_session('Centinel_TransactionId')); $this->add_log('Centinal client request : ' . print_r($this->centinel_client->request, true)); $this->add_log('Centinal client response: ' . print_r($response_to_log, true)); $this->add_log('3dsecure pa_res_status: ' . $this->get_centinel_value("PAResStatus")); @@ -1019,14 +1019,14 @@ function authorise_3dsecure() { $card->cvc = $this->get_centinel_value("CardCode"); $card->exp_month = $this->get_centinel_value("CardExpMonth"); $card->exp_year = $this->get_centinel_value("CardExpYear"); - $card->start_month = WC()->session->get('Centinel_card_start_month'); - $card->start_year = WC()->session->get('Centinel_card_start_year'); + $card->start_month = angelleye_get_session('Centinel_card_start_month'); + $card->start_year = angelleye_get_session('Centinel_card_start_year'); $centinel_data = array(); $centinel_data['AUTHSTATUS3DS'] = $this->get_centinel_value("PAResStatus"); $centinel_data['XID'] = $this->get_centinel_value("Xid"); $centinel_data['CAVV'] = $this->get_centinel_value("Cavv"); $centinel_data['ECI'] = $this->get_centinel_value("EciFlag"); - $centinel_data['MPIVENDOR3DS'] = WC()->session->get('Centinel_Enrolled'); + $centinel_data['MPIVENDOR3DS'] = angelleye_get_session('Centinel_Enrolled'); $this->do_payment($order, $card->number, $card->exp_month . $card->exp_year, $card->cvc, $centinel_data); $this->clear_centinel_session(); wp_safe_redirect($redirect_url); @@ -1094,10 +1094,10 @@ function authorise_3dsecure() { } } $centinel['THREEDSVERSION'] = '1.0.2'; - $acct = WC()->session->get('acct'); - $exp_month = WC()->session->get('exp_month'); - $exp_year = WC()->session->get('exp_year'); - $cvv2 = WC()->session->get('cvv2'); + $acct = angelleye_get_session('acct'); + $exp_month = angelleye_get_session('exp_month'); + $exp_year = angelleye_get_session('exp_year'); + $cvv2 = angelleye_get_session('cvv2'); $this->do_payment($order, $acct, $exp_month . $exp_year, $cvv2, $centinel); wp_safe_redirect($redirect_url); exit(); @@ -2420,16 +2420,16 @@ public function get_token_by_token($token_id, $token_result = null) { } function clear_centinel_session() { - WC()->session->set('Centinel_ErrorNo', null); - WC()->session->set('Centinel_ErrorDesc', null); - WC()->session->set('Centinel_TransactionId', null); - WC()->session->set('Centinel_OrderId', null); - WC()->session->set('Centinel_Enrolled', null); - WC()->session->set('Centinel_ACSUrl', null); - WC()->session->set('Centinel_Payload', null); - WC()->session->set('Centinel_EciFlag', null); - WC()->session->set('Centinel_card_start_month', null); - WC()->session->set('Centinel_card_start_year', null); + angelleye_set_session('Centinel_ErrorNo', null); + angelleye_set_session('Centinel_ErrorDesc', null); + angelleye_set_session('Centinel_TransactionId', null); + angelleye_set_session('Centinel_OrderId', null); + angelleye_set_session('Centinel_Enrolled', null); + angelleye_set_session('Centinel_ACSUrl', null); + angelleye_set_session('Centinel_Payload', null); + angelleye_set_session('Centinel_EciFlag', null); + angelleye_set_session('Centinel_card_start_month', null); + angelleye_set_session('Centinel_card_start_year', null); } /** @@ -2439,7 +2439,7 @@ function clear_centinel_session() { public function get_centinel_value($key) { $value = $this->centinel_client->getValue($key); if (empty($value)) { - $value = WC()->session->get($key); + $value = angelleye_get_session($key); } $value = wc_clean($value); return $value; diff --git a/paypal-for-woocommerce.php b/paypal-for-woocommerce.php index c39c3bba6..17c3dc2de 100644 --- a/paypal-for-woocommerce.php +++ b/paypal-for-woocommerce.php @@ -63,7 +63,9 @@ if (!function_exists('angelleye_queue_update')) { require_once( 'angelleye-includes/angelleye-functions.php' ); } +require_once( 'angelleye-includes/angelleye-session-functions.php' ); require_once( 'angelleye-includes/angelleye-conditional-functions.php' ); + /** * Set global parameters */ @@ -1062,8 +1064,8 @@ public function angelleye_express_checkout_woocommerce_enable_guest_checkout($bo return false; } $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", 'woocommerce_enable_guest_checkout' ) ); - $paypal_express_checkout = WC()->session->get( 'paypal_express_checkout' ); - $ec_save_to_account = WC()->session->get( 'ec_save_to_account' ); + $paypal_express_checkout = angelleye_get_session( 'paypal_express_checkout' ); + $ec_save_to_account = angelleye_get_session( 'ec_save_to_account' ); if( !empty($row->option_value) && $row->option_value == 'yes' && isset($paypal_express_checkout) && !empty($paypal_express_checkout) && isset($ec_save_to_account) && $ec_save_to_account == 'on') { $return = 'no'; } else { From 0b07deefd359bb42008f65bb11ac3a3ab3412876 Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Tue, 21 Jul 2020 17:57:27 +0530 Subject: [PATCH 2/4] update condition, PFW-664 --- .../class-wc-gateway-paypal-express-helper-angelleye.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-helper-angelleye.php b/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-helper-angelleye.php index 8146dce14..41fc2499c 100644 --- a/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-helper-angelleye.php +++ b/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-helper-angelleye.php @@ -537,7 +537,7 @@ public function ec_add_body_class($classes) { $paypal_express_terms = angelleye_get_session('paypal_express_terms'); if ($this->ec_is_checkout() && $this->function_helper->ec_is_express_checkout()) { $classes[] = 'express-checkout'; - if ($this->show_on_checkout && isset($paypal_express_terms)) { + if ($this->show_on_checkout && $paypal_express_terms === true) { $classes[] = 'express-hide-terms'; } } @@ -561,7 +561,7 @@ public function ec_terms_express_checkout($checked_default) { return $checked_default; } $paypal_express_terms = angelleye_get_session('paypal_express_terms'); - if ($this->show_on_checkout && isset($paypal_express_terms)) { + if ($this->show_on_checkout && $paypal_express_terms === true) { $checked_default = true; } return $checked_default; From 0d2b5786a50a847261fb804d728de761c3c10535 Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Tue, 21 Jul 2020 18:44:43 +0530 Subject: [PATCH 3/4] update session function, PFW-664 --- .../angelleye-session-functions.php | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/angelleye-includes/angelleye-session-functions.php b/angelleye-includes/angelleye-session-functions.php index 7a0e11a83..4573f8fcb 100644 --- a/angelleye-includes/angelleye-session-functions.php +++ b/angelleye-includes/angelleye-session-functions.php @@ -3,32 +3,52 @@ if (!function_exists('angelleye_set_session')) { function angelleye_set_session($key, $value) { - if (!class_exists('WooCommerce') || WC()->session == null) { + if (!class_exists('WooCommerce') || !function_exists('WC')) { + return false; + } + if (WC()->session == null) { + WC()->initialize_session(); + } + if (WC()->session) { + WC()->session->set($key, $value); + } else { return false; } - WC()->session->set($key, $value); } } if (!function_exists('angelleye_get_session')) { function angelleye_get_session($key) { - if (!class_exists('WooCommerce') || WC()->session == null) { + + if (!class_exists('WooCommerce') || !function_exists('WC')) { + return false; + } + if (WC()->session == null) { + WC()->initialize_session(); + } + if (WC()->session) { + $angelleye_session = WC()->session->get($key); + return $angelleye_session; + } else { return false; } - $angelleye_session = WC()->session->get($key); - return $angelleye_session; } } if (!function_exists('angelleye_unset_session')) { function angelleye_unset_session($key) { - if (!class_exists('WooCommerce') || WC()->session == null) { + if (!class_exists('WooCommerce') || !function_exists('WC')) { return false; } - WC()->session->__unset($key); - unset(WC()->session->$key); + if (WC()->session == null) { + WC()->initialize_session(); + } + if (WC()->session) { + WC()->session->__unset($key); + unset(WC()->session->$key); + } } } \ No newline at end of file From 4a1ad6d98302006827c0303464963eaab370ecc9 Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Wed, 22 Jul 2020 09:28:41 +0530 Subject: [PATCH 4/4] update session function, PFW-664 --- .../angelleye-conditional-functions.php | 3 - .../angelleye-session-functions.php | 76 +++++++++++-------- ...eway-paypal-express-function-angelleye.php | 3 - ...ateway-paypal-express-helper-angelleye.php | 3 - 4 files changed, 44 insertions(+), 41 deletions(-) diff --git a/angelleye-includes/angelleye-conditional-functions.php b/angelleye-includes/angelleye-conditional-functions.php index a04055f0a..0893237df 100644 --- a/angelleye-includes/angelleye-conditional-functions.php +++ b/angelleye-includes/angelleye-conditional-functions.php @@ -10,9 +10,6 @@ * @return bool */ function is_angelleye_ec_review_page() { - if (!class_exists('WooCommerce') || WC()->session == null) { - return false; - } $paypal_express_checkout = angelleye_get_session('paypal_express_checkout'); if (isset($paypal_express_checkout['token']) && !empty($paypal_express_checkout['token']) && isset($paypal_express_checkout['payer_id']) && !empty($paypal_express_checkout['payer_id'])) { return true; diff --git a/angelleye-includes/angelleye-session-functions.php b/angelleye-includes/angelleye-session-functions.php index 4573f8fcb..4ddd0db7f 100644 --- a/angelleye-includes/angelleye-session-functions.php +++ b/angelleye-includes/angelleye-session-functions.php @@ -3,16 +3,20 @@ if (!function_exists('angelleye_set_session')) { function angelleye_set_session($key, $value) { - if (!class_exists('WooCommerce') || !function_exists('WC')) { - return false; - } - if (WC()->session == null) { - WC()->initialize_session(); - } - if (WC()->session) { - WC()->session->set($key, $value); - } else { - return false; + try { + if (!class_exists('WooCommerce') || !function_exists('WC')) { + return false; + } + if (WC()->session == null) { + WC()->initialize_session(); + } + if (WC()->session) { + WC()->session->set($key, $value); + } else { + return false; + } + } catch (Exception $ex) { + } } @@ -20,35 +24,43 @@ function angelleye_set_session($key, $value) { if (!function_exists('angelleye_get_session')) { function angelleye_get_session($key) { + try { + if (!class_exists('WooCommerce') || !function_exists('WC')) { + return false; + } + if (WC()->session == null) { + WC()->initialize_session(); + } + if (WC()->session) { + $angelleye_session = WC()->session->get($key); + return $angelleye_session; + } else { + return false; + } + } catch (Exception $ex) { - if (!class_exists('WooCommerce') || !function_exists('WC')) { - return false; - } - if (WC()->session == null) { - WC()->initialize_session(); - } - if (WC()->session) { - $angelleye_session = WC()->session->get($key); - return $angelleye_session; - } else { - return false; } } } if (!function_exists('angelleye_unset_session')) { - function angelleye_unset_session($key) { - if (!class_exists('WooCommerce') || !function_exists('WC')) { - return false; - } - if (WC()->session == null) { - WC()->initialize_session(); - } - if (WC()->session) { - WC()->session->__unset($key); - unset(WC()->session->$key); + try { + + function angelleye_unset_session($key) { + if (!class_exists('WooCommerce') || !function_exists('WC')) { + return false; + } + if (WC()->session == null) { + WC()->initialize_session(); + } + if (WC()->session) { + WC()->session->__unset($key); + unset(WC()->session->$key); + } } - } + } catch (Exception $ex) { + + } } \ No newline at end of file diff --git a/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-function-angelleye.php b/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-function-angelleye.php index 01d338ea4..369180034 100644 --- a/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-function-angelleye.php +++ b/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-function-angelleye.php @@ -37,9 +37,6 @@ public function ec_get_checkout_url($action) { } public function ec_is_express_checkout() { - if ( ! class_exists( 'WooCommerce' ) || WC()->session == null ) { - return false; - } $paypal_express_checkout = angelleye_get_session( 'paypal_express_checkout' ); if( isset($paypal_express_checkout['token']) && !empty($paypal_express_checkout['token']) && isset($paypal_express_checkout['payer_id']) && !empty($paypal_express_checkout['payer_id']) ) { return true; diff --git a/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-helper-angelleye.php b/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-helper-angelleye.php index 41fc2499c..7de4a2c2b 100644 --- a/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-helper-angelleye.php +++ b/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-helper-angelleye.php @@ -354,9 +354,6 @@ public function add_to_cart_redirect($url = null) { public function ec_get_session_data($key = '') { try { - if (!class_exists('WooCommerce') || WC()->session == null) { - return false; - } $session_data = angelleye_get_session('paypal_express_checkout'); if (isset($session_data[$key])) { $session_data = $session_data[$key];