Plugin Directory

Changeset 1459818


Ignore:
Timestamp:
07/24/2016 04:02:35 PM (10 years ago)
Author:
akeda
Message:

Preparing for 1.2.3 release

Location:
woocommerce-gateway-paypal-powered-by-braintree/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • woocommerce-gateway-paypal-powered-by-braintree/trunk/classes/class-wc-gateway-paypal-braintree-subscription.php

    r1418857 r1459818  
    108108            );
    109109
    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            }
    111117
    112118            if ( ! $result->success ) {
     
    287293            'customerId' => $braintree_customer_id,
    288294            'channel' => 'WooThemes_BT', // aka BN tracking code
    289             'orderId' => $order_id,
     295            'orderId' => $order->id,
    290296            'options' => array(
    291297                'submitForSettlement' => true,
     
    294300        );
    295301
    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
    297309        if ( ! $result->success ) {
    298310            $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  
    830830        ) );
    831831
    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        }
    833840
    834841        // Check result
     
    958965            $transaction = $gateway->transaction()->find( $transaction_id );
    959966        } 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() );
    961968            return false;
    962969        }
     
    984991        }
    985992
    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;
    9901002        }
    9911003
  • woocommerce-gateway-paypal-powered-by-braintree/trunk/readme.txt

    r1436496 r1459818  
    11=== WooCommerce PayPal Powered by Braintree Payment Gateway ===
    2 Contributors: automattic, woothemes, akeda, allendav, royho, slash1andy, woosteve, spraveenitpro, mikedmoore, fernashes, shellbeezy
     2Contributors: automattic, woothemes, akeda, allendav, royho, slash1andy, woosteve, spraveenitpro, mikedmoore, fernashes, shellbeezy, BFTrick
    33Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, store, sales, sell, shop, shopping, cart, checkout, configurable, paypal, braintree
    44Requires at least: 4.4
    55Tested up to: 4.5.2
    6 Stable tag: 1.2.2
     6Stable tag: 1.2.3
    77License: GPLv3
    88License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    7878Make sure PayPal is enabled on your Braintree account by following the [Braintree PayPal Setup Guide](https://articles.braintreepayments.com/guides/paypal/setup-guide).
    7979
     80= What do I need to do if I'm updating from the retired premium Braintree plugin from WooThemes.com?
     81
     82You'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
     84Credit 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
     88You 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
    8090= Where can I get support or talk to other users? =
    8191
     
    100110
    101111== 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
    102116
    103117= 1.2.2 =
  • woocommerce-gateway-paypal-powered-by-braintree/trunk/woocommerce-gateway-paypal-powered-by-braintree.php

    r1436496 r1459818  
    66 * Author: WooThemes
    77 * Author URI: http://woothemes.com/
    8  * Version: 1.2.2
     8 * Version: 1.2.3
    99 *
    1010 * Copyright (c) 2016 WooThemes
     
    257257     */
    258258    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        }
    260263
    261264        if ( $this->subscription_support_enabled ) {
     
    378381     */
    379382    function possibly_enqueue_scripts() {
     383        if ( ! function_exists( 'is_checkout' ) || ! function_exists( 'is_cart' ) ) {
     384            return;
     385        }
    380386
    381387        if ( ! is_checkout() && ! is_cart() ) {
     
    422428            'accessToken' => $merchant_access_token,
    423429        ) );
    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        }
    425437
    426438        $paypal_braintree_data = array(
     
    589601    public function possibly_cancel_checkout_with_paypal() {
    590602
    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'] ) ) {
    592604            $this->possibly_clear_session_data();
    593605            wc_add_notice( __( 'You have cancelled Checkout with PayPal. Please try to process your order again.', 'woocommerce-gateway-paypal-braintree' ), 'notice' );
     
    833845            ) );
    834846
    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            }
    836857
    837858            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
    843862                    $order->add_order_note( sprintf( __( 'PayPal Braintree charge complete (Charge ID: %s)', 'woocommerce-gateway-paypal-braintree' ), $result->transaction->id ) );
    844863                    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() );
    845866                }
    846867            }
     
    867888            ) );
    868889
    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            }
    870900
    871901            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
    877905                    $order->add_order_note( sprintf( __( 'PayPal Braintree charge voided (Charge ID: %s)', 'woocommerce-gateway-paypal-braintree' ), $result->transaction->id ) );
    878906                    delete_post_meta( $order->id, '_pp_braintree_charge_captured' );
    879907                    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() );
    880911                }
    881912            }
Note: See TracChangeset for help on using the changeset viewer.