From 705fa1f6f07651861f023b6f849f2d2acc7a99e5 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja Date: Sun, 4 Aug 2024 18:25:22 +0530 Subject: [PATCH 1/7] feat: plaid payments flow integration --- src/Components/DynamicFields.res | 60 +++++++++++++++++++++++++++ src/Payments/PaymentMethodsRecord.res | 23 ++++------ src/Utilities/PaymentHelpers.res | 1 + src/orca-loader/Elements.res | 29 +++++++++++++ 4 files changed, 97 insertions(+), 16 deletions(-) diff --git a/src/Components/DynamicFields.res b/src/Components/DynamicFields.res index 73c728905..11714a244 100644 --- a/src/Components/DynamicFields.res +++ b/src/Components/DynamicFields.res @@ -76,6 +76,8 @@ let make = ( }, (requiredFields, isAllStoredCardsHaveName, isSavedCardFlow)) let {config, themeObj, localeString} = Recoil.useRecoilValueFromAtom(configAtom) + let {publishableKey} = Recoil.useRecoilValueFromAtom(keys) + let switchToCustomPodValue = Recoil.useRecoilValueFromAtom(switchToCustomPod) let isSpacedInnerLayout = config.appearance.innerLayout === Spaced let logger = Recoil.useRecoilValueFromAtom(loggerAtom) @@ -229,6 +231,64 @@ let make = ( None }) + React.useEffect0(() => { + open Promise + let onPlaidCallback = (ev: Window.event) => { + let json = ev.data->JSON.parseExn + let dict = json->Utils.getDictFromJson + if dict->getBool("isPlaid", false) { + let headers = [("Content-Type", "application/json"), ("api-key", publishableKey)] + PaymentHelpers.retrievePaymentIntent( + config.clientSecret, + headers, + ~optLogger=Some(logger), + ~switchToCustomPod=switchToCustomPodValue, + ) + ->then(json => { + let dict = json->JSON.Decode.object->Option.getOr(Dict.make()) + let status = dict->getString("status", "") + let return_url = dict->getString("return_url", "") + + // TODO: NEED TO DISCUSS WHAT TO DO IN THIS CASE + if ( + status === "succeeded" || + status === "requires_customer_action" || + status === "processing" + ) { + handlePostMessage([("fullscreen", false->JSON.Encode.bool)]) + postSubmitResponse(~jsonData=json, ~url=return_url) + } else if status === "failed" { + postFailedSubmitResponse( + ~errortype="confirm_payment_failed", + ~message="Payment failed. Try again!", + ) + } else { + postFailedSubmitResponse( + ~errortype="sync_payment_failed", + ~message="Payment is processing. Try again later!", + ) + } + resolve(json) + }) + ->then(_ => { + resolve(Nullable.null) + }) + ->catch(e => { + Console.log2("Retrieve Failed", e) + resolve(Nullable.null) + }) + ->ignore + } + } + + Window.addEventListener("message", onPlaidCallback) + Some( + () => { + Window.removeEventListener("message", ev => onPlaidCallback(ev)) + }, + ) + }) + let onPostalChange = ev => { let val = ReactEvent.Form.target(ev)["value"] diff --git a/src/Payments/PaymentMethodsRecord.res b/src/Payments/PaymentMethodsRecord.res index 338ffb5f9..69e7db956 100644 --- a/src/Payments/PaymentMethodsRecord.res +++ b/src/Payments/PaymentMethodsRecord.res @@ -499,6 +499,13 @@ let paymentMethodsFields = [ fields: [InfoElement], miniIcon: Some(icon("bank", ~size=19)), }, + { + paymentMethodName: "open_banking_pis", + icon: Some(icon("bank", ~size=19)), + displayName: "Plaid", + fields: [InfoElement], + miniIcon: Some(icon("bank", ~size=19)), + }, { paymentMethodName: "evoucher", icon: Some(icon("cashtocode", ~size=50)), @@ -740,9 +747,6 @@ let getPaymentDetails = (arr: array) => { finalArr } -type paymentMethod = - Cards | Wallets | PayLater | BankRedirect | BankTransfer | BankDebit | Crypto | Voucher | NONE - type cardType = Credit | Debit type paymentExperience = { @@ -826,19 +830,6 @@ let defaultList = { merchant_name: "", collect_billing_details_from_wallets: true, } -let getMethod = str => { - switch str { - | "card" => Cards - | "wallet" => Wallets - | "pay_later" => PayLater - | "bank_redirect" => BankRedirect - | "bank_transfer" => BankTransfer - | "bank_debit" => BankDebit - | "crypto" => Crypto - | "voucher" => Voucher - | _ => NONE - } -} let getPaymentExperienceType = str => { switch str { diff --git a/src/Utilities/PaymentHelpers.res b/src/Utilities/PaymentHelpers.res index 08b456285..16a1e750b 100644 --- a/src/Utilities/PaymentHelpers.res +++ b/src/Utilities/PaymentHelpers.res @@ -742,6 +742,7 @@ let rec intentCall = ( ("applePayPresent", session_token->anyTypeToJson), ] | "google_pay" => [("googlePayThirdPartyFlow", session_token->anyTypeToJson)] + | "open_banking" => [("openBankingPlaid", session_token->anyTypeToJson)] | _ => [] } diff --git a/src/orca-loader/Elements.res b/src/orca-loader/Elements.res index bf640d4df..9acf32446 100644 --- a/src/orca-loader/Elements.res +++ b/src/orca-loader/Elements.res @@ -496,6 +496,34 @@ let make = ( } } + let handleOpenBankingPlaidSessionToken = (event: Types.event) => { + let json = event.data->anyTypeToJson + let dict = json->getDictFromJson + switch dict->Dict.get("openBankingPlaid") { + | Some(openBankingTokenJson) => + let metaData = [ + ( + "linkToken", + openBankingTokenJson + ->getDictFromJson + ->getString("open_banking_session_token", "") + ->JSON.Encode.string, + ), + ("pmAuthConnectorArray", ["plaid"]->Identity.anyTypeToJson), + ("payment_id", clientSecret->getPaymentId->JSON.Encode.string), + ("publishableKey", publishableKey->JSON.Encode.string), + ]->getJsonFromArrayOfJson + + handlePostMessage([ + ("fullscreen", true->JSON.Encode.bool), + ("param", "plaidSDK"->JSON.Encode.string), + ("iframeId", selectorString->JSON.Encode.string), + ("metadata", metaData), + ]) + | _ => () + } + } + let handleApplePayThirdPartyFlow = (event: Types.event) => { let json = event.data->Identity.anyTypeToJson let dict = json->getDictFromJson @@ -729,6 +757,7 @@ let make = ( addSmartEventListener("message", handlePollStatusMessage, "onPollStatusMsg") addSmartEventListener("message", handleGooglePayThirdPartyFlow, "onGooglePayThirdParty") addSmartEventListener("message", handleApplePayThirdPartyFlow, "onApplePayThirdParty") + addSmartEventListener("message", handleOpenBankingPlaidSessionToken, "onOpenBankingPlaid") let fetchSessionTokens = mountedIframeRef => { let handleSessionTokensLoaded = (event: Types.event) => { From e3b6e7200aaeb2b45f0a96f61aadee49b5a1178e Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja Date: Mon, 5 Aug 2024 16:37:40 +0530 Subject: [PATCH 2/7] fix: open banking pis flow fix --- src/Payments/PlaidSDKIframe.res | 2 +- src/Utilities/PaymentHelpers.res | 21 ++++++++++++++++++++- src/orca-loader/Elements.res | 29 ----------------------------- 3 files changed, 21 insertions(+), 31 deletions(-) diff --git a/src/Payments/PlaidSDKIframe.res b/src/Payments/PlaidSDKIframe.res index e557efe58..370129124 100644 --- a/src/Payments/PlaidSDKIframe.res +++ b/src/Payments/PlaidSDKIframe.res @@ -18,7 +18,7 @@ let make = () => { React.useEffect0(() => { let handle = (ev: Window.event) => { - let json = ev.data->JSON.parseExn + let json = ev.data->safeParse let metaData = json->getDictFromJson->getDictFromDict("metadata") let linkToken = metaData->getString("linkToken", "") if linkToken->String.length > 0 { diff --git a/src/Utilities/PaymentHelpers.res b/src/Utilities/PaymentHelpers.res index 16a1e750b..45d33e77f 100644 --- a/src/Utilities/PaymentHelpers.res +++ b/src/Utilities/PaymentHelpers.res @@ -736,13 +736,32 @@ let rec intentCall = ( | None => Dict.make() } let walletName = session_token->getString("wallet_name", "") + if walletName === "open_banking" { + let metaData = [ + ( + "linkToken", + session_token + ->getString("open_banking_session_token", "") + ->JSON.Encode.string, + ), + ("pmAuthConnectorArray", ["plaid"]->Identity.anyTypeToJson), + ("payment_id", clientSecret->getPaymentId->JSON.Encode.string), + ("publishableKey", confirmParam.publishableKey->JSON.Encode.string), + ]->getJsonFromArrayOfJson + + handlePostMessage([ + ("fullscreen", true->JSON.Encode.bool), + ("param", "plaidSDK"->JSON.Encode.string), + ("iframeId", iframeId->JSON.Encode.string), + ("metadata", metaData), + ]) + } let message = switch walletName { | "apple_pay" => [ ("applePayButtonClicked", true->JSON.Encode.bool), ("applePayPresent", session_token->anyTypeToJson), ] | "google_pay" => [("googlePayThirdPartyFlow", session_token->anyTypeToJson)] - | "open_banking" => [("openBankingPlaid", session_token->anyTypeToJson)] | _ => [] } diff --git a/src/orca-loader/Elements.res b/src/orca-loader/Elements.res index 9acf32446..bf640d4df 100644 --- a/src/orca-loader/Elements.res +++ b/src/orca-loader/Elements.res @@ -496,34 +496,6 @@ let make = ( } } - let handleOpenBankingPlaidSessionToken = (event: Types.event) => { - let json = event.data->anyTypeToJson - let dict = json->getDictFromJson - switch dict->Dict.get("openBankingPlaid") { - | Some(openBankingTokenJson) => - let metaData = [ - ( - "linkToken", - openBankingTokenJson - ->getDictFromJson - ->getString("open_banking_session_token", "") - ->JSON.Encode.string, - ), - ("pmAuthConnectorArray", ["plaid"]->Identity.anyTypeToJson), - ("payment_id", clientSecret->getPaymentId->JSON.Encode.string), - ("publishableKey", publishableKey->JSON.Encode.string), - ]->getJsonFromArrayOfJson - - handlePostMessage([ - ("fullscreen", true->JSON.Encode.bool), - ("param", "plaidSDK"->JSON.Encode.string), - ("iframeId", selectorString->JSON.Encode.string), - ("metadata", metaData), - ]) - | _ => () - } - } - let handleApplePayThirdPartyFlow = (event: Types.event) => { let json = event.data->Identity.anyTypeToJson let dict = json->getDictFromJson @@ -757,7 +729,6 @@ let make = ( addSmartEventListener("message", handlePollStatusMessage, "onPollStatusMsg") addSmartEventListener("message", handleGooglePayThirdPartyFlow, "onGooglePayThirdParty") addSmartEventListener("message", handleApplePayThirdPartyFlow, "onApplePayThirdParty") - addSmartEventListener("message", handleOpenBankingPlaidSessionToken, "onOpenBankingPlaid") let fetchSessionTokens = mountedIframeRef => { let handleSessionTokensLoaded = (event: Types.event) => { From 73553cc1d5ec3ce3b7f7a07e2f76d47ed01fe18f Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja Date: Mon, 5 Aug 2024 17:14:21 +0530 Subject: [PATCH 3/7] fix: forceSync added --- src/Components/DynamicFields.res | 1 + src/Payments/PaymentMethodsRecord.res | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Components/DynamicFields.res b/src/Components/DynamicFields.res index 11714a244..194d97a4c 100644 --- a/src/Components/DynamicFields.res +++ b/src/Components/DynamicFields.res @@ -243,6 +243,7 @@ let make = ( headers, ~optLogger=Some(logger), ~switchToCustomPod=switchToCustomPodValue, + ~isForceSync=true, ) ->then(json => { let dict = json->JSON.Decode.object->Option.getOr(Dict.make()) diff --git a/src/Payments/PaymentMethodsRecord.res b/src/Payments/PaymentMethodsRecord.res index 69e7db956..e5ba5ae80 100644 --- a/src/Payments/PaymentMethodsRecord.res +++ b/src/Payments/PaymentMethodsRecord.res @@ -502,7 +502,7 @@ let paymentMethodsFields = [ { paymentMethodName: "open_banking_pis", icon: Some(icon("bank", ~size=19)), - displayName: "Plaid", + displayName: "Open Banking", fields: [InfoElement], miniIcon: Some(icon("bank", ~size=19)), }, From bc5c771b09db6057ec78f37e52d4c74987684f2a Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja Date: Wed, 7 Aug 2024 15:21:39 +0530 Subject: [PATCH 4/7] fix: plaid integration pis flow --- src/Components/DynamicFields.res | 59 ------------------------- src/Payments/PlaidSDKIframe.res | 75 +++++++++++++++++++++++++++----- src/Utilities/PaymentHelpers.res | 6 ++- 3 files changed, 68 insertions(+), 72 deletions(-) diff --git a/src/Components/DynamicFields.res b/src/Components/DynamicFields.res index e8f92fadc..f5d17ed4a 100644 --- a/src/Components/DynamicFields.res +++ b/src/Components/DynamicFields.res @@ -230,65 +230,6 @@ let make = ( None }) - React.useEffect0(() => { - open Promise - let onPlaidCallback = (ev: Window.event) => { - let json = ev.data->JSON.parseExn - let dict = json->Utils.getDictFromJson - if dict->getBool("isPlaid", false) { - let headers = [("Content-Type", "application/json"), ("api-key", publishableKey)] - PaymentHelpers.retrievePaymentIntent( - config.clientSecret, - headers, - ~optLogger=Some(logger), - ~switchToCustomPod=switchToCustomPodValue, - ~isForceSync=true, - ) - ->then(json => { - let dict = json->JSON.Decode.object->Option.getOr(Dict.make()) - let status = dict->getString("status", "") - let return_url = dict->getString("return_url", "") - - // TODO: NEED TO DISCUSS WHAT TO DO IN THIS CASE - if ( - status === "succeeded" || - status === "requires_customer_action" || - status === "processing" - ) { - handlePostMessage([("fullscreen", false->JSON.Encode.bool)]) - postSubmitResponse(~jsonData=json, ~url=return_url) - } else if status === "failed" { - postFailedSubmitResponse( - ~errortype="confirm_payment_failed", - ~message="Payment failed. Try again!", - ) - } else { - postFailedSubmitResponse( - ~errortype="sync_payment_failed", - ~message="Payment is processing. Try again later!", - ) - } - resolve(json) - }) - ->then(_ => { - resolve(Nullable.null) - }) - ->catch(e => { - Console.log2("Retrieve Failed", e) - resolve(Nullable.null) - }) - ->ignore - } - } - - Window.addEventListener("message", onPlaidCallback) - Some( - () => { - Window.removeEventListener("message", ev => onPlaidCallback(ev)) - }, - ) - }) - let onPostalChange = ev => { let val = ReactEvent.Form.target(ev)["value"] diff --git a/src/Payments/PlaidSDKIframe.res b/src/Payments/PlaidSDKIframe.res index 0350cc519..3857557ca 100644 --- a/src/Payments/PlaidSDKIframe.res +++ b/src/Payments/PlaidSDKIframe.res @@ -6,10 +6,11 @@ let make = () => { let (isReady, setIsReady) = React.useState(_ => false) let (pmAuthConnectorsArr, setPmAuthConnectorsArr) = React.useState(_ => []) let (publishableKey, setPublishableKey) = React.useState(_ => "") - let (paymentId, setPaymentId) = React.useState(_ => "") + let (clientSecret, setClientSecret) = React.useState(_ => "") + let (isForceSync, setIsForceSync) = React.useState(_ => false) let logger = React.useMemo(() => { - OrcaLogger.make(~source=Elements(Payment), ~clientSecret=paymentId, ~merchantId=publishableKey) - }, (publishableKey, paymentId)) + OrcaLogger.make(~source=Elements(Payment), ~clientSecret, ~merchantId=publishableKey) + }, (publishableKey, clientSecret)) React.useEffect0(() => { let handle = (ev: Window.event) => { @@ -24,8 +25,9 @@ let make = () => { setLinkToken(_ => linkToken) setPmAuthConnectorsArr(_ => pmAuthConnectorArray) - setPublishableKey(_ => metaData->getString("payment_id", "")) - setPaymentId(_ => metaData->getString("publishableKey", "")) + setPublishableKey(_ => metaData->getString("publishableKey", "")) + setClientSecret(_ => metaData->getString("clientSecret", "")) + setIsForceSync(_ => metaData->getBool("isForceSync", false)) } } Window.addEventListener("message", handle) @@ -47,6 +49,50 @@ let make = () => { None }, [pmAuthConnectorsArr]) + let callbackOnSuccessOfPlaidPaymentsFlow = () => { + open Promise + let headers = [("Content-Type", "application/json"), ("api-key", publishableKey)] + + PaymentHelpers.retrievePaymentIntent( + clientSecret, + headers, + ~optLogger=Some(logger), + ~switchToCustomPod=false, + ~isForceSync=true, + ) + ->then(json => { + let dict = json->JSON.Decode.object->Option.getOr(Dict.make()) + let status = dict->getString("status", "") + let return_url = dict->getString("return_url", "") + + if ( + status === "succeeded" || status === "requires_customer_action" || status === "processing" + ) { + postSubmitResponse(~jsonData=json, ~url=return_url) + } else if status === "failed" { + postFailedSubmitResponse( + ~errortype="confirm_payment_failed", + ~message="Payment failed. Try again!", + ) + } else { + postFailedSubmitResponse( + ~errortype="sync_payment_failed", + ~message="Payment is processing. Try again later!", + ) + } + handlePostMessage([("fullscreen", false->JSON.Encode.bool)]) + resolve(json) + }) + ->then(_ => { + resolve(Nullable.null) + }) + ->catch(e => { + Console.log2("Retrieve Failed", e) + resolve(Nullable.null) + }) + ->ignore + } + React.useEffect(() => { if isReady && linkToken->String.length > 0 { let handler = Plaid.create({ @@ -59,14 +105,21 @@ let make = () => { ("isPlaid", true->JSON.Encode.bool), ("publicToken", publicToken->JSON.Encode.string), ]) + if isForceSync { + callbackOnSuccessOfPlaidPaymentsFlow() + } }, onExit: _ => { - handlePostMessage([ - ("fullscreen", false->JSON.Encode.bool), - ("isPlaid", true->JSON.Encode.bool), - ("isExited", true->JSON.Encode.bool), - ("publicToken", ""->JSON.Encode.string), - ]) + if isForceSync { + callbackOnSuccessOfPlaidPaymentsFlow() + } else { + handlePostMessage([ + ("fullscreen", false->JSON.Encode.bool), + ("isPlaid", true->JSON.Encode.bool), + ("isExited", true->JSON.Encode.bool), + ("publicToken", ""->JSON.Encode.string), + ]) + } }, }) diff --git a/src/Utilities/PaymentHelpers.res b/src/Utilities/PaymentHelpers.res index 4eb0c3af1..77151a76b 100644 --- a/src/Utilities/PaymentHelpers.res +++ b/src/Utilities/PaymentHelpers.res @@ -702,8 +702,9 @@ let rec intentCall = ( ->JSON.Encode.string, ), ("pmAuthConnectorArray", ["plaid"]->Identity.anyTypeToJson), - ("payment_id", clientSecret->getPaymentId->JSON.Encode.string), ("publishableKey", confirmParam.publishableKey->JSON.Encode.string), + ("clientSecret", clientSecret->JSON.Encode.string), + ("isForceSync", true->JSON.Encode.bool), ]->getJsonFromArrayOfJson handlePostMessage([ @@ -1707,8 +1708,9 @@ let callAuthLink = ( [ ("linkToken", data->getDictFromJson->getString("link_token", "")->JSON.Encode.string), ("pmAuthConnectorArray", pmAuthConnectorsArr->Identity.anyTypeToJson), - ("payment_id", clientSecret->Option.getOr("")->getPaymentId->JSON.Encode.string), ("publishableKey", publishableKey->JSON.Encode.string), + ("clientSecret", clientSecret->Option.getOr("")->JSON.Encode.string), + ("isForceSync", false->JSON.Encode.bool), ]->getJsonFromArrayOfJson handlePostMessage([ From df6ede588c6536b1a115a3ad3e21c4e30ae47e2d Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja Date: Wed, 7 Aug 2024 15:23:11 +0530 Subject: [PATCH 5/7] fix: remove unwanted lines --- src/Components/DynamicFields.res | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Components/DynamicFields.res b/src/Components/DynamicFields.res index f5d17ed4a..273645123 100644 --- a/src/Components/DynamicFields.res +++ b/src/Components/DynamicFields.res @@ -75,8 +75,6 @@ let make = ( }, (requiredFields, isAllStoredCardsHaveName, isSavedCardFlow)) let {config, themeObj, localeString} = Recoil.useRecoilValueFromAtom(configAtom) - let {publishableKey} = Recoil.useRecoilValueFromAtom(keys) - let switchToCustomPodValue = Recoil.useRecoilValueFromAtom(switchToCustomPod) let isSpacedInnerLayout = config.appearance.innerLayout === Spaced let logger = Recoil.useRecoilValueFromAtom(loggerAtom) From 772db297209aa1add9ca986f8b01ad7ae19b7a00 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja Date: Wed, 7 Aug 2024 16:08:12 +0530 Subject: [PATCH 6/7] fix: getDictFromJson utils added --- src/Payments/PlaidSDKIframe.res | 2 +- src/Payments/QRCodeDisplay.res | 2 +- src/ThreeDSAuth.res | 2 +- src/Utilities/PaymentHelpers.res | 4 ++-- src/orca-loader/Elements.res | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Payments/PlaidSDKIframe.res b/src/Payments/PlaidSDKIframe.res index 3857557ca..9130e6a21 100644 --- a/src/Payments/PlaidSDKIframe.res +++ b/src/Payments/PlaidSDKIframe.res @@ -61,7 +61,7 @@ let make = () => { ~isForceSync=true, ) ->then(json => { - let dict = json->JSON.Decode.object->Option.getOr(Dict.make()) + let dict = json->getDictFromJson let status = dict->getString("status", "") let return_url = dict->getString("return_url", "") diff --git a/src/Payments/QRCodeDisplay.res b/src/Payments/QRCodeDisplay.res index dbcadd077..212c826a1 100644 --- a/src/Payments/QRCodeDisplay.res +++ b/src/Payments/QRCodeDisplay.res @@ -91,7 +91,7 @@ let make = () => { ~switchToCustomPod, ) ->then(json => { - let dict = json->JSON.Decode.object->Option.getOr(Dict.make()) + let dict = json->getDictFromJson let status = dict->getString("status", "") if ( diff --git a/src/ThreeDSAuth.res b/src/ThreeDSAuth.res index 911b98406..91262087c 100644 --- a/src/ThreeDSAuth.res +++ b/src/ThreeDSAuth.res @@ -61,7 +61,7 @@ let make = () => { ~headers, ) ->then(json => { - let dict = json->JSON.Decode.object->Option.getOr(Dict.make()) + let dict = json->getDictFromJson if dict->Dict.get("error")->Option.isSome { let errorObj = PaymentError.itemToObjMapper(dict) handlePostMessage([("fullscreen", false->JSON.Encode.bool)]) diff --git a/src/Utilities/PaymentHelpers.res b/src/Utilities/PaymentHelpers.res index 77151a76b..fd7ad56af 100644 --- a/src/Utilities/PaymentHelpers.res +++ b/src/Utilities/PaymentHelpers.res @@ -176,7 +176,7 @@ let rec pollRetrievePaymentIntent = ( open Promise retrievePaymentIntent(clientSecret, headers, ~optLogger, ~switchToCustomPod, ~isForceSync) ->then(json => { - let dict = json->JSON.Decode.object->Option.getOr(Dict.make()) + let dict = json->getDictFromJson let status = dict->getString("status", "") if status === "succeeded" || status === "failed" { @@ -261,7 +261,7 @@ let rec pollStatus = ( open Promise retrieveStatus(~headers, ~switchToCustomPod, pollId, logger) ->then(json => { - let dict = json->JSON.Decode.object->Option.getOr(Dict.make()) + let dict = json->getDictFromJson let status = dict->getString("status", "") Promise.make((resolve, _) => { if status === "completed" { diff --git a/src/orca-loader/Elements.res b/src/orca-loader/Elements.res index acc9859ec..196cf7698 100644 --- a/src/orca-loader/Elements.res +++ b/src/orca-loader/Elements.res @@ -643,7 +643,7 @@ let make = ( ) ->then(json => { if redirect.contents === "always" { - let dict = json->JSON.Decode.object->Option.getOr(Dict.make()) + let dict = json->getDictFromJson let status = dict->getString("status", "") let returnUrl = dict->getString("return_url", "") Window.Location.replace( From 195a42fb9ec5086bcec67fb3d7fcb6e067ae038e Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja Date: Wed, 7 Aug 2024 17:45:57 +0530 Subject: [PATCH 7/7] fix: comments addressed --- src/Payments/PlaidSDKIframe.res | 2 +- src/Utilities/PaymentHelpers.res | 40 ++++++++++++++++---------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Payments/PlaidSDKIframe.res b/src/Payments/PlaidSDKIframe.res index 9130e6a21..43a66bf4c 100644 --- a/src/Payments/PlaidSDKIframe.res +++ b/src/Payments/PlaidSDKIframe.res @@ -87,7 +87,7 @@ let make = () => { resolve(Nullable.null) }) ->catch(e => { - Console.log2("Retrieve Failed", e) + logInfo(Console.log2("Retrieve Failed", e)) resolve(Nullable.null) }) ->ignore diff --git a/src/Utilities/PaymentHelpers.res b/src/Utilities/PaymentHelpers.res index fd7ad56af..253f1a17b 100644 --- a/src/Utilities/PaymentHelpers.res +++ b/src/Utilities/PaymentHelpers.res @@ -693,33 +693,33 @@ let rec intentCall = ( | None => Dict.make() } let walletName = session_token->getString("wallet_name", "") - if walletName === "open_banking" { - let metaData = [ - ( - "linkToken", - session_token - ->getString("open_banking_session_token", "") - ->JSON.Encode.string, - ), - ("pmAuthConnectorArray", ["plaid"]->Identity.anyTypeToJson), - ("publishableKey", confirmParam.publishableKey->JSON.Encode.string), - ("clientSecret", clientSecret->JSON.Encode.string), - ("isForceSync", true->JSON.Encode.bool), - ]->getJsonFromArrayOfJson - handlePostMessage([ - ("fullscreen", true->JSON.Encode.bool), - ("param", "plaidSDK"->JSON.Encode.string), - ("iframeId", iframeId->JSON.Encode.string), - ("metadata", metaData), - ]) - } let message = switch walletName { | "apple_pay" => [ ("applePayButtonClicked", true->JSON.Encode.bool), ("applePayPresent", session_token->anyTypeToJson), ] | "google_pay" => [("googlePayThirdPartyFlow", session_token->anyTypeToJson)] + | "open_banking" => { + let metaData = [ + ( + "linkToken", + session_token + ->getString("open_banking_session_token", "") + ->JSON.Encode.string, + ), + ("pmAuthConnectorArray", ["plaid"]->Identity.anyTypeToJson), + ("publishableKey", confirmParam.publishableKey->JSON.Encode.string), + ("clientSecret", clientSecret->JSON.Encode.string), + ("isForceSync", true->JSON.Encode.bool), + ]->getJsonFromArrayOfJson + [ + ("fullscreen", true->JSON.Encode.bool), + ("param", "plaidSDK"->JSON.Encode.string), + ("iframeId", iframeId->JSON.Encode.string), + ("metadata", metaData), + ] + } | _ => [] }