From e94a33393fa0a2ba25499e00c8298344b7732eef Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Mon, 27 May 2024 13:04:39 +0530 Subject: [PATCH] fix: sdk button loader issue --- src/Components/PayNowButton.res | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Components/PayNowButton.res b/src/Components/PayNowButton.res index 7d4653914..d8795f3d6 100644 --- a/src/Components/PayNowButton.res +++ b/src/Components/PayNowButton.res @@ -21,9 +21,23 @@ let make = () => { let confirmPayload = sdkHandleConfirmPayment->PaymentBody.confirmPayloadForSDKButton let buttonText = sdkHandleConfirmPayment.buttonText->Option.getOr(localeString.payNowButton) + let handleMessage = (event: Types.event) => { + let json = event.data->Identity.anyTypeToJson->getStringFromJson("")->safeParse + let dict = json->getDictFromJson + switch dict->Dict.get("submitSuccessful") { + | Some(submitSuccessfulVal) => + if !(submitSuccessfulVal->JSON.Decode.bool->Option.getOr(false)) { + setIsPayNowButtonDisable(_ => false) + setShowLoader(_ => false) + } + | None => () + } + } + let handleOnClick = _ => { setIsPayNowButtonDisable(_ => true) setShowLoader(_ => true) + EventListenerManager.addSmartEventListener("message", handleMessage, "onSubmitSuccessful") handlePostMessage([("handleSdkConfirm", confirmPayload)]) }