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 369180034..4c889a56d 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 @@ -33,7 +33,7 @@ public function express_checkout_get_option($option_name) { } public function ec_get_checkout_url($action) { - return add_query_arg( array( 'pp_action' => $action, 'utm_nooverride' => '1'), WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE') ); + return add_query_arg( array( 'pp_action' => $action, 'utm_nooverride' => '1'), untrailingslashit(WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE')) ); } public function ec_is_express_checkout() { 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 7de4a2c2b..04dae90c7 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 @@ -312,7 +312,7 @@ public function buy_now_button() { break; } if ($this->show_paypal_credit == 'yes') { - $paypal_credit_button_markup = ''; + $paypal_credit_button_markup = ''; $paypal_credit_button_markup .= ''; $paypal_credit_button_markup .= ''; $ec_html_button .= $paypal_credit_button_markup; @@ -344,7 +344,7 @@ public function add_to_cart_redirect($url = null) { } else { unset(WC()->session->ec_save_to_account); } - $url = esc_url_raw(add_query_arg('pp_action', 'set_express_checkout', add_query_arg('wc-api', 'WC_Gateway_PayPal_Express_AngellEYE', home_url('/')))); + $url = esc_url_raw(add_query_arg('pp_action', 'set_express_checkout', untrailingslashit(WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE')))); } return $url; } catch (Exception $ex) { @@ -576,7 +576,12 @@ public function ec_clear_session_data() { } public function ec_is_checkout() { - return is_page(wc_get_page_id('checkout')) || apply_filters('woocommerce_is_checkout', false); + if(function_exists('is_checkout')) { + if(is_checkout()) { + return true; + } + } + return false; } public function ec_order_received_text($text, $order) { @@ -710,7 +715,7 @@ public function ec_enqueue_scripts_product_page($is_mini_cart = false) { wp_localize_script('angelleye-in-context-checkout-js-frontend', 'angelleye_in_content_param', array( 'environment' => ( $this->testmode == true) ? 'sandbox' : 'production', 'locale' => ($this->use_wp_locale_code === 'yes' && AngellEYE_Utility::get_button_locale_code() != '') ? AngellEYE_Utility::get_button_locale_code() : '', - 'start_flow' => esc_url(add_query_arg(array('startcheckout' => 'true'), wc_get_page_permalink('cart'))), + 'start_flow' => esc_url(add_query_arg(array('startcheckout' => 'true'), wc_get_cart_url())), 'show_modal' => apply_filters('woocommerce_paypal_express_checkout_show_cart_modal', true), 'update_shipping_costs_nonce' => wp_create_nonce('_wc_angelleye_ppec_update_shipping_costs_nonce'), 'ajaxurl' => WC_AJAX::get_endpoint('wc_angelleye_ppec_update_shipping_costs'), @@ -737,7 +742,7 @@ public function ec_enqueue_scripts_product_page($is_mini_cart = false) { 'wsc_cart_button_height' => $this->wsc_cart_button_height, 'wsc_cart_button_label' => $this->wsc_cart_button_label, 'button_fundingicons' => $this->button_fundingicons, - 'cancel_page' => add_query_arg('pp_action', 'cancel_order', WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE')), + 'cancel_page' => add_query_arg('pp_action', 'cancel_order', untrailingslashit(WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE'))), 'is_paypal_credit_enable' => $this->is_paypal_credit_enable ? "yes" : 'no', 'allowed_funding_methods' => $allowed_funding_methods_json, 'disallowed_funding_methods' => $disallowed_funding_methods_json, @@ -746,7 +751,7 @@ public function ec_enqueue_scripts_product_page($is_mini_cart = false) { 'wsc_cart_allowed_funding_methods' => $wsc_cart_allowed_funding_methods_json, 'wsc_cart_disallowed_funding_methods' => $wsc_cart_disallowed_funding_methods_json, 'enable_google_analytics_click' => $this->enable_google_analytics_click, - 'set_express_checkout' => add_query_arg('pp_action', 'set_express_checkout', add_query_arg('wc-api', 'WC_Gateway_PayPal_Express_AngellEYE', home_url('/'))), + 'set_express_checkout' => add_query_arg('pp_action', 'set_express_checkout', untrailingslashit(WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE'))), 'zcommit' => $this->angelleye_ec_force_to_display_checkout_page_js() == true ? 'false' : 'true', 'checkout_page_disable_smart_button' => $this->checkout_page_disable_smart_button ? "yes" : "no", 'is_cartflow' => $is_cartflow, @@ -834,21 +839,21 @@ public function woocommerce_paypal_express_checkout_button_angelleye($return = f if ($this->enable_in_context_checkout_flow == 'no') { switch ($this->checkout_with_pp_button_type) { case 'textbutton': - $cart_button_html .= '' . $this->pp_button_type_text_button . ''; + $cart_button_html .= '' . $this->pp_button_type_text_button . ''; break; case 'paypalimage': - $cart_button_html .= ''; + $cart_button_html .= ''; $cart_button_html .= '' . __('Pay with PayPal', 'paypal-for-woocommerce') . ''; $cart_button_html .= ""; break; case 'customimage': - $cart_button_html .= ''; + $cart_button_html .= ''; $cart_button_html .= '' . __('Pay with PayPal', 'paypal-for-woocommerce') . ''; $cart_button_html .= ""; break; } if ($this->show_paypal_credit == 'yes') { - $paypal_credit_button_markup = ''; + $paypal_credit_button_markup = ''; $paypal_credit_button_markup .= ''; $paypal_credit_button_markup .= ''; $cart_button_html .= $paypal_credit_button_markup; @@ -894,12 +899,12 @@ public function checkout_message() { switch ($this->checkout_with_pp_button_type) { case "textbutton": $ec_top_checkout_button .= '
'; - $ec_top_checkout_button .= '' . $this->pp_button_type_text_button . ''; + $ec_top_checkout_button .= '' . $this->pp_button_type_text_button . ''; $ec_top_checkout_button .= '
'; break; case "paypalimage": $ec_top_checkout_button .= '
'; - $ec_top_checkout_button .= ''; + $ec_top_checkout_button .= ''; $ec_top_checkout_button .= "" . __("; $ec_top_checkout_button .= ""; $ec_top_checkout_button .= '
'; @@ -907,7 +912,7 @@ public function checkout_message() { case "customimage": $button_img = $this->pp_button_type_my_custom; $ec_top_checkout_button .= '
'; - $ec_top_checkout_button .= ''; + $ec_top_checkout_button .= ''; $ec_top_checkout_button .= "" . __("; $ec_top_checkout_button .= ""; $ec_top_checkout_button .= '
'; @@ -915,7 +920,7 @@ public function checkout_message() { } if ($this->show_paypal_credit == 'yes') { $paypal_credit_button_markup = '
'; - $paypal_credit_button_markup .= ''; + $paypal_credit_button_markup .= ''; $paypal_credit_button_markup .= "Check out with PayPal Credit"; $paypal_credit_button_markup .= ''; $paypal_credit_button_markup .= '
'; @@ -998,7 +1003,7 @@ public function woocommerce_before_cart() { public function angelleye_woocommerce_order_button_html($order_button_hrml) { if ($this->function_helper->ec_is_express_checkout()) { $order_button_text = __('Cancel order', 'paypal-for-woocommerce'); - $cancel_order_url = add_query_arg('pp_action', 'cancel_order', WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE')); + $cancel_order_url = add_query_arg('pp_action', 'cancel_order', untrailingslashit(WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE'))); $order_button_hrml = apply_filters('angelleye_review_order_cance_button_html', '' . $order_button_text . '' . $order_button_hrml); } return $order_button_hrml; @@ -1060,7 +1065,7 @@ public function angelleye_ajax_generate_cart() { } WC()->shipping->reset_shipping(); $product_id = absint(wp_unslash($_POST['product_id'])); - $url = esc_url_raw(add_query_arg('pp_action', 'set_express_checkout', add_query_arg('wc-api', 'WC_Gateway_PayPal_Express_AngellEYE', home_url('/')))); + $url = esc_url_raw(add_query_arg('pp_action', 'set_express_checkout', untrailingslashit(WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE')))); 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)) { $url = add_query_arg('ec_save_to_account', 'true', $url); } @@ -1166,7 +1171,7 @@ public function angelleye_redirect_to_checkout_page() { return; } if ($this->function_helper->ec_is_express_checkout() && is_cart()) { - wp_redirect(wc_get_page_permalink('checkout')); + wp_redirect(wc_get_checkout_url()); exit; } } 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 777b66fa7..6f2a09425 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 @@ -670,9 +670,9 @@ public function angelleye_set_express_checkout_request() { $cancel_url = add_query_arg('utm_nooverride', '1', $cancel_url); $order_total = ''; if( !empty($_REQUEST['request_from']) && $_REQUEST['request_from'] == 'JSv4' ) { - $returnurl = urldecode(add_query_arg(array('pp_action' => 'get_express_checkout_details', 'utm_nooverride' => 1, 'request_from' => 'JSv4'), WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE'))); + $returnurl = urldecode(add_query_arg(array('pp_action' => 'get_express_checkout_details', 'utm_nooverride' => 1, 'request_from' => 'JSv4'), untrailingslashit(WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE')))); } else { - $returnurl = urldecode(add_query_arg(array('pp_action' => 'get_express_checkout_details', 'utm_nooverride' => 1), WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE'))); + $returnurl = urldecode(add_query_arg(array('pp_action' => 'get_express_checkout_details', 'utm_nooverride' => 1), untrailingslashit(WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE')))); } if (!empty($_GET['pay_for_order']) && $_GET['pay_for_order'] == true && !empty($_GET['key'])) { @@ -696,7 +696,7 @@ public function angelleye_set_express_checkout_request() { 'key' => wc_clean($_GET['key']), 'order_id' => $order_id, 'utm_nooverride' => 1 - ), WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE'))); + ), untrailingslashit(WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE')))); } else { $returnurl = urldecode(add_query_arg(array( 'pp_action' => 'get_express_checkout_details', @@ -704,7 +704,7 @@ public function angelleye_set_express_checkout_request() { 'key' => wc_clean($_GET['key']), 'order_id' => $order_id, 'utm_nooverride' => 1 - ), WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE'))); + ), untrailingslashit(WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE')))); } angelleye_set_session('order_awaiting_payment', absint( wp_unslash( $order_id) ) ); } else { diff --git a/classes/wc-gateway-paypal-advanced-angelleye.php b/classes/wc-gateway-paypal-advanced-angelleye.php index 1af707fda..69106537e 100644 --- a/classes/wc-gateway-paypal-advanced-angelleye.php +++ b/classes/wc-gateway-paypal-advanced-angelleye.php @@ -10,7 +10,7 @@ public function __construct() { $this->home_url = is_ssl() ? home_url('/', 'https') : home_url('/'); //set the urls (cancel or return) based on SSL $this->testurl = 'https://pilot-payflowpro.paypal.com'; $this->liveurl = 'https://payflowpro.paypal.com'; - $this->relay_response_url = add_query_arg('wc-api', 'WC_Gateway_PayPal_Advanced_AngellEYE', $this->home_url); + $this->relay_response_url = WC()->api_request_url('WC_Gateway_PayPal_Advanced_AngellEYE'); $this->method_title = __('PayPal Advanced', 'paypal-for-woocommerce'); $this->secure_token_id = ''; $this->securetoken = ''; @@ -541,13 +541,14 @@ public function get_secure_token($order) { } // Determine the ERRORURL,CANCELURL and SILENTPOSTURL - $cancelurl = add_query_arg('wc-api', 'WC_Gateway_PayPal_Advanced_AngellEYE', add_query_arg('cancel_ec_trans', 'true', $this->home_url)); + + $cancelurl = add_query_arg('cancel_ec_trans', 'true', untrailingslashit(WC()->api_request_url('WC_Gateway_PayPal_Advanced_AngellEYE'))); $paypal_args['CANCELURL[' . strlen($cancelurl) . ']'] = $cancelurl; - $errorurl = add_query_arg('wc-api', 'WC_Gateway_PayPal_Advanced_AngellEYE', add_query_arg('error', 'true', $this->home_url)); + $errorurl = add_query_arg('error', 'true', untrailingslashit(WC()->api_request_url('WC_Gateway_PayPal_Advanced_AngellEYE'))); $paypal_args['ERRORURL[' . strlen($errorurl) . ']'] = $errorurl; - $silentposturl = add_query_arg('wc-api', 'WC_Gateway_PayPal_Advanced_AngellEYE', add_query_arg('silent', 'true', $this->home_url)); + $silentposturl = add_query_arg('silent', 'true', untrailingslashit(WC()->api_request_url('WC_Gateway_PayPal_Advanced_AngellEYE'))); $paypal_args['SILENTPOSTURL[' . strlen($silentposturl) . ']'] = $silentposturl; if( $this->send_items ) { $PaymentData = $this->calculation_angelleye->order_calculation($order_id); diff --git a/classes/wc-gateway-paypal-pro-angelleye.php b/classes/wc-gateway-paypal-pro-angelleye.php index d78acc039..b9bd43542 100644 --- a/classes/wc-gateway-paypal-pro-angelleye.php +++ b/classes/wc-gateway-paypal-pro-angelleye.php @@ -928,7 +928,7 @@ public function process_payment($order_id) { return array( 'result' => 'success', - 'redirect' => add_query_arg(array('acs' => $order_id), WC()->api_request_url('WC_Gateway_PayPal_Pro_AngellEYE', is_ssl())) + 'redirect' => add_query_arg(array('acs' => $order_id), untrailingslashit(WC()->api_request_url('WC_Gateway_PayPal_Pro_AngellEYE', is_ssl()))) ); } elseif ($this->liability_shift && 'N' !== $this->get_centinel_value("Enrolled")) { wc_add_notice(apply_filters('angelleye_pc_process_payment_authentication_unavailable', __('Authentication unavailable. Please try a different payment method or card.', 'paypal-for-woocommerce')), 'error'); diff --git a/classes/wc-gateway-paypal-pro-payflow-angelleye.php b/classes/wc-gateway-paypal-pro-payflow-angelleye.php index eb94548ea..30fcfa10a 100644 --- a/classes/wc-gateway-paypal-pro-payflow-angelleye.php +++ b/classes/wc-gateway-paypal-pro-payflow-angelleye.php @@ -818,7 +818,7 @@ function process_payment($order_id) { return array( 'result' => 'success', - 'redirect' => add_query_arg(array('acs' => $order_id), WC()->api_request_url('WC_Gateway_PayPal_Pro_PayFlow_AngellEYE', is_ssl())) + 'redirect' => add_query_arg(array('acs' => $order_id), untrailingslashit(WC()->api_request_url('WC_Gateway_PayPal_Pro_PayFlow_AngellEYE', is_ssl()))) ); } elseif ($this->liability_shift && 'N' !== $this->get_centinel_value("Enrolled")) { wc_add_notice(apply_filters('angelleye_pc_process_payment_authentication_unavailable', __('Authentication unavailable. Please try a different payment method or card.', 'paypal-for-woocommerce')), 'error'); @@ -905,7 +905,7 @@ function process_payment($order_id) { $this->add_log('PaReq: ' . $PayPalResult['PAREQ']); return array( 'result' => 'success', - 'redirect' => add_query_arg(array('acs' => $order_id), WC()->api_request_url('WC_Gateway_PayPal_Pro_PayFlow_AngellEYE', is_ssl())) + 'redirect' => add_query_arg(array('acs' => $order_id), untrailingslashit(WC()->api_request_url('WC_Gateway_PayPal_Pro_PayFlow_AngellEYE', is_ssl()))) ); } elseif ($this->liability_shift === false && 'E' !== $PayPalResult['AUTHENTICATION_STATUS']) { $pass_required_field = array('AUTHENTICATION_ID', 'AUTHENTICATION_STATUS', 'ECI'); diff --git a/paypal-for-woocommerce.php b/paypal-for-woocommerce.php index 27b8defca..84d27754b 100644 --- a/paypal-for-woocommerce.php +++ b/paypal-for-woocommerce.php @@ -620,7 +620,7 @@ public function angelleye_woocommerce_add_to_cart_sold_individually_quantity($qt foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { $cart_product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key ); if( $product_id == $cart_product_id || $variation_id == $cart_product_id) { - wp_redirect(add_query_arg( array( 'pp_action' => 'set_express_checkout', 'utm_nooverride' => '1' ), add_query_arg('wc-api', 'WC_Gateway_PayPal_Express_AngellEYE', home_url('/')) )); + wp_redirect(add_query_arg( array( 'pp_action' => 'set_express_checkout', 'utm_nooverride' => '1' ), untrailingslashit(WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE')) )); exit(); } }