• Resolved DevanToast

    (@devancadman)


    Hi Support,

    Since the latest update of the Payment Plugins for Stripe WooCommerce plugin, the checkout payment options are no longer loading correctly.

    When Stripe payment methods are enabled, the checkout gets stuck in a loading loop and the following JavaScript errors appear in the browser console:

    credit-card.js:
    Uncaught TypeError: Cannot read properties of null (reading 'cardFormType')
    
    gateways.js:
    Uncaught TypeError: Cannot read properties of null (reading 'button_placement')
    
    applepay-checkout.js:
    Uncaught TypeError: Cannot read properties of null (reading 'button_placement')
    
    googlepay-checkout.js:
    Uncaught TypeError: Cannot read properties of null (reading 'button_placement')
    
    local-payment-checkout.js:
    Uncaught TypeError: Cannot convert undefined or null to object
    at Object.entries
    

    The issue occurs with multiple Stripe payment methods, including:

    • Credit/Debit Cards
    • Apple Pay
    • Google Pay
    • Klarna
    • Local Payment Methods

    If all Stripe payment methods are disabled, PayPal continues to work correctly, so the issue appears to be isolated to the Stripe plugin.

    Could you please investigate whether this is a known issue with the latest version (4.0.8)?


    Plugin version: Version 4.0.8 |
    WooCommerce: Version 10.9.4
    WordPress: Version 7.0.2

    Thanks.

    • This topic was modified 1 week, 5 days ago by DevanToast.

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Clayton R

    (@mrclayton)

    Hi @devancadman

    Could you please investigate whether this is a known issue with the latest version (4.0.8)?

    It is not a known issue. Please provide a site url where this can be replicated. Stripe is not active on the site url you shared.

    It appears required JS variables are not loading on your page. Are you using a cache?

    Thanks

    Thread Starter DevanToast

    (@devancadman)

    Hey Clayton,

    I have now re-enabled the payment methods on the site.
    Not using any caching plugin. Server cache is set to not cache the Basket and Checkout pages.

    Thanks,
    Devan

    Plugin Author Clayton R

    (@mrclayton)

    Hi @devancadman

    You can disable it now, your site has been tested. The plugin now relies on a single JS variable called wcStripeSettings and that’s not defined on your checkout page.

    That variable uses the core WordPress action wp_print_footer_scripts which doesn’t appear to be triggered on your site. Can you confirm why wp_print_footer_scripts would not be triggered?

    Kind Regards

    Plugin Author Clayton R

    (@mrclayton)

    Hi @devancadman

    What doesn’t make sense is the PayPal plugin uses the same action, wp_print_footer_scripts to output the wcPPCPSettings variable. That action seems to be triggered so it seems impossible that the wcStripeSettings variable would not exist.

    The only thing I can think of is your cart and checkout page is being cached. The wcStripeSettings variable is not on your cart page as well but wcPPCPSettings is.

    Kind Regards

    Thread Starter DevanToast

    (@devancadman)

    Hey Clayton,

    I have completed some further debugging.

    The Stripe scripts are all registered correctly. The following handles are present:

    wc-stripe-gateways
    wc-stripe-credit-card
    wc-stripe-applepay-checkout
    wc-stripe-googlepay-checkout
    wc-stripe-local-payment-checkout
    

    However, none of the Stripe handles have any inline scripts attached.

    There is no output similar to:

    var wcStripeSettings = {...};
    

    The WordPress hooks are definitely firing:

    • wp_footer
    • wp_print_footer_scripts

    WooCommerce also detects the Stripe gateways correctly:

    ppcp, stripe_cc, stripe_applepay, stripe_googlepay, stripe_klarna
    

    Could you confirm which script handle wcStripeSettings should be attached to, and which PHP class/function is responsible for registering it?

    At this point it looks like the plugin is enqueueing the JS assets but not registering the configuration data.

    Thanks.

    Plugin Author Clayton R

    (@mrclayton)

    Hi @devancadman

    At this point it looks like the plugin is enqueueing the JS assets but not registering the configuration data.

    That is not correct, the plugin uses the exact same design as the PayPal plugin. It doesn’t use an enqueued script, it prints the variable to the page.

    Can you check that your checkout page isn’t being cached?

    Thank You

    Plugin Author Clayton R

    (@mrclayton)

    Hi @devancadman

    Here is a link to the code where the wcStripeSettings variable is output to the page:

    The action is registered: https://plugins.trac.wordpress.org/browser/woo-stripe-payment/tags/4.0.8/src/Assets/AssetDataController.php#L58

    The data is output to the page: https://plugins.trac.wordpress.org/browser/woo-stripe-payment/tags/4.0.8/src/Assets/AssetDataController.php#L89

    Maybe you can add some logging to confirm this code is being called.

    Here is the PayPal plugin code that is identical to the Stripe plugin: https://plugins.trac.wordpress.org/browser/pymntpl-paypal-woocommerce/tags/2.0.23/src/Assets/AssetDataController.php

    Kind Regards

    Plugin Author Clayton R

    (@mrclayton)

    Hi @devancadman

    Following up on this request.

    Kind Regards

    Thread Starter DevanToast

    (@devancadman)

    Hi Clayton,

    I have added logging around the enqueue_asset_data() method and can confirm that wp_print_footer_scripts is firing correctly.

    The logs show:

    • Stripe: enqueue_asset_data() called
    • Stripe: has_data BEFORE action = YES
    • Stripe: has_data AFTER action = YES
    • Stripe: Printing wcStripeSettings

    However, the browser error remains:

    credit-card.js:
    Uncaught TypeError: Cannot read properties of null (reading 'cardFormType')

    While debugging in the browser I found something unexpected.

    window.wcStripeSettings is undefined:

    console.log(window.wcStripeSettings);
    // undefined

    However, the same data is available under:

    console.log(window.wcCardSettings);

    which returns the full settings object, including stripe_cc_data.

    The plugin logs indicate that print_data( 'wcStripeSettings', ... ) is being called, but the rendered page ends up creating window.wcCardSettings instead of window.wcStripeSettings.

    Since credit-card.js calls:

    getSetting("stripe_cc_data")

    and getSetting() reads from:

    window.wcStripeSettings

    it seems the script is looking for a global that doesn’t exist, even though the data itself has been generated.

    The site is hosted on WP Engine. They have confirmed that the basket and checkout pages are not cached, and there are no caching plugins installed.

    Does anything within the plugin intentionally rename wcStripeSettings to wcCardSettings, or is there another component that aliases or rewrites the settings object before credit-card.js executes?

    Thanks.

    Plugin Author Clayton R

    (@mrclayton)

    Hi @devancadman

    Thank you for that update. That is very odd that the javascript variable is being renamed. There isn’t any code in the Stripe plugin that would alias that variable or rename it.

    I believe that confirms something is renaming that variable but that wouldn’t be coming from the Stripe plugin.

    Kind Regards

    Thread Starter DevanToast

    (@devancadman)

    Hey Clayton,

    Sorry, you were right this was caused by another plugin:

    Real-Time Find and Replace – A rule had been setup to replace “Stripe” with “Card”.

    I have removed this and the issue is now fixed.

    Many Thanks,
    Devan

Viewing 11 replies - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.