11/**
22 * Paddle.js Singleton
3- *
3+ *
44 * Ensures only one Paddle instance is initialized across the application.
55 * Provides event subscription mechanism for checkout events.
66 */
@@ -19,14 +19,14 @@ interface PaddleCache {
1919// Global singleton storage
2020const globalRef = globalThis as unknown as { __paddleSingleton ?: PaddleCache }
2121if ( ! globalRef . __paddleSingleton ) {
22- globalRef . __paddleSingleton = { listeners : [ ] }
22+ globalRef . __paddleSingleton = { listeners : [ ] }
2323}
2424const cache = globalRef . __paddleSingleton
2525
2626/**
2727 * Build unique cache key from environment and token
2828 */
29- const buildKey = ( env : Environment , token : string ) =>
29+ const buildKey = ( env : Environment , token : string ) =>
3030 `${ String ( env ) . toLowerCase ( ) . trim ( ) } :${ String ( token ) . trim ( ) } `
3131
3232/**
@@ -79,9 +79,9 @@ function logPaddleScriptTags(): void {
7979function debugPaddleStatus ( ) : void {
8080 const w = globalThis as { Paddle ?: Paddle }
8181 const hasGlobal = ! ! w . Paddle
82- console . log ( '[Paddle][debug] key:' , cache . key ,
83- 'hasInstance:' , ! ! cache . instance ,
84- 'hasPromise:' , ! ! cache . promise ,
82+ console . log ( '[Paddle][debug] key:' , cache . key ,
83+ 'hasInstance:' , ! ! cache . instance ,
84+ 'hasPromise:' , ! ! cache . promise ,
8585 'globalThis.Paddle:' , hasGlobal )
8686 logPaddleScriptTags ( )
8787}
@@ -110,13 +110,13 @@ function waitForPaddle(timeoutMs = 10000, intervalMs = 50): Promise<Paddle> {
110110
111111/**
112112 * Initialize Paddle with the given client token
113- *
113+ *
114114 * @param token - Paddle client-side token
115115 * @param environment - 'sandbox' for testing, 'production' for live
116116 * @returns Promise resolving to Paddle instance
117117 */
118118export async function initPaddle (
119- token : string ,
119+ token : string ,
120120 environment : Environment = 'sandbox'
121121) : Promise < Paddle > {
122122 if ( ! token ) {
@@ -181,10 +181,10 @@ export async function initPaddle(
181181
182182/**
183183 * Open Paddle checkout overlay with a transaction ID
184- *
184+ *
185185 * The transactionId should be obtained from your backend API which creates
186186 * the transaction with customData (userId, etc.) already set.
187- *
187+ *
188188 * @param paddle - Paddle instance
189189 * @param transactionId - Transaction ID from backend (e.g., "txn_01abc123...")
190190 * @param options - Additional checkout options
@@ -225,10 +225,10 @@ export function openCheckoutWithTransaction(
225225
226226/**
227227 * Open Paddle checkout overlay with a price ID (direct checkout)
228- *
228+ *
229229 * NOTE: This bypasses the backend and won't include customData like userId.
230230 * Prefer using openCheckoutWithTransaction() with a backend-created transaction.
231- *
231+ *
232232 * @param paddle - Paddle instance
233233 * @param priceId - Paddle price ID (e.g., "pri_01abc123...")
234234 * @param options - Additional checkout options
0 commit comments