Plugin Directory

Changeset 2540675


Ignore:
Timestamp:
06/01/2021 12:01:56 PM (5 years ago)
Author:
woothemes
Message:

Tagging version 3.2.2

Location:
woocommerce-gateway-eway
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • woocommerce-gateway-eway/tags/3.2.2/changelog.txt

    r2533058 r2540675  
    11*** WooCommerce eWAY Gateway Changelog ***
     2
     3= 3.2.2 - 2021-06-01 =
     4* Fix - Fatal error when updating payment for all subscriptions.
    25
    36= 3.2.1 - 2021-05-17 =
  • woocommerce-gateway-eway/tags/3.2.2/includes/class-wc-gateway-eway-subscriptions.php

    r2277835 r2540675  
    2626            add_filter( 'woocommerce_subscription_validate_payment_meta', array( $this, 'validate_subscription_payment_meta' ), 10, 2 );
    2727
     28            // Don't update payment methods immediately when changing payment for subscriptions to eWay - wait until we get payment token.
     29            add_filter( 'woocommerce_subscriptions_update_payment_via_pay_shortcode', array( $this, 'maybe_update_payment_method' ), 10, 3 );
     30
     31            add_action( 'woocommerce_api_wc_gateway_eway_payment_completed', array( $this, 'maybe_update_all_subscriptions_payment' ), 10, 3 );
     32        }
     33
     34        /**
     35         * Maybe update payment method of all subscriptions.
     36         *
     37         * @param WC_Order        $order The order whose payment failed.
     38         * @param stdClass        $result The result from the API call.
     39         * @param WC_Gateway_EWAY $gateway The instance of the gateway.
     40         */
     41        public function maybe_update_all_subscriptions_payment( $order, $result, $gateway ) {
     42            if ( $this->id !== $gateway->id ) {
     43                return;
     44            }
     45
     46            if ( ! wcs_is_subscription( $order ) ) {
     47                return;
     48            }
     49
     50            if ( ! WC_Subscriptions_Change_Payment_Gateway::will_subscription_update_all_payment_methods( $order ) ) {
     51                return;
     52            }
     53
     54            switch ( $result->ResponseMessage ) {
     55                case 'A2000':
     56                case 'A2008':
     57                case 'A2010':
     58                case 'A2011':
     59                case 'A2016':
     60                    if ( empty( $result->TokenCustomerID ) ) {
     61                        return;
     62                    }
     63                    WC_Subscriptions_Change_Payment_Gateway::update_all_payment_methods_from_subscription( $order, $gateway->id );
     64                    break;
     65            }
     66        }
     67
     68        /**
     69         * Updates payment method if necessary.
     70         *
     71         * When changing payment to eWay for subscriptions it doesn't update payment methods immediately but waits until payment token available.
     72         *
     73         * @param  bool            $update
     74         * @param  string          $new_payment_method
     75         * @param  WC_Subscription $subscription
     76         * @return bool
     77         */
     78        public function maybe_update_payment_method( $update, $new_payment_method, $subscription ) {
     79            if ( empty( $_POST['update_all_subscriptions_payment_method'] ) ) {
     80                return $update;
     81            }
     82
     83            if ( $this->id !== $new_payment_method ) {
     84                return $update;
     85            }
     86
     87            /*
     88             * So that 'pay for order' page shows the credit card form, the order whose
     89             * payment method is to be changed needs to have payment method = eway.
     90             * That's why, when payment method is not eway, we want to update it immediately.
     91             * Hence, return $update here.
     92             */
     93            if ( $this->id !== $subscription->get_payment_method() ) {
     94                return $update;
     95            }
     96
     97            $is_new_card = ! isset( $_POST['eway_card_id'] ) || 'new' === $_POST['eway_card_id'];
     98            if ( ! $is_new_card ) {
     99                return $update;
     100            }
     101
     102            // Don't update payment methods immediately when changing payment for subscriptions to eWay - wait until we get payment token.
     103            return false;
    28104        }
    29105
  • woocommerce-gateway-eway/tags/3.2.2/includes/class-wc-gateway-eway.php

    r2531558 r2540675  
    3838                'subscription_payment_method_change_admin',
    3939                'multiple_subscriptions',
     40                'subscription_payment_method_delayed_change',
    4041            );
    4142
  • woocommerce-gateway-eway/tags/3.2.2/readme.txt

    r2533058 r2540675  
    44Requires at least: 4.4
    55Tested up to: 5.7
    6 Stable tag: 3.2.1
     6Stable tag: 3.2.2
    77Requires PHP: 5.6
    88License: GPLv3
     
    8484== Changelog ==
    8585
     86= 3.2.2 - 2021-06-01 =
     87* Fix - Fatal error when updating payment for all subscriptions.
     88
    8689= 3.2.1 - 2021-05-17 =
    8790* Fix - Fatal error when PHP version is older than 7.3.
  • woocommerce-gateway-eway/tags/3.2.2/woocommerce-gateway-eway.php

    r2533058 r2540675  
    66 * Author: WooCommerce
    77 * Author URI: https://woocommerce.com/
    8  * Version: 3.2.1
     8 * Version: 3.2.2
    99 * Text Domain: wc-eway
    1010 * Domain Path: /languages
     
    2222}
    2323
    24 define( 'WOOCOMMERCE_GATEWAY_EWAY_VERSION', '3.2.1' ); // WRCS: DEFINED_VERSION.
     24define( 'WOOCOMMERCE_GATEWAY_EWAY_VERSION', '3.2.2' ); // WRCS: DEFINED_VERSION.
    2525define( 'WOOCOMMERCE_GATEWAY_EWAY_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
    2626define( 'WOOCOMMERCE_GATEWAY_EWAY_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
  • woocommerce-gateway-eway/trunk/changelog.txt

    r2533058 r2540675  
    11*** WooCommerce eWAY Gateway Changelog ***
     2
     3= 3.2.2 - 2021-06-01 =
     4* Fix - Fatal error when updating payment for all subscriptions.
    25
    36= 3.2.1 - 2021-05-17 =
  • woocommerce-gateway-eway/trunk/includes/class-wc-gateway-eway-subscriptions.php

    r2277835 r2540675  
    2626            add_filter( 'woocommerce_subscription_validate_payment_meta', array( $this, 'validate_subscription_payment_meta' ), 10, 2 );
    2727
     28            // Don't update payment methods immediately when changing payment for subscriptions to eWay - wait until we get payment token.
     29            add_filter( 'woocommerce_subscriptions_update_payment_via_pay_shortcode', array( $this, 'maybe_update_payment_method' ), 10, 3 );
     30
     31            add_action( 'woocommerce_api_wc_gateway_eway_payment_completed', array( $this, 'maybe_update_all_subscriptions_payment' ), 10, 3 );
     32        }
     33
     34        /**
     35         * Maybe update payment method of all subscriptions.
     36         *
     37         * @param WC_Order        $order The order whose payment failed.
     38         * @param stdClass        $result The result from the API call.
     39         * @param WC_Gateway_EWAY $gateway The instance of the gateway.
     40         */
     41        public function maybe_update_all_subscriptions_payment( $order, $result, $gateway ) {
     42            if ( $this->id !== $gateway->id ) {
     43                return;
     44            }
     45
     46            if ( ! wcs_is_subscription( $order ) ) {
     47                return;
     48            }
     49
     50            if ( ! WC_Subscriptions_Change_Payment_Gateway::will_subscription_update_all_payment_methods( $order ) ) {
     51                return;
     52            }
     53
     54            switch ( $result->ResponseMessage ) {
     55                case 'A2000':
     56                case 'A2008':
     57                case 'A2010':
     58                case 'A2011':
     59                case 'A2016':
     60                    if ( empty( $result->TokenCustomerID ) ) {
     61                        return;
     62                    }
     63                    WC_Subscriptions_Change_Payment_Gateway::update_all_payment_methods_from_subscription( $order, $gateway->id );
     64                    break;
     65            }
     66        }
     67
     68        /**
     69         * Updates payment method if necessary.
     70         *
     71         * When changing payment to eWay for subscriptions it doesn't update payment methods immediately but waits until payment token available.
     72         *
     73         * @param  bool            $update
     74         * @param  string          $new_payment_method
     75         * @param  WC_Subscription $subscription
     76         * @return bool
     77         */
     78        public function maybe_update_payment_method( $update, $new_payment_method, $subscription ) {
     79            if ( empty( $_POST['update_all_subscriptions_payment_method'] ) ) {
     80                return $update;
     81            }
     82
     83            if ( $this->id !== $new_payment_method ) {
     84                return $update;
     85            }
     86
     87            /*
     88             * So that 'pay for order' page shows the credit card form, the order whose
     89             * payment method is to be changed needs to have payment method = eway.
     90             * That's why, when payment method is not eway, we want to update it immediately.
     91             * Hence, return $update here.
     92             */
     93            if ( $this->id !== $subscription->get_payment_method() ) {
     94                return $update;
     95            }
     96
     97            $is_new_card = ! isset( $_POST['eway_card_id'] ) || 'new' === $_POST['eway_card_id'];
     98            if ( ! $is_new_card ) {
     99                return $update;
     100            }
     101
     102            // Don't update payment methods immediately when changing payment for subscriptions to eWay - wait until we get payment token.
     103            return false;
    28104        }
    29105
  • woocommerce-gateway-eway/trunk/includes/class-wc-gateway-eway.php

    r2531558 r2540675  
    3838                'subscription_payment_method_change_admin',
    3939                'multiple_subscriptions',
     40                'subscription_payment_method_delayed_change',
    4041            );
    4142
  • woocommerce-gateway-eway/trunk/readme.txt

    r2533058 r2540675  
    44Requires at least: 4.4
    55Tested up to: 5.7
    6 Stable tag: 3.2.1
     6Stable tag: 3.2.2
    77Requires PHP: 5.6
    88License: GPLv3
     
    8484== Changelog ==
    8585
     86= 3.2.2 - 2021-06-01 =
     87* Fix - Fatal error when updating payment for all subscriptions.
     88
    8689= 3.2.1 - 2021-05-17 =
    8790* Fix - Fatal error when PHP version is older than 7.3.
  • woocommerce-gateway-eway/trunk/woocommerce-gateway-eway.php

    r2533058 r2540675  
    66 * Author: WooCommerce
    77 * Author URI: https://woocommerce.com/
    8  * Version: 3.2.1
     8 * Version: 3.2.2
    99 * Text Domain: wc-eway
    1010 * Domain Path: /languages
     
    2222}
    2323
    24 define( 'WOOCOMMERCE_GATEWAY_EWAY_VERSION', '3.2.1' ); // WRCS: DEFINED_VERSION.
     24define( 'WOOCOMMERCE_GATEWAY_EWAY_VERSION', '3.2.2' ); // WRCS: DEFINED_VERSION.
    2525define( 'WOOCOMMERCE_GATEWAY_EWAY_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
    2626define( 'WOOCOMMERCE_GATEWAY_EWAY_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
Note: See TracChangeset for help on using the changeset viewer.