Plugin Directory

Changeset 3183324


Ignore:
Timestamp:
11/06/2024 04:54:55 PM (17 months ago)
Author:
weeconnectpay
Message:

Deploying version 3.11.5 from pipeline

Location:
weeconnectpay
Files:
608 added
3 edited

Legend:

Unmodified
Added
Removed
  • weeconnectpay/trunk/README.txt

    r3181924 r3183324  
    66Author: WeeConnectPay
    77Contributors: weeconnectpay
    8 Stable Tag: 3.11.4
     8Stable Tag: 3.11.5
    99Requires at least: 5.6
    1010Tested Up To: 6.6.2
     
    128128
    129129== Changelog ==
     130= 3.11.5 =
     131* Updated the state tracking for the front-end to prevent other plugins
    130132
    131133= 3.11.4 =
  • weeconnectpay/trunk/dist/js/payment-fields.js

    r3181924 r3183324  
    265265    };
    266266    const state = {
    267         readyToSubmit: false,
    268     };
     267        cloverTokenReady: false,
     268        cardBrandSaved: false,
     269        zipVerified: false,
     270        recaptchaCompleted: false
     271    };
     272    const errorState = {
     273        CARD_NUMBER: { error: false, touched: false },
     274        CARD_DATE: { error: false, touched: false },
     275        CARD_CVV: { error: false, touched: false },
     276        CARD_POSTAL_CODE: { error: false, touched: false },
     277    };
     278    // Update error and touch state
     279    function updateFieldState(fieldKey, hasError, isTouched) {
     280        const fieldState = errorState[fieldKey];
     281        // Determine if the state has changed
     282        const errorChanged = fieldState.error !== hasError;
     283        const touchedChanged = isTouched !== undefined && fieldState.touched !== isTouched;
     284        // Only update and log if there is a change
     285        if (errorChanged || touchedChanged) {
     286            fieldState.error = hasError;
     287            // Update touched only if isTouched is provided
     288            if (isTouched !== undefined) {
     289                fieldState.touched = isTouched;
     290            }
     291            // Log the updated state (for debugging)
     292            // console.log(`State updated for ${fieldKey}:`, { error: hasError, touched: fieldState.touched });
     293            // console.log("Current Error State:", errorState);
     294        }
     295    }
     296    // Check if all fields have been touched and are error-free + dynamic data for the gateway properly initialized
     297    function canSubmit() {
     298        const allFieldsTouchedAndNoErrors = Object.values(errorState).every(state => state.touched && !state.error);
     299        const allFlagsTrue = state.cloverTokenReady && state.cardBrandSaved && state.zipVerified && state.recaptchaCompleted;
     300        return allFieldsTouchedAndNoErrors && allFlagsTrue;
     301    }
     302    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    269303    const maybeExecuteGoogleRecaptcha = (formToSubmitOnceDone, state) => {
    270304        if (typeof grecaptcha !== "undefined" && settings.siteKey !== '') {
     
    273307                    grecaptcha.execute(settings.siteKey, { action: 'submit' }).then(function (token) {
    274308                        saveRecaptchaTokenToForm(token);
    275                         state.readyToSubmit = true; // Modify the property of the object
     309                        state.recaptchaCompleted = true;
    276310                        formToSubmitOnceDone.trigger('submit');
    277311                    }, function (response) {
     
    285319                        // Set the exception text in the token so that we can check for it in the payment processing part
    286320                        saveRecaptchaTokenToForm(jsonStringException);
    287                         state.readyToSubmit = true; // Modify the property of the object
     321                        state.recaptchaCompleted = true;
    288322                        formToSubmitOnceDone.trigger('submit');
    289323                    });
     
    298332                    // Set the exception text in the token so that we can check for it in the payment processing part
    299333                    saveRecaptchaTokenToForm(jsonStringException);
    300                     state.readyToSubmit = true; // Modify the property of the object
     334                    state.recaptchaCompleted = true;
    301335                    formToSubmitOnceDone.trigger('submit');
    302336                }
     
    304338        }
    305339        else {
    306             state.readyToSubmit = true; // Modify the property of the object
     340            state.recaptchaCompleted = true; // Mark as complete if reCAPTCHA is not enabled
    307341            formToSubmitOnceDone.trigger('submit');
    308342        }
     
    341375                    if (error !== undefined) {
    342376                        addError(wrapperElement, displayError, error);
     377                        updateFieldState(cloverIframeEventMember, true, true);
    343378                    }
    344379                    else {
    345380                        removeError(wrapperElement, displayError);
     381                        updateFieldState(cloverIframeEventMember, false, true);
    346382                    }
    347383                }
    348384                else {
    349385                    removeError(wrapperElement, displayError);
     386                    updateFieldState(cloverIframeEventMember, false, true); // Mark touched when no error data
    350387                }
    351388            }
     
    376413            const jQueryCheckoutForm = jQuery('form.checkout');
    377414            jQueryCheckoutForm.on('checkout_place_order', function (event) {
    378                 if (state.readyToSubmit) {
    379                     // Reset the logic skip so that if there is any errors in later event handlers we will re-populate the fields with fresh data
    380                     state.readyToSubmit = false;
     415                if (canSubmit()) {
    381416                    return true;
    382417                }
     
    392427                            .then(function (tokenDataEvent) {
    393428                            const result = tokenDataEvent;
     429                            // console.log('Clover tokenization result: ', result);
    394430                            if (result.errors) {
    395431                                handleTokenCreationErrors(result);
     
    427463            const jQueryOrderPayForm = jQuery('form#order_review');
    428464            jQueryOrderPayForm.on('submit', function (event) {
    429                 if (state.readyToSubmit) {
    430                     // Reset the logic skip so that if there is any errors in later event handlers we will re-populate the fields with fresh data
    431                     state.readyToSubmit = false;
     465                if (canSubmit()) {
    432466                    return true;
    433467                }
     
    478512    };
    479513    const handleTokenCreationErrors = (result) => {
     514        console.log('result: ', result);
    480515        if (result.errors) {
    481516            // Number
     
    485520                if (displayNumberError && wrapperNumberElement) {
    486521                    addError(wrapperNumberElement, displayNumberError, result.errors.CARD_NUMBER);
     522                    updateFieldState("CARD_NUMBER", true); // Set error and touched to true
    487523                }
    488524            }
     
    493529                if (displayDateError && wrapperDateElement) {
    494530                    addError(wrapperDateElement, displayDateError, result.errors.CARD_DATE);
     531                    updateFieldState("CARD_DATE", true);
    495532                }
    496533            }
     
    501538                if (displayCvvError && wrapperCvvElement) {
    502539                    addError(wrapperCvvElement, displayCvvError, result.errors.CARD_CVV);
     540                    updateFieldState("CARD_CVV", true);
    503541                }
    504542            }
     
    509547                if (displayPostalCodeError && wrapperPostalCodeElement) {
    510548                    addError(wrapperPostalCodeElement, displayPostalCodeError, result.errors.CARD_POSTAL_CODE);
     549                    updateFieldState("CARD_POSTAL_CODE", true);
    511550                }
    512551            }
     
    514553    };
    515554    function cloverTokenHandler(token) {
     555        // console.log('in cloverTokenHandler. token: ',token)
    516556        // Insert the token ID into the form, so it gets submitted to the server
    517557        const hiddenInput = document.querySelector('#wcp-token');
     
    521561        if (hiddenInput /*.value === ''*/) {
    522562            hiddenInput.value = token;
     563            state.cloverTokenReady = true;
    523564            return false;
    524565        }
     
    551592        if (hiddenZipInput.value === '' && zipCode) {
    552593            hiddenZipInput.value = zipCode;
     594            state.zipVerified = true;
    553595            return;
    554596        }
     
    578620         */
    579621        if (brand && brand === '') {
     622            state.cardBrandSaved = true;
    580623            cardBrandInput.value = brand;
    581624            return;
    582625        }
    583626        else if (brand && brand.length > 0) {
     627            state.cardBrandSaved = true;
    584628            cardBrandInput.value = brand;
    585629            return;
  • weeconnectpay/trunk/weeconnectpay.php

    r3181924 r3183324  
    1818 * Description:       Integrate Clover Payments with your WooCommerce online store.
    1919 * Tags:              clover, payments, weeconnect, e-commerce, gateway
    20  * Version:           3.11.4
     20 * Version:           3.11.5
    2121 * Requires at least: 5.6
    2222 * Tested Up To:      6.6.2
     
    3838    die;
    3939}
    40 const WEECONNECT_VERSION = '3.11.4';
     40const WEECONNECT_VERSION = '3.11.5';
    4141
    4242define( 'WEECONNECTPAY_PLUGIN_URL', plugin_dir_url(__FILE__));
Note: See TracChangeset for help on using the changeset viewer.