diff --git a/angelleye-includes/angelleye-utility.php b/angelleye-includes/angelleye-utility.php index 356b4222b..38e898313 100644 --- a/angelleye-includes/angelleye-utility.php +++ b/angelleye-includes/angelleye-utility.php @@ -1587,7 +1587,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; @@ -1672,6 +1672,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/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 66d432e52..01aba2d69 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 @@ -404,7 +404,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'); @@ -457,9 +459,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'); @@ -1371,6 +1373,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-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 6c6540557..2735fd560 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(); @@ -2197,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 44ae9975f..0e6a8149e 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(); @@ -1983,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;