Skip to content

Commit 33e12a9

Browse files
chore: add types for loadHyper
1 parent 838577d commit 33e12a9

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

src/index.d.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,31 +63,52 @@ declare module "@juspay-tech/hyper-js" {
6363

6464
export interface LoadOptions {
6565
customBackendUrl?: string;
66+
env?: "SANDBOX" | "PROD";
6667
[key: string]: any;
6768
}
6869

70+
export interface HyperObject {
71+
publishableKey?: string;
72+
[key: string]: any;
73+
}
74+
75+
export interface AnalyticsData {
76+
sessionID: string;
77+
timeStamp: string;
78+
}
79+
6980
/**
7081
* Initializes the Hyper SDK with the given publishable key and options.
7182
*
72-
* @param publishableKey - Your publishable API key
73-
* @param options - Configuration options including customBackendUrl settings
83+
* @param hyperObject - Either a string publishable key or an object containing publishableKey
84+
* @param options - Configuration options including customBackendUrl and env settings
7485
* @returns A Promise that resolves to a HyperInstance object
7586
*
7687
* @example
88+
* // Using string publishable key
7789
* const hyperPromise = loadHyper("YOUR_PUBLISHABLE_KEY", {
78-
* customBackendUrl: "YOUR_BACKEND_URL"
90+
* customBackendUrl: "YOUR_BACKEND_URL",
91+
* env: "SANDBOX"
92+
* });
93+
*
94+
* // Using object with publishable key
95+
* const hyperPromise = loadHyper({
96+
* publishableKey: "YOUR_PUBLISHABLE_KEY"
97+
* }, {
98+
* customBackendUrl: "YOUR_BACKEND_URL",
99+
* env: "PROD"
79100
* });
80101
*/
81102
export function loadHyper(
82-
publishableKey: string,
103+
hyperObject: string | HyperObject,
83104
options?: LoadOptions
84105
): Promise<HyperInstance>;
85106

86107
/**
87108
* @deprecated Use loadHyper instead
88109
*/
89110
export function loadStripe(
90-
publishableKey: string,
111+
hyperObject: string | HyperObject,
91112
options?: LoadOptions
92113
): Promise<HyperInstance>;
93114

0 commit comments

Comments
 (0)