Skip to content

Commit

Permalink
fix: sdk button loader issue (#400)
Browse files Browse the repository at this point in the history
Co-authored-by: Pritish Budhiraja <[email protected]>
  • Loading branch information
PritishBudhiraja and Pritish Budhiraja authored May 27, 2024
1 parent f085bfb commit e012642
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Components/PayNowButton.res
Original file line number Diff line number Diff line change
Expand Up @@ -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)])
}

Expand Down

0 comments on commit e012642

Please sign in to comment.