From 7ec9ada7e1cea6b692c83747055862ea0064c465 Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Mon, 10 Jun 2019 15:26:36 +0530 Subject: [PATCH 1/4] Woo Subscriptions issue ( regression testing ), PFW-433 --- ...-wc-gateway-paypal-express-request-angelleye.php | 1 + classes/wc-gateway-paypal-express-angelleye.php | 13 +++++++++++++ classes/wc-gateway-paypal-pro-angelleye.php | 4 ++++ 3 files changed, 18 insertions(+) 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 9ddef3bcc..60d08ee79 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 @@ -1362,6 +1362,7 @@ public function DoReferenceTransaction($order_id) { $PayPalRequestData['PaymentDetails'] = $PaymentDetails; $this->paypal_response = $this->paypal->DoReferenceTransaction($PayPalRequestData); AngellEYE_Gateway_Paypal::angelleye_paypal_for_woocommerce_curl_error_handler($this->paypal_response, $methos_name = 'DoExpressCheckoutPayment', $gateway = 'PayPal Express Checkout', $this->gateway->error_email_notify); + $this->save_payment_token($order, $referenceid); WC_Gateway_PayPal_Express_AngellEYE::log('Test Mode: ' . $this->testmode); WC_Gateway_PayPal_Express_AngellEYE::log('Endpoint: ' . $this->gateway->API_Endpoint); $PayPalRequest = isset($this->paypal_response['RAWREQUEST']) ? $this->paypal_response['RAWREQUEST'] : ''; diff --git a/classes/wc-gateway-paypal-express-angelleye.php b/classes/wc-gateway-paypal-express-angelleye.php index 6fadafa63..a69791764 100644 --- a/classes/wc-gateway-paypal-express-angelleye.php +++ b/classes/wc-gateway-paypal-express-angelleye.php @@ -1584,6 +1584,15 @@ public function process_subscription_payment($order_id) { $result = $paypal_express_request->DoReferenceTransaction($order_id); if (!empty($result['ACK']) && $result['ACK'] == 'Success' || $result['ACK'] == 'SuccessWithWarning') { $paypal_express_request->update_payment_status_by_paypal_responce($order_id, $result); + if ( isset( WC()->cart ) || '' != WC()->cart ) { + if ( ! WC()->cart->is_empty() ) { + WC()->cart->empty_cart(); + return array( + 'result' => 'success', + 'redirect' => add_query_arg( 'utm_nooverride', '1', $this->get_return_url($order) ) + ); + } + } } else { $ErrorCode = urldecode(!empty($result["L_ERRORCODE0"]) ? $result["L_ERRORCODE0"] : ''); $ErrorLongMsg = urldecode(!empty($result["L_LONGMESSAGE0"]) ? $result["L_LONGMESSAGE0"] : ''); @@ -2140,6 +2149,10 @@ public function free_signup_order_payment($order_id) { $token_id = wc_clean($_POST['wc-paypal_express-payment-token']); $token = WC_Payment_Tokens::get($token_id); $order->payment_complete($token->get_token()); + $payment_tokens_id = $token->get_token(); + 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); + $paypal_express_request->save_payment_token($order, $payment_tokens_id); update_post_meta($order_id, '_first_transaction_id', $token->get_token()); $order->add_order_note('Payment Action: ' . $this->payment_action); WC()->cart->empty_cart(); diff --git a/classes/wc-gateway-paypal-pro-angelleye.php b/classes/wc-gateway-paypal-pro-angelleye.php index 298aa9db4..c4262abd5 100644 --- a/classes/wc-gateway-paypal-pro-angelleye.php +++ b/classes/wc-gateway-paypal-pro-angelleye.php @@ -1232,6 +1232,10 @@ function do_payment($order, $card_number, $card_type, $card_exp_month, $card_exp $token_id = wc_clean( $_POST['wc-paypal_pro-payment-token'] ); $token = WC_Payment_Tokens::get( $token_id ); $order->add_payment_token($token); + if( $this->is_subscription($order_id) ) { + $TRANSACTIONID = $PayPalResult['TRANSACTIONID']; + $this->save_payment_token($order, $TRANSACTIONID); + } } else { $TRANSACTIONID = $PayPalResult['TRANSACTIONID']; $token = new WC_Payment_Token_CC(); From a87149b00e916c326fa403a4b592a7041d2cb449 Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Tue, 11 Jun 2019 11:52:13 +0530 Subject: [PATCH 2/4] Woo Subscriptions issue ( regression testing ), PFW-433 --- angelleye-includes/angelleye-utility.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angelleye-includes/angelleye-utility.php b/angelleye-includes/angelleye-utility.php index bd973e150..aa2c315a6 100644 --- a/angelleye-includes/angelleye-utility.php +++ b/angelleye-includes/angelleye-utility.php @@ -1577,7 +1577,7 @@ public function angelleye_is_display_paypal_transaction_details($post_id) { $_payment_method = $old_wc ? get_post_meta($order_id, '_payment_method', true) : get_post_meta($order->get_id(), '_payment_method', true); $_payment_action = $old_wc ? get_post_meta($order_id, '_payment_action', true) : get_post_meta($order->get_id(), '_payment_action', true); if (isset($_payment_method) && !empty($_payment_method) && isset($_payment_action) && !empty($_payment_action)) { - if (($_payment_method == 'paypal_pro' || $_payment_method == 'paypal_express' || $_payment_method == 'paypal_pro_payflow' || $_payment_method == 'braintree') && $_payment_method != "Sale") { + if ( (($_payment_method == 'paypal_pro' || $_payment_method == 'paypal_express' || $_payment_method == 'paypal_pro_payflow' || $_payment_method == 'braintree')) && ($_payment_method != "Sale" && $order->get_total() > 0)) { return true; } else { return false; From d1f0367343b4135d4538c6d64f6f71cd31f104f1 Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Tue, 11 Jun 2019 14:48:17 +0530 Subject: [PATCH 3/4] Woo Subscriptions issue ( regression testing ), PFW-433 --- ...ass-wc-gateway-paypal-express-request-angelleye.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 60d08ee79..43d64a6a6 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 @@ -398,7 +398,9 @@ public function angelleye_do_express_checkout_payment() { update_post_meta($order->get_id(), '_express_chekout_transactionid', isset($this->paypal_response['PAYMENTINFO_0_TRANSACTIONID']) ? $this->paypal_response['PAYMENTINFO_0_TRANSACTIONID'] : '' ); update_post_meta($order->get_id(), 'paypal_email', $payeremail); } - $order->add_order_note(sprintf(__('%s payment Transaction ID: %s', 'paypal-for-woocommerce'), $this->gateway->title, isset($this->paypal_response['PAYMENTINFO_0_TRANSACTIONID']) ? $this->paypal_response['PAYMENTINFO_0_TRANSACTIONID'] : '')); + if( !empty($this->paypal_response['PAYMENTINFO_0_TRANSACTIONID'])) { + $order->add_order_note(sprintf(__('%s payment Transaction ID: %s', 'paypal-for-woocommerce'), $this->gateway->title, isset($this->paypal_response['PAYMENTINFO_0_TRANSACTIONID']) ? $this->paypal_response['PAYMENTINFO_0_TRANSACTIONID'] : '')); + } WC()->cart->empty_cart(); wc_clear_notices(); $this->angelleye_wp_safe_redirect(add_query_arg('utm_nooverride', '1', $this->gateway->get_return_url($order)), 'do_express_checkout_payment'); @@ -449,9 +451,9 @@ public function angelleye_do_express_checkout_payment() { } else { update_post_meta($order->get_id(), '_express_chekout_transactionid', isset($this->paypal_response['PAYMENTINFO_0_TRANSACTIONID']) ? $this->paypal_response['PAYMENTINFO_0_TRANSACTIONID'] : '' ); } - - $order->add_order_note(sprintf(__('%s payment Transaction ID: %s', 'paypal-for-woocommerce'), $this->gateway->title, $this->paypal_response['PAYMENTINFO_0_TRANSACTIONID'])); - + if( !empty($this->paypal_response['PAYMENTINFO_0_TRANSACTIONID'])) { + $order->add_order_note(sprintf(__('%s payment Transaction ID: %s', 'paypal-for-woocommerce'), $this->gateway->title, $this->paypal_response['PAYMENTINFO_0_TRANSACTIONID'])); + } WC()->cart->empty_cart(); wc_clear_notices(); $this->angelleye_wp_safe_redirect(add_query_arg('utm_nooverride', '1', $this->gateway->get_return_url($order)), 'do_express_checkout_payment'); From 6b769d48c2a3d44261b29bbd84f023d6b4614533 Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Fri, 28 Jun 2019 12:11:17 +0530 Subject: [PATCH 4/4] Woo Subscriptions issue ( regression testing ), PFW-433 --- angelleye-includes/angelleye-utility.php | 4 ++++ classes/wc-gateway-braintree-angelleye.php | 4 ++++ classes/wc-gateway-paypal-advanced-angelleye.php | 4 ++++ classes/wc-gateway-paypal-credit-cards-rest-angelleye.php | 4 ++++ classes/wc-gateway-paypal-express-angelleye.php | 4 ++++ classes/wc-gateway-paypal-pro-angelleye.php | 4 ++++ 6 files changed, 24 insertions(+) diff --git a/angelleye-includes/angelleye-utility.php b/angelleye-includes/angelleye-utility.php index aa2c315a6..a03664b47 100644 --- a/angelleye-includes/angelleye-utility.php +++ b/angelleye-includes/angelleye-utility.php @@ -1662,6 +1662,10 @@ public static function angelleye_paypal_for_woocommerce_is_set_sandbox_product() if (isset(WC()->cart) && sizeof(WC()->cart->get_cart()) > 0) { 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); + $product_type = get_post_type($product_id); + if($product_type == 'product_variation') { + $product_id = wp_get_post_parent_id($product_id); + } $_enable_sandbox_mode = get_post_meta($product_id, '_enable_sandbox_mode', true); if ($_enable_sandbox_mode == 'yes') { $is_sandbox_set = true; diff --git a/classes/wc-gateway-braintree-angelleye.php b/classes/wc-gateway-braintree-angelleye.php index 3e03591ca..5670890a1 100644 --- a/classes/wc-gateway-braintree-angelleye.php +++ b/classes/wc-gateway-braintree-angelleye.php @@ -2251,6 +2251,10 @@ public function angelleye_reload_gateway_credentials_for_woo_subscription_renewa $product = $order->get_product_from_item($values); $product_id = $product->get_id(); if (!empty($product_id)) { + $product_type = get_post_type($product_id); + if($product_type == 'product_variation') { + $product_id = wp_get_post_parent_id($product_id); + } $_enable_sandbox_mode = get_post_meta($product_id, '_enable_sandbox_mode', true); if ($_enable_sandbox_mode == 'yes') { $this->sandbox = true; diff --git a/classes/wc-gateway-paypal-advanced-angelleye.php b/classes/wc-gateway-paypal-advanced-angelleye.php index 912979aae..808a46c5d 100644 --- a/classes/wc-gateway-paypal-advanced-angelleye.php +++ b/classes/wc-gateway-paypal-advanced-angelleye.php @@ -1532,6 +1532,10 @@ public function angelleye_reload_gateway_credentials_for_woo_subscription_renewa foreach ($order->get_items() as $cart_item_key => $values) { $product = $order->get_product_from_item($values); $product_id = $product->get_id(); + $product_type = get_post_type($product_id); + if($product_type == 'product_variation') { + $product_id = wp_get_post_parent_id($product_id); + } if( !empty($product_id) ) { $_enable_sandbox_mode = get_post_meta($product_id, '_enable_sandbox_mode', true); if ($_enable_sandbox_mode == 'yes') { diff --git a/classes/wc-gateway-paypal-credit-cards-rest-angelleye.php b/classes/wc-gateway-paypal-credit-cards-rest-angelleye.php index 9a6eec7ea..799bae3e5 100644 --- a/classes/wc-gateway-paypal-credit-cards-rest-angelleye.php +++ b/classes/wc-gateway-paypal-credit-cards-rest-angelleye.php @@ -378,6 +378,10 @@ public function angelleye_reload_gateway_credentials_for_woo_subscription_renewa $product = $order->get_product_from_item($values); $product_id = $product->get_id(); if( !empty($product_id) ) { + $product_type = get_post_type($product_id); + if($product_type == 'product_variation') { + $product_id = wp_get_post_parent_id($product_id); + } $_enable_sandbox_mode = get_post_meta($product_id, '_enable_sandbox_mode', true); if ($_enable_sandbox_mode == 'yes') { $this->testmode = true; diff --git a/classes/wc-gateway-paypal-express-angelleye.php b/classes/wc-gateway-paypal-express-angelleye.php index a69791764..7b3c4c089 100644 --- a/classes/wc-gateway-paypal-express-angelleye.php +++ b/classes/wc-gateway-paypal-express-angelleye.php @@ -2210,6 +2210,10 @@ public function angelleye_reload_gateway_credentials_for_woo_subscription_renewa $product = $order->get_product_from_item($values); $product_id = $product->get_id(); if( !empty($product_id) ) { + $product_type = get_post_type($product_id); + if($product_type == 'product_variation') { + $product_id = wp_get_post_parent_id($product_id); + } $_enable_sandbox_mode = get_post_meta($product_id, '_enable_sandbox_mode', true); if ($_enable_sandbox_mode == 'yes') { $this->testmode = true; diff --git a/classes/wc-gateway-paypal-pro-angelleye.php b/classes/wc-gateway-paypal-pro-angelleye.php index c4262abd5..fb9f5f69c 100644 --- a/classes/wc-gateway-paypal-pro-angelleye.php +++ b/classes/wc-gateway-paypal-pro-angelleye.php @@ -1987,6 +1987,10 @@ public function angelleye_reload_gateway_credentials_for_woo_subscription_renewa $product = $order->get_product_from_item($values); $product_id = $product->get_id(); if( !empty($product_id) ) { + $product_type = get_post_type($product_id); + if($product_type == 'product_variation') { + $product_id = wp_get_post_parent_id($product_id); + } $_enable_sandbox_mode = get_post_meta($product_id, '_enable_sandbox_mode', true); if ($_enable_sandbox_mode == 'yes') { $this->testmode = true;