From 87453f81c603e9fb13830e7d92e41c2a93527816 Mon Sep 17 00:00:00 2001 From: Zeyar Paing Date: Wed, 28 Aug 2024 00:56:33 +0700 Subject: [PATCH] fix onValidationError not firing for client onchange --- example/package-lock.json | 2 +- lib/components/form.tsx | 3 ++- package-lock.json | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/example/package-lock.json b/example/package-lock.json index d4496ba..df4b642 100644 --- a/example/package-lock.json +++ b/example/package-lock.json @@ -28,7 +28,7 @@ }, "..": { "name": "@getopenpay/openpay-js-react", - "version": "0.0.7", + "version": "0.0.8", "license": "ISC", "dependencies": { "react": "^18.3.1", diff --git a/lib/components/form.tsx b/lib/components/form.tsx index fab6806..47791fd 100644 --- a/lib/components/form.tsx +++ b/lib/components/form.tsx @@ -175,7 +175,8 @@ const ElementsForm: FC = (props) => { if (onLoadError) onLoadError(eventPayload.message); } else if (eventType === EventType.enum.VALIDATION_ERROR) { - if (extraData?.checkoutPaymentMethod.provider === 'credit_card') { + const provider = extraData?.checkoutPaymentMethod.provider; + if (provider === 'credit_card' || provider === undefined) { console.error(`[form] Validation error for ${eventPayload.elementType}:`, eventPayload.errors); if (onValidationError) onValidationError(eventPayload.elementType, eventPayload.errors, elementId); } diff --git a/package-lock.json b/package-lock.json index 14a9812..1fe2323 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getopenpay/openpay-js-react", - "version": "0.0.7", + "version": "0.0.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getopenpay/openpay-js-react", - "version": "0.0.7", + "version": "0.0.8", "license": "ISC", "dependencies": { "react": "^18.3.1",