GiftCard clear() method works, but triggers an invalid input error message

I am calling the GiftCard.clear() method as described here in the docs:

When I call this method, the form is cleared just fine, but it seems to then trigger an internal WebPaymentsSDK event of some sort which causes an “Enter a valid gift card number.” alert message below the box.

I’ve tried calling it in a timeout, a second time, etc ,etc and the error message keeps showing up despite a cleared form.

I haven’t been able to replicate this with our quickstart. Is the page hosted so we can take a look? :slightly_smiling_face:

Sorry for the delayed reply. Here is a page will all the cruft cut out showing the issue.

https://www.laurelhursttheater.com/sqdemo.html

Enter in some gibberish and click “add card” to tokenize it, wait a second and the .clear() method will be called via setTimeout() and the input box will clear, but the error message will not. If you type in gibberish again, then clear it out with the backspace key, the error message keeps showing.

The docs say “Clears the gift card fields and removes error messages”, the field is being cleared, but the error message is not. I want to get the form back to the state as if the user had not entered anything.

This is the expected behavior of the Web Payments SDK. Our Quickstart example behaves the same way if you try to submit an invalid value. Only when you refresh the page will it clear the error. :slightly_smiling_face:

ok, so the API docs are incorrect because they don’t clear all error messages? I read this as it would clear everything and bring the user back to the “Enter your gift card number” state.

I guess as a workaround I can delete the message string on reset. This is a problem for me due to the way the payment page is setup and that multiple gift cards can be used. I’ll figure something out.