Skip to content

Commit

Permalink
Update API Endpoint and checkout Page URL, PFW-672
Browse files Browse the repository at this point in the history
  • Loading branch information
kcppdevelopers committed Aug 19, 2020
1 parent fd1c4b2 commit f151355
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public function buy_now_button() {
break;
}
if ($this->show_paypal_credit == 'yes') {
$paypal_credit_button_markup = '<a style="' . $hide . '" class="single_add_to_cart_button paypal_checkout_button paypal_checkout_button_cc" href="' . esc_url(add_query_arg('use_paypal_credit', 'true', add_query_arg('pp_action', 'set_express_checkout', add_query_arg('wc-api', 'WC_Gateway_PayPal_Express_AngellEYE', home_url('/'))))) . '" >';
$paypal_credit_button_markup = '<a style="' . $hide . '" class="single_add_to_cart_button paypal_checkout_button paypal_checkout_button_cc" href="' . esc_url(add_query_arg('use_paypal_credit', 'true', add_query_arg('pp_action', 'set_express_checkout', WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE')))) . '" >';
$paypal_credit_button_markup .= '<img src="https://www.paypalobjects.com/webstatic/en_US/i/buttons/ppcredit-logo-small.png" width="148" height="26" class="ppcreditlogo ec_checkout_page_button_type_pc" align="top" alt="' . __('Check out with PayPal Credit', 'paypal-for-woocommerce') . '" />';
$paypal_credit_button_markup .= '</a>';
$ec_html_button .= $paypal_credit_button_markup;
Expand Down Expand Up @@ -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', WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE')));
}
return $url;
} catch (Exception $ex) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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'),
Expand Down Expand Up @@ -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', 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,
Expand Down Expand Up @@ -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 .= '<a class="paypal_checkout_button button ' . $class_top . ' alt ec_checkout_page_button_type_textbutton" href="' . esc_url(add_query_arg('pp_action', 'set_express_checkout', add_query_arg('wc-api', 'WC_Gateway_PayPal_Express_AngellEYE', home_url('/')))) . '">' . $this->pp_button_type_text_button . '</a>';
$cart_button_html .= '<a class="paypal_checkout_button button ' . $class_top . ' alt ec_checkout_page_button_type_textbutton" href="' . esc_url(add_query_arg('pp_action', 'set_express_checkout', WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE'))) . '">' . $this->pp_button_type_text_button . '</a>';
break;
case 'paypalimage':
$cart_button_html .= '<a class="paypal_checkout_button ' . $class_top . '" href="' . esc_url(add_query_arg('pp_action', 'set_express_checkout', add_query_arg('wc-api', 'WC_Gateway_PayPal_Express_AngellEYE', home_url('/')))) . '">';
$cart_button_html .= '<a class="paypal_checkout_button ' . $class_top . '" href="' . esc_url(add_query_arg('pp_action', 'set_express_checkout', WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE'))) . '">';
$cart_button_html .= '<img src=' . WC_Gateway_PayPal_Express_AngellEYE::angelleye_get_paypalimage() . ' class="ec_checkout_page_button_type_paypalimage" align="top" alt="' . __('Pay with PayPal', 'paypal-for-woocommerce') . '" />';
$cart_button_html .= "</a>";
break;
case 'customimage':
$cart_button_html .= '<a class="paypal_checkout_button ' . $class_top . '" href="' . esc_url(add_query_arg('pp_action', 'set_express_checkout', add_query_arg('wc-api', 'WC_Gateway_PayPal_Express_AngellEYE', home_url('/')))) . '">';
$cart_button_html .= '<a class="paypal_checkout_button ' . $class_top . '" href="' . esc_url(add_query_arg('pp_action', 'set_express_checkout', WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE'))) . '">';
$cart_button_html .= '<img src="' . $this->pp_button_type_my_custom . '" class="ec_checkout_page_button_type_customimage" align="top" alt="' . __('Pay with PayPal', 'paypal-for-woocommerce') . '" />';
$cart_button_html .= "</a>";
break;
}
if ($this->show_paypal_credit == 'yes') {
$paypal_credit_button_markup = '<a class="paypal_checkout_button ' . $class_cc_top . '" href="' . esc_url(add_query_arg('use_paypal_credit', 'true', add_query_arg('pp_action', 'set_express_checkout', add_query_arg('wc-api', 'WC_Gateway_PayPal_Express_AngellEYE', home_url('/'))))) . '" >';
$paypal_credit_button_markup = '<a class="paypal_checkout_button ' . $class_cc_top . '" href="' . esc_url(add_query_arg('use_paypal_credit', 'true', add_query_arg('pp_action', 'set_express_checkout', WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE')))) . '" >';
$paypal_credit_button_markup .= '<img src="https://www.paypalobjects.com/webstatic/en_US/i/buttons/ppcredit-logo-small.png" width="148" height="26" class="ppcreditlogo ec_checkout_page_button_type_pc" align="top" alt="' . __('Check out with PayPal Credit', 'paypal-for-woocommerce') . '" />';
$paypal_credit_button_markup .= '</a>';
$cart_button_html .= $paypal_credit_button_markup;
Expand Down Expand Up @@ -894,28 +899,28 @@ public function checkout_message() {
switch ($this->checkout_with_pp_button_type) {
case "textbutton":
$ec_top_checkout_button .= '<div class="paypal_ec_textbutton">';
$ec_top_checkout_button .= '<a class="paypal_checkout_button paypal_checkout_button_text button alt" href="' . esc_url(add_query_arg('pp_action', 'set_express_checkout', add_query_arg('wc-api', 'WC_Gateway_PayPal_Express_AngellEYE', home_url('/')))) . '">' . $this->pp_button_type_text_button . '</a>';
$ec_top_checkout_button .= '<a class="paypal_checkout_button paypal_checkout_button_text button alt" href="' . esc_url(add_query_arg('pp_action', 'set_express_checkout', WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE'))) . '">' . $this->pp_button_type_text_button . '</a>';
$ec_top_checkout_button .= '</div>';
break;
case "paypalimage":
$ec_top_checkout_button .= '<div id="paypal_ec_button">';
$ec_top_checkout_button .= '<a class="paypal_checkout_button" href="' . esc_url(add_query_arg('pp_action', 'set_express_checkout', add_query_arg('wc-api', 'WC_Gateway_PayPal_Express_AngellEYE', home_url('/')))) . '">';
$ec_top_checkout_button .= '<a class="paypal_checkout_button" href="' . esc_url(add_query_arg('pp_action', 'set_express_checkout', WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE'))) . '">';
$ec_top_checkout_button .= "<img src='" . WC_Gateway_PayPal_Express_AngellEYE::angelleye_get_paypalimage() . "' class='ec_checkout_page_button_type_paypalimage' border='0' alt='" . __('Pay with PayPal', 'paypal-for-woocommerce') . "'/>";
$ec_top_checkout_button .= "</a>";
$ec_top_checkout_button .= '</div>';
break;
case "customimage":
$button_img = $this->pp_button_type_my_custom;
$ec_top_checkout_button .= '<div id="paypal_ec_button">';
$ec_top_checkout_button .= '<a class="paypal_checkout_button" href="' . esc_url(add_query_arg('pp_action', 'set_express_checkout', add_query_arg('wc-api', 'WC_Gateway_PayPal_Express_AngellEYE', home_url('/')))) . '">';
$ec_top_checkout_button .= '<a class="paypal_checkout_button" href="' . esc_url(add_query_arg('pp_action', 'set_express_checkout', WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE'))) . '">';
$ec_top_checkout_button .= "<img src='{$button_img}' class='ec_checkout_page_button_type_paypalimage' width='150' border='0' alt='" . __('Pay with PayPal', 'paypal-for-woocommerce') . "'/>";
$ec_top_checkout_button .= "</a>";
$ec_top_checkout_button .= '</div>';
break;
}
if ($this->show_paypal_credit == 'yes') {
$paypal_credit_button_markup = '<div id="paypal_ec_paypal_credit_button">';
$paypal_credit_button_markup .= '<a class="paypal_checkout_button paypal_checkout_button_cc" href="' . esc_url(add_query_arg('use_paypal_credit', 'true', add_query_arg('pp_action', 'set_express_checkout', add_query_arg('wc-api', 'WC_Gateway_PayPal_Express_AngellEYE', home_url('/'))))) . '" >';
$paypal_credit_button_markup .= '<a class="paypal_checkout_button paypal_checkout_button_cc" href="' . esc_url(add_query_arg('use_paypal_credit', 'true', add_query_arg('pp_action', 'set_express_checkout', WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE')))) . '" >';
$paypal_credit_button_markup .= "<img src='https://www.paypalobjects.com/webstatic/en_US/i/buttons/ppcredit-logo-small.png' class='ec_checkout_page_button_type_paypalimage' alt='Check out with PayPal Credit'/>";
$paypal_credit_button_markup .= '</a>';
$paypal_credit_button_markup .= '</div>';
Expand Down Expand Up @@ -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', 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);
}
Expand Down Expand Up @@ -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;
}
}
Expand Down
9 changes: 5 additions & 4 deletions classes/wc-gateway-paypal-advanced-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down Expand Up @@ -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', 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', 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', 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);
Expand Down
2 changes: 1 addition & 1 deletion paypal-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ), WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE') ));
exit();
}
}
Expand Down

0 comments on commit f151355

Please sign in to comment.