Plugin Directory

Changeset 2476032


Ignore:
Timestamp:
02/17/2021 04:37:00 AM (5 years ago)
Author:
subscribility
Message:

release 2.9.22.5

Location:
subscribility
Files:
6 deleted
8 edited
52 copied

Legend:

Unmodified
Added
Removed
  • subscribility/tags/2.9.22.5/includes/admin/controllers/class-wp99234-admin-settings-data-collection.php

    r2415557 r2476032  
    144144        ),
    145145
    146         [
    147             'title' => __( 'Select customer referral coupon', 'troly' ),
    148             'type' => 'select',
    149             'desc' => __( 'Select customer referral coupon to assign it with your referral code.', 'troly' ),
    150             'desc_tip' => true,
    151             'id' => 'troly_member_referral_coupon',
    152             'css' => 'min-width:550px;',
    153             'options' => $this->getAllCoupons(),
    154         ],
    155 
    156146        array( 'type' => 'sectionend', 'id' => 'sync_options' ),
    157147    ) );
  • subscribility/tags/2.9.22.5/includes/admin/controllers/class-wp99234-admin-settings-signup-checkout.php

    r2415557 r2476032  
    123123    }
    124124
     125    /**
     126     * Get all the coupons found in the DB
     127     */
    125128    public function getAllCoupons()
    126129    {
  • subscribility/tags/2.9.22.5/includes/frontend/controllers/class-wp99234-registration-forms.php

    r2382505 r2476032  
    103103                'required' => __( 'Please enter your credit card number.', 'wp99234' ),
    104104            );
    105             $fields['cc_exp'] = array(
     105            $fields['cc_expiry'] = array(
    106106                'required' => __( 'Please enter your card expiry date.', 'wp99234' ),
    107107                'contains' => array(
     
    204204        if ( !isset( $_POST['wp99234_use_existing_card'] ) || $_POST['wp99234_use_existing_card'] !== 'yes' ) {
    205205
    206             $exp_array = explode( '/', str_replace( ' ', '', wp_kses( $data['cc_exp'], array() ) ) );
     206            $exp_array = explode( '/', str_replace( ' ', '', wp_kses( $data['cc_expiry'], array() ) ) );
    207207
    208208            $exp_month   = $exp_array[0];
     
    280280                $this->setNewClubSignupSession();
    281281            }
    282 
    283             wc_add_notice( 'Thank you for joining our club. Your membership benefits have been applied to this order.', 'success' );
    284282
    285283            if ( isset($_POST) && isset($data[ 'user_pass' ]) ) {
     
    300298            if ( isset( $_GET['troly_redirect'] ) ) {
    301299                if ( $_GET['troly_redirect'] === 'cart' ) {
     300                    wc_add_notice( 'Thank you for joining our club. Your membership benefits have been applied to this cart.', 'success' );
    302301                    wp_redirect( wc_get_cart_url() );
    303302                    exit;
    304303                }
    305304                elseif ( $_GET['troly_redirect'] === 'checkout' ) {
     305                    wc_add_notice( 'Thank you for joining our club. Your membership benefits have been applied to this order.', 'success' );
    306306                    wp_redirect( wc_get_checkout_url() );
    307307                    exit;
    308308                }
    309309                elseif ( $_GET['troly_redirect'] === 'product' && ! empty( $_GET['pid'] ) ) {
     310                    wc_add_notice( 'Thank you for joining our club!', 'success' );
    310311                    wp_redirect( get_permalink( $_GET['pid'] ) );
    311312                    exit;
    312313                }
    313             }
     314            } else {
     315                /* They are signing up on the page directly. */
     316                wc_add_notice( 'Thank you for joining our club!', 'success' );
     317            }
    314318        } else {
    315             wc_add_notice( 'An unknown error has occurred. Please try again.', 'error' );
     319            /* Troly may have reported errors. Lets attempt to break these down and let the
     320            user know that they need to amend their details */
     321            $field_mappings = [
     322                "cc_exp_month" => "Card expiry month",
     323                "cc_exp_year" => "Card expiry year",
     324                "cc_number" => "Card number",
     325                "cc_name" => "Card name",
     326                "cc_exp_date" => "Card expiry date"
     327            ];
     328            if(isset($results->errors)){
     329                wc_add_notice( 'Some details could not be accepted. Please review them and try again', 'error' );
     330                foreach($results->errors as $field => $elist){
     331                    if(strpos($field, '.') > -1) continue;
     332                    foreach($elist as $erroritem){
     333                        wc_add_notice( $field_mappings[$field] . " $erroritem", 'error');
     334                    }
     335                }
     336            } else {
     337                wc_add_notice( 'An unknown error has occurred. Please try again.', 'error' );
     338            }
    316339        }
    317340    }
  • subscribility/tags/2.9.22.5/includes/frontend/controllers/class-wp99234-users.php

    r2457995 r2476032  
    474474         */
    475475        if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) && ! isset( $_POST[ 'wp99234_use_existing_card' ] ) ) {
    476             $cc_exp = explode('/', str_replace(' ', '', wp_kses($_POST['cc_exp'], array())));
     476            $cc_exp = explode('/', str_replace(' ', '', wp_kses($_POST['cc_expiry'], array())));
    477477
    478478            if (count($cc_exp) > 1) {
     
    606606        if( ! empty( $errors ) ){
    607607
    608             if ($subs_id) {
    609                 $message .= "\nFailed to update user on Troly because of: {${WP99234()->get_var_dump($errors)}}";
    610             } else {
    611                 $message .= "\nFailed to export user to Troly because of: {${WP99234()->get_var_dump($errors)}}";
    612             }
     608            $details = '';
     609            if(is_array($errors)){
     610                foreach($errors as $field => $ferrors){
     611                    $details .= "{$field} ";
     612                    if(is_array($ferrors)){
     613                        foreach($ferrors as $ferror){
     614                            $details .= "{$ferror} ";
     615                        }
     616                    } else {
     617                        $details .= "{$ferror} ";
     618                    }
     619                }
     620            }
     621
     622            $message .= " failed.";
    613623
    614624            if ($reporting_options == 'verbose' || $reporting_options == 'medium') {
    615                 wp99234_log_troly( 0, 1, 0, $message );
     625                wp99234_log_troly( 0, 1, 0, $message, $details );
    616626            }
    617627
  • subscribility/tags/2.9.22.5/includes/frontend/controllers/class-wp99234-wc-filter.php

    r2415557 r2476032  
    7777
    7878        // Action to validate credit card
    79         add_action( 'woocommerce_after_checkout_validation',        array($this, 'wp99234_validate_credit_card'), 10, 2 );
     79        add_action( 'woocommerce_after_checkout_validation',        array($this, 'wp99234_validate_credit_card_checkout'), 10, 2 );
     80
     81        // Account details error handling
     82        add_action('woocommerce_save_account_details_errors', array($this, 'wp99234_validate_credit_card_account_details'), 10, 1);
    8083
    8184        if ( 'checkout' === get_option( 'troly_require_dob' ) ||
     
    728731
    729732        $cc_exp = '<p class="woocommerce-FormRow woocommerce-FormRow--wide form-row form-row-first">';
    730         $cc_exp .= '<label for="cc_exp">Expiry (MM/YY)</label>';
    731         $cc_exp .= '<input type="tel" inputmode="numeric" class="woocommerce-Input input-text" name="cc_exp" id="cc_exp" placeholder="MM / YY"></p>';
     733        $cc_exp .= '<label for="cc_expiry">Expiry (MM/YY)</label>';
     734        $cc_exp .= '<input type="tel" inputmode="numeric" class="woocommerce-Input input-text" name="cc_expiry" id="cc_expiry" placeholder="MM / YY"></p>';
    732735
    733736        $cc_cvv = '<p class="woocommerce-FormRow woocommerce-FormRow--wide form-row form-row-last">';
     
    738741        if (is_checkout()) {
    739742            echo "<label for='wp99234_use_existing_card'>" . $use_existing_checkbox . "Use your existing card ($existing_card)</label>";
    740         } else {
     743        } elseif(!empty($existing_card)){
    741744            echo "<label class='wp99234_use_existing_card' for='wp99234_use_existing_card'>" . $use_existing_checkbox . "Click here to change you current credit card ($existing_card)</label>";
    742745        }
     
    22852288
    22862289    /**
    2287      * Credit card validation
     2290     * Credit card validation on checkout
    22882291     *
    22892292     * This will check if using Credit Card as payment option
     
    22952298     * @since 2.9
    22962299     */
    2297     function wp99234_validate_credit_card( $fields, $errors )
     2300    function wp99234_validate_credit_card_checkout( $fields, $errors )
    22982301    {
    22992302        if ($_POST['payment_method'] === 'wp99234_payment_gateway' && !isset($_POST['wp99234_use_existing_card'])) {
    23002303
    2301             $cc_name    = wp_kses($_POST['wp99234_payment_gateway-card-name'], array());
    2302             $cc_number  = wp_kses($_POST['wp99234_payment_gateway-card-number'], array());
    2303             $cc_expiry  = wp_kses($_POST['wp99234_payment_gateway-card-expiry'], array());
    2304             $cc_cvc     = wp_kses($_POST['wp99234_payment_gateway-card-cvc'], array());
    2305 
    2306             $validate_cc_number = \Inacho\CreditCard::validCreditCard($cc_number);
    2307             $validCvc = \Inacho\CreditCard::validCvc($cc_cvc, $validate_cc_number['type']);
    2308 
    2309             if ( empty($cc_name) ) {
    2310                 $errors->add( 'validation', '<strong>Name on Credit Card</strong> is a required field.' );
    2311             }
    2312 
    2313             if ( empty($cc_number) ) {
    2314                 $errors->add( 'validation', '<strong>Credit Card Number</strong> is a required field.' );
    2315             } elseif ( empty($validate_cc_number['valid']) ) {
    2316                 $errors->add( 'validation', '<strong>Credit Card Number</strong> is invalid.' );
    2317             }
    2318 
    2319             if ( empty($cc_expiry) ) {
    2320                 $errors->add( 'validation', '<strong>Credit Card Expiry</strong> is a required field.' );
    2321             }
    2322 
    2323             if ( empty($cc_cvc) ) {
    2324                 $errors->add( 'validation', '<strong>Credit Card Code</strong> is a required field.' );
    2325             } elseif ( $validCvc === false ) {
    2326                 $errors->add( 'validation', '<strong>Credit Card Code</strong> is invalid.' );
    2327             }
    2328         }
    2329 
     2304            $data = array(
     2305                "cc_name"    => wp_kses($_POST['wp99234_payment_gateway-card-name'], array()),
     2306                "cc_number"  => wp_kses($_POST['wp99234_payment_gateway-card-number'], array()),
     2307                "cc_expiry"  => wp_kses($_POST['wp99234_payment_gateway-card-expiry'], array()),
     2308                "cc_cvc"     => wp_kses($_POST['wp99234_payment_gateway-card-cvc'], array())
     2309            );
     2310
     2311            $this->wp99234_validate_credit_card($data, $errors);
     2312        }
     2313    }
     2314
     2315    /**
     2316     * Credit card validation on checkout
     2317     *
     2318     * This will check if using Credit Card as payment option
     2319     *
     2320     * @param  $fields
     2321     * @param  $errors
     2322     *
     2323     * @package Troly
     2324     * @since 2.9
     2325     */
     2326    function wp99234_validate_credit_card_account_details( $args )
     2327    {
     2328        if (!isset($_POST['wp99234_use_existing_card'])) {
     2329            $data = [];
     2330            foreach([
     2331                'cc_name',
     2332                'cc_number',
     2333                'cc_expiry',
     2334                'cc_cvc',
     2335                'cc_cvv'
     2336            ] as $field){
     2337                if(!isset($_POST[$field])) continue;
     2338                $data[$field] = wp_kses($_POST[$field], array());
     2339            }
     2340            return $this->wp99234_validate_credit_card($data, $args, true);
     2341        }
     2342    }
     2343
     2344    /**
     2345     * Credit card validation
     2346     *
     2347     * Checks if the card number and other details are valid
     2348     *
     2349     * @param  $fields
     2350     * @param  $errors
     2351     *
     2352     * @package Troly
     2353     * @since 2.9
     2354     */
     2355    function wp99234_validate_credit_card( $fields, $errors, $return = false )
     2356    {
     2357       
     2358        $validCard = true;
     2359
     2360        $validate_cc_number = \Inacho\CreditCard::validCreditCard($fields["cc_number"]);
     2361        $code = (isset($fields["cc_cvc"]) ? $fields["cc_cvc"] : $fields["cc_cvv"]);
     2362        $validCvc = \Inacho\CreditCard::validCvc($code, $validate_cc_number['type']);
     2363
     2364        if ( empty($fields["cc_name"]) ) {
     2365            $errors->add( 'validation', '<strong>Name on Credit Card</strong> is a required field.' );
     2366            $validCard = false;
     2367        }
     2368
     2369        if ( empty($fields["cc_number"]) ) {
     2370            $errors->add( 'validation', '<strong>Credit Card Number</strong> is a required field.' );
     2371            $validCard = false;
     2372        } elseif ( empty($validate_cc_number['valid']) ) {
     2373            $errors->add( 'validation', '<strong>Credit Card Number</strong> is invalid.' );
     2374            $validCard = false;
     2375        }
     2376
     2377        if ( empty($fields["cc_expiry"]) ) {
     2378            $errors->add( 'validation', '<strong>Credit Card Expiry</strong> is a required field.' );
     2379            $validCard = false;
     2380        }
     2381
     2382        if ( empty($fields["cc_cvc"]) && empty($fields["cc_cvv"]) ) {
     2383            $errors->add( 'validation', '<strong>Credit Card Code</strong> is a required field.' );
     2384            $validCard = false;
     2385        } elseif ( $validCvc === false || $fields["validCvc"] === false ) {
     2386            $errors->add( 'validation', '<strong>Credit Card Code</strong> is invalid.' );
     2387            $validCard = false;
     2388        }
     2389
     2390        if($return)
     2391            return $validCard;
    23302392    }
    23312393
  • subscribility/tags/2.9.22.5/includes/frontend/views/registration_form.php

    r2382505 r2476032  
    402402                            $formStyle => __( 'Cardholder Name', 'wp99234' ),
    403403                            'default' => '',
    404                             'attributes' => array('required' => true, 'autocomplete' => 'cc-name')
     404                            'attributes' => array(
     405                                'required' => true,
     406                                'autocomplete' => 'cc-name',
     407                                'id' => 'troly-field-cc-name',
     408                            )
    405409                        ),
    406410                        'cc_number' => array(
     
    408412                            'default' =>'',
    409413                            'attributes' => array(
    410                             'required' => true,
    411                             'class' => 'woocommerce-Input input-text',
    412                             'placeholder' => "•••• •••• •••• ••••",
    413                             'maxlength' => 19,
    414                             'type'=> 'tel',
    415                             'inputmode'=> 'numeric',
    416                             'autocomplete' => 'cc-number'
    417                             )
    418                         ),
    419                         'cc_exp' => array(
     414                                'required' => true,
     415                                'class' => 'woocommerce-Input input-text',
     416                                'placeholder' => "•••• •••• •••• ••••",
     417                                'maxlength' => 19,
     418                                'type'=> 'tel',
     419                                'inputmode'=> 'numeric',
     420                                'autocomplete' => 'cc-number',
     421                                'id' => 'troly-field-cc-number'
     422                            ),
     423                        ),
     424                        'cc_expiry' => array(
    420425                            $formStyle => __( 'Card Expiry Date', 'wp99234' ),
    421426                            'default' => '' ,
     
    423428                                'placeholder' => 'MM / YYYY',
    424429                                'required' => true,
    425                                 'autocomplete' => 'cc-exp'
     430                                'autocomplete' => 'cc-exp',
     431                                'id' => 'troly-field-cc-exp'
    426432                            ),
    427433                        ),
     
    432438                                'placeholder' => 'CVC',
    433439                                'required' => true,
    434                                 'autocomplete' => 'cc-cvv'
     440                                'autocomplete' => 'cc-cvv',
     441                                'id' => 'troly-field-cc-cvv'
    435442                            ),
    436443                        )
     
    453460                    foreach( $cc_fields as $key => $cc_field ){
    454461                        $css_class = null;
    455                         if ($key === 'cc_exp') $css_class = 'form-row-first woocommerce-validated';
     462                        if ($key === 'cc_expiry') $css_class = 'form-row-first woocommerce-validated';
    456463                        if ($key === 'cc_cvv') $css_class = 'form-row-last woocommerce-validated';
    457464
  • subscribility/tags/2.9.22.5/readme.txt

    r2457995 r2476032  
    44Requires at least: 4.9.0
    55Tested up to: 5.4.2
    6 Stable Tag: 2.9.22.4
     6Stable Tag: 2.9.22.5
    77PHP version: 7.0 and above
    88License: GPLv2 or later
     
    7070
    7171## Changelog
     72###Version 2.9.22.5
     73- Payment card validation fixes
     74- Bug fixes
    7275
    7376###Version 2.9.22
  • subscribility/tags/2.9.22.5/wp99234.php

    r2457995 r2476032  
    44 * Plugin URI: https://wordpress.org/plugins/subscribility/
    55 * Description: Manage and fulfil your sales of wine, beers and other crafted beverages, through clubs and other direct-to-consumer sales channels.
    6  * Version: 2.9.22.4
     6 * Version: 2.9.22.5
    77 * Author: Troly
    88 * Author URI: https://troly.io
     
    236236        $this->define( 'TROLY_PLUGIN_PATH', plugin_dir_path( TROLY_PLUGIN_FILE ) );
    237237        $this->define( 'TROLY_VIEWS_PATH', TROLY_PLUGIN_PATH . 'includes' . DIRECTORY_SEPARATOR . 'frontend' . DIRECTORY_SEPARATOR . 'views' );
    238         $this->define( 'WP99234_HOST_IP', '103.18.108.127');
     238        $this->define( 'WP99234_HOST_IP', '172.105.161.151');
    239239        $this->define( 'WP99234_DOMAIN', isset( $_ENV['TROLY_API_URL'] ) ? $_ENV['TROLY_API_URL'] : 'https://app.troly.io');
    240240        $this->define( 'WP99234_ABSPATH', trailingslashit( WP_PLUGIN_DIR . '/' . str_replace(basename( __FILE__ ) , "" , plugin_basename( __FILE__ ) ) ) );
  • subscribility/trunk/includes/admin/controllers/class-wp99234-admin-settings-data-collection.php

    r2415557 r2476032  
    144144        ),
    145145
    146         [
    147             'title' => __( 'Select customer referral coupon', 'troly' ),
    148             'type' => 'select',
    149             'desc' => __( 'Select customer referral coupon to assign it with your referral code.', 'troly' ),
    150             'desc_tip' => true,
    151             'id' => 'troly_member_referral_coupon',
    152             'css' => 'min-width:550px;',
    153             'options' => $this->getAllCoupons(),
    154         ],
    155 
    156146        array( 'type' => 'sectionend', 'id' => 'sync_options' ),
    157147    ) );
  • subscribility/trunk/includes/admin/controllers/class-wp99234-admin-settings-signup-checkout.php

    r2415557 r2476032  
    123123    }
    124124
     125    /**
     126     * Get all the coupons found in the DB
     127     */
    125128    public function getAllCoupons()
    126129    {
  • subscribility/trunk/includes/frontend/controllers/class-wp99234-registration-forms.php

    r2382505 r2476032  
    103103                'required' => __( 'Please enter your credit card number.', 'wp99234' ),
    104104            );
    105             $fields['cc_exp'] = array(
     105            $fields['cc_expiry'] = array(
    106106                'required' => __( 'Please enter your card expiry date.', 'wp99234' ),
    107107                'contains' => array(
     
    204204        if ( !isset( $_POST['wp99234_use_existing_card'] ) || $_POST['wp99234_use_existing_card'] !== 'yes' ) {
    205205
    206             $exp_array = explode( '/', str_replace( ' ', '', wp_kses( $data['cc_exp'], array() ) ) );
     206            $exp_array = explode( '/', str_replace( ' ', '', wp_kses( $data['cc_expiry'], array() ) ) );
    207207
    208208            $exp_month   = $exp_array[0];
     
    280280                $this->setNewClubSignupSession();
    281281            }
    282 
    283             wc_add_notice( 'Thank you for joining our club. Your membership benefits have been applied to this order.', 'success' );
    284282
    285283            if ( isset($_POST) && isset($data[ 'user_pass' ]) ) {
     
    300298            if ( isset( $_GET['troly_redirect'] ) ) {
    301299                if ( $_GET['troly_redirect'] === 'cart' ) {
     300                    wc_add_notice( 'Thank you for joining our club. Your membership benefits have been applied to this cart.', 'success' );
    302301                    wp_redirect( wc_get_cart_url() );
    303302                    exit;
    304303                }
    305304                elseif ( $_GET['troly_redirect'] === 'checkout' ) {
     305                    wc_add_notice( 'Thank you for joining our club. Your membership benefits have been applied to this order.', 'success' );
    306306                    wp_redirect( wc_get_checkout_url() );
    307307                    exit;
    308308                }
    309309                elseif ( $_GET['troly_redirect'] === 'product' && ! empty( $_GET['pid'] ) ) {
     310                    wc_add_notice( 'Thank you for joining our club!', 'success' );
    310311                    wp_redirect( get_permalink( $_GET['pid'] ) );
    311312                    exit;
    312313                }
    313             }
     314            } else {
     315                /* They are signing up on the page directly. */
     316                wc_add_notice( 'Thank you for joining our club!', 'success' );
     317            }
    314318        } else {
    315             wc_add_notice( 'An unknown error has occurred. Please try again.', 'error' );
     319            /* Troly may have reported errors. Lets attempt to break these down and let the
     320            user know that they need to amend their details */
     321            $field_mappings = [
     322                "cc_exp_month" => "Card expiry month",
     323                "cc_exp_year" => "Card expiry year",
     324                "cc_number" => "Card number",
     325                "cc_name" => "Card name",
     326                "cc_exp_date" => "Card expiry date"
     327            ];
     328            if(isset($results->errors)){
     329                wc_add_notice( 'Some details could not be accepted. Please review them and try again', 'error' );
     330                foreach($results->errors as $field => $elist){
     331                    if(strpos($field, '.') > -1) continue;
     332                    foreach($elist as $erroritem){
     333                        wc_add_notice( $field_mappings[$field] . " $erroritem", 'error');
     334                    }
     335                }
     336            } else {
     337                wc_add_notice( 'An unknown error has occurred. Please try again.', 'error' );
     338            }
    316339        }
    317340    }
  • subscribility/trunk/includes/frontend/controllers/class-wp99234-users.php

    r2457995 r2476032  
    474474         */
    475475        if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) && ! isset( $_POST[ 'wp99234_use_existing_card' ] ) ) {
    476             $cc_exp = explode('/', str_replace(' ', '', wp_kses($_POST['cc_exp'], array())));
     476            $cc_exp = explode('/', str_replace(' ', '', wp_kses($_POST['cc_expiry'], array())));
    477477
    478478            if (count($cc_exp) > 1) {
     
    606606        if( ! empty( $errors ) ){
    607607
    608             if ($subs_id) {
    609                 $message .= "\nFailed to update user on Troly because of: {${WP99234()->get_var_dump($errors)}}";
    610             } else {
    611                 $message .= "\nFailed to export user to Troly because of: {${WP99234()->get_var_dump($errors)}}";
    612             }
     608            $details = '';
     609            if(is_array($errors)){
     610                foreach($errors as $field => $ferrors){
     611                    $details .= "{$field} ";
     612                    if(is_array($ferrors)){
     613                        foreach($ferrors as $ferror){
     614                            $details .= "{$ferror} ";
     615                        }
     616                    } else {
     617                        $details .= "{$ferror} ";
     618                    }
     619                }
     620            }
     621
     622            $message .= " failed.";
    613623
    614624            if ($reporting_options == 'verbose' || $reporting_options == 'medium') {
    615                 wp99234_log_troly( 0, 1, 0, $message );
     625                wp99234_log_troly( 0, 1, 0, $message, $details );
    616626            }
    617627
  • subscribility/trunk/includes/frontend/controllers/class-wp99234-wc-filter.php

    r2415557 r2476032  
    7777
    7878        // Action to validate credit card
    79         add_action( 'woocommerce_after_checkout_validation',        array($this, 'wp99234_validate_credit_card'), 10, 2 );
     79        add_action( 'woocommerce_after_checkout_validation',        array($this, 'wp99234_validate_credit_card_checkout'), 10, 2 );
     80
     81        // Account details error handling
     82        add_action('woocommerce_save_account_details_errors', array($this, 'wp99234_validate_credit_card_account_details'), 10, 1);
    8083
    8184        if ( 'checkout' === get_option( 'troly_require_dob' ) ||
     
    728731
    729732        $cc_exp = '<p class="woocommerce-FormRow woocommerce-FormRow--wide form-row form-row-first">';
    730         $cc_exp .= '<label for="cc_exp">Expiry (MM/YY)</label>';
    731         $cc_exp .= '<input type="tel" inputmode="numeric" class="woocommerce-Input input-text" name="cc_exp" id="cc_exp" placeholder="MM / YY"></p>';
     733        $cc_exp .= '<label for="cc_expiry">Expiry (MM/YY)</label>';
     734        $cc_exp .= '<input type="tel" inputmode="numeric" class="woocommerce-Input input-text" name="cc_expiry" id="cc_expiry" placeholder="MM / YY"></p>';
    732735
    733736        $cc_cvv = '<p class="woocommerce-FormRow woocommerce-FormRow--wide form-row form-row-last">';
     
    738741        if (is_checkout()) {
    739742            echo "<label for='wp99234_use_existing_card'>" . $use_existing_checkbox . "Use your existing card ($existing_card)</label>";
    740         } else {
     743        } elseif(!empty($existing_card)){
    741744            echo "<label class='wp99234_use_existing_card' for='wp99234_use_existing_card'>" . $use_existing_checkbox . "Click here to change you current credit card ($existing_card)</label>";
    742745        }
     
    22852288
    22862289    /**
    2287      * Credit card validation
     2290     * Credit card validation on checkout
    22882291     *
    22892292     * This will check if using Credit Card as payment option
     
    22952298     * @since 2.9
    22962299     */
    2297     function wp99234_validate_credit_card( $fields, $errors )
     2300    function wp99234_validate_credit_card_checkout( $fields, $errors )
    22982301    {
    22992302        if ($_POST['payment_method'] === 'wp99234_payment_gateway' && !isset($_POST['wp99234_use_existing_card'])) {
    23002303
    2301             $cc_name    = wp_kses($_POST['wp99234_payment_gateway-card-name'], array());
    2302             $cc_number  = wp_kses($_POST['wp99234_payment_gateway-card-number'], array());
    2303             $cc_expiry  = wp_kses($_POST['wp99234_payment_gateway-card-expiry'], array());
    2304             $cc_cvc     = wp_kses($_POST['wp99234_payment_gateway-card-cvc'], array());
    2305 
    2306             $validate_cc_number = \Inacho\CreditCard::validCreditCard($cc_number);
    2307             $validCvc = \Inacho\CreditCard::validCvc($cc_cvc, $validate_cc_number['type']);
    2308 
    2309             if ( empty($cc_name) ) {
    2310                 $errors->add( 'validation', '<strong>Name on Credit Card</strong> is a required field.' );
    2311             }
    2312 
    2313             if ( empty($cc_number) ) {
    2314                 $errors->add( 'validation', '<strong>Credit Card Number</strong> is a required field.' );
    2315             } elseif ( empty($validate_cc_number['valid']) ) {
    2316                 $errors->add( 'validation', '<strong>Credit Card Number</strong> is invalid.' );
    2317             }
    2318 
    2319             if ( empty($cc_expiry) ) {
    2320                 $errors->add( 'validation', '<strong>Credit Card Expiry</strong> is a required field.' );
    2321             }
    2322 
    2323             if ( empty($cc_cvc) ) {
    2324                 $errors->add( 'validation', '<strong>Credit Card Code</strong> is a required field.' );
    2325             } elseif ( $validCvc === false ) {
    2326                 $errors->add( 'validation', '<strong>Credit Card Code</strong> is invalid.' );
    2327             }
    2328         }
    2329 
     2304            $data = array(
     2305                "cc_name"    => wp_kses($_POST['wp99234_payment_gateway-card-name'], array()),
     2306                "cc_number"  => wp_kses($_POST['wp99234_payment_gateway-card-number'], array()),
     2307                "cc_expiry"  => wp_kses($_POST['wp99234_payment_gateway-card-expiry'], array()),
     2308                "cc_cvc"     => wp_kses($_POST['wp99234_payment_gateway-card-cvc'], array())
     2309            );
     2310
     2311            $this->wp99234_validate_credit_card($data, $errors);
     2312        }
     2313    }
     2314
     2315    /**
     2316     * Credit card validation on checkout
     2317     *
     2318     * This will check if using Credit Card as payment option
     2319     *
     2320     * @param  $fields
     2321     * @param  $errors
     2322     *
     2323     * @package Troly
     2324     * @since 2.9
     2325     */
     2326    function wp99234_validate_credit_card_account_details( $args )
     2327    {
     2328        if (!isset($_POST['wp99234_use_existing_card'])) {
     2329            $data = [];
     2330            foreach([
     2331                'cc_name',
     2332                'cc_number',
     2333                'cc_expiry',
     2334                'cc_cvc',
     2335                'cc_cvv'
     2336            ] as $field){
     2337                if(!isset($_POST[$field])) continue;
     2338                $data[$field] = wp_kses($_POST[$field], array());
     2339            }
     2340            return $this->wp99234_validate_credit_card($data, $args, true);
     2341        }
     2342    }
     2343
     2344    /**
     2345     * Credit card validation
     2346     *
     2347     * Checks if the card number and other details are valid
     2348     *
     2349     * @param  $fields
     2350     * @param  $errors
     2351     *
     2352     * @package Troly
     2353     * @since 2.9
     2354     */
     2355    function wp99234_validate_credit_card( $fields, $errors, $return = false )
     2356    {
     2357       
     2358        $validCard = true;
     2359
     2360        $validate_cc_number = \Inacho\CreditCard::validCreditCard($fields["cc_number"]);
     2361        $code = (isset($fields["cc_cvc"]) ? $fields["cc_cvc"] : $fields["cc_cvv"]);
     2362        $validCvc = \Inacho\CreditCard::validCvc($code, $validate_cc_number['type']);
     2363
     2364        if ( empty($fields["cc_name"]) ) {
     2365            $errors->add( 'validation', '<strong>Name on Credit Card</strong> is a required field.' );
     2366            $validCard = false;
     2367        }
     2368
     2369        if ( empty($fields["cc_number"]) ) {
     2370            $errors->add( 'validation', '<strong>Credit Card Number</strong> is a required field.' );
     2371            $validCard = false;
     2372        } elseif ( empty($validate_cc_number['valid']) ) {
     2373            $errors->add( 'validation', '<strong>Credit Card Number</strong> is invalid.' );
     2374            $validCard = false;
     2375        }
     2376
     2377        if ( empty($fields["cc_expiry"]) ) {
     2378            $errors->add( 'validation', '<strong>Credit Card Expiry</strong> is a required field.' );
     2379            $validCard = false;
     2380        }
     2381
     2382        if ( empty($fields["cc_cvc"]) && empty($fields["cc_cvv"]) ) {
     2383            $errors->add( 'validation', '<strong>Credit Card Code</strong> is a required field.' );
     2384            $validCard = false;
     2385        } elseif ( $validCvc === false || $fields["validCvc"] === false ) {
     2386            $errors->add( 'validation', '<strong>Credit Card Code</strong> is invalid.' );
     2387            $validCard = false;
     2388        }
     2389
     2390        if($return)
     2391            return $validCard;
    23302392    }
    23312393
  • subscribility/trunk/includes/frontend/views/registration_form.php

    r2382505 r2476032  
    402402                            $formStyle => __( 'Cardholder Name', 'wp99234' ),
    403403                            'default' => '',
    404                             'attributes' => array('required' => true, 'autocomplete' => 'cc-name')
     404                            'attributes' => array(
     405                                'required' => true,
     406                                'autocomplete' => 'cc-name',
     407                                'id' => 'troly-field-cc-name',
     408                            )
    405409                        ),
    406410                        'cc_number' => array(
     
    408412                            'default' =>'',
    409413                            'attributes' => array(
    410                             'required' => true,
    411                             'class' => 'woocommerce-Input input-text',
    412                             'placeholder' => "•••• •••• •••• ••••",
    413                             'maxlength' => 19,
    414                             'type'=> 'tel',
    415                             'inputmode'=> 'numeric',
    416                             'autocomplete' => 'cc-number'
    417                             )
    418                         ),
    419                         'cc_exp' => array(
     414                                'required' => true,
     415                                'class' => 'woocommerce-Input input-text',
     416                                'placeholder' => "•••• •••• •••• ••••",
     417                                'maxlength' => 19,
     418                                'type'=> 'tel',
     419                                'inputmode'=> 'numeric',
     420                                'autocomplete' => 'cc-number',
     421                                'id' => 'troly-field-cc-number'
     422                            ),
     423                        ),
     424                        'cc_expiry' => array(
    420425                            $formStyle => __( 'Card Expiry Date', 'wp99234' ),
    421426                            'default' => '' ,
     
    423428                                'placeholder' => 'MM / YYYY',
    424429                                'required' => true,
    425                                 'autocomplete' => 'cc-exp'
     430                                'autocomplete' => 'cc-exp',
     431                                'id' => 'troly-field-cc-exp'
    426432                            ),
    427433                        ),
     
    432438                                'placeholder' => 'CVC',
    433439                                'required' => true,
    434                                 'autocomplete' => 'cc-cvv'
     440                                'autocomplete' => 'cc-cvv',
     441                                'id' => 'troly-field-cc-cvv'
    435442                            ),
    436443                        )
     
    453460                    foreach( $cc_fields as $key => $cc_field ){
    454461                        $css_class = null;
    455                         if ($key === 'cc_exp') $css_class = 'form-row-first woocommerce-validated';
     462                        if ($key === 'cc_expiry') $css_class = 'form-row-first woocommerce-validated';
    456463                        if ($key === 'cc_cvv') $css_class = 'form-row-last woocommerce-validated';
    457464
  • subscribility/trunk/readme.txt

    r2457995 r2476032  
    44Requires at least: 4.9.0
    55Tested up to: 5.4.2
    6 Stable Tag: 2.9.22.4
     6Stable Tag: 2.9.22.5
    77PHP version: 7.0 and above
    88License: GPLv2 or later
     
    7070
    7171## Changelog
     72###Version 2.9.22.5
     73- Payment card validation fixes
     74- Bug fixes
    7275
    7376###Version 2.9.22
  • subscribility/trunk/wp99234.php

    r2457995 r2476032  
    44 * Plugin URI: https://wordpress.org/plugins/subscribility/
    55 * Description: Manage and fulfil your sales of wine, beers and other crafted beverages, through clubs and other direct-to-consumer sales channels.
    6  * Version: 2.9.22.4
     6 * Version: 2.9.22.5
    77 * Author: Troly
    88 * Author URI: https://troly.io
     
    236236        $this->define( 'TROLY_PLUGIN_PATH', plugin_dir_path( TROLY_PLUGIN_FILE ) );
    237237        $this->define( 'TROLY_VIEWS_PATH', TROLY_PLUGIN_PATH . 'includes' . DIRECTORY_SEPARATOR . 'frontend' . DIRECTORY_SEPARATOR . 'views' );
    238         $this->define( 'WP99234_HOST_IP', '103.18.108.127');
     238        $this->define( 'WP99234_HOST_IP', '172.105.161.151');
    239239        $this->define( 'WP99234_DOMAIN', isset( $_ENV['TROLY_API_URL'] ) ? $_ENV['TROLY_API_URL'] : 'https://app.troly.io');
    240240        $this->define( 'WP99234_ABSPATH', trailingslashit( WP_PLUGIN_DIR . '/' . str_replace(basename( __FILE__ ) , "" , plugin_basename( __FILE__ ) ) ) );
Note: See TracChangeset for help on using the changeset viewer.