This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
Option to only trigger canMakePayment
on change
event
#7309
Labels
block: checkout
Issues related to the checkout block.
type: enhancement
The issue is a request for an enhancement.
The Problem
In the Checkout Block, the
canMakePayment
function gets triggered by theinput
event, which means that on every keystroke the function is called. This is incredibly taxing on systems that are making more expensive calculations.An example would be the Credit Check Plugin I am developing where the plugin makes a call to an external API to see if that customer is allowed to use our Payment Method. And if we didn't add any other logic, we'd be making a call to our API on every keystroke 50+ times per customer
Right now we're solving this like so:
Of course number one would still remain, but we could remove number 2. The 1 Second timeout was chosen very arbitrarily, and this also means that there's a 1 second delay until the check starts to run after the customer has finished typing.
I've attached how our code works at the bottom of this issue. This Change would mean that we could remove the new Promise logic and the timeout, and I could just return the ajax request directly.
Possible Solutions
canMakePayment
, likecanMakePaymentOnChange
,canMakePaymentOnBlur
and more, which will only get triggered on a specific HTML event.canMakePayment
listens onAdditional context
Our current code for
canMakePayment
The text was updated successfully, but these errors were encountered: