Skip to content

Commit

Permalink
Auth & Capture Adjustments Necessary, ref #730
Browse files Browse the repository at this point in the history
  • Loading branch information
kcppdevelopers committed May 31, 2017
1 parent 85450fd commit b2999f2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
22 changes: 17 additions & 5 deletions angelleye-includes/angelleye-utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ public function angelleye_woocommerce_order_actions($order_actions = array()) {
if ($this->total_Pending_DoAuthorization == 0) {
unset($paypal_payment_action['DoCapture']);
}
if (!is_object($order_id)) {
$order = wc_get_order($order_id);
}
if ($this->total_Pending_DoAuthorization == 0 && $this->total_Completed_DoAuthorization > 0 || $this->total_Pending_DoAuthorization == $this->total_DoCapture) {
unset($paypal_payment_action['DoVoid']);
Expand Down Expand Up @@ -330,7 +332,7 @@ public function angelleye_wc_paypal_express_docapture($order) {
$transaction_id = $_POST['angelleye_paypal_capture_transaction_dropdown'];
} else {
$old_wc = version_compare(WC_VERSION, '3.0', '<');
$transaction_id = $old_wc ? get_post_meta($order_id, '_transaction_id', true) : get_post_meta($order->get_id(), '_transaction_id', true);
$transaction_id = $old_wc ? get_post_meta($order_id, '_first_transaction_id', true) : get_post_meta($order->get_id(), '_first_transaction_id', true);
}
remove_action('woocommerce_order_action_wc_paypal_express_docapture', array($this, 'angelleye_wc_paypal_express_docapture'));
remove_action('woocommerce_process_shop_order_meta', 'WC_Meta_Box_Order_Data::save', 40, 2);
Expand All @@ -352,7 +354,7 @@ public function angelleye_wc_paypal_pro_docapture($order) {
}
$old_wc = version_compare(WC_VERSION, '3.0', '<');
$order_id = version_compare(WC_VERSION, '3.0', '<') ? $order->id : $order->get_id();
$transaction_id = $old_wc ? get_post_meta($order_id, '_transaction_id', true) : get_post_meta($order->get_id(), '_transaction_id', true);
$transaction_id = $old_wc ? get_post_meta($order_id, '_first_transaction_id', true) : get_post_meta($order->get_id(), '_first_transaction_id', true);
remove_action('woocommerce_order_action_wc_paypal_pro_docapture', array($this, 'angelleye_wc_paypal_pro_docapture'));
remove_action('woocommerce_process_shop_order_meta', 'WC_Meta_Box_Order_Data::save', 40, 2);
$this->pfw_do_capture($order, $transaction_id, null);
Expand All @@ -362,11 +364,13 @@ public function pfw_do_capture($order, $transaction_id = null, $capture_total =
$this->add_ec_angelleye_paypal_php_library();
$this->ec_add_log('DoCapture API call');
$order_id = version_compare(WC_VERSION, '3.0', '<') ? $order->id : $order->get_id();
if ($capture_total == null)
if( !empty($_POST['_regular_price'])) {
$AMT = self::number_format($_POST['_regular_price']);
} elseif ($capture_total == null) {
$AMT = $this->get_amount_by_transaction_id($transaction_id);
else
} else {
$AMT = $capture_total;

}
$DataArray = array(
'AUTHORIZATIONID' => $transaction_id,
'AMT' => $AMT,
Expand Down Expand Up @@ -958,6 +962,11 @@ public function angelleye_paypal_for_woocommerce_order_action_callback($post) {
endforeach;
$order = wc_get_order($post->ID);

$payment_method = get_post_meta($post->ID, '_payment_method', true);
$payment_action = get_post_meta($post->ID, '_payment_action', true);



if (empty($this->angelleye_woocommerce_order_actions)) {
$this->angelleye_woocommerce_order_actions = $this->angelleye_woocommerce_order_actions();
}
Expand All @@ -980,6 +989,7 @@ public function angelleye_paypal_for_woocommerce_order_action_callback($post) {
endforeach;
?>
</select>

<div class="angelleye_authorization_box" style="display: none;">
<?php
$payment_method = get_post_meta($post->ID, '_payment_method', true);
Expand Down Expand Up @@ -1032,6 +1042,7 @@ public function angelleye_paypal_for_woocommerce_order_action_callback($post) {
</script>
<?php
}

?>
<table class="widefat angelleye_order_action_table" style="width: 190px;float: right;">
<tbody>
Expand Down Expand Up @@ -1528,6 +1539,7 @@ public static function crypting($string, $action = 'e') {
return $output;
}


public function angelleye_paypal_for_woocommerce_billing_agreement_details($order) {
if (!is_object($order)) {
$order = wc_get_order($order);
Expand Down
10 changes: 10 additions & 0 deletions assets/js/angelleye-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ jQuery(document).ready(function ($) {
});

jQuery('.angelleye_enable_notifyurl').change(function () {

var express_notifyurl = jQuery('.angelleye_notifyurl').closest('tr');
if (jQuery(this).is(':checked')) {
express_notifyurl.show();
Expand All @@ -240,17 +241,26 @@ jQuery(document).ready(function ($) {
}).change();

jQuery('#angelleye_payment_action').change(function(){

if(jQuery(this).val() == 'DoCapture') {
jQuery("#angelleye_paypal_capture_transaction_dropdown").show();

} else {
jQuery("#angelleye_paypal_capture_transaction_dropdown").hide();
}

if(jQuery(this).val() == 'DoAuthorization') {
jQuery(".angelleye_authorization_box").show();
} else {
jQuery(".angelleye_authorization_box").hide();
}

if(jQuery(this).val() == 'DoCapture') {
if(angelleye_admin.payment_action != 'Order') {
jQuery(".angelleye_authorization_box").show();
}
}

if(jQuery(this).val() == 'DoVoid') {
jQuery("#angelleye_paypal_dovoid_transaction_dropdown").show();
} else {
Expand Down
7 changes: 6 additions & 1 deletion paypal-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ public function init(){
*/
public function admin_scripts()
{
global $post;
$payment_method = get_post_meta($post->ID, '_payment_method', true);
$payment_action = get_post_meta($post->ID, '_payment_action', true);
$dir = plugin_dir_path( __FILE__ );
wp_enqueue_media();
wp_enqueue_script( 'jquery');
Expand All @@ -302,7 +305,9 @@ public function admin_scripts()
$translation_array = array(
'is_ssl' => AngellEYE_Gateway_Paypal::is_ssl()? "yes":"no",
'choose_image' => __('Choose Image', 'paypal-for-woocommerce'),
'shop_based_us_or_uk' => (substr(get_option("woocommerce_default_country"), 0, 2) == 'US' || substr(get_option("woocommerce_default_country"), 0, 2) == 'GB')? "yes":"no"
'shop_based_us_or_uk' => (substr(get_option("woocommerce_default_country"), 0, 2) == 'US' || substr(get_option("woocommerce_default_country"), 0, 2) == 'GB')? "yes":"no",
'payment_method' => $payment_method,
'payment_action' => $payment_action

);
wp_localize_script( 'angelleye_admin', 'angelleye_admin', $translation_array );
Expand Down

0 comments on commit b2999f2

Please sign in to comment.