Changeset 1459818
- Timestamp:
- 07/24/2016 04:02:35 PM (10 years ago)
- Location:
- woocommerce-gateway-paypal-powered-by-braintree/trunk
- Files:
-
- 4 edited
-
classes/class-wc-gateway-paypal-braintree-subscription.php (modified) (3 diffs)
-
classes/class-wc-gateway-paypal-braintree.php (modified) (3 diffs)
-
readme.txt (modified) (3 diffs)
-
woocommerce-gateway-paypal-powered-by-braintree.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woocommerce-gateway-paypal-powered-by-braintree/trunk/classes/class-wc-gateway-paypal-braintree-subscription.php
r1418857 r1459818 108 108 ); 109 109 110 $result = $gateway->customer()->create( $customer_args ); 110 try { 111 $result = $gateway->customer()->create( $customer_args ); 112 } catch ( Exception $e ) { 113 $this->log( __FUNCTION__, 'Error: Unable to create customer. Reason: ' . $e->getMessage() ); 114 wc_add_notice( __( 'Error: PayPal Powered by Braintree was unable to create a customer record for you. Please try again later or use another means of payment.', 'woocommerce-gateway-paypal-braintree' ), 'error' ); 115 return false; 116 } 111 117 112 118 if ( ! $result->success ) { … … 287 293 'customerId' => $braintree_customer_id, 288 294 'channel' => 'WooThemes_BT', // aka BN tracking code 289 'orderId' => $order _id,295 'orderId' => $order->id, 290 296 'options' => array( 291 297 'submitForSettlement' => true, … … 294 300 ); 295 301 296 $result = $gateway->transaction()->sale( $sale_args ); 302 try { 303 $result = $gateway->transaction()->sale( $sale_args ); 304 } catch ( Exception $e ) { 305 $this->log( __FUNCTION__, 'Error: Unable to process scheduled payment. Reason: ' . $e->getMessage() ); 306 return false; 307 } 308 297 309 if ( ! $result->success ) { 298 310 $this->log( __FUNCTION__, "Error: Unable to process scheduled payment: {$result->message}" ); -
woocommerce-gateway-paypal-powered-by-braintree/trunk/classes/class-wc-gateway-paypal-braintree.php
r1418857 r1459818 830 830 ) ); 831 831 832 $result = $gateway->transaction()->sale( $sale_args ); 832 try { 833 $result = $gateway->transaction()->sale( $sale_args ); 834 } catch ( Exception $e ) { 835 $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() ); 836 wc_add_notice( $notice, 'error' ); 837 $this->log( __FUNCTION__, 'Error: Unable to complete transaction. Reason: ' . $e->getMessage() ); 838 return false; 839 } 833 840 834 841 // Check result … … 958 965 $transaction = $gateway->transaction()->find( $transaction_id ); 959 966 } catch ( Exception $e ) { 960 $this->log( __FUNCTION__, "Error: Unable to find transaction with transaction ID {$transaction_id} ");967 $this->log( __FUNCTION__, "Error: Unable to find transaction with transaction ID {$transaction_id}. Reason: " . $e->getMessage() ); 961 968 return false; 962 969 } … … 984 991 } 985 992 986 if ( "void" === $action_to_take ) { 987 $result = $gateway->transaction()->void( $transaction_id ); 988 } else { 989 $result = $gateway->transaction()->refund( $transaction_id, $refund_amount ); 993 try { 994 if ( "void" === $action_to_take ) { 995 $result = $gateway->transaction()->void( $transaction_id ); 996 } else { 997 $result = $gateway->transaction()->refund( $transaction_id, $refund_amount ); 998 } 999 } catch ( Exception $e ) { 1000 $this->log( __FUNCTION__, 'Error: The transaction cannot be voided nor refunded. Reason: ' . $e->getMessage() ); 1001 return false; 990 1002 } 991 1003 -
woocommerce-gateway-paypal-powered-by-braintree/trunk/readme.txt
r1436496 r1459818 1 1 === WooCommerce PayPal Powered by Braintree Payment Gateway === 2 Contributors: automattic, woothemes, akeda, allendav, royho, slash1andy, woosteve, spraveenitpro, mikedmoore, fernashes, shellbeezy 2 Contributors: automattic, woothemes, akeda, allendav, royho, slash1andy, woosteve, spraveenitpro, mikedmoore, fernashes, shellbeezy, BFTrick 3 3 Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, store, sales, sell, shop, shopping, cart, checkout, configurable, paypal, braintree 4 4 Requires at least: 4.4 5 5 Tested up to: 4.5.2 6 Stable tag: 1.2. 26 Stable tag: 1.2.3 7 7 License: GPLv3 8 8 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 78 78 Make sure PayPal is enabled on your Braintree account by following the [Braintree PayPal Setup Guide](https://articles.braintreepayments.com/guides/paypal/setup-guide). 79 79 80 = What do I need to do if I'm updating from the retired premium Braintree plugin from WooThemes.com? 81 82 You'll need to go through the same installation process as everyone else. Luckily it's only a few clicks (no need to copy and paste API keys) so it should only take a minute. 83 84 Credit card tokens will not migrate. Your customers will have to reenter their CC details once. All transactions made with the new plugin will let the user choose if they want their CC details saved (as tokens of course) so they don't have to reneter them every time. 85 86 = Can I use this extension just for PayPal and use another gateway for Credit Cards? = 87 88 You have to connect to PayPal through your Braintree account so it doesn't make a lot of sense to use this just for PayPal. But there's nothing stopping you from adding another gateway to accept credit cards. 89 80 90 = Where can I get support or talk to other users? = 81 91 … … 100 110 101 111 == Changelog == 112 113 = 1.2.3 = 114 * Fix - Handle uncaught exceptions thrown by Braintree SDK. API calls from SDK may throws exception, thus it need to be handled properly in try/catch block. 115 * Fix - Issue where deactivating WooCommerce might throws an error 102 116 103 117 = 1.2.2 = -
woocommerce-gateway-paypal-powered-by-braintree/trunk/woocommerce-gateway-paypal-powered-by-braintree.php
r1436496 r1459818 6 6 * Author: WooThemes 7 7 * Author URI: http://woothemes.com/ 8 * Version: 1.2. 28 * Version: 1.2.3 9 9 * 10 10 * Copyright (c) 2016 WooThemes … … 257 257 */ 258 258 public function get_setting_link() { 259 $use_id_as_section = version_compare( WC()->version, '2.6', '>=' ); 259 $use_id_as_section = true; 260 if ( function_exists( 'WC' ) ) { 261 $use_id_as_section = version_compare( WC()->version, '2.6', '>=' ); 262 } 260 263 261 264 if ( $this->subscription_support_enabled ) { … … 378 381 */ 379 382 function possibly_enqueue_scripts() { 383 if ( ! function_exists( 'is_checkout' ) || ! function_exists( 'is_cart' ) ) { 384 return; 385 } 380 386 381 387 if ( ! is_checkout() && ! is_cart() ) { … … 422 428 'accessToken' => $merchant_access_token, 423 429 ) ); 424 $client_token = $braintree_gateway->clientToken()->generate(); 430 431 try { 432 $client_token = $braintree_gateway->clientToken()->generate(); 433 } catch ( Exception $e ) { 434 $this->log( __FUNCTION__, 'Error: Unable to generate client token. Reason: ' . $e->getMessage() ); 435 return; 436 } 425 437 426 438 $paypal_braintree_data = array( … … 589 601 public function possibly_cancel_checkout_with_paypal() { 590 602 591 if ( is_cart() && ! empty( $_GET['wc_paypal_braintree_clear_session'] ) ) {603 if ( function_exists( 'is_cart' ) && is_cart() && ! empty( $_GET['wc_paypal_braintree_clear_session'] ) ) { 592 604 $this->possibly_clear_session_data(); 593 605 wc_add_notice( __( 'You have cancelled Checkout with PayPal. Please try to process your order again.', 'woocommerce-gateway-paypal-braintree' ), 'notice' ); … … 833 845 ) ); 834 846 835 $transaction_details = $trans_id ? $gateway->transaction()->find( $trans_id ) : false; 847 $transaction_details = false; 848 if ( $trans_id ) { 849 try { 850 $transaction_details = $gateway->transaction()->find( $trans_id ); 851 } catch ( Exception $e ) { 852 $order->add_order_note( __( 'Unable to capture charge!', 'woocommerce-gateway-paypal-braintree' ) . ' ' . $e->getMessage() ); 853 $this->log( __FUNCTION__, "Error: Unable to find transaction with transaction ID {$trans_id}. Reason: " . $e->getMessage() ); 854 return; 855 } 856 } 836 857 837 858 if ( $trans_id && 'authorized' === $transaction_details->status ) { 838 $result = $gateway->transaction()->submitForSettlement( $trans_id, floatval( $order->order_total ) ); 839 840 if ( is_wp_error( $result ) ) { 841 $order->add_order_note( __( 'Unable to capture charge!', 'woocommerce-gateway-paypal-braintree' ) . ' ' . $result->get_error_message() ); 842 } else { 859 try { 860 $result = $gateway->transaction()->submitForSettlement( $trans_id, floatval( $order->order_total ) ); 861 843 862 $order->add_order_note( sprintf( __( 'PayPal Braintree charge complete (Charge ID: %s)', 'woocommerce-gateway-paypal-braintree' ), $result->transaction->id ) ); 844 863 update_post_meta( $order->id, '_pp_braintree_charge_captured', 'yes' ); 864 } catch ( Exception $e ) { 865 $order->add_order_note( __( 'Unable to capture charge!', 'woocommerce-gateway-paypal-braintree' ) . ' ' . $result->get_error_message() ); 845 866 } 846 867 } … … 867 888 ) ); 868 889 869 $transaction_details = $trans_id ? $gateway->transaction()->find( $trans_id ) : false; 890 $transaction_details = false; 891 if ( $trans_id ) { 892 try { 893 $transaction_details = $gateway->transaction()->find( $trans_id ); 894 } catch ( Exception $e ) { 895 $this->log( __FUNCTION__, "Error: Unable to find transaction with transaction ID {$trans_id}. Reason: " . $e->getMessage() ); 896 $order->add_order_note( __( 'Unable to void charge!', 'woocommerce-gateway-paypal-braintree' ) . ' ' . $e->getMessage() ); 897 return; 898 } 899 } 870 900 871 901 if ( $trans_id && 'authorized' === $transaction_details->status ) { 872 $result = $gateway->transaction()->void( $trans_id ); 873 874 if ( is_wp_error( $result ) ) { 875 $order->add_order_note( __( 'Unable to void charge!', 'woocommerce-gateway-paypal-braintree' ) . ' ' . $result->get_error_message() ); 876 } else { 902 try { 903 $result = $gateway->transaction()->void( $trans_id ); 904 877 905 $order->add_order_note( sprintf( __( 'PayPal Braintree charge voided (Charge ID: %s)', 'woocommerce-gateway-paypal-braintree' ), $result->transaction->id ) ); 878 906 delete_post_meta( $order->id, '_pp_braintree_charge_captured' ); 879 907 delete_post_meta( $order->id, '_transaction_id' ); 908 } catch ( Exception $e ) { 909 $this->log( __FUNCTION__, 'Error: Unable to void charge. Reason: ' . $e->getMessage() ); 910 $order->add_order_note( __( 'Unable to void charge!', 'woocommerce-gateway-paypal-braintree' ) . ' ' . $e->getMessage() ); 880 911 } 881 912 }
Note: See TracChangeset
for help on using the changeset viewer.