@mygigsters/card-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +613 -0
- package/cdn/card-sdk-entry.js +2 -0
- package/cdn/card-sdk-entry.js.map +1 -0
- package/dist/index.cjs.js +518 -0
- package/dist/index.d.ts +229 -0
- package/dist/index.esm.js +1038 -0
- package/dist/index.umd.js +518 -0
- package/index.d.ts +229 -0
- package/package.json +61 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
3
|
+
* @mygigsters/card-sdk TypeScript Declarations
|
|
4
|
+
* MyGigsters Card SDK - Secure single-step card saving payment elements integration.
|
|
5
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export type CardEnvironment = 'dev' | 'demo' | 'prod';
|
|
9
|
+
export type CardThemeMode = 'light' | 'dark';
|
|
10
|
+
|
|
11
|
+
export interface CardSuccessResponse {
|
|
12
|
+
/** The unique Airwallex payment consent identifier */
|
|
13
|
+
paymentConsentId: string;
|
|
14
|
+
/** Customer ID associated with this payment consent */
|
|
15
|
+
customerId: string;
|
|
16
|
+
/** MyGigster ID associated with this payment consent */
|
|
17
|
+
myGigsterId?: string;
|
|
18
|
+
/** Account ID associated with this payment consent */
|
|
19
|
+
accountId?: string;
|
|
20
|
+
/** ISO-8601 timestamp when the card was successfully saved */
|
|
21
|
+
timestamp: string;
|
|
22
|
+
/** Event identifier ('card.saved') */
|
|
23
|
+
event: 'card.saved' | string;
|
|
24
|
+
/** Additional backend response properties */
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface MygigstersCardConfig {
|
|
29
|
+
/**
|
|
30
|
+
* Your MyGigsters API Key.
|
|
31
|
+
* Required for authentication.
|
|
32
|
+
* Example: "3113ee27-ba11-48f7-81e2-f5a2f0e54340"
|
|
33
|
+
*/
|
|
34
|
+
apiKey: string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Your MyGigsters API Secret.
|
|
38
|
+
* Required for authentication.
|
|
39
|
+
* Example: "HUdxQCCrOFuF9fSkQRbd"
|
|
40
|
+
*/
|
|
41
|
+
apiSecret: string;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* ID of the DOM element container where the SDK is mounted or validated.
|
|
45
|
+
* Example: "card-mount"
|
|
46
|
+
*/
|
|
47
|
+
containerId: string;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Customer ID for whom the card will be saved.
|
|
51
|
+
* Required.
|
|
52
|
+
* Example: "cus_hkdmcdjshhknkk4lc2t"
|
|
53
|
+
*/
|
|
54
|
+
customerId: string;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* MyGigster ID for whom the payment consent is created (Frontend identifier).
|
|
58
|
+
* Either `myGigsterId` or `accountId` is required.
|
|
59
|
+
* Example: "4407c3ba-10c9-4822-9f51-c2c96692f8d7"
|
|
60
|
+
*/
|
|
61
|
+
myGigsterId?: string;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Account ID for whom the payment consent is created (Legacy alias for myGigsterId).
|
|
65
|
+
* Example: "4407c3ba-10c9-4822-9f51-c2c96692f8d7"
|
|
66
|
+
*/
|
|
67
|
+
accountId?: string;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Target environment.
|
|
71
|
+
* - 'demo': Demo server (QA: https://qa-payments.mygigsters.com.au) [Default]
|
|
72
|
+
* - 'dev': Development server (http://3.108.128.110:5000)
|
|
73
|
+
* - 'prod': Production server (https://prod-payments.mygigsters.com.au)
|
|
74
|
+
* @default 'demo'
|
|
75
|
+
*/
|
|
76
|
+
env?: CardEnvironment;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Custom base URL to override the environment default URL.
|
|
80
|
+
*/
|
|
81
|
+
baseUrl?: string;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Theme mode for the card modal popup.
|
|
85
|
+
* - 'dark': Modern sleek dark slate theme [Default]
|
|
86
|
+
* - 'light': Clean high-contrast light theme
|
|
87
|
+
* @default 'dark'
|
|
88
|
+
*/
|
|
89
|
+
mode?: CardThemeMode;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Callback fired upon successful card entry and verification.
|
|
93
|
+
* @param res Enriched response payload containing paymentConsentId, customerId, myGigsterId, accountId, timestamp.
|
|
94
|
+
*/
|
|
95
|
+
onSuccess?: (res: CardSuccessResponse) => void;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Callback fired if an error occurs during initialization, authentication, or card submission.
|
|
99
|
+
* @param err The error instance or error details.
|
|
100
|
+
*/
|
|
101
|
+
onError?: (err: Error | any) => void;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Callback fired when the user closes the modal (via Close button 'X', backdrop click, or Escape key).
|
|
105
|
+
*/
|
|
106
|
+
onClose?: () => void;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Optional webhook URL. The SDK will automatically POST the success payload to this URL.
|
|
110
|
+
*/
|
|
111
|
+
webhookUrl?: string;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Optional JS callback for receiving the webhook payload in real-time.
|
|
115
|
+
*/
|
|
116
|
+
onWebhook?: (payload: CardSuccessResponse) => void;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export class MygigstersCardSDK {
|
|
120
|
+
constructor();
|
|
121
|
+
|
|
122
|
+
/** Current SDK configuration */
|
|
123
|
+
config: MygigstersCardConfig | null;
|
|
124
|
+
|
|
125
|
+
/** Whether the SDK has been successfully initialized */
|
|
126
|
+
isInitialized: boolean;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Initialize the Card SDK and display the single-step Card Details modal.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* const sdk = new MygigstersCardSDK();
|
|
134
|
+
* await sdk.init({
|
|
135
|
+
* containerId: "card-mount",
|
|
136
|
+
* apiKey: "3113ee27-ba11-48f7-81e2-f5a2f0e54340",
|
|
137
|
+
* apiSecret: "HUdxQCCrOFuF9fSkQRbd",
|
|
138
|
+
* customerId: "cus_hkdmcdjshhknkk4lc2t",
|
|
139
|
+
* myGigsterId: "4407c3ba-10c9-4822-9f51-c2c96692f8d7",
|
|
140
|
+
* env: "demo",
|
|
141
|
+
* mode: "light",
|
|
142
|
+
* onSuccess: (res) => console.log("Card saved!", res),
|
|
143
|
+
* onError: (err) => console.error("Error:", err),
|
|
144
|
+
* onClose: () => console.log("Modal closed")
|
|
145
|
+
* });
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
init(config: MygigstersCardConfig): Promise<void>;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Display the card modal.
|
|
152
|
+
*/
|
|
153
|
+
show(): void;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Hide the card modal without destroying instance.
|
|
157
|
+
*/
|
|
158
|
+
hide(): void;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Switch the UI theme dynamically.
|
|
162
|
+
*/
|
|
163
|
+
setTheme(mode: CardThemeMode): void;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Fully teardown and remove the SDK from DOM.
|
|
167
|
+
*/
|
|
168
|
+
destroy(): void;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export interface MygigstersCardGlobal {
|
|
172
|
+
/**
|
|
173
|
+
* Initialize the singleton Card SDK instance and display the single-step Card Details modal.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```js
|
|
177
|
+
* MygigstersCard.init({
|
|
178
|
+
* containerId: "card-mount",
|
|
179
|
+
* apiKey: "3113ee27-ba11-48f7-81e2-f5a2f0e54340",
|
|
180
|
+
* apiSecret: "HUdxQCCrOFuF9fSkQRbd",
|
|
181
|
+
* customerId: "cus_hkdmcdjshhknkk4lc2t",
|
|
182
|
+
* myGigsterId: "4407c3ba-10c9-4822-9f51-c2c96692f8d7",
|
|
183
|
+
* env: "demo",
|
|
184
|
+
* mode: "dark",
|
|
185
|
+
* onSuccess: (res) => console.log("Card saved!", res),
|
|
186
|
+
* onError: (err) => console.error("Error:", err),
|
|
187
|
+
* onClose: () => console.log("Modal closed")
|
|
188
|
+
* });
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
init(config: MygigstersCardConfig): Promise<MygigstersCardSDK>;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Display the card modal.
|
|
195
|
+
*/
|
|
196
|
+
show(): void;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Hide the card modal.
|
|
200
|
+
*/
|
|
201
|
+
hide(): void;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Destroy the current instance and clean up DOM.
|
|
205
|
+
*/
|
|
206
|
+
destroy(): void;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Update the modal theme.
|
|
210
|
+
*/
|
|
211
|
+
setTheme(mode: CardThemeMode): void;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Get current SDK instance.
|
|
215
|
+
*/
|
|
216
|
+
getInstance(): MygigstersCardSDK | null;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** Global singleton available in browser / CDN builds and package import */
|
|
220
|
+
export const MygigstersCard: MygigstersCardGlobal;
|
|
221
|
+
|
|
222
|
+
export default MygigstersCardSDK;
|
|
223
|
+
|
|
224
|
+
declare global {
|
|
225
|
+
interface Window {
|
|
226
|
+
MygigstersCard: MygigstersCardGlobal;
|
|
227
|
+
MygigstersCardSDK: typeof MygigstersCardSDK;
|
|
228
|
+
}
|
|
229
|
+
}
|