Skip to content

Commit

Permalink
fix: apple pay map type (#801)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeevaRamu0104 authored Jun 6, 2024
1 parent 21c7370 commit 7da9f5b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/screens/Connectors/ConnectorPaymentMethod.res
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ let make = (
connectorID->Option.getOr(""),
connectorIgnoredField,
)
// Need to refactor
let metaData = body->getDictFromJsonObject->getDictfromDict("metadata")->JSON.Encode.object
let _ = ConnectorUtils.updateMetaData(~metaData)
//
let connectorUrl = getURL(~entityName=CONNECTOR, ~methodType=Post, ~id=connectorID, ())
let response = await updateAPIHook(connectorUrl, body, Post, ())
setInitialValues(_ => response)
Expand Down
20 changes: 20 additions & 0 deletions src/screens/Connectors/ConnectorUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -1489,3 +1489,23 @@ let existsInArray = (element, connectorList) => {
}
)
}

// Need to refactor

let updateMetaData = (~metaData) => {
open LogicUtils
let apple_pay_combined = metaData->getDictFromJsonObject->getDictfromDict("apple_pay_combined")
let manual = apple_pay_combined->getDictfromDict("manual")
switch manual->Dict.keysToArray->Array.length > 0 {
| true => {
let applepay =
manual
->getDictfromDict("session_token_data")
->JSON.Encode.object
->Identity.jsonToAnyType
->convertMapObjectToDict
manual->Dict.set("session_token_data", applepay->JSON.Encode.object)
}
| false => ()
}
}
2 changes: 2 additions & 0 deletions src/screens/Connectors/Wallets/ApplePayWalletIntegration.res
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ module Manual = {
open LogicUtils
open ApplePayWalletIntegrationUtils
open FormRenderer
// Need to refactor
let _ = ConnectorUtils.updateMetaData(~metaData)
let configurationFields =
metadataInputs
->getDictfromDict("apple_pay")
Expand Down
14 changes: 9 additions & 5 deletions src/utils/LogicUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,15 @@ let getDictFromJsonObject = json => {
}

let convertMapObjectToDict = genericTypeMapVal => {
open MapTypes
let map = create(genericTypeMapVal)
let mapIterator = map.entries(.)
let dict = object.fromEntries(. mapIterator)->getDictFromJsonObject
dict
try {
open MapTypes
let map = create(genericTypeMapVal)
let mapIterator = map.entries(.)
let dict = object.fromEntries(. mapIterator)->getDictFromJsonObject
dict
} catch {
| _ => genericTypeMapVal
}
}

let removeDuplicate = (arr: array<string>) => {
Expand Down

0 comments on commit 7da9f5b

Please sign in to comment.