Skip to content

Commit

Permalink
fix: sdk button redirect issue (#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
rising-dragon401 committed May 23, 2024
1 parent f95bd66 commit 5478f8e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
12 changes: 0 additions & 12 deletions src/Components/PayNowButton.res
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,9 @@ 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(_) =>
setIsPayNowButtonDisable(_ => false)
setShowLoader(_ => false)
| None => ()
}
}

let handleOnClick = _ => {
setIsPayNowButtonDisable(_ => true)
setShowLoader(_ => true)
EventListenerManager.addSmartEventListener("message", handleMessage, "onSubmitSuccessful")
handlePostMessage([("handleSdkConfirm", confirmPayload)])
}

Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/PaymentBody.res
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ let paymentTypeBody = paymentType =>

let confirmPayloadForSDKButton = (sdkHandleConfirmPayment: PaymentType.sdkHandleConfirmPayment) =>
[
("redirect", "always"->JSON.Encode.string),
(
"confirmParams",
[
("return_url", sdkHandleConfirmPayment.confirmParams.return_url->JSON.Encode.string),
("redirect", "always"->JSON.Encode.string), // *As in the case of SDK Button we are not returning the promise back so it will always redirect
]->Utils.getJsonFromArrayOfJson,
),
]->Utils.getJsonFromArrayOfJson
Expand Down

0 comments on commit 5478f8e

Please sign in to comment.