@youidian/sdk 3.4.1 → 3.4.3

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
@@ -38,7 +38,7 @@ declare function detectLoginEnvironment(input?: LoginEnvironmentInput): LoginEnv
38
38
  /**
39
39
  * Payment event types from checkout pages
40
40
  */
41
- 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";
42
42
  /**
43
43
  * Payment event data from postMessage
44
44
  */
@@ -56,6 +56,13 @@ interface OrderStatus {
56
56
  paidAt?: string;
57
57
  channelTransactionId?: string;
58
58
  }
59
+ interface PaymentUIThemeColors {
60
+ primary?: string;
61
+ secondary?: string;
62
+ foreground?: string;
63
+ muted?: string;
64
+ surface?: string;
65
+ }
59
66
  /**
60
67
  * Payment UI Options
61
68
  */
@@ -64,8 +71,23 @@ interface PaymentUIOptions {
64
71
  onSuccess?: (orderId?: string) => void;
65
72
  onCancel?: (orderId?: string) => void;
66
73
  onClose?: () => void;
74
+ onFallbackBlocked?: (url: string) => void;
75
+ onFallbackOpen?: (url: string) => void;
76
+ onFallbackVisible?: () => void;
67
77
  /** Origin to validate postMessage (defaults to '*', set for security) */
68
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;
69
91
  }
70
92
  /**
71
93
  * Poll Options
@@ -122,6 +144,16 @@ declare class PaymentUI extends HostedFrameModal<PaymentEventData> {
122
144
  private activeOrderId;
123
145
  private paymentCompleted;
124
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;
125
157
  private cancelHostedOrder;
126
158
  /**
127
159
  * Opens the payment checkout page in an iframe modal.
@@ -129,6 +161,7 @@ declare class PaymentUI extends HostedFrameModal<PaymentEventData> {
129
161
  * @param options - UI options
130
162
  */
131
163
  openPayment(urlOrParams: string | PaymentParams, options?: PaymentUIOptions): void;
164
+ close(): void;
132
165
  /**
133
166
  * Poll order status from integrator's API endpoint
134
167
  * @param statusUrl - The integrator's API endpoint to check order status
@@ -137,9 +170,18 @@ declare class PaymentUI extends HostedFrameModal<PaymentEventData> {
137
170
  */
138
171
  pollOrderStatus(statusUrl: string, options?: PollOptions): Promise<OrderStatus>;
139
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;
140
182
  /**
141
183
  * Convenience function to create a PaymentUI instance
142
184
  */
143
185
  declare function createPaymentUI(): PaymentUI;
144
186
 
145
- export { type LoginDeviceType, type LoginEnvironment, type LoginEnvironmentInput, type OrderStatus, type PaymentEventData, type PaymentEventType, type PaymentParams, PaymentUI, type PaymentUIOptions, type PollOptions, createPaymentUI, detectLoginEnvironment };
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
@@ -38,7 +38,7 @@ declare function detectLoginEnvironment(input?: LoginEnvironmentInput): LoginEnv
38
38
  /**
39
39
  * Payment event types from checkout pages
40
40
  */
41
- 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";
42
42
  /**
43
43
  * Payment event data from postMessage
44
44
  */
@@ -56,6 +56,13 @@ interface OrderStatus {
56
56
  paidAt?: string;
57
57
  channelTransactionId?: string;
58
58
  }
59
+ interface PaymentUIThemeColors {
60
+ primary?: string;
61
+ secondary?: string;
62
+ foreground?: string;
63
+ muted?: string;
64
+ surface?: string;
65
+ }
59
66
  /**
60
67
  * Payment UI Options
61
68
  */
@@ -64,8 +71,23 @@ interface PaymentUIOptions {
64
71
  onSuccess?: (orderId?: string) => void;
65
72
  onCancel?: (orderId?: string) => void;
66
73
  onClose?: () => void;
74
+ onFallbackBlocked?: (url: string) => void;
75
+ onFallbackOpen?: (url: string) => void;
76
+ onFallbackVisible?: () => void;
67
77
  /** Origin to validate postMessage (defaults to '*', set for security) */
68
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;
69
91
  }
70
92
  /**
71
93
  * Poll Options
@@ -122,6 +144,16 @@ declare class PaymentUI extends HostedFrameModal<PaymentEventData> {
122
144
  private activeOrderId;
123
145
  private paymentCompleted;
124
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;
125
157
  private cancelHostedOrder;
126
158
  /**
127
159
  * Opens the payment checkout page in an iframe modal.
@@ -129,6 +161,7 @@ declare class PaymentUI extends HostedFrameModal<PaymentEventData> {
129
161
  * @param options - UI options
130
162
  */
131
163
  openPayment(urlOrParams: string | PaymentParams, options?: PaymentUIOptions): void;
164
+ close(): void;
132
165
  /**
133
166
  * Poll order status from integrator's API endpoint
134
167
  * @param statusUrl - The integrator's API endpoint to check order status
@@ -137,9 +170,18 @@ declare class PaymentUI extends HostedFrameModal<PaymentEventData> {
137
170
  */
138
171
  pollOrderStatus(statusUrl: string, options?: PollOptions): Promise<OrderStatus>;
139
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;
140
182
  /**
141
183
  * Convenience function to create a PaymentUI instance
142
184
  */
143
185
  declare function createPaymentUI(): PaymentUI;
144
186
 
145
- export { type LoginDeviceType, type LoginEnvironment, type LoginEnvironmentInput, type OrderStatus, type PaymentEventData, type PaymentEventType, type PaymentParams, PaymentUI, type PaymentUIOptions, type PollOptions, createPaymentUI, detectLoginEnvironment };
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 };