From a793022e8ee8c5f670b5513c8844382331c9f2c1 Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Tue, 12 Jul 2022 14:59:51 +0530 Subject: [PATCH 1/2] Classic EC - Taxes are not passing correctly to PayPal when secondary rule is triggered, PFWMA-283 --- ...ount-management-admin-express-checkout.php | 83 ++++++++++--------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/admin/class-paypal-for-woocommerce-multi-account-management-admin-express-checkout.php b/admin/class-paypal-for-woocommerce-multi-account-management-admin-express-checkout.php index c4ca21a..554a29a 100644 --- a/admin/class-paypal-for-woocommerce-multi-account-management-admin-express-checkout.php +++ b/admin/class-paypal-for-woocommerce-multi-account-management-admin-express-checkout.php @@ -302,9 +302,9 @@ public function angelleye_get_account_for_ec_parallel_payments($gateways, $gatew if (empty($passed_rules['buyer_countries'])) { continue; } - - - + + + $buyer_states = get_post_meta($value->ID, 'buyer_states', true); if (!empty($buyer_states)) { foreach ($buyer_states as $buyer_states_key => $buyer_states_value) { @@ -348,10 +348,10 @@ public function angelleye_get_account_for_ec_parallel_payments($gateways, $gatew if (empty($passed_rules['buyer_states'])) { continue; } - - - - + + + + $postcode_string = get_post_meta($value->ID, 'postcode', true); if (!empty($postcode_string)) { $postcode = explode(',', $postcode_string); @@ -765,16 +765,16 @@ public function angelleye_paypal_for_woocommerce_multi_account_api_paypal_expres public function angelleye_unset_multi_account_dataset($gateways) { try { if (isset($gateways) || isset($gateways->testmode)) { - if ($gateways->testmode == true) { + if ($gateways->testmode == true) { $session_key_account = 'angelleye_sandbox_payment_load_balancer_ec_account'; } else { $session_key_account = 'angelleye_payment_load_balancer_ec_account'; } $angelleye_payment_load_balancer_account = WC()->session->get($session_key_account); - if(!empty($angelleye_payment_load_balancer_account) && isset($angelleye_payment_load_balancer_account['multi_account_id']) && $angelleye_payment_load_balancer_account['multi_account_id'] !== 'default') { + if (!empty($angelleye_payment_load_balancer_account) && isset($angelleye_payment_load_balancer_account['multi_account_id']) && $angelleye_payment_load_balancer_account['multi_account_id'] !== 'default') { update_post_meta($angelleye_payment_load_balancer_account['multi_account_id'], 'woocommerce_paypal_express_enable', ''); } - } + } delete_transient('angelleye_multi_ec_payment_load_balancer_synce_sandbox'); delete_transient('angelleye_multi_ec_payment_load_balancer_synce'); WC()->session->set('multi_account_api_username', ''); @@ -787,8 +787,6 @@ public function angelleye_unset_multi_account_dataset($gateways) { WC()->session->__unset('angelleye_sandbox_payment_load_balancer_ec_account'); WC()->session->set('angelleye_payment_load_balancer_ec_account', ''); WC()->session->__unset('angelleye_payment_load_balancer_ec_account'); - - } catch (Exception $ex) { } @@ -1730,28 +1728,34 @@ public function angelleye_modified_ec_parallel_parameter($request, $gateways, $o if (abs($Difference) > 0.000001 && 0.0 !== (float) $Difference) { if (isset($new_payments[0]['amt']) && $new_payments[0]['amt'] > 1) { $new_payments[0]['amt'] = $new_payments[0]['amt'] + $Difference; - $item_names = array(); - if (!empty($new_payments[0]['order_items'])) { - $first_line_item = $new_payments[0]['order_items']; - } - if (!empty($first_line_item)) { - unset($new_payments[0]['order_items']); - $new_payments[0]['order_items'] = array(); - $new_payments[0]['itemamt'] = $new_payments[0]['amt']; - foreach ($first_line_item as $key => $value) { - $item_names[] = $value['name'] . ' x ' . $value['qty']; + if (isset($new_payments[0]['taxamt']) && $new_payments[0]['taxamt'] > 1) { + $new_payments[0]['taxamt'] = $new_payments[0]['taxamt'] + $Difference; + } elseif (isset($new_payments[0]['shippingamt']) && $new_payments[0]['shippingamt'] > 1) { + $new_payments[0]['shippingamt'] = $new_payments[0]['shippingamt'] + $Difference; + } else { + $item_names = array(); + if (!empty($new_payments[0]['order_items'])) { + $first_line_item = $new_payments[0]['order_items']; } - $item_details = implode(', ', $item_names); - $item_details = html_entity_decode(wc_trim_string($item_details ? wp_strip_all_tags($item_details) : __('Item', 'paypal-for-woocommerce-multi-account-management'), 127), ENT_NOQUOTES, 'UTF-8'); - $new_payments[0]['order_items'][0] = array( - 'name' => $item_details, - 'desc' => '', - 'amt' => $new_payments[0]['amt'], - 'qty' => 1 - ); + if (!empty($first_line_item)) { + unset($new_payments[0]['order_items']); + $new_payments[0]['order_items'] = array(); + $new_payments[0]['itemamt'] = $new_payments[0]['amt']; + foreach ($first_line_item as $key => $value) { + $item_names[] = $value['name'] . ' x ' . $value['qty']; + } + $item_details = implode(', ', $item_names); + $item_details = html_entity_decode(wc_trim_string($item_details ? wp_strip_all_tags($item_details) : __('Item', 'paypal-for-woocommerce-multi-account-management'), 127), ENT_NOQUOTES, 'UTF-8'); + $new_payments[0]['order_items'][0] = array( + 'name' => $item_details, + 'desc' => '', + 'amt' => $new_payments[0]['amt'], + 'qty' => 1 + ); + } + unset($new_payments[0]['shippingamt']); + unset($new_payments[0]['taxamt']); } - unset($new_payments[0]['shippingamt']); - unset($new_payments[0]['taxamt']); } } } @@ -2662,16 +2666,16 @@ public function angelleye_is_account_ready_to_paid($bool, $email) { $paypal = new Angelleye_PayPal_WC($PayPalConfig); $SECFields = array( 'token' => '', - 'returnurl' => 'https://www.google.com/', - 'cancelurl' => 'https://www.google.com/', + 'returnurl' => 'https://www.google.com/', + 'cancelurl' => 'https://www.google.com/', ); $Payments = array(); $Payment = array( 'amt' => '1.00', - 'currencycode' => 'USD', - 'invnum' => time().'testing', + 'currencycode' => 'USD', + 'invnum' => time() . 'testing', 'paymentaction' => 'Sale', - 'paymentrequestid' => time() .'-id', + 'paymentrequestid' => time() . '-id', 'sellerpaypalaccountid' => $email ); array_push($Payments, $Payment); @@ -2680,12 +2684,12 @@ public function angelleye_is_account_ready_to_paid($bool, $email) { 'Payments' => $Payments ); $paypal_response = $paypal->SetExpressCheckout($PayPalRequest); - if( isset($paypal_response['ACK']) && 'Success' === $paypal_response['ACK']) { + if (isset($paypal_response['ACK']) && 'Success' === $paypal_response['ACK']) { return true; } return false; } - + public function angelleye_multi_account_dokan_refund_approve($refund, $args, $vendor_refund) { $parent_order_id = ''; $order = wc_get_order($refund->get_order_id()); @@ -2778,4 +2782,5 @@ public function angelleye_multi_account_dokan_refund_approve($refund, $args, $ve } } } + } From bc616c58cf7328fda9a6cf6c90a8b170fbab94fb Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Mon, 18 Jul 2022 13:30:15 +0530 Subject: [PATCH 2/2] Update returnurl and cancelurl URL value, PFWMA-283 --- ...mmerce-multi-account-management-admin-express-checkout.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/class-paypal-for-woocommerce-multi-account-management-admin-express-checkout.php b/admin/class-paypal-for-woocommerce-multi-account-management-admin-express-checkout.php index 554a29a..dbb32e8 100644 --- a/admin/class-paypal-for-woocommerce-multi-account-management-admin-express-checkout.php +++ b/admin/class-paypal-for-woocommerce-multi-account-management-admin-express-checkout.php @@ -2666,8 +2666,8 @@ public function angelleye_is_account_ready_to_paid($bool, $email) { $paypal = new Angelleye_PayPal_WC($PayPalConfig); $SECFields = array( 'token' => '', - 'returnurl' => 'https://www.google.com/', - 'cancelurl' => 'https://www.google.com/', + 'returnurl' => 'https://www.paypal.com/checkoutnow/error', + 'cancelurl' => 'https://www.paypal.com/checkoutnow/error', ); $Payments = array(); $Payment = array(