Skip to content

Commit

Permalink
fix: redirection for 400 confirm call (#402)
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 b5961de commit a169a44
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/orca-loader/Hyper.res
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ let make = (publishableKey, options: option<JSON.t>, analyticsInfo: option<JSON.
})
}

let confirmPaymentWrapper = (payload, isOneClick, result) => {
let confirmPaymentWrapper = (payload, isOneClick, result, ~isSdkButton=false) => {
let confirmTimestamp = Date.now()
let confirmParams =
payload
Expand Down Expand Up @@ -328,7 +328,11 @@ let make = (publishableKey, options: option<JSON.t>, analyticsInfo: option<JSON.
)
}
postSubmitMessage(dict)
if val->JSON.Decode.bool->Option.getOr(false) && redirect === "always" {

if (
isSdkButton ||
(val->JSON.Decode.bool->Option.getOr(false) && redirect === "always")
) {
Window.replace(returnUrl)
} else if !(val->JSON.Decode.bool->Option.getOr(false)) {
resolve1(json)
Expand Down Expand Up @@ -370,11 +374,15 @@ let make = (publishableKey, options: option<JSON.t>, analyticsInfo: option<JSON.
confirmPaymentWrapper(payload, true, result)
}

let confirmPaymentViaSDKButton = payload => {
confirmPaymentWrapper(payload, false, true, ~isSdkButton=true)
}

let handleSdkConfirm = (event: Types.event) => {
let json = event.data->anyTypeToJson
let dict = json->getDictFromJson
switch dict->Dict.get("handleSdkConfirm") {
| Some(payload) => confirmPayment(payload)->ignore
| Some(payload) => confirmPaymentViaSDKButton(payload)->ignore
| None => ()
}
}
Expand Down

0 comments on commit a169a44

Please sign in to comment.