Skip to content

Fix "event is not a function" error on My Payment Methods page - #867

Merged
agibson-godaddy merged 3 commits into
release/6.2.5from
mwc-20379
Oct 27, 2026
Merged

agibson-godaddy merged 3 commits into
release/6.2.5from
mwc-20379

Conversation

@smoen-godaddy

@smoen-godaddy smoen-godaddy commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes an uncaught TypeError: event is not a function thrown by the My Payment Methods handler whenever a customer has at least one saved payment method.

Story: MWC-20379

Release: TBD

Details

In sv-wc-payment-gateway-my-payment-methods.coffee, the click handler for the "Add payment method" button was written as .on 'click', event ->. Without parentheses, CoffeeScript compiles this to .on('click', event(function() {...})), a call to window.event, which isn't a function. The constructor throws at that line, so the handler never finishes setting up and the guard that stops a disabled "Add payment method" button from navigating is never registered.

The fix adds the missing parentheses: .on 'click', ( event ) ->. The thin arrow is kept because the body relies on $( this ) being the clicked button. The dist asset and source map are rebuilt.

The error only appears when a saved method exists, because WooCommerce only renders the payment methods table then. Other framework-based gateways bundling an affected version are likely affected too.

UI Changes

None.

QA

Setup

  • A framework-based gateway with saved payment methods enabled (for example Authorize.Net CIM in sandbox mode)

Steps

  1. Add a payment method, then open My Account > Payment Methods with the browser console open
    • No event is not a function error is logged
  2. Click Edit on a saved method, then click the "Add payment method" button
    • The button does not navigate while editing
  • Code review

Before merge

  • I have confirmed these changes in each supported minor WooCommerce version

@smoen-godaddy smoen-godaddy self-assigned this Oct 26, 2026
@smoen-godaddy

Copy link
Copy Markdown
Contributor Author

Hi @agibson-godaddy , I’ve opened a framework fix for MWC-20379: #867. A missing pair of parentheses in the My Payment Methods CoffeeScript (.on 'click', event ->) throws “event is not a function” for any customer with a saved payment method. It affects every plugin bundling framework 6.2.4, and I confirmed it on Authorize.Net. It’s a one-liner plus the rebuilt dist. Two questions: should this go out as 6.2.5 with #864 or on its own, and who triggers the framework release? I’ve cut release/3.10.22 for Authorize.Net (#152) and will pin the new framework version in the story PR once it’s tagged.

@smoen-godaddy

Copy link
Copy Markdown
Contributor Author

Tested this branch (7fae387) in WooCommerce Authorize.Net Gateway 3.10.22-dev.1, installed via a zip built from the branch’s own dist. On My Account > Payment Methods with a saved method, there is no event is not a function error in the console. The disabled “Add payment method” button no longer navigates while a method is being edited. Nickname save/cancel, set default, and delete (Cancel and OK) all work as before. Local PHPUnit errors identically (18 of 26) with and without this change on PHP 8.5

@agibson-godaddy agibson-godaddy mentioned this pull request Oct 27, 2026
2 tasks done
@agibson-godaddy
agibson-godaddy changed the base branch from master to release/6.2.5 October 27, 2026 10:34
@agibson-godaddy
agibson-godaddy merged commit 7580c0e into release/6.2.5 Oct 27, 2026
5 checks passed
@agibson-godaddy
agibson-godaddy deleted the mwc-20379 branch October 27, 2026 10:42
agibson-godaddy added a commit that referenced this pull request Oct 30, 2026
* Version 6.2.5

* Fix "event is not a function" error on My Payment Methods page (#867)

* Fix event handler syntax error on My Payment Methods page (MWC-20379)

* Update changelog

---------

Co-authored-by: Ashley Gibson <agibson@godaddy.com>

* Add additional nonce & capability checks (#869)

* Add nonce checks to notice dismissal

* Add capaiblity check to batch handling

* Add changelog entry

* Change since version

* Fix false _doing_it_wrong in ScriptHelper::addInlineScript() on WP 6.9+ block editor (#864)

* Update class-sv-wc-admin-notice-handler.php

* Add fallback for wp_print_inline_script_tag function

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Updated Tests

* Code updates to address Ashely's comment

* Update ScriptHelperTest to correct failing tests

* Update namespace

* Customize messaging based on required hook

* Update changelog

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Ashley Gibson <agibson@godaddy.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: smoen-godaddy <76167060+smoen-godaddy@users.noreply.github.com>
Co-authored-by: Ashley Gibson <agibson@godaddy.com>
Co-authored-by: Ashley Gibson <99189195+agibson-godaddy@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants