Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: promise core changes #236

Merged
merged 4 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Components/NicknamePaymentInput.res
Original file line number Diff line number Diff line change
Expand Up @@ -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
/>
}
14 changes: 7 additions & 7 deletions src/Utilities/PaymentHelpers.res
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ let rec intentCall = (
res
->Fetch.Response.json
->then(data => {
Js.Promise.make(
(~resolve, ~reject as _) => {
Promise.make(
(resolve, _) => {
if isConfirm {
let paymentMethod = switch paymentType {
| Card => "CARD"
Expand Down Expand Up @@ -210,8 +210,8 @@ let rec intentCall = (
)->then(resolve)
})
->catch(err => {
Js.Promise.make(
(~resolve, ~reject as _) => {
Promise.make(
(resolve, _) => {
let exceptionMessage = err->Utils.formatException
logApi(
~optLogger,
Expand Down Expand Up @@ -279,8 +279,8 @@ let rec intentCall = (
res
->Fetch.Response.json
->then(data => {
Js.Promise.make(
(~resolve, ~reject as _) => {
Promise.make(
(resolve, _) => {
logApi(~optLogger, ~url=uri, ~statusCode, ~type_="response", ~eventName, ())
let intent = PaymentConfirmTypes.itemToObjMapper(data->getDictFromJson)
let paymentMethod = switch paymentType {
Expand Down Expand Up @@ -488,7 +488,7 @@ let rec intentCall = (
}
})
->catch(err => {
Js.Promise.make((~resolve, ~reject as _) => {
Promise.make((resolve, _) => {
let url = urlSearch(confirmParam.return_url)
url.searchParams.set("payment_intent_client_secret", clientSecret)
url.searchParams.set("status", "failed")
Expand Down
2 changes: 1 addition & 1 deletion src/orca-loader/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ let make = (
})
}
let fetchUpdates = () => {
Js.Promise.make((~resolve, ~reject as _) => {
Promise.make((resolve, _) => {
setTimeout(() => resolve(Dict.make()->JSON.Encode.object), 1000)->ignore
})
}
Expand Down
8 changes: 4 additions & 4 deletions src/orca-loader/Hyper.res
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ let make = (publishableKey, options: option<JSON.t>, analyticsInfo: option<JSON.
->Option.flatMap(JSON.Decode.string)
->Option.getOr("")

Js.Promise.make((~resolve, ~reject as _) => {
Promise.make((resolve, _) => {
let handleMessage = (event: Types.event) => {
let json = event.data->eventToJson
let dict = json->getDictFromJson
Expand Down Expand Up @@ -355,7 +355,7 @@ let make = (publishableKey, options: option<JSON.t>, analyticsInfo: option<JSON.
->Option.flatMap(JSON.Decode.string)
->Option.getOr("")
clientSecret := clientSecretId
Js.Promise.make((~resolve, ~reject as _) => {
Promise.make((resolve, _) => {
logger.setClientSecret(clientSecretId)
resolve(JSON.Encode.null)
})
Expand All @@ -381,7 +381,7 @@ let make = (publishableKey, options: option<JSON.t>, analyticsInfo: option<JSON.
_options: option<JSON.t>,
) => {
let decodedData = data->Option.flatMap(JSON.Decode.object)->Option.getOr(Dict.make())
Js.Promise.make((~resolve, ~reject as _) => {
Promise.make((resolve, _) => {
iframeRef.contents
->Array.map(iframe => {
iframe->Window.iframePostMessage(
Expand Down Expand Up @@ -499,7 +499,7 @@ let make = (publishableKey, options: option<JSON.t>, analyticsInfo: option<JSON.
->Option.flatMap(JSON.Decode.string)
->Option.getOr("")
clientSecret := clientSecretId
Js.Promise.make((~resolve, ~reject as _) => {
Promise.make((resolve, _) => {
logger.setClientSecret(clientSecretId)
resolve(JSON.Encode.null)
})
Expand Down
4 changes: 2 additions & 2 deletions src/orca-loader/OrcaUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ let eventHandlerFunc = (

let makeIframe = (element, url) => {
open Types
Js.Promise.make((~resolve, ~reject as _) => {
Promise.make((resolve, _) => {
let iframe = createElement("iframe")
iframe.id = "orca-fullscreen"
iframe.src = url
Expand Down Expand Up @@ -325,7 +325,7 @@ let getArrayOfTupleFromDict = dict => {

let makeOneClickHandlerPromise = sdkHandleOneClickConfirmPayment => {
open EventListenerManager
Js.Promise.make((~resolve, ~reject as _) => {
Promise.make((resolve, _) => {
if sdkHandleOneClickConfirmPayment {
resolve(JSON.Encode.bool(true))
} else {
Expand Down
10 changes: 5 additions & 5 deletions src/orca-loader/Types.res
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type hyperInstance = {
confirmPayment: JSON.t => Promise.t<JSON.t>,
elements: JSON.t => element,
confirmCardPayment: (string, option<JSON.t>, option<JSON.t>) => Promise.t<JSON.t>,
retrievePaymentIntent: string => Js.Promise.t<JSON.t>,
retrievePaymentIntent: string => Promise.t<JSON.t>,
widgets: JSON.t => element,
paymentRequest: JSON.t => JSON.t,
initPaymentSession: JSON.t => initPaymentSession,
Expand Down Expand Up @@ -91,7 +91,7 @@ let getElement = _componentName => {
}

let fetchUpdates = () => {
Js.Promise.make((~resolve, ~reject as _) => {
Promise.make((resolve, _) => {
setTimeout(() => resolve(Dict.make()->JSON.Encode.object), 1000)->ignore
})
}
Expand Down Expand Up @@ -123,16 +123,16 @@ let getCustomerDefaultSavedPaymentMethodData = () => {
}

let confirmWithCustomerDefaultPaymentMethod = _confirmParams => {
Js.Promise.resolve(Dict.make()->JSON.Encode.object)
Promise.resolve(Dict.make()->JSON.Encode.object)
}

let defaultGetCustomerSavedPaymentMethods = () => {
// TODO: After rescript migration to v11, add this without TAG using enums
// Js.Promise.resolve({
// Promise.resolve({
PritishBudhiraja marked this conversation as resolved.
Show resolved Hide resolved
// getCustomerDefaultSavedPaymentMethodData,
// confirmWithCustomerDefaultPaymentMethod,
// })
Js.Promise.resolve(JSON.Encode.null)
Promise.resolve(JSON.Encode.null)
}

let defaultInitPaymentSession: initPaymentSession = {
Expand Down
Loading