diff --git a/Hyperswitch-React-Demo-App/src/something.js b/Hyperswitch-React-Demo-App/src/something.js
index 48a40c320..5ecac09bf 100644
--- a/Hyperswitch-React-Demo-App/src/something.js
+++ b/Hyperswitch-React-Demo-App/src/something.js
@@ -8,8 +8,8 @@ export const loadSDK = (clientSecret, pubkey) => {
const appearance = {
theme: "charcoal",
};
- const ephimeralKey = "epk_199235de39aa4ca08c596a98635e6bbb";
- const widgets = hyper.widgets({ appearance, clientSecret, ephimeralKey });
+ const ephemeralKey = "epk_8dd34bfa79b1483b9f9a56ba9ad23009";
+ const widgets = hyper.widgets({ appearance, clientSecret, ephemeralKey });
const unifiedCheckoutOptions = {
layout: "tabs",
wallets: {
diff --git a/src/RenderPaymentMethods.res b/src/RenderPaymentMethods.res
index 4bf4da3f6..ca3fd3e01 100644
--- a/src/RenderPaymentMethods.res
+++ b/src/RenderPaymentMethods.res
@@ -149,6 +149,7 @@ let make = (
}>
+ | PaymentRequestButtonsElement
| NONE => React.null
}}
diff --git a/src/orca-loader/Hyper.res b/src/orca-loader/Hyper.res
index 30bb77a22..b31137742 100644
--- a/src/orca-loader/Hyper.res
+++ b/src/orca-loader/Hyper.res
@@ -614,6 +614,7 @@ let make = (publishableKey, options: option, analyticsInfo: option) => {
+let make = (
+ options,
+ ~clientSecret,
+ ~publishableKey,
+ ~logger: option,
+ ~ephemeralKey,
+) => {
let logger = logger->Option.getOr(OrcaLogger.defaultLoggerConfig)
let switchToCustomPod =
GlobalVars.isInteg &&
@@ -20,6 +26,13 @@ let make = (options, ~clientSecret, ~publishableKey, ~logger: option
+ PaymentSessionMethods.getPaymentManagementMethods(
+ ~ephemeralKey,
+ ~logger,
+ ~switchToCustomPod,
+ ~endpoint,
+ ),
}
defaultInitPaymentSession
diff --git a/src/orca-loader/PaymentSessionMethods.res b/src/orca-loader/PaymentSessionMethods.res
index bd6c2d983..4aa448512 100644
--- a/src/orca-loader/PaymentSessionMethods.res
+++ b/src/orca-loader/PaymentSessionMethods.res
@@ -1,3 +1,7 @@
+open Promise
+open Types
+open Utils
+
let getCustomerSavedPaymentMethods = (
~clientSecret,
~publishableKey,
@@ -5,9 +9,6 @@ let getCustomerSavedPaymentMethods = (
~logger,
~switchToCustomPod,
) => {
- open Promise
- open Types
- open Utils
PaymentHelpers.fetchCustomerPaymentMethodList(
~clientSecret,
~publishableKey,
@@ -196,3 +197,65 @@ let getCustomerSavedPaymentMethods = (
updatedCustomerDetails->resolve
})
}
+
+let getPaymentManagementMethods = (~ephemeralKey, ~logger, ~switchToCustomPod, ~endpoint) => {
+ let getSavedPaymentManagementMethodsList = _ => {
+ PaymentHelpers.fetchSavedPaymentMethodList(
+ ~ephemeralKey,
+ ~optLogger=Some(logger),
+ ~switchToCustomPod=false,
+ ~endpoint,
+ )
+ ->then(response => {
+ response->resolve
+ })
+ ->catch(err => {
+ let exceptionMessage = err->formatException->JSON.stringify
+ let updatedCustomerDetails =
+ [
+ (
+ "error",
+ [
+ ("type", "server_error"->JSON.Encode.string),
+ ("message", exceptionMessage->JSON.Encode.string),
+ ]->getJsonFromArrayOfJson,
+ ),
+ ]->getJsonFromArrayOfJson
+ updatedCustomerDetails->resolve
+ })
+ }
+
+ let deleteSavedPaymentMethod = paymentMethodId => {
+ PaymentHelpers.deletePaymentMethod(
+ ~ephemeralKey,
+ ~paymentMethodId={paymentMethodId->JSON.Decode.string->Option.getOr("")},
+ ~logger,
+ ~switchToCustomPod,
+ )
+ ->then(response => {
+ response->resolve
+ })
+ ->catch(err => {
+ let exceptionMessage = err->formatException->JSON.stringify
+ let updatedCustomerDetails =
+ [
+ (
+ "error",
+ [
+ ("type", "server_error"->JSON.Encode.string),
+ ("message", exceptionMessage->JSON.Encode.string),
+ ]->getJsonFromArrayOfJson,
+ ),
+ ]->getJsonFromArrayOfJson
+
+ updatedCustomerDetails->resolve
+ })
+ }
+
+ {
+ getSavedPaymentManagementMethodsList,
+ deleteSavedPaymentMethod,
+ }
+ ->Identity.anyTypeToJson
+ ->resolve
+}
diff --git a/src/orca-loader/Types.res b/src/orca-loader/Types.res
index 4a2774a2e..2b22ed3e9 100644
--- a/src/orca-loader/Types.res
+++ b/src/orca-loader/Types.res
@@ -46,7 +46,15 @@ type getCustomerSavedPaymentMethods = {
confirmWithLastUsedPaymentMethod: JSON.t => Promise.t,
}
-type initPaymentSession = {getCustomerSavedPaymentMethods: unit => Promise.t}
+type getPaymentManagementMethods = {
+ getSavedPaymentManagementMethodsList: unit => Promise.t,
+ deleteSavedPaymentMethod: JSON.t => Promise.t,
+}
+
+type initPaymentSession = {
+ getCustomerSavedPaymentMethods: unit => Promise.t,
+ getPaymentManagementMethods: unit => Promise.t,
+}
type confirmParams = {return_url: string}
@@ -125,6 +133,14 @@ let getCustomerDefaultSavedPaymentMethodData = () => {
JSON.Encode.null
}
+let getSavedPaymentManagementMethodsList = () => {
+ JSON.Encode.null
+}
+
+let deleteSavedPaymentMethod = () => {
+ JSON.Encode.null
+}
+
let getCustomerLastUsedPaymentMethodData = () => {
JSON.Encode.null
}
@@ -146,8 +162,13 @@ let defaultGetCustomerSavedPaymentMethods = () => {
Promise.resolve(JSON.Encode.null)
}
+let defaultGetPaymentManagementMethods = () => {
+ Promise.resolve(JSON.Encode.null)
+}
+
let defaultInitPaymentSession: initPaymentSession = {
getCustomerSavedPaymentMethods: defaultGetCustomerSavedPaymentMethods,
+ getPaymentManagementMethods: defaultGetPaymentManagementMethods,
}
let defaultHyperInstance = {