From 83efa087e3c7dde222ad9ed4ddea1f9bd43fd0af Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Thu, 24 Jan 2019 17:00:01 +0530 Subject: [PATCH 1/2] Braintree - 1.5.5 Update - Payment fails when user is logged in, PFW-357 --- classes/wc-gateway-braintree-angelleye.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/classes/wc-gateway-braintree-angelleye.php b/classes/wc-gateway-braintree-angelleye.php index 61d325c29..d9a10016f 100644 --- a/classes/wc-gateway-braintree-angelleye.php +++ b/classes/wc-gateway-braintree-angelleye.php @@ -1032,6 +1032,7 @@ public function angelleye_do_payment($order) { return false; } $request_data['paymentMethodNonce'] = $payment_method_nonce; + $request_data['creditCard']['cardholderName'] = $order->get_formatted_billing_full_name(); } if (is_user_logged_in()) { $customer_id = get_current_user_id(); @@ -1055,7 +1056,6 @@ public function angelleye_do_payment($order) { } $request_data['orderId'] = $order->get_order_number(); $request_data['options'] = $this->get_braintree_options(); - $request_data['creditCard']['cardholderName'] = $order->get_formatted_billing_full_name(); $request_data['channel'] = 'AngellEYEPayPalforWoo_BT'; if (!empty($this->softdescriptor)) { $request_data['descriptor'] = array('name' => $this->softdescriptor); @@ -1715,6 +1715,11 @@ public function braintree_create_payment_method($braintree_customer_id, $zero_am if (isset($this->merchant_account_id) && !empty($this->merchant_account_id)) { $payment_method_request['options']['verificationMerchantAccountId'] = $this->merchant_account_id; } + if (is_user_logged_in()) { + $customer_id = get_current_user_id(); + $customer = new WC_Customer( $customer_id ); + $payment_method_request['creditCard']['cardholderName'] = $customer->get_first_name() . ' ' . $customer->get_last_name(); + } } else { $this->add_log("Error: The payment_method_nonce was unexpectedly empty"); wc_add_notice(__('Error: PayPal Powered by Braintree did not supply a payment nonce. Please try again later or use another means of payment.', 'paypal-for-woocommerce'), 'error'); @@ -2025,7 +2030,6 @@ public function process_subscription_payment($order, $amount, $payment_token = n } $request_data['orderId'] = $order->get_order_number(); $request_data['options'] = $this->get_braintree_options(); - $request_data['creditCard']['cardholderName'] = $order->get_formatted_billing_full_name(); $request_data['channel'] = 'AngellEYEPayPalforWoo_BT'; if ($this->debug) { $this->add_log('Begin Braintree_Transaction::sale request'); @@ -2462,10 +2466,10 @@ public function braintree_create_payment_method_auth($braintree_customer_id, $or $payment_method_request = array('customerId' => $braintree_customer_id, 'paymentMethodNonce' => $payment_method_nonce); $this->merchant_account_id = $this->angelleye_braintree_get_merchant_account_id(); $payment_method_request['options']['verifyCard'] = true; - $request_data['creditCard']['cardholderName'] = $order->get_formatted_billing_full_name(); if (isset($this->merchant_account_id) && !empty($this->merchant_account_id)) { $payment_method_request['options']['verificationMerchantAccountId'] = $this->merchant_account_id; } + $payment_method_request['creditCard']['cardholderName'] = $order->get_formatted_billing_full_name(); } else { $this->add_log("Error: The payment_method_nonce was unexpectedly empty"); wc_add_notice(__('Error: PayPal Powered by Braintree did not supply a payment nonce. Please try again later or use another means of payment.', 'paypal-for-woocommerce'), 'error'); From 7732cbf4268639f720f70c017734bcffb2877657 Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Wed, 30 Jan 2019 18:07:48 +0530 Subject: [PATCH 2/2] Braintree - 1.5.5 Update - Payment fails when user is logged in, PFW-357 --- classes/wc-gateway-braintree-angelleye.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/classes/wc-gateway-braintree-angelleye.php b/classes/wc-gateway-braintree-angelleye.php index d9a10016f..66a232cae 100644 --- a/classes/wc-gateway-braintree-angelleye.php +++ b/classes/wc-gateway-braintree-angelleye.php @@ -1032,7 +1032,6 @@ public function angelleye_do_payment($order) { return false; } $request_data['paymentMethodNonce'] = $payment_method_nonce; - $request_data['creditCard']['cardholderName'] = $order->get_formatted_billing_full_name(); } if (is_user_logged_in()) { $customer_id = get_current_user_id(); @@ -1048,6 +1047,8 @@ public function angelleye_do_payment($order) { 'email' => version_compare(WC_VERSION, '3.0', '<') ? $order->billing_email : $order->get_billing_email(), ); } + } else { + $request_data['creditCard']['cardholderName'] = $order->get_formatted_billing_full_name(); } $request_data['amount'] = number_format($order->get_total(), 2, '.', ''); $this->merchant_account_id = $this->angelleye_braintree_get_merchant_account_id($order_id); @@ -1715,11 +1716,6 @@ public function braintree_create_payment_method($braintree_customer_id, $zero_am if (isset($this->merchant_account_id) && !empty($this->merchant_account_id)) { $payment_method_request['options']['verificationMerchantAccountId'] = $this->merchant_account_id; } - if (is_user_logged_in()) { - $customer_id = get_current_user_id(); - $customer = new WC_Customer( $customer_id ); - $payment_method_request['creditCard']['cardholderName'] = $customer->get_first_name() . ' ' . $customer->get_last_name(); - } } else { $this->add_log("Error: The payment_method_nonce was unexpectedly empty"); wc_add_notice(__('Error: PayPal Powered by Braintree did not supply a payment nonce. Please try again later or use another means of payment.', 'paypal-for-woocommerce'), 'error'); @@ -1782,7 +1778,7 @@ public function braintree_create_payment_method($braintree_customer_id, $zero_am return false; } } catch (Exception $ex) { - $error = $this->get_braintree_exception_message($e); + $error = $this->get_braintree_exception_message($ex); wc_add_notice($error, 'error'); if ($zero_amount_payment == false) { wp_redirect(wc_get_account_endpoint_url('payment-methods')); @@ -2448,10 +2444,10 @@ public function braintree_create_payment_method_auth($braintree_customer_id, $or $payment_method_nonce = $token->get_token(); $order_id = version_compare(WC_VERSION, '3.0', '<') ? $order->id : $order->get_id(); update_post_meta($order_id, '_first_transaction_id', $payment_method_nonce); - $payment_order_meta = array('_transaction_id' => $payment_method_token, '_payment_action' => $this->payment_action); + $payment_order_meta = array('_transaction_id' => $payment_method_nonce, '_payment_action' => $this->payment_action); AngellEYE_Utility::angelleye_add_order_meta($order_id, $payment_order_meta); $order->update_status('on-hold', __('Authorization only transaction', 'paypal-for-woocommerce')); - $this->save_payment_token($order, $payment_method_token); + $this->save_payment_token($order, $payment_method_nonce); return true; } else { $payment_method_nonce = self::get_posted_variable('braintree_token'); @@ -2469,7 +2465,6 @@ public function braintree_create_payment_method_auth($braintree_customer_id, $or if (isset($this->merchant_account_id) && !empty($this->merchant_account_id)) { $payment_method_request['options']['verificationMerchantAccountId'] = $this->merchant_account_id; } - $payment_method_request['creditCard']['cardholderName'] = $order->get_formatted_billing_full_name(); } else { $this->add_log("Error: The payment_method_nonce was unexpectedly empty"); wc_add_notice(__('Error: PayPal Powered by Braintree did not supply a payment nonce. Please try again later or use another means of payment.', 'paypal-for-woocommerce'), 'error');