Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/Issue-217' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Angell committed Jun 16, 2015
2 parents 8b97ace + 3ff43dd commit ba3edd8
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions classes/wc-gateway-paypal-express-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -916,15 +916,17 @@ function paypal_express_checkout($posted = null) {
}

$creds = array(
'user_login' => $username,
'user_login' => wc_clean($username),
'user_password' => $password,
'remember' => true,
);
$user = wp_signon( $creds, false );
if ( is_wp_error($user) ) {
wc_add_notice($user->get_error_message(), 'error');
} else {
wp_set_current_user($user->ID); //Here is where we update the global user variables
wp_set_current_user($user->ID); //Here is where we update the global user variables
$secure_cookie = is_ssl() ? true : false;
wp_set_auth_cookie( $user->ID, true, $secure_cookie );
}

} catch (Exception $e) {
Expand Down Expand Up @@ -1332,6 +1334,10 @@ function CallSetExpressCheckout($paymentAmount, $returnURL, $cancelURL, $usePayP
$shipping = WC()->cart->shipping_total;
$tax = WC()->cart->get_taxes_total();
}

if('yes' === get_option( 'woocommerce_calc_taxes' ) && 'yes' === get_option( 'woocommerce_prices_include_tax' )) {
$tax = wc_round_tax_total( WC()->cart->tax_total + WC()->cart->shipping_tax_total );
}

$Payments = array();
$Payment = array(
Expand Down Expand Up @@ -1598,7 +1604,12 @@ function CallSetExpressCheckout($paymentAmount, $returnURL, $cancelURL, $usePayP
} else {
$shipping = WC()->cart->shipping_total;
}
$PayPalRequestData['Payments'][0]['shippingamt'] = $this->cut_off($shipping, 2);
if($shipping > 0) {
$PayPalRequestData['Payments'][0]['shippingamt'] = $this->cut_off($shipping, 2);
} elseif ($tax > 0) {
$PayPalRequestData['Payments'][0]['taxamt'] = $this->cut_off($tax, 2);
}

}

// Pass data into class for processing with PayPal and load the response array into $PayPalResult
Expand Down Expand Up @@ -1831,7 +1842,7 @@ function ConfirmPayment($FinalPaymentAmt) {
$Item = array(
'name' => $values['name'], // Item name. 127 char max.
'desc' => '', // Item description. 127 char max.
'amt' => $product_price, // Cost of item.
'amt' => round( $values['line_subtotal'] / $qty, 2 ), // Cost of item.
'number' => $sku, // Item number. 127 char max.
'qty' => $qty, // Item qty on order. Any positive integer.
'taxamt' => '', // Item sales tax
Expand All @@ -1852,7 +1863,7 @@ function ConfirmPayment($FinalPaymentAmt) {
);
array_push($PaymentOrderItems, $Item);

$ITEMAMT += $product_price * $values['qty'];
$ITEMAMT += $values['line_subtotal'];;
}

/**
Expand Down Expand Up @@ -1948,6 +1959,10 @@ function ConfirmPayment($FinalPaymentAmt) {
$tax = $order->get_total_tax();
}

if('yes' === get_option( 'woocommerce_calc_taxes' ) && 'yes' === get_option( 'woocommerce_prices_include_tax' )) {
$tax = $order->get_total_tax();
}

if( $tax > 0) {
$tax = number_format($tax, 2, '.', '');
}
Expand Down Expand Up @@ -2013,7 +2028,12 @@ function ConfirmPayment($FinalPaymentAmt) {
} else {
$shipping = WC()->cart->shipping_total;
}
$PayPalRequestData['Payments'][0]['shippingamt'] = $this->cut_off($shipping, 2);
if($shipping > 0) {
$PayPalRequestData['Payments'][0]['shippingamt'] = $this->cut_off($shipping, 2);
} elseif ($tax > 0) {
$PayPalRequestData['Payments'][0]['taxamt'] = $this->cut_off($tax, 2);
}

}

// Pass data into class for processing with PayPal and load the response array into $PayPalResult
Expand Down

0 comments on commit ba3edd8

Please sign in to comment.