Plugin Directory

Changeset 2466033


Ignore:
Timestamp:
01/31/2021 08:04:36 PM (5 years ago)
Author:
idofri
Message:

new version-20210131

Location:
woo-pelecard-gateway/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • woo-pelecard-gateway/trunk/includes/Gateway.php

    r2462069 r2466033  
    176176        add_action( 'woocommerce_checkout_update_order_review', [ $this, 'maybe_display_tokenization' ] );
    177177        add_filter( 'woocommerce_credit_card_type_labels', [ $this, 'get_credit_card_type_labels' ] );
    178         add_filter( 'woocommerce_payment_complete_order_status', [ $this, 'order_needs_processing' ] );
    179178
    180179        // WooCommerce Multilingual (WPML)
     
    285284        return ( $hook ? $this->get_option( 'hook_password' ) : null )
    286285            ?: $this->get_option( 'password' );
    287     }
    288 
    289     /**
    290      * @param string $status
    291      *
    292      * @return string
    293      */
    294     public function order_needs_processing( string $status ) {
    295         if ( 'J5' === $this->get_action_type() ) {
    296             $status = 'on-hold';
    297         }
    298 
    299         return $status;
    300286    }
    301287
     
    907893        }
    908894
     895        // Set auth number for future transactions
     896        if ( 'J5' === $this->get_action_type() && ! $this->has_subscription( $order->get_id() ) ) {
     897            $this->order_mark_as_chargeable( $order );
     898            $this->order_save_auth_number( $order, $transaction );
     899        }
     900
    909901        unset( WC()->session->total_payments );
    910902
     
    912904
    913905        return $order->payment_complete( $transaction->get_id() );
     906    }
     907
     908    /**
     909     * @param \WC_Order $order
     910     */
     911    public function order_mark_as_chargeable( WC_Order $order ) {
     912        $order->update_meta_data( '_wpg_is_chargeable', true );
     913        $order->save_meta_data();
     914    }
     915
     916    /**
     917     * @param \WC_Order $order
     918     *
     919     * @return bool
     920     */
     921    public static function is_order_chargeable( WC_Order $order ) {
     922        return (bool) $order->get_meta( '_wpg_is_chargeable' );
    914923    }
    915924
     
    10581067        $order = wc_get_order( $order_id );
    10591068
     1069        if ( ! self::is_order_chargeable( $order ) ) {
     1070            wp_die( -1 );
     1071        }
     1072
    10601073        $token = $this->get_order_payment_token( $order );
    10611074        if ( ! $token ) {
     
    10861099                ->set_data( $result );
    10871100
    1088             /**
    1089              * Orders with payment delay (J5) have on-hold status
    1090              */
    1091             add_filter( 'woocommerce_valid_order_statuses_for_payment', function( $statuses ) {
    1092                 $statuses[] = 'on-hold';
    1093 
    1094                 return $statuses;
    1095             } );
    1096 
    10971101            $this->do_payment( $transaction );
    10981102        } catch ( \Exception $e ) {
    10991103            wp_send_json_error( [ 'error' => $e->getMessage() ] );
    11001104        }
     1105
     1106        $order->delete_meta_data( '_wpg_is_chargeable' );
     1107        $order->save_meta_data();
    11011108
    11021109        wp_send_json_success();
  • woo-pelecard-gateway/trunk/includes/Order.php

    r2460563 r2466033  
    8383     */
    8484    public function render_charge_button( WC_Order $order ) {
    85         if ( ! $order->has_status( 'on-hold' ) ) {
    86             return;
    87         }
    88 
    89         if ( ! current_user_can( 'edit_shop_orders' ) ) {
     85        $is_chargeable = Gateway::is_order_chargeable( $order );
     86        if ( ! $is_chargeable || ! current_user_can( 'edit_shop_orders' ) ) {
    9087            return;
    9188        }
  • woo-pelecard-gateway/trunk/includes/Plugin.php

    r2462069 r2466033  
    1818     * @var string $version
    1919     */
    20     public static $version = '1.4.1';
     20    public static $version = '1.4.2';
    2121
    2222    /**
  • woo-pelecard-gateway/trunk/readme.txt

    r2462069 r2466033  
    44Requires at least: 5.3
    55Tested up to: 5.6
    6 Stable tag: 1.4.1
     6Stable tag: 1.4.2
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5555
    5656== Changelog ==
     57
     58= 1.4.2 =
     59* Fixed J5 transactions logic.
    5760
    5861= 1.4.1 =
  • woo-pelecard-gateway/trunk/woocommerce-pelecard-gateway.php

    r2462069 r2466033  
    44 * Plugin URI: https://wordpress.org/plugins/woo-pelecard-gateway/
    55 * Description: Extends WooCommerce with Pelecard payment gateway.
    6  * Version: 1.4.1
     6 * Version: 1.4.2
    77 * Author: Ido Friedlander
    88 * Author URI: https://profiles.wordpress.org/idofri/
Note: See TracChangeset for help on using the changeset viewer.