From a169a44585f2f2a33cce3d0d2b232b0c82671107 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja Date: Mon, 27 May 2024 18:54:40 +0530 Subject: [PATCH] fix: redirection for 400 confirm call (#402) Co-authored-by: Pritish Budhiraja <1805317@kiit.ac.in> --- src/orca-loader/Hyper.res | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/orca-loader/Hyper.res b/src/orca-loader/Hyper.res index 59de6eb2f..7adabb05c 100644 --- a/src/orca-loader/Hyper.res +++ b/src/orca-loader/Hyper.res @@ -269,7 +269,7 @@ let make = (publishableKey, options: option, analyticsInfo: option { + let confirmPaymentWrapper = (payload, isOneClick, result, ~isSdkButton=false) => { let confirmTimestamp = Date.now() let confirmParams = payload @@ -328,7 +328,11 @@ let make = (publishableKey, options: option, analyticsInfo: optionJSON.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) @@ -370,11 +374,15 @@ let make = (publishableKey, options: option, analyticsInfo: option { + 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 => () } }