Skip to content

Commit

Permalink
Braintree - Errors being reported on Order Received page, ref #538
Browse files Browse the repository at this point in the history
  • Loading branch information
kcppdevelopers committed Aug 18, 2016
1 parent 451730d commit e1100f4
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions classes/wc-gateway-braintree-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,19 +359,22 @@ private function get_posted_card() {
*/
public function process_payment($order_id) {
$order = new WC_Order($order_id);
$this->angelleye_do_payment($order);
if (is_ajax()) {
$success = $this->angelleye_do_payment($order);
if($success == true) {
return array(
'result' => 'success',
'redirect' => $this->get_return_url($order)
'result' => 'success',
'redirect' => $this->get_return_url( $order )
);
} else {
wp_redirect($this->get_return_url($order));
exit();
return array(
'result' => 'fail',
'redirect' => ''
);
}
}

public function angelleye_do_payment($order) {
$success = true;
global $woocommerce;
try {
if (isset($_POST['braintree_token']) && !empty($_POST['braintree_token'])) {
Expand Down Expand Up @@ -450,14 +453,13 @@ public function angelleye_do_payment($order) {
$notice = sprintf( __( 'Error: PayPal Powered by Braintree was unable to complete the transaction. Please try again later or use another means of payment. Reason: %s', 'woocommerce-gateway-paypal-braintree' ), $e->getMessage() );
wc_add_notice( $notice, 'error' );
$this->add_log('Error: Unable to complete transaction. Reason: ' . $e->getMessage() );
return false;
return $success = false;
}

if ( !$this->response->success ) {
$notice = sprintf( __( 'Error: PayPal Powered by Braintree was unable to complete the transaction. Please try again later or use another means of payment. Reason: %s', 'woocommerce-gateway-paypal-braintree' ), $this->response->message );
wc_add_notice( $notice, 'error' );
$this->add_log( "Error: Unable to complete transaction. Reason: {$this->response->message}" );
return false;
return $success = false;
}

$this->add_log('Braintree_Transaction::sale Response code: ' . print_r($this->get_status_code(), true));
Expand All @@ -479,9 +481,9 @@ public function angelleye_do_payment($order) {
}
} catch (Exception $ex) {
wc_add_notice($ex->getMessage(), 'error');
wp_redirect($order->get_checkout_payment_url(true));
exit;
return $success = false;
}
return $success;
}

public function get_braintree_options() {
Expand Down

0 comments on commit e1100f4

Please sign in to comment.