Skip to content

Commit

Permalink
Merge pull request #63 from angelleye/PFWMA-164
Browse files Browse the repository at this point in the history
Refunds Not Working Even After Adding API Credentials : PFWMA-164
  • Loading branch information
deepakmaurya authored Jul 23, 2020
2 parents 4fd4a99 + 21192f1 commit 6db3be2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,7 @@ public function own_woocommerce_payment_gateway_supports($bool, $feature, $curre
foreach ($angelleye_multi_account_ec_parallel_data_map as $key => $value) {
if (isset($value['multi_account_id']) && $value['multi_account_id'] == 'default') {
return true;
} elseif (isset($value['multi_account_id']) && $value['multi_account_id'] != 'default' && (!empty($value['is_api_set']) && $value['is_api_set'] == true)) {
} elseif (isset($value['multi_account_id']) && $value['multi_account_id'] != 'default' && (!empty($value['is_api_set']) && apply_filters('angelleye_pfwma_is_api_set', $value['is_api_set'], $value) === true)) {
return true;
}
}
Expand Down Expand Up @@ -1571,7 +1571,7 @@ public function own_angelleye_is_express_checkout_parallel_payment_handle($bool,
$angelleye_multi_account_ec_parallel_data_map = get_post_meta($order_id, '_angelleye_multi_account_ec_parallel_data_map', true);
if( !empty($angelleye_multi_account_ec_parallel_data_map) ) {
foreach ($angelleye_multi_account_ec_parallel_data_map as $key => $value) {
if (!empty($value['product_id']) && isset($value['is_api_set']) && $value['is_api_set'] == false) {
if (!empty($value['product_id']) && isset($value['is_api_set']) && apply_filters('angelleye_pfwma_is_api_set', $value['is_api_set'], $value) === false) {
$product = wc_get_product($value['product_id']);
$refund_error_message_after[] = $product->get_title();
}
Expand Down Expand Up @@ -1879,7 +1879,7 @@ public function own_angelleye_is_express_checkout_payment_load_balancer_handle($
$refund_error_message_pre = __('We can not refund this order as the Express Checkout API keys are missing! Please go to multi-account setup and add API key to process the refund', 'paypal-for-woocommerce-multi-account-management');
$angelleye_payment_load_balancer_account = get_post_meta($order_id, '_angelleye_payment_load_balancer_account', true);
if (!empty($angelleye_payment_load_balancer_account)) {
if( !empty($angelleye_payment_load_balancer_account['is_api_set']) && $angelleye_payment_load_balancer_account['is_api_set'] === true) {
if( !empty($angelleye_payment_load_balancer_account['is_api_set']) && apply_filters('angelleye_pfwma_is_api_set', $angelleye_payment_load_balancer_account['is_api_set'], $angelleye_payment_load_balancer_account) === true) {
$_transaction_id = get_post_meta($order_id, '_transaction_id', true);
$angelleye_payment_load_balancer_account['transaction_id'] = $_transaction_id;
$this->angelleye_express_checkout_load_paypal($angelleye_payment_load_balancer_account, $gateway, $order_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public function angelleye_woocommerce_paypal_refund_request($request, $order, $a
$order_id = version_compare(WC_VERSION, '3.0', '<') ? $order->id : $order->get_id();
$angelleye_multi_account_ec_parallel_data_map = get_post_meta($order_id, '_angelleye_multi_account_paypal_data_map', true);
if (!empty($angelleye_multi_account_ec_parallel_data_map)) {
if (empty($angelleye_multi_account_ec_parallel_data_map['is_api_set']) || $angelleye_multi_account_ec_parallel_data_map['is_api_set'] == false) {
if (empty($angelleye_multi_account_ec_parallel_data_map['is_api_set']) || apply_filters('angelleye_pfwma_is_api_set', $angelleye_multi_account_ec_parallel_data_map['is_api_set'], $angelleye_multi_account_ec_parallel_data_map) === false) {
return new WP_Error('invalid_refund', __('You can not refund this order, as the credentials are not present for the order', 'paypal-for-woocommerce-multi-account-management'));
} else {
return $this->angelleye_set_api_details_refund($request, $angelleye_multi_account_ec_parallel_data_map);
Expand Down Expand Up @@ -356,7 +356,7 @@ public function can_refund_order($order) {
$order_id = version_compare(WC_VERSION, '3.0', '<') ? $order->id : $order->get_id();
$angelleye_multi_account_paypal_data_map = get_post_meta($order_id, '_angelleye_multi_account_paypal_data_map', true);
if (!empty($angelleye_multi_account_paypal_data_map)) {
if (!empty($angelleye_multi_account_paypal_data_map['is_api_set'] && $angelleye_multi_account_paypal_data_map['is_api_set'] == true)) {
if (!empty($angelleye_multi_account_paypal_data_map['is_api_set'] && apply_filters('angelleye_pfwma_is_api_set', $angelleye_multi_account_paypal_data_map['is_api_set'], $angelleye_multi_account_paypal_data_map) === true)) {
return true;
} else {
return false;
Expand All @@ -373,7 +373,7 @@ public function own_woocommerce_payment_gateway_supports($bool, $feature, $curre
if (!empty($post->ID)) {
$angelleye_multi_account_paypal_data_map = get_post_meta($post->ID, '_angelleye_multi_account_paypal_data_map', true);
if (!empty($angelleye_multi_account_paypal_data_map)) {
if (!empty($angelleye_multi_account_paypal_data_map['is_api_set'] && $angelleye_multi_account_paypal_data_map['is_api_set'] == true)) {
if (!empty($angelleye_multi_account_paypal_data_map['is_api_set'] && apply_filters('angelleye_pfwma_is_api_set', $angelleye_multi_account_paypal_data_map['is_api_set'], $angelleye_multi_account_paypal_data_map) === true)) {
return true;
} else {
return false;
Expand Down
27 changes: 27 additions & 0 deletions includes/class-paypal-for-woocommerce-multi-account-management.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public function __construct() {
add_filter("{$prefix}plugin_action_links_" . PFWMA_PLUGIN_BASENAME, array($this, 'paypal_for_woocommerce_multi_account_management_action_links'), 10, 4);
add_filter('woocommerce_settings_tabs_array', array($this, 'angelleye_woocommerce_settings_tabs_array'), 50, 1);
add_action('woocommerce_settings_tabs_multi_account_management', array($this, 'display_plugin_admin_page'));
add_filter('angelleye_pfwma_is_api_set', array($this, 'angelleye_pfwma_is_api_set'), 10, 2);
}

/**
Expand Down Expand Up @@ -349,5 +350,31 @@ public function angelleye_woocommerce_settings_tabs_array($settings_tabs) {
$settings_tabs['multi_account_management'] = __('PayPal Multi-Account Setup', 'paypal-for-woocommerce-multi-account-management');
return $settings_tabs;
}

public function angelleye_pfwma_is_api_set($is_api_set, $value) {
if( $value['multi_account_id'] === 'default' ) {
return $is_api_set;
}
$microprocessing_array = get_post_meta($value['multi_account_id']);
if (!empty($microprocessing_array['woocommerce_paypal_express_testmode']) && $microprocessing_array['woocommerce_paypal_express_testmode'][0] == 'on') {
$testmode = true;
} else {
$testmode = false;
}
if ($testmode) {
if( !empty($microprocessing_array['woocommerce_paypal_express_sandbox_api_username'][0]) && !empty($microprocessing_array['woocommerce_paypal_express_sandbox_api_password'][0] && !empty($microprocessing_array['woocommerce_paypal_express_sandbox_api_signature'][0]))) {
$is_api_set = true;
} else {
$is_api_set = false;
}
} else {
if( !empty($microprocessing_array['woocommerce_paypal_express_api_username'][0]) && !empty($microprocessing_array['woocommerce_paypal_express_api_signature'][0]) && !empty($microprocessing_array['woocommerce_paypal_express_api_password'][0])) {
$is_api_set = true;
} else {
$is_api_set = false;
}
}
return $is_api_set;
}

}

0 comments on commit 6db3be2

Please sign in to comment.