Plugin Directory

Changeset 3181924


Ignore:
Timestamp:
11/05/2024 01:36:07 AM (17 months ago)
Author:
weeconnectpay
Message:

Deploying version 3.11.4 from pipeline

Location:
weeconnectpay
Files:
608 added
6 edited

Legend:

Unmodified
Added
Removed
  • weeconnectpay/trunk/README.txt

    r3174607 r3181924  
    66Author: WeeConnectPay
    77Contributors: weeconnectpay
    8 Stable Tag: 3.11.3
     8Stable Tag: 3.11.4
    99Requires at least: 5.6
    1010Tested Up To: 6.6.2
     
    128128
    129129== Changelog ==
     130
     131= 3.11.4 =
     132* Updated the Clover SDK Tokenization logic to handle less than ideal environments
     133
    130134= 3.11.3 =
    131135* Updated Clover SDK initialisation for WooCommerce Blocks - This should fix iframe placeholder translation issues
    132136
     137= 3.11.2 =
     138* Updated plugin to show more information about the mismatched amounts when checkout amounts would not match -- This is mostly to help us help the merchants figure out which plugin is conflicting and to help us add support for these plugins faster
     139
    133140= 3.11.1 =
    134141* Added the following requirements: WordPress database must be properly set and not empty
     142* Updated plugin to show when an authentication was successful instead of simply showing the settings as a landing page
    135143
    136144= 3.11.0 =
  • weeconnectpay/trunk/dist/js/payment-fields.js

    r3095409 r3181924  
    177177        }
    178178    };
     179    const tokenRateLimiter = {
     180        timestamps: []
     181    };
     182    function canCallCreateToken() {
     183        const now = Date.now();
     184        const windowSize = 5000; // 5 seconds in milliseconds
     185        const maxCalls = 2;
     186        // Remove timestamps older than the 5-second window
     187        tokenRateLimiter.timestamps = tokenRateLimiter.timestamps.filter((timestamp) => now - timestamp < windowSize);
     188        if (tokenRateLimiter.timestamps.length < maxCalls) {
     189            // Allow the call and record the timestamp
     190            tokenRateLimiter.timestamps.push(now);
     191            return true;
     192        }
     193        else {
     194            // Rate limit exceeded
     195            return false;
     196        }
     197    }
     198    /////
     199    // CLOVER SDK TOKENIZATION FAILSAFE ENDS
     200    /////
    179201    let cardNumber;
    180202    let cardDate;
     
    364386                const jQueryPaymentMethod = jQuery('input[name="payment_method"]:checked').val();
    365387                if (jQueryPaymentMethod === 'weeconnectpay') {
    366                     // Use the iframe's tokenization method with the user-entered card details
    367                     clover.createToken()
    368                         .then(function (tokenDataEvent) {
    369                         const result = tokenDataEvent;
    370                         if (result.errors) {
    371                             handleTokenCreationErrors(result);
    372                         }
    373                         else if (result.token) {
    374                             cloverTokenHandler(result.token);
    375                             const cardBrand = result.card?.brand ?? '';
    376                             saveCardBrandToForm(cardBrand);
    377                             cloverTokenizedDataVerificationHandler(result);
    378                             maybeExecuteGoogleRecaptcha(jQueryCheckoutForm, state);
    379                         }
    380                         else {
    381                             throw new Error('Something went wrong tokenizing the card. Payment will not be processed.');
    382                         }
    383                     });
     388                    // TEMPORARY RATE LIMIT FAILSAFE FOR CLOVER SDK
     389                    if (canCallCreateToken()) {
     390                        // Use the iframe's tokenization method with the user-entered card details
     391                        clover.createToken()
     392                            .then(function (tokenDataEvent) {
     393                            const result = tokenDataEvent;
     394                            if (result.errors) {
     395                                handleTokenCreationErrors(result);
     396                            }
     397                            else if (result.token) {
     398                                cloverTokenHandler(result.token);
     399                                const cardBrand = result.card?.brand ?? '';
     400                                saveCardBrandToForm(cardBrand);
     401                                cloverTokenizedDataVerificationHandler(result);
     402                                maybeExecuteGoogleRecaptcha(jQueryCheckoutForm, state);
     403                            }
     404                            else {
     405                                throw new Error('Something went wrong tokenizing the card. Payment will not be processed.');
     406                            }
     407                        });
     408                    }
     409                    else {
     410                        const result = {
     411                            errors: {
     412                                CARD_NUMBER: "Rate Limit Exceeded! Try again in 5 seconds."
     413                            }
     414                        };
     415                        handleTokenCreationErrors(result);
     416                        console.warn('Rate limit exceeded: clover.createToken() not called.');
     417                        return false;
     418                    }
    384419                }
    385420                else {
     
    402437                const jQueryPaymentMethod = jQuery('input[name="payment_method"]:checked').val();
    403438                if (jQueryPaymentMethod === 'weeconnectpay') {
    404                     // Use the iframe's tokenization method with the user-entered card details
    405                     clover.createToken()
    406                         .then(function (tokenDataEvent) {
    407                         const result = tokenDataEvent;
    408                         if (result.errors) {
    409                             handleTokenCreationErrors(result);
    410                         }
    411                         else if (result.token) {
    412                             cloverTokenHandler(result.token);
    413                             const cardBrand = result.card?.brand ?? '';
    414                             saveCardBrandToForm(cardBrand);
    415                             cloverTokenizedDataVerificationHandler(result);
    416                             maybeExecuteGoogleRecaptcha(jQueryOrderPayForm, state);
    417                         }
    418                         else {
    419                             throw new Error('Something went wrong tokenizing the card. Payment will not be processed.');
    420                         }
    421                     });
     439                    // TEMPORARY RATE LIMIT FAILSAFE FOR CLOVER SDK
     440                    if (canCallCreateToken()) {
     441                        clover.createToken()
     442                            .then(function (tokenDataEvent) {
     443                            const result = tokenDataEvent;
     444                            if (result.errors) {
     445                                handleTokenCreationErrors(result);
     446                            }
     447                            else if (result.token) {
     448                                cloverTokenHandler(result.token);
     449                                const cardBrand = result.card?.brand ?? '';
     450                                saveCardBrandToForm(cardBrand);
     451                                cloverTokenizedDataVerificationHandler(result);
     452                                maybeExecuteGoogleRecaptcha(jQueryOrderPayForm, state);
     453                            }
     454                            else {
     455                                throw new Error('Something went wrong tokenizing the card. Payment will not be processed.');
     456                            }
     457                        });
     458                    }
     459                    else {
     460                        const result = {
     461                            errors: {
     462                                CARD_NUMBER: "Rate Limit Exceeded! Try again in 5 seconds."
     463                            }
     464                        };
     465                        handleTokenCreationErrors(result);
     466                        console.warn('Rate limit exceeded: clover.createToken() not called.');
     467                    }
    422468                }
    423469                else {
  • weeconnectpay/trunk/includes/WeeConnectPayAPI.php

    r3133358 r3181924  
    620620     * @throws MissingStateException
    621621     * @throws UnsupportedOrderItemTypeException|WeeConnectPayException
     622     * @updated 3.11.1
    622623     */
    623624    public function prepare_order_for_payment( WC_Order $order, string $customerId) {
     
    658659                    }
    659660                } else {
    660                     error_log( "WeeConnectPay: Line item and order total amounts do not match." );
    661                     throw new WeeConnectPayException(
    662                         'Line items total and order total do not match. This is likely due to an unsupported discount, gift card or fee plugin. Please contact us at support@weeconnectpay.com to help us resolve this.',
     661                    $clover_total = $this->get_clover_order_total_from_products($clover_order); // Amount in cents
     662
     663                    $difference_in_cents = $clover_total - $amount_in_cents;
     664                    $difference_in_dollars = WeeConnectPayUtilities::centsToDollars(abs($difference_in_cents));
     665
     666                    $message = "There is a difference of {$difference_in_dollars} between the amounts. | ";
     667                    $message .= "WooCommerce Order Total: $" . $order->get_total() . " (Subtotal: $" . $order->get_subtotal() . " + Taxes: $" . $order->get_total_tax() . ") | ";
     668                    $message .= "Clover Order Total: " .WeeConnectPayUtilities::centsToDollars($clover_total) . " | ";
     669                    error_log( "WeeConnectPay: Line item and order total amounts do not match." . $message );
     670
     671
     672                    throw new WeeConnectPayException(
     673                        'Line items total and order total do not match. This is likely due to an unsupported discount, gift card or fee plugin. '.$message.' Please contact us at support@weeconnectpay.com to help us resolve this.',
    663674                        ExceptionCode::ORDER_LINE_ITEM_TOTAL_MISMATCH);
    664675                }
  • weeconnectpay/trunk/includes/WeeConnectPayUtilities.php

    r3133358 r3181924  
    264264    }
    265265
    266 
     266    /**
     267     * @since 3.11.1
     268     *
     269     * @param int $cents
     270     * @return string
     271     */
     272    public static function centsToDollars(int $cents): string
     273    {
     274        return '$' . number_format($cents / 100, 2);
     275    }
    267276
    268277
  • weeconnectpay/trunk/vendor/composer/installed.php

    r3174607 r3181924  
    22    'root' => array(
    33        'name' => '__root__',
    4         'pretty_version' => '3.11.3',
    5         'version' => '3.11.3.0',
    6         'reference' => 'cbe9b645f05932cfd3bc9ab4297d42bc2f7e6c05',
     4        'pretty_version' => '3.11.4',
     5        'version' => '3.11.4.0',
     6        'reference' => 'bf815eba318f8ead39efce8e13940e19ceef6ef6',
    77        'type' => 'library',
    88        'install_path' => __DIR__ . '/../../',
     
    1212    'versions' => array(
    1313        '__root__' => array(
    14             'pretty_version' => '3.11.3',
    15             'version' => '3.11.3.0',
    16             'reference' => 'cbe9b645f05932cfd3bc9ab4297d42bc2f7e6c05',
     14            'pretty_version' => '3.11.4',
     15            'version' => '3.11.4.0',
     16            'reference' => 'bf815eba318f8ead39efce8e13940e19ceef6ef6',
    1717            'type' => 'library',
    1818            'install_path' => __DIR__ . '/../../',
  • weeconnectpay/trunk/weeconnectpay.php

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