,
+ ~savedMethod=PaymentType.defaultCustomerMethods,
~cardProps=None,
~expiryProps=None,
~cvcProps=None,
@@ -46,8 +46,8 @@ let make = (
}, [requiredFieldsWithBillingDetails])
let isAllStoredCardsHaveName = React.useMemo1(() => {
- PaymentType.getIsAllStoredCardsHaveName(savedCards)
- }, [savedCards])
+ PaymentType.getIsStoredPaymentMethodHasName(savedMethod)
+ }, [savedMethod])
//<...>//
let fieldsArr = React.useMemo3(() => {
@@ -509,7 +509,6 @@ let make = (
}}
onChange=onPostalChange
paymentType
- type_="tel"
name="postal"
inputRef=postalRef
placeholder=localeString.postalCodeLabel
@@ -622,7 +621,6 @@ let make = (
}}
onChange=onPostalChange
paymentType
- type_="tel"
name="postal"
inputRef=postalRef
placeholder=localeString.postalCodeLabel
diff --git a/src/Components/NicknamePaymentInput.res b/src/Components/NicknamePaymentInput.res
index 941a26df7..c2b6abda0 100644
--- a/src/Components/NicknamePaymentInput.res
+++ b/src/Components/NicknamePaymentInput.res
@@ -13,7 +13,7 @@ let make = (~paymentType: CardThemeType.mode, ~value, ~setValue) => {
onChange
paymentType
appearance=config.appearance
- inputRef={React.useRef(Js.Nullable.null)}
+ inputRef={React.useRef(Nullable.null)}
placeholder=localeString.nicknamePlaceholder
/>
}
diff --git a/src/Components/SavedCardItem.res b/src/Components/SavedCardItem.res
index 9dff89ff1..d14cd0cfa 100644
--- a/src/Components/SavedCardItem.res
+++ b/src/Components/SavedCardItem.res
@@ -9,7 +9,6 @@ let make = (
~cvcProps,
~paymentType,
~list,
- ~savedMethods,
~setRequiredFieldsBody,
) => {
let {themeObj, config} = Recoil.useRecoilValueFromAtom(RecoilAtoms.configAtom)
@@ -51,7 +50,7 @@ let make = (
let isRenderCvv = isCard && paymentItem.requiresCvv
let paymentMethodType = switch paymentItem.paymentMethodType {
- | Some(paymentMethodType) => paymentMethodType->Utils.snakeToTitleCase
+ | Some(paymentMethodType) => paymentMethodType
| None => "debit"
}
@@ -101,7 +100,7 @@ let make = (
{React.string(paymentItem.card.last4Digits)}
- : {React.string(paymentMethodType)}
}
+ : {React.string(paymentMethodType->Utils.snakeToTitleCase)}
}
})
diff --git a/src/PaymentElement.res b/src/PaymentElement.res
index 2a2a87a4d..b38b99f62 100644
--- a/src/PaymentElement.res
+++ b/src/PaymentElement.res
@@ -388,11 +388,6 @@ let make = (
}
- React.useEffect(() => {
- setShowFields(_ => !displaySavedPaymentMethods)
- None
- }, [displaySavedPaymentMethods])
-
let paymentLabel = if displaySavedPaymentMethods {
showFields
? optionAtomValue.paymentMethodsHeaderText
diff --git a/src/Payments/ApplePay.res b/src/Payments/ApplePay.res
index 2dc6b59e6..04b77fcce 100644
--- a/src/Payments/ApplePay.res
+++ b/src/Payments/ApplePay.res
@@ -333,7 +333,7 @@ let make = (
None
}, (isApplePayReady, isInvokeSDKFlow, paymentExperience, isWallet))
- let submitCallback = (ev: Window.event) => {
+ let submitCallback = React.useCallback((ev: Window.event) => {
if !isWallet {
let json = ev.data->JSON.parseExn
let confirm = json->getDictFromJson->ConfirmType.itemToObjMapper
@@ -353,7 +353,7 @@ let make = (
)
}
}
- }
+ }, (areRequiredFieldsValid, areRequiredFieldsEmpty))
useSubmitPaymentData(submitCallback)
{
diff --git a/src/ThreeDSAuth.res b/src/ThreeDSAuth.res
new file mode 100644
index 000000000..3f00fe92e
--- /dev/null
+++ b/src/ThreeDSAuth.res
@@ -0,0 +1,91 @@
+open Utils
+
+@react.component
+let make = () => {
+ let (openModal, setOpenModal) = React.useState(_ => false)
+ let (loader, setloader) = React.useState(_ => true)
+
+ let logger = Recoil.useRecoilValueFromAtom(RecoilAtoms.loggerAtom)
+
+ React.useEffect0(() => {
+ handlePostMessage([("iframeMountedCallback", true->JSON.Encode.bool)])
+ let handle = (ev: Window.event) => {
+ let json = ev.data->JSON.parseExn
+ let dict = json->Utils.getDictFromJson
+ if dict->Dict.get("fullScreenIframeMounted")->Option.isSome {
+ let metadata = dict->getJsonObjectFromDict("metadata")
+ let metaDataDict = metadata->JSON.Decode.object->Option.getOr(Dict.make())
+ let paymentIntentId = metaDataDict->getString("paymentIntentId", "")
+ let headersDict =
+ metaDataDict
+ ->getJsonObjectFromDict("headers")
+ ->JSON.Decode.object
+ ->Option.getOr(Dict.make())
+ let threeDsAuthoriseUrl =
+ metaDataDict
+ ->getJsonObjectFromDict("threeDSData")
+ ->JSON.Decode.object
+ ->Option.getOr(Dict.make())
+ ->getString("three_ds_authorize_url", "")
+ let headers =
+ headersDict
+ ->Dict.toArray
+ ->Array.map(entries => {
+ let (x, val) = entries
+ (x, val->JSON.Decode.string->Option.getOr(""))
+ })
+
+ let threeDsMethodComp = metaDataDict->getString("3dsMethodComp", "U")
+ open Promise
+ PaymentHelpers.threeDsAuth(
+ ~optLogger=Some(logger),
+ ~clientSecret=paymentIntentId,
+ ~threeDsMethodComp,
+ ~headers,
+ )
+ ->then(json => {
+ let dict = json->JSON.Decode.object->Option.getOr(Dict.make())
+ let creq = dict->getString("challenge_request", "")
+ let transStatus = dict->getString("trans_status", "Y")
+ let acsUrl = dict->getString("acs_url", "")
+
+ let ele = Window.querySelector("#threeDsAuthDiv")
+
+ switch ele->Nullable.toOption {
+ | Some(elem) =>
+ if transStatus === "C" {
+ setloader(_ => false)
+ let form = elem->OrcaUtils.makeForm(acsUrl, "3dsChallenge")
+ let input = Types.createElement("input")
+ input.name = "creq"
+ input.value = creq
+ form.target = "threeDsAuthFrame"
+ form.appendChild(input)
+ form.submit()
+ } else {
+ let form1 = elem->OrcaUtils.makeForm(threeDsAuthoriseUrl, "3dsFrintionLess")
+ form1.submit()
+ }
+ | None => ()
+ }
+ resolve(json)
+ })
+ ->ignore
+ }
+ }
+ Window.addEventListener("message", handle)
+ Some(() => {Window.removeEventListener("message", handle)})
+ })
+
+
+
+
+}
diff --git a/src/ThreeDSMethod.res b/src/ThreeDSMethod.res
new file mode 100644
index 000000000..7255e39af
--- /dev/null
+++ b/src/ThreeDSMethod.res
@@ -0,0 +1,93 @@
+open Utils
+@react.component
+let make = () => {
+ let logger = Recoil.useRecoilValueFromAtom(RecoilAtoms.loggerAtom)
+
+ let mountToInnerHTML = innerHTML => {
+ let ele = Window.querySelector("#threeDsInvisibleIframe")
+ switch ele->Nullable.toOption {
+ | Some(elem) => elem->Window.innerHTML(innerHTML)
+ | None =>
+ Console.warn(
+ "INTEGRATION ERROR: Div does not seem to exist on which threeDSMethod is to be mounted",
+ )
+ }
+ }
+
+ React.useEffect0(() => {
+ handlePostMessage([("iframeMountedCallback", true->JSON.Encode.bool)])
+ let handle = (ev: Window.event) => {
+ let json = ev.data->JSON.parseExn
+ let dict = json->Utils.getDictFromJson
+ if dict->Dict.get("fullScreenIframeMounted")->Option.isSome {
+ let metadata = dict->getJsonObjectFromDict("metadata")
+ let metaDataDict = metadata->JSON.Decode.object->Option.getOr(Dict.make())
+ let threeDsDataDict =
+ metaDataDict
+ ->Dict.get("threeDSData")
+ ->Belt.Option.flatMap(JSON.Decode.object)
+ ->Option.getOr(Dict.make())
+ let threeDsUrl =
+ threeDsDataDict
+ ->Dict.get("three_ds_method_details")
+ ->Belt.Option.flatMap(JSON.Decode.object)
+ ->Belt.Option.flatMap(x => x->Dict.get("three_ds_method_url"))
+ ->Belt.Option.flatMap(JSON.Decode.string)
+ ->Option.getOr("")
+ let threeDsMethodData =
+ threeDsDataDict
+ ->Dict.get("three_ds_method_details")
+ ->Belt.Option.flatMap(JSON.Decode.object)
+ ->Belt.Option.flatMap(x => x->Dict.get("three_ds_method_data"))
+ ->Option.getOr(Dict.make()->JSON.Encode.object)
+ let iframeId = metaDataDict->getString("iframeId", "")
+
+ open Promise
+ PaymentHelpers.threeDsMethod(threeDsUrl, threeDsMethodData, ~optLogger=Some(logger))
+ ->then(res => {
+ mountToInnerHTML(res)
+ resolve(res)
+ })
+ ->then(res => {
+ metadata->Utils.getDictFromJson->Dict.set("3dsMethodComp", "Y"->JSON.Encode.string)
+ handlePostMessage([
+ ("fullscreen", true->JSON.Encode.bool),
+ ("param", `3dsAuth`->JSON.Encode.string),
+ ("iframeId", iframeId->JSON.Encode.string),
+ ("metadata", metadata),
+ ])
+ resolve(res)
+ })
+ ->catch(e => {
+ metadata->Utils.getDictFromJson->Dict.set("3dsMethodComp", "N"->JSON.Encode.string)
+ handlePostMessage([
+ ("fullscreen", true->JSON.Encode.bool),
+ ("param", `3dsAuth`->JSON.Encode.string),
+ ("iframeId", iframeId->JSON.Encode.string),
+ ("metadata", metadata),
+ ])
+ reject(e)
+ })
+ ->ignore
+
+ let headersDict =
+ metaDataDict
+ ->getJsonObjectFromDict("headers")
+ ->JSON.Decode.object
+ ->Option.getOr(Dict.make())
+ let headers = Dict.make()
+
+ headersDict
+ ->Dict.toArray
+ ->Array.forEach(entries => {
+ let (x, val) = entries
+ Dict.set(headers, x, val->JSON.Decode.string->Option.getOr(""))
+ })
+ }
+ }
+ Window.addEventListener("message", handle)
+ Some(() => {Window.removeEventListener("message", handle)})
+ })
+
+
+}
diff --git a/src/Types/PaymentConfirmTypes.res b/src/Types/PaymentConfirmTypes.res
index 59202a67a..caa90596a 100644
--- a/src/Types/PaymentConfirmTypes.res
+++ b/src/Types/PaymentConfirmTypes.res
@@ -39,6 +39,7 @@ type nextAction = {
bank_transfer_steps_and_charges_details: option,
session_token: option,
image_data_url: option,
+ three_ds_data: option,
voucher_details: option,
display_to_timestamp: option,
}
@@ -63,6 +64,7 @@ let defaultNextAction = {
bank_transfer_steps_and_charges_details: None,
session_token: None,
image_data_url: None,
+ three_ds_data: None,
voucher_details: None,
display_to_timestamp: None,
}
@@ -140,6 +142,11 @@ let getNextAction = (dict, str) => {
getJsonObjFromDict(json, "session_token", Dict.make())->JSON.Encode.object,
),
image_data_url: Some(json->getString("image_data_url", "")),
+ three_ds_data: Some(
+ json
+ ->Dict.get("three_ds_data")
+ ->Option.getOr(Dict.make()->JSON.Encode.object),
+ ),
display_to_timestamp: Some(
json
->Dict.get("display_to_timestamp")
diff --git a/src/Types/PaymentType.res b/src/Types/PaymentType.res
index 7b031ebf1..98fc092a7 100644
--- a/src/Types/PaymentType.res
+++ b/src/Types/PaymentType.res
@@ -974,14 +974,6 @@ let itemToObjMapper = (dict, logger) => {
type loadType = Loading | Loaded(JSON.t) | SemiLoaded | LoadError(JSON.t)
-let getIsAllStoredCardsHaveName = (savedCards: array) => {
- savedCards
- ->Array.filter(savedCard => {
- switch savedCard.card.cardHolderName {
- | None
- | Some("") => false
- | _ => true
- }
- })
- ->Array.length === savedCards->Array.length
+let getIsStoredPaymentMethodHasName = (savedMethod: customerMethods) => {
+ savedMethod.card.cardHolderName->Option.getOr("")->String.length > 0
}
diff --git a/src/Utilities/ApiEndpoint.res b/src/Utilities/ApiEndpoint.res
index effeb52e9..ef14526f1 100644
--- a/src/Utilities/ApiEndpoint.res
+++ b/src/Utilities/ApiEndpoint.res
@@ -2,7 +2,7 @@ let switchToInteg = false
let isLocal = false
let sdkDomainUrl = `${GlobalVars.sdkUrl}${GlobalVars.repoPublicPath}`
-let apiEndPoint = ref(None)
+let apiEndPoint: ref