Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR with Payflow Authorization Options : PFWMA-54 #11

Merged
merged 3 commits into from
Jul 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 121 additions & 34 deletions admin/class-paypal-for-woocommerce-multi-account-management-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,8 @@ public function is_angelleye_multi_account_used($order_id) {
$_multi_account_api_username = get_post_meta($order_id, '_multi_account_api_username', true);
if (!empty($_multi_account_api_username)) {
return true;
} else {
return false;
}
}
if (!class_exists('WooCommerce') || WC()->session == null) {
Expand Down Expand Up @@ -979,38 +981,74 @@ public function angelleye_get_multi_account_by_order_total_latest($gateways, $ga
}
}
}
foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
$_product = apply_filters('woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key);
$product_id = apply_filters('woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key);
// Categories
$woo_product_categories = wp_get_post_terms($product_id, 'product_cat', array('fields' => 'ids'));
$product_categories = get_post_meta($value->ID, 'product_categories', true);
if (!empty($product_categories)) {
if (!array_intersect($product_categories, $woo_product_categories)) {
unset($result[$key]);
unset($passed_rules);
continue;
if (is_null(WC()->cart) && WC()->cart->is_empty()) {
foreach ($order->get_items() as $cart_item_key => $values) {
$product = $order->get_product_from_item($values);
$product_id = $product->get_id();
// Categories
$woo_product_categories = wp_get_post_terms($product_id, 'product_cat', array('fields' => 'ids'));
$product_categories = get_post_meta($value->ID, 'product_categories', true);
if (!empty($product_categories)) {
if (!array_intersect($product_categories, $woo_product_categories)) {
unset($result[$key]);
unset($passed_rules);
continue;
}
}
}
// Tags
$woo_product_tag = wp_get_post_terms($product_id, 'product_tag', array('fields' => 'ids'));
$product_tags = get_post_meta($value->ID, 'product_tags', true);
if (!empty($product_tags)) {
if (!array_intersect($product_tags, $woo_product_tag)) {
unset($result[$key]);
unset($passed_rules);
continue;
// Tags
$woo_product_tag = wp_get_post_terms($product_id, 'product_tag', array('fields' => 'ids'));
$product_tags = get_post_meta($value->ID, 'product_tags', true);
if (!empty($product_tags)) {
if (!array_intersect($product_tags, $woo_product_tag)) {
unset($result[$key]);
unset($passed_rules);
continue;
}
}
}
$product_ids = get_post_meta($value->ID, 'woocommerce_paypal_express_api_product_ids', true);
if (!empty($product_ids)) {
if (!array_intersect((array) $product_id, $product_ids)) {
unset($result[$key]);
unset($passed_rules);
continue;
$product_ids = get_post_meta($value->ID, 'woocommerce_paypal_express_api_product_ids', true);
if (!empty($product_ids)) {
if (!array_intersect((array) $product_id, $product_ids)) {
unset($result[$key]);
unset($passed_rules);
continue;
}
}
}
} else {
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);
// Categories
$woo_product_categories = wp_get_post_terms($product_id, 'product_cat', array('fields' => 'ids'));
$product_categories = get_post_meta($value->ID, 'product_categories', true);
if (!empty($product_categories)) {
if (!array_intersect($product_categories, $woo_product_categories)) {
unset($result[$key]);
unset($passed_rules);
continue;
}
}
// Tags
$woo_product_tag = wp_get_post_terms($product_id, 'product_tag', array('fields' => 'ids'));
$product_tags = get_post_meta($value->ID, 'product_tags', true);
if (!empty($product_tags)) {
if (!array_intersect($product_tags, $woo_product_tag)) {
unset($result[$key]);
unset($passed_rules);
continue;
}
}
$product_ids = get_post_meta($value->ID, 'woocommerce_paypal_express_api_product_ids', true);
if (!empty($product_ids)) {
if (!array_intersect((array) $product_id, $product_ids)) {
unset($result[$key]);
unset($passed_rules);
continue;
}
}
}
}


}
unset($passed_rules);
}
Expand Down Expand Up @@ -1214,15 +1252,30 @@ public function angelleye_paypal_for_woocommerce_multi_account_api_paypal_expres
$gateway_setting->paypal_password = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_password'];
$gateway_setting->paypal_vendor = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_vendor'];
$gateway_setting->paypal_partner = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_partner'];
WC()->session->set('multi_account_api_username', $gateway_setting->paypal_user);
if(isset($request->paypal_user)) {
$request->paypal_user = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_user'];
$request->paypal_password = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_password'];
$request->paypal_vendor = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_vendor'];
$request->paypal_partner = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_partner'];
}
if (class_exists('WooCommerce') && WC()->session ) {
WC()->session->set('multi_account_api_username', $gateway_setting->paypal_user);
}
return;
}
} elseif (!empty($gateway_setting->id) && $gateway_setting->id == 'paypal_express') {
if (!empty($microprocessing_value['woocommerce_paypal_express_sandbox_api_username']) && !empty($microprocessing_value['woocommerce_paypal_express_sandbox_api_password']) && !empty($microprocessing_value['woocommerce_paypal_express_sandbox_api_signature'])) {
$gateway_setting->api_username = $microprocessing_value['woocommerce_paypal_express_sandbox_api_username'];
$gateway_setting->api_password = $microprocessing_value['woocommerce_paypal_express_sandbox_api_password'];
$gateway_setting->api_signature = $microprocessing_value['woocommerce_paypal_express_sandbox_api_signature'];
WC()->session->set('multi_account_api_username', $gateway_setting->api_username);
if(isset($request->api_username)) {
$request->api_username = $microprocessing_value['woocommerce_paypal_express_sandbox_api_username'];
$request->api_password = $microprocessing_value['woocommerce_paypal_express_sandbox_api_password'];
$request->api_signature = $microprocessing_value['woocommerce_paypal_express_sandbox_api_signature'];
}
if (class_exists('WooCommerce') && WC()->session ) {
WC()->session->set('multi_account_api_username', $gateway_setting->api_username);
}
return;
}
}
Expand All @@ -1232,15 +1285,30 @@ public function angelleye_paypal_for_woocommerce_multi_account_api_paypal_expres
$gateway_setting->api_username = $microprocessing_value['woocommerce_paypal_express_api_username'];
$gateway_setting->api_password = $microprocessing_value['woocommerce_paypal_express_api_password'];
$gateway_setting->api_signature = $microprocessing_value['woocommerce_paypal_express_api_signature'];
WC()->session->set('multi_account_api_username', $gateway_setting->api_username);
if(isset($request->paypal_user)) {
$request->paypal_user = $microprocessing_value['woocommerce_paypal_pro_payflow_api_paypal_user'];
$request->paypal_password = $microprocessing_value['woocommerce_paypal_pro_payflow_api_password'];
$request->paypal_vendor = $microprocessing_value['woocommerce_paypal_pro_payflow_api_paypal_vendor'];
$request->paypal_partner = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_partner'];
}
if (class_exists('WooCommerce') && WC()->session ) {
WC()->session->set('multi_account_api_username', $gateway_setting->api_username);
}
return;
}
} elseif (!empty($gateway_setting->id) && $gateway_setting->id == 'paypal_express') {
if (!empty($microprocessing_value['woocommerce_paypal_express_api_username']) && !empty($microprocessing_value['woocommerce_paypal_express_api_password']) && !empty($microprocessing_value['woocommerce_paypal_express_api_signature'])) {
$gateway_setting->api_username = $microprocessing_value['woocommerce_paypal_express_api_username'];
$gateway_setting->api_password = $microprocessing_value['woocommerce_paypal_express_api_password'];
$gateway_setting->api_signature = $microprocessing_value['woocommerce_paypal_express_api_signature'];
WC()->session->set('multi_account_api_username', $gateway_setting->api_username);
if(isset($request->api_username)) {
$request->api_username = $microprocessing_value['woocommerce_paypal_express_api_username'];
$request->api_password = $microprocessing_value['woocommerce_paypal_express_api_password'];
$request->api_signature = $microprocessing_value['woocommerce_paypal_express_api_signature'];
}
if (class_exists('WooCommerce') && WC()->session ) {
WC()->session->set('multi_account_api_username', $gateway_setting->api_username);
}
return;
}
}
Expand All @@ -1251,8 +1319,11 @@ public function angelleye_paypal_for_woocommerce_multi_account_api_paypal_expres
public function angelleye_paypal_for_woocommerce_multi_account_api_paypal_payflow($gateways, $request = null, $order_id = null) {
if ($request == null) {
$gateway_setting = $gateways;
} elseif($gateways == null) {
$gateways = $request;
$gateway_setting = $gateways;
} else {
$gateway_setting = $request;
$gateway_setting = $gateways;
}

if ($order_id == null) {
Expand Down Expand Up @@ -1280,7 +1351,15 @@ public function angelleye_paypal_for_woocommerce_multi_account_api_paypal_payflo
$gateway_setting->paypal_password = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_password'];
$gateway_setting->paypal_vendor = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_vendor'];
$gateway_setting->paypal_partner = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_partner'];
WC()->session->set('multi_account_api_username', $gateway_setting->paypal_user);
if(isset($request->paypal_user)) {
$request->paypal_user = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_user'];
$request->paypal_password = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_password'];
$request->paypal_vendor = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_vendor'];
$request->paypal_partner = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_partner'];
}
if (class_exists('WooCommerce') && WC()->session ) {
WC()->session->set('multi_account_api_username', $gateway_setting->paypal_user);
}
return;
}
} else {
Expand All @@ -1289,7 +1368,15 @@ public function angelleye_paypal_for_woocommerce_multi_account_api_paypal_payflo
$gateway_setting->paypal_password = $microprocessing_value['woocommerce_paypal_pro_payflow_api_password'];
$gateway_setting->paypal_vendor = $microprocessing_value['woocommerce_paypal_pro_payflow_api_paypal_vendor'];
$gateway_setting->paypal_partner = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_partner'];
WC()->session->set('multi_account_api_username', $gateway_setting->paypal_user);
if(isset($request->paypal_user)) {
$request->paypal_user = $microprocessing_value['woocommerce_paypal_pro_payflow_api_paypal_user'];
$request->paypal_password = $microprocessing_value['woocommerce_paypal_pro_payflow_api_password'];
$request->paypal_vendor = $microprocessing_value['woocommerce_paypal_pro_payflow_api_paypal_vendor'];
$request->paypal_partner = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_partner'];
}
if (class_exists('WooCommerce') && WC()->session ) {
WC()->session->set('multi_account_api_username', $gateway_setting->paypal_user);
}
return;
}
}
Expand Down