Event Handling
Payment Form Events
The PaymentElement emits events that can be used to trigger actions in your application. The following events are
available:
fatalError: Triggered when a fatal error occurs. The element will be disabled.formValid: Triggered when the form is valid.
const allMethods = checkout.paymentMethods.value
const method = allMethods.find((method) => method.method === "creditcard");
const paymentElement = method.getPaymentElement();
paymentElement.on("fatalError", (error) => {
console.error("Fatal error:", error);
});
paymentElement.on("formValid", (isValid) => {
console.log("Form is valid", isValid);
});