@youidian/sdk 3.3.10 → 3.4.2

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/dist/client.d.cts CHANGED
@@ -1,5 +1,33 @@
1
- import { H as HostedFrameModal } from './login-DerOcXcH.cjs';
2
- export { L as LoginCallbackOptions, a as LoginDisplayMode, b as LoginEventData, c as LoginEventType, e as LoginParams, f as LoginResult, g as LoginUI, h as LoginUIOptions, i as createLoginUI, j as handleLoginCallbackIfPresent } from './login-DerOcXcH.cjs';
1
+ import { H as HostedFrameModal } from './login-Dqemys65.cjs';
2
+ export { L as LoginCallbackOptions, a as LoginDisplayMode, b as LoginEventData, c as LoginEventType, e as LoginParams, f as LoginResult, g as LoginUI, h as LoginUIOptions, i as createLoginUI, j as handleLoginCallbackIfPresent } from './login-Dqemys65.cjs';
3
+
4
+ type LoginDeviceType = "desktop" | "mobile" | "tablet" | "unknown";
5
+ type LoginEnvironmentInput = {
6
+ coarsePointer?: boolean;
7
+ maxTouchPoints?: number;
8
+ platform?: string;
9
+ standalone?: boolean;
10
+ userAgent?: string;
11
+ userAgentDataMobile?: boolean;
12
+ };
13
+ type LoginEnvironment = {
14
+ deviceType: LoginDeviceType;
15
+ isAndroid: boolean;
16
+ isCoarsePointer: boolean;
17
+ isDesktop: boolean;
18
+ isIOS: boolean;
19
+ isIPadOS: boolean;
20
+ isMobile: boolean;
21
+ isStandalone: boolean;
22
+ isTablet: boolean;
23
+ isTouch: boolean;
24
+ isWeChat: boolean;
25
+ maxTouchPoints: number;
26
+ platform: string;
27
+ shouldUseRedirectLogin: boolean;
28
+ userAgent: string;
29
+ };
30
+ declare function detectLoginEnvironment(input?: LoginEnvironmentInput): LoginEnvironment;
3
31
 
4
32
  /**
5
33
  * Youidian Payment SDK - Client Module
@@ -10,7 +38,7 @@ export { L as LoginCallbackOptions, a as LoginDisplayMode, b as LoginEventData,
10
38
  /**
11
39
  * Payment event types from checkout pages
12
40
  */
13
- type PaymentEventType = "PAYMENT_SUCCESS" | "PAYMENT_CANCELLED" | "PAYMENT_CLOSE" | "PAYMENT_RESIZE" | "PAYMENT_STARTED";
41
+ type PaymentEventType = "PAYMENT_READY" | "PAYMENT_SUCCESS" | "PAYMENT_CANCELLED" | "PAYMENT_CLOSE" | "PAYMENT_RESIZE" | "PAYMENT_STARTED";
14
42
  /**
15
43
  * Payment event data from postMessage
16
44
  */
@@ -28,6 +56,13 @@ interface OrderStatus {
28
56
  paidAt?: string;
29
57
  channelTransactionId?: string;
30
58
  }
59
+ interface PaymentUIThemeColors {
60
+ primary?: string;
61
+ secondary?: string;
62
+ foreground?: string;
63
+ muted?: string;
64
+ surface?: string;
65
+ }
31
66
  /**
32
67
  * Payment UI Options
33
68
  */
@@ -36,8 +71,23 @@ interface PaymentUIOptions {
36
71
  onSuccess?: (orderId?: string) => void;
37
72
  onCancel?: (orderId?: string) => void;
38
73
  onClose?: () => void;
74
+ onFallbackBlocked?: (url: string) => void;
75
+ onFallbackOpen?: (url: string) => void;
76
+ onFallbackVisible?: () => void;
39
77
  /** Origin to validate postMessage (defaults to '*', set for security) */
40
78
  allowedOrigin?: string;
79
+ /** Theme colors for SDK fallback/loading chrome. Defaults to Youidian green. */
80
+ theme?: PaymentUIThemeColors;
81
+ /** Text for the fallback button shown when the checkout iframe is slow. */
82
+ fallbackButtonText?: string;
83
+ /** Text for retrying the embedded checkout iframe. */
84
+ fallbackRetryText?: string;
85
+ /** How long to wait for PAYMENT_READY or PAYMENT_RESIZE. Defaults to 8000ms. */
86
+ iframeLoadTimeoutMs?: number;
87
+ /** Description shown while the hosted checkout iframe is loading. */
88
+ loadingDescription?: string;
89
+ /** Title shown while the hosted checkout iframe is loading. */
90
+ loadingTitle?: string;
41
91
  }
42
92
  /**
43
93
  * Poll Options
@@ -94,6 +144,16 @@ declare class PaymentUI extends HostedFrameModal<PaymentEventData> {
94
144
  private activeOrderId;
95
145
  private paymentCompleted;
96
146
  private cancelRequestedOrderId;
147
+ private iframeFallbackPanel;
148
+ private iframeLoadingPanel;
149
+ private iframeLoadTimer;
150
+ private iframeReady;
151
+ private cleanupPaymentFrameState;
152
+ private markPaymentIframeReady;
153
+ private showPaymentIframeLoading;
154
+ private openFallbackPaymentPage;
155
+ private showPaymentIframeFallback;
156
+ private startPaymentIframeWatchdog;
97
157
  private cancelHostedOrder;
98
158
  /**
99
159
  * Opens the payment checkout page in an iframe modal.
@@ -101,6 +161,7 @@ declare class PaymentUI extends HostedFrameModal<PaymentEventData> {
101
161
  * @param options - UI options
102
162
  */
103
163
  openPayment(urlOrParams: string | PaymentParams, options?: PaymentUIOptions): void;
164
+ close(): void;
104
165
  /**
105
166
  * Poll order status from integrator's API endpoint
106
167
  * @param statusUrl - The integrator's API endpoint to check order status
@@ -109,9 +170,18 @@ declare class PaymentUI extends HostedFrameModal<PaymentEventData> {
109
170
  */
110
171
  pollOrderStatus(statusUrl: string, options?: PollOptions): Promise<OrderStatus>;
111
172
  }
173
+ interface WechatMessageBindingUIOptions {
174
+ bindingUrl: string;
175
+ displayMode?: "redirect" | "popup";
176
+ popupName?: string;
177
+ }
178
+ declare class MessageUI {
179
+ openWechatBinding(options: WechatMessageBindingUIOptions): void;
180
+ }
181
+ declare function createMessageUI(): MessageUI;
112
182
  /**
113
183
  * Convenience function to create a PaymentUI instance
114
184
  */
115
185
  declare function createPaymentUI(): PaymentUI;
116
186
 
117
- export { type OrderStatus, type PaymentEventData, type PaymentEventType, type PaymentParams, PaymentUI, type PaymentUIOptions, type PollOptions, createPaymentUI };
187
+ export { type LoginDeviceType, type LoginEnvironment, type LoginEnvironmentInput, MessageUI, type OrderStatus, type PaymentEventData, type PaymentEventType, type PaymentParams, PaymentUI, type PaymentUIOptions, type PaymentUIThemeColors, type PollOptions, type WechatMessageBindingUIOptions, createMessageUI, createPaymentUI, detectLoginEnvironment };
package/dist/client.d.ts CHANGED
@@ -1,5 +1,33 @@
1
- import { H as HostedFrameModal } from './login-DerOcXcH.js';
2
- export { L as LoginCallbackOptions, a as LoginDisplayMode, b as LoginEventData, c as LoginEventType, e as LoginParams, f as LoginResult, g as LoginUI, h as LoginUIOptions, i as createLoginUI, j as handleLoginCallbackIfPresent } from './login-DerOcXcH.js';
1
+ import { H as HostedFrameModal } from './login-Dqemys65.js';
2
+ export { L as LoginCallbackOptions, a as LoginDisplayMode, b as LoginEventData, c as LoginEventType, e as LoginParams, f as LoginResult, g as LoginUI, h as LoginUIOptions, i as createLoginUI, j as handleLoginCallbackIfPresent } from './login-Dqemys65.js';
3
+
4
+ type LoginDeviceType = "desktop" | "mobile" | "tablet" | "unknown";
5
+ type LoginEnvironmentInput = {
6
+ coarsePointer?: boolean;
7
+ maxTouchPoints?: number;
8
+ platform?: string;
9
+ standalone?: boolean;
10
+ userAgent?: string;
11
+ userAgentDataMobile?: boolean;
12
+ };
13
+ type LoginEnvironment = {
14
+ deviceType: LoginDeviceType;
15
+ isAndroid: boolean;
16
+ isCoarsePointer: boolean;
17
+ isDesktop: boolean;
18
+ isIOS: boolean;
19
+ isIPadOS: boolean;
20
+ isMobile: boolean;
21
+ isStandalone: boolean;
22
+ isTablet: boolean;
23
+ isTouch: boolean;
24
+ isWeChat: boolean;
25
+ maxTouchPoints: number;
26
+ platform: string;
27
+ shouldUseRedirectLogin: boolean;
28
+ userAgent: string;
29
+ };
30
+ declare function detectLoginEnvironment(input?: LoginEnvironmentInput): LoginEnvironment;
3
31
 
4
32
  /**
5
33
  * Youidian Payment SDK - Client Module
@@ -10,7 +38,7 @@ export { L as LoginCallbackOptions, a as LoginDisplayMode, b as LoginEventData,
10
38
  /**
11
39
  * Payment event types from checkout pages
12
40
  */
13
- type PaymentEventType = "PAYMENT_SUCCESS" | "PAYMENT_CANCELLED" | "PAYMENT_CLOSE" | "PAYMENT_RESIZE" | "PAYMENT_STARTED";
41
+ type PaymentEventType = "PAYMENT_READY" | "PAYMENT_SUCCESS" | "PAYMENT_CANCELLED" | "PAYMENT_CLOSE" | "PAYMENT_RESIZE" | "PAYMENT_STARTED";
14
42
  /**
15
43
  * Payment event data from postMessage
16
44
  */
@@ -28,6 +56,13 @@ interface OrderStatus {
28
56
  paidAt?: string;
29
57
  channelTransactionId?: string;
30
58
  }
59
+ interface PaymentUIThemeColors {
60
+ primary?: string;
61
+ secondary?: string;
62
+ foreground?: string;
63
+ muted?: string;
64
+ surface?: string;
65
+ }
31
66
  /**
32
67
  * Payment UI Options
33
68
  */
@@ -36,8 +71,23 @@ interface PaymentUIOptions {
36
71
  onSuccess?: (orderId?: string) => void;
37
72
  onCancel?: (orderId?: string) => void;
38
73
  onClose?: () => void;
74
+ onFallbackBlocked?: (url: string) => void;
75
+ onFallbackOpen?: (url: string) => void;
76
+ onFallbackVisible?: () => void;
39
77
  /** Origin to validate postMessage (defaults to '*', set for security) */
40
78
  allowedOrigin?: string;
79
+ /** Theme colors for SDK fallback/loading chrome. Defaults to Youidian green. */
80
+ theme?: PaymentUIThemeColors;
81
+ /** Text for the fallback button shown when the checkout iframe is slow. */
82
+ fallbackButtonText?: string;
83
+ /** Text for retrying the embedded checkout iframe. */
84
+ fallbackRetryText?: string;
85
+ /** How long to wait for PAYMENT_READY or PAYMENT_RESIZE. Defaults to 8000ms. */
86
+ iframeLoadTimeoutMs?: number;
87
+ /** Description shown while the hosted checkout iframe is loading. */
88
+ loadingDescription?: string;
89
+ /** Title shown while the hosted checkout iframe is loading. */
90
+ loadingTitle?: string;
41
91
  }
42
92
  /**
43
93
  * Poll Options
@@ -94,6 +144,16 @@ declare class PaymentUI extends HostedFrameModal<PaymentEventData> {
94
144
  private activeOrderId;
95
145
  private paymentCompleted;
96
146
  private cancelRequestedOrderId;
147
+ private iframeFallbackPanel;
148
+ private iframeLoadingPanel;
149
+ private iframeLoadTimer;
150
+ private iframeReady;
151
+ private cleanupPaymentFrameState;
152
+ private markPaymentIframeReady;
153
+ private showPaymentIframeLoading;
154
+ private openFallbackPaymentPage;
155
+ private showPaymentIframeFallback;
156
+ private startPaymentIframeWatchdog;
97
157
  private cancelHostedOrder;
98
158
  /**
99
159
  * Opens the payment checkout page in an iframe modal.
@@ -101,6 +161,7 @@ declare class PaymentUI extends HostedFrameModal<PaymentEventData> {
101
161
  * @param options - UI options
102
162
  */
103
163
  openPayment(urlOrParams: string | PaymentParams, options?: PaymentUIOptions): void;
164
+ close(): void;
104
165
  /**
105
166
  * Poll order status from integrator's API endpoint
106
167
  * @param statusUrl - The integrator's API endpoint to check order status
@@ -109,9 +170,18 @@ declare class PaymentUI extends HostedFrameModal<PaymentEventData> {
109
170
  */
110
171
  pollOrderStatus(statusUrl: string, options?: PollOptions): Promise<OrderStatus>;
111
172
  }
173
+ interface WechatMessageBindingUIOptions {
174
+ bindingUrl: string;
175
+ displayMode?: "redirect" | "popup";
176
+ popupName?: string;
177
+ }
178
+ declare class MessageUI {
179
+ openWechatBinding(options: WechatMessageBindingUIOptions): void;
180
+ }
181
+ declare function createMessageUI(): MessageUI;
112
182
  /**
113
183
  * Convenience function to create a PaymentUI instance
114
184
  */
115
185
  declare function createPaymentUI(): PaymentUI;
116
186
 
117
- export { type OrderStatus, type PaymentEventData, type PaymentEventType, type PaymentParams, PaymentUI, type PaymentUIOptions, type PollOptions, createPaymentUI };
187
+ export { type LoginDeviceType, type LoginEnvironment, type LoginEnvironmentInput, MessageUI, type OrderStatus, type PaymentEventData, type PaymentEventType, type PaymentParams, PaymentUI, type PaymentUIOptions, type PaymentUIThemeColors, type PollOptions, type WechatMessageBindingUIOptions, createMessageUI, createPaymentUI, detectLoginEnvironment };