Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 dist/bundle.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@juspay-tech/react-hyper-js",
"version": "2.8.0",
"version": "2.9.0",
"main": "dist/bundle.js",
"files": [
"dist/",
Expand Down
18 changes: 9 additions & 9 deletions src/Context.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions src/Context.res
Original file line number Diff line number Diff line change
Expand Up @@ -254,25 +254,25 @@ module CardFormContextProvider = {
let make = React.Context.provider(cardFormContext)
}

type paymentMethodsSessionContextType = {
session: option<OrcaJs.paymentMethodsSession>,
type paymentMethodSessionContextType = {
session: option<OrcaJs.initPaymentMethodSession>,
isPresent: bool,
}

let defaultPaymentMethodsSessionContext: paymentMethodsSessionContextType = {
let defaultPaymentMethodSessionContext: paymentMethodSessionContextType = {
session: None,
isPresent: false,
}

let pendingPaymentMethodsSessionContext: paymentMethodsSessionContextType = {
...defaultPaymentMethodsSessionContext,
let pendingPaymentMethodSessionContext: paymentMethodSessionContextType = {
...defaultPaymentMethodSessionContext,
isPresent: true,
}

let paymentMethodsSessionContext = React.createContext(defaultPaymentMethodsSessionContext)
let paymentMethodSessionContext = React.createContext(defaultPaymentMethodSessionContext)

module PaymentMethodsSessionContextProvider = {
let make = React.Context.provider(paymentMethodsSessionContext)
module PaymentMethodSessionContextProvider = {
let make = React.Context.provider(paymentMethodSessionContext)
}

let paymentMethodsManagementElementsOptionObjMapper = (options: JSON.t) => {
Expand Down
12 changes: 6 additions & 6 deletions src/Index.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/Index.res
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ let useWidgets = () => {
let useCardForm = () => {
React.useContext(Context.cardFormContext)
}
let usePaymentMethodsSession = () => {
React.useContext(Context.paymentMethodsSessionContext)
let usePaymentMethodSession = () => {
React.useContext(Context.paymentMethodSessionContext)
}
let useElements = () => {
Console.warn("useElements() is deprecated. Use useWidgets() instead")
Expand All @@ -43,7 +43,7 @@ let \"Elements" = Elements.make

let \"HyperElements" = HyperElements.make

let \"HyperPaymentMethodsSession" = HyperPaymentMethodsSession.make
let \"HyperPaymentMethodSession" = HyperPaymentMethodSession.make

let \"CardForm" = CardForm.make

Expand Down
4 changes: 2 additions & 2 deletions src/Index.resi
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let useWidgets: unit => Context.elementsType
let useElements: unit => Context.elementsType
let usePaymentSession: unit => Context.paymentSessionContextType
let useCardForm: unit => Context.cardFormContextType
let usePaymentMethodsSession: unit => Context.paymentMethodsSessionContextType
let usePaymentMethodSession: unit => Context.paymentMethodSessionContextType
let initPaymentSession: (
promise<OrcaJs.switchInstance>,
RescriptCore.JSON.t,
Expand All @@ -28,7 +28,7 @@ let \"HyperElements": HyperElements.props<
RescriptCore.Promise.t<OrcaJs.switchInstance>,
RescriptCore.JSON.t,
> => React.element
let \"HyperPaymentMethodsSession": HyperPaymentMethodsSession.props<
let \"HyperPaymentMethodSession": HyperPaymentMethodSession.props<
React.element,
RescriptCore.Promise.t<OrcaJs.switchInstance>,
RescriptCore.JSON.t,
Expand Down
4 changes: 2 additions & 2 deletions src/OrcaJs.res
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type vaultCardForm = {
fields: ref<JSON.t>,
}

type paymentMethodsSession = {
type initPaymentMethodSession = {
createCardForm: unit => vaultCardForm,
update: JSON.t => unit,
on: (string, JSON.t => unit) => unit,
Expand Down Expand Up @@ -129,7 +129,7 @@ type switchInstance = {
completeUpdateIntent: string => promise<JSON.t>,
initiateUpdateIntent: unit => promise<JSON.t>,
confirmTokenization: JSON.t => Promise.t<JSON.t>,
paymentMethodsSession: JSON.t => paymentMethodsSession,
initPaymentMethodSession: JSON.t => initPaymentMethodSession,
}

type paymentElementProps = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/CardForm.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/components/CardForm.res
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let make = React.forwardRef((
imperativeRef,
) => {
let elementsState = React.useContext(Context.elementsContext)
let sessionState = React.useContext(Context.paymentMethodsSessionContext)
let sessionState = React.useContext(Context.paymentMethodSessionContext)
let createdRef = React.useRef(false)
let (cardFormValue, setCardFormValue) = React.useState(() => Context.defaultCardFormContext)

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
@react.component
let make = (~children, ~hyper: Promise.t<OrcaJs.switchInstance>, ~options: JSON.t) => {
let (sessionState, setSessionState) = React.useState(() =>
Context.pendingPaymentMethodsSessionContext
Context.pendingPaymentMethodSessionContext
)

React.useEffect(() => {
Promise.all2((hyper, options->Utils.normalizeToPromise))
->Promise.then(((switchInstance: OrcaJs.switchInstance, resolvedOptions)) => {
let session = switchInstance.paymentMethodsSession(resolvedOptions)
let newSessionValues: Context.paymentMethodsSessionContextType = {
let session = switchInstance.initPaymentMethodSession(resolvedOptions)
let newSessionValues: Context.paymentMethodSessionContextType = {
session: Some(session),
isPresent: true,
}
setSessionState(_ => newSessionValues)
Promise.resolve(newSessionValues)
})
->Promise.catch(err => {
Console.error2("[HyperPaymentMethodsSession] Failed to initialise hyper promise:", err)
Promise.resolve(Context.pendingPaymentMethodsSessionContext)
Console.error2("[HyperPaymentMethodSession] Failed to initialise hyper promise:", err)
Promise.resolve(Context.pendingPaymentMethodSessionContext)
})
->ignore
None
}, (hyper, options))

<Context.PaymentMethodsSessionContextProvider value={sessionState}>
<Context.PaymentMethodSessionContextProvider value={sessionState}>
{children}
</Context.PaymentMethodsSessionContextProvider>
</Context.PaymentMethodSessionContextProvider>
}
Loading