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": "1.2.4",
"version": "1.3.4",
"main": "dist/bundle.js",
"files": [
"dist/",
Expand Down
9 changes: 7 additions & 2 deletions src/Context.bs.js

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

5 changes: 4 additions & 1 deletion src/Context.res
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ type switchContextType = {
paymentRequest: JSON.t => JSON.t,
completeUpdateIntent: string => promise<JSON.t>,
initiateUpdateIntent: unit => promise<JSON.t>,
confirmTokenization: JSON.t => Promise.t<JSON.t>,
}

type paymentMethodsManagementSwitchContextType = {
Expand All @@ -90,6 +91,7 @@ type paymentMethodsManagementSwitchContextType = {
let confirmPaymentFn = (_elements: JSON.t) => {
Promise.resolve(Dict.make()->JSON.Encode.object)
}

let confirmCardPaymentFn = (
_clientSecretId: string,
_data: option<JSON.t>,
Expand All @@ -113,6 +115,7 @@ let defaultSwitchContext = {
paymentRequest,
completeUpdateIntent: _ => Promise.resolve(Dict.make()->JSON.Encode.object),
initiateUpdateIntent: _ => Promise.resolve(Dict.make()->JSON.Encode.object),
confirmTokenization: _ => Promise.resolve(Dict.make()->JSON.Encode.object),
}

let switchContext = React.createContext(defaultSwitchContext)
Expand All @@ -131,7 +134,7 @@ let paymentMethodsManagementSwitchContext = React.createContext(
)

module PaymentMethodsManagementSwitchContextProvider = {
let make = React.Context.provider(paymentMethodsManagementSwitchContext)
let make = React.Context.provider(switchContext)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let defaultPaymentMethodsManagementSwitchContext = {
  ephemeralKey: "",
  paymentRequest,
}

do we need to add ephemeralKey: "" in defaultSwitchContext?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked and tested this so we do not need the switch context to have this value since its not needed and used
cc: @ArushKapoorJuspay

}

let getString = (dict, key, defaultVal) => {
Expand Down
1 change: 1 addition & 0 deletions src/OrcaJs.res
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ type switchInstance = {
paymentMethodsManagementElements: JSON.t => element,
completeUpdateIntent: string => promise<JSON.t>,
initiateUpdateIntent: unit => promise<JSON.t>,
confirmTokenization: JSON.t => Promise.t<JSON.t>,
}
4 changes: 3 additions & 1 deletion src/components/Elements.bs.js

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

1 change: 1 addition & 0 deletions src/components/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ let make = (~children, ~stripe: Promise.t<OrcaJs.switchInstance>, ~options: JSON
paymentRequest: switchInstance.paymentRequest,
completeUpdateIntent: switchInstance.completeUpdateIntent,
initiateUpdateIntent: switchInstance.initiateUpdateIntent,
confirmTokenization: switchInstance.confirmTokenization,
}

setSwitchState(_ => switchValClone)
Expand Down
4 changes: 3 additions & 1 deletion src/components/HyperElements.bs.js

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

1 change: 1 addition & 0 deletions src/components/HyperElements.res
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ let make = (~children, ~hyper: Promise.t<OrcaJs.switchInstance>, ~options: JSON.
paymentRequest: switchInstance.paymentRequest,
completeUpdateIntent: switchInstance.completeUpdateIntent,
initiateUpdateIntent: switchInstance.initiateUpdateIntent,
confirmTokenization: switchInstance.confirmTokenization,
}

setSwitchState(_ => switchValClone)
Expand Down
19 changes: 15 additions & 4 deletions src/components/HyperManagementElements.bs.js

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

14 changes: 9 additions & 5 deletions src/components/HyperManagementElements.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
let make = (~children, ~hyper: Promise.t<OrcaJs.switchInstance>, ~options: JSON.t) => {
let paymentMethodsManagementElementOptions =
options->Context.paymentMethodsManagementElementsOptionObjMapper
let (switchState, setSwitchState) = React.useState(() =>
Context.defaultPaymentMethodsManagementSwitchContext
)
let (switchState, setSwitchState) = React.useState(() => Context.defaultSwitchContext)
let (elementsState, setElementsState) = React.useState(() =>
Context.defaultPaymentMethodsManagementElementsContext
)
Expand All @@ -21,9 +19,15 @@ let make = (~children, ~hyper: Promise.t<OrcaJs.switchInstance>, ~options: JSON.
create: orcaElementsConfig.create,
}

let switchValClone: Context.paymentMethodsManagementSwitchContextType = {
let switchValClone: Context.switchContextType = {
confirmPayment: switchInstance.confirmPayment,
confirmCardPayment: switchInstance.confirmCardPayment,
retrievePaymentIntent: switchInstance.retrievePaymentIntent,
clientSecret: "",
paymentRequest: switchInstance.paymentRequest,
ephemeralKey: paymentMethodsManagementElementOptions.ephemeralKey,
completeUpdateIntent: switchInstance.completeUpdateIntent,
initiateUpdateIntent: switchInstance.initiateUpdateIntent,
confirmTokenization: switchInstance.confirmTokenization,
Comment on lines +22 to +30
Copy link

@aritro2002 aritro2002 Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ephemeralKey support will be needed for paymentMethodsManagement, right?

Image Image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On testing this i found out that even though we have client secret value but its not needed or consumed anywhere since its provided in element options and not from the switch context, so we do not need to add the ephemeral key here since its not needed
cc: @ArushKapoorJuspay

}
setSwitchState(_ => switchValClone)
setElementsState(_ => newElemValues)
Expand Down
Loading