The form will not submit when "New credit card" has been selected and then deselected.

User scenario / steps to reproduce: User fills out payment form, goes to review page. User then chooses to edit Payment Information, is taken back to previous page. If the user now selects New credit card, and then without filling out the form selects the previously entered card instead, the form can no longer be submitted. Attempts to click on the submit button will fail silently.

Cause:
The issue seems to be that square's JS is attempting to validate fields in iframes which no longer exist on the page.

JS console output:

Uncaught TypeError: Cannot read property 'postMessage' of null
    at n.blurAllInputs (paymentform:1)

and

Uncaught TypeError: Cannot read property 'postMessage' of null
    at n.setPostalCode (paymentform:1)
    at n.setPostalCode (paymentform:1)
    at HTMLButtonElement.requestCardNonce (eval at globalEval (jquery.min.js?v=2.2.4:2), <anonymous>:158:19)
    at HTMLButtonElement.dispatch (jquery.min.js?v=2.2.4:3)
    at HTMLButtonElement.r.handle (jquery.min.js?v=2.2.4:3)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

collin.rickford created an issue. See original summary.

mglaman’s picture

This is also happening with AJAX from shipping. I believe there is a fix we can borrow from Braintree.

mglaman’s picture

Status: Active » Needs review
FileSize
2.04 KB

Proposed patch, based off of Braintree

mglaman’s picture

This fixed our demo store and I'm able to complete check out in our automated Behat test. Will commit and tag new beta

  • mglaman committed 02521c3 on 8.x-1.x
    Issue #2903013 by mglaman: Form submit broken when switching between new...
mglaman’s picture

Status: Needs review » Fixed
collin.rickford’s picture

I'm still seeing the issue on the latest beta - will test on a vanilla commerce install and report back.

mglaman’s picture

Version: 8.x-1.0-beta5 » 8.x-1.0-beta6

collin.rickford, shoot. Thanks. Let me know. I know this fixed my automated testing when using Shipping and AJAX calculation of shipping methods. I'll help review other AJAX as well when time allows. Let me know.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.