@paynext/sdk 0.0.136 → 0.0.138

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/_headers ADDED
@@ -0,0 +1,21 @@
1
+ /*
2
+ Access-Control-Allow-Origin: *
3
+ Access-Control-Allow-Methods: GET, HEAD, OPTIONS
4
+ Access-Control-Allow-Headers: Content-Type, Authorization
5
+ Access-Control-Max-Age: 86400
6
+ Cache-Control: public, max-age=3600
7
+ X-Content-Type-Options: nosniff
8
+ X-Frame-Options: SAMEORIGIN
9
+
10
+ /*.js
11
+ Content-Type: text/javascript; charset=utf-8
12
+ Cache-Control: public, max-age=3600
13
+
14
+ /*.css
15
+ Content-Type: text/css; charset=utf-8
16
+ Cache-Control: public, max-age=3600
17
+
18
+ /*.map
19
+ Content-Type: application/json
20
+ Cache-Control: public, max-age=3600
21
+
package/dist/index.d.ts CHANGED
@@ -1,84 +1,16 @@
1
1
  import { ApplePayOptions } from '@evervault/react';
2
- import { Client } from 'braintree-web/client';
3
- import { EncryptedApplePayData } from '@evervault/react';
4
- import { EncryptedGooglePayData } from '@evervault/react';
5
- import { EvervaultInstance } from '@evervault/js';
6
2
  import { GooglePayOptions } from '@evervault/react';
7
- import { PayPalButtonsComponentOptions } from '@paypal/paypal-js';
8
3
  import { PayPalButtonStyle } from '@paypal/paypal-js';
9
- import { PayPalScriptOptions } from '@paypal/paypal-js';
10
- import { Venmo } from 'braintree-web/venmo';
11
-
12
- declare type ApplePayButtonLocale = 'ar-AB' | 'ca-ES' | 'cs-CZ' | 'da-DK' | 'de-DE' | 'el-GR' | 'en-AU' | 'en-GB' | 'en-US' | 'es-ES' | 'es-MX' | 'fi-FI' | 'fr-CA' | 'fr-FR' | 'he-IL' | 'hi-IN' | 'hr-HR' | 'hu-HU' | 'id-ID' | 'it-IT' | 'ja-JP' | 'ko-KR' | 'ms-MY' | 'nb-NO' | 'nl-NL' | 'pl-PL' | 'pt-BR' | 'pt-PT' | 'ro-RO' | 'ru-RU' | 'sk-SK' | 'sv-SE' | 'th-TH' | 'tr-TR' | 'uk-UA' | 'vi-VN' | 'zh-CN' | 'zh-HK' | 'zh-TW';
13
-
14
- declare type ApplePayCardNetwork = 'amex' | 'bancomat' | 'bancontact' | 'cartesBancaires' | 'chinaUnionPay' | 'dankort' | 'discover' | 'eftpos' | 'electron' | 'elo' | 'girocard' | 'interac' | 'jcb' | 'mada' | 'maestro' | 'masterCard' | 'mir' | 'privateLabel' | 'visa' | 'vPay';
15
-
16
- declare interface ApplePayConfig extends IButtonActionsHandler<EncryptedApplePayData> {
17
- transaction: ApplePayTransaction;
18
- supportedCardTypes?: ApplePayCardNetwork[];
19
- locale?: ApplePayButtonLocale;
20
- onPaymentAttempt?: (result: AttemptResult) => void;
21
- }
22
-
23
- declare interface ApplePayTransaction {
24
- amount: number;
25
- currency: string;
26
- country: string;
27
- merchantId: string;
28
- lineItems: Array<{
29
- label: string;
30
- amount: number;
31
- }>;
32
- }
33
4
 
34
5
  export declare interface AttemptResult {
35
6
  paymentMethod: PaymentMethod;
36
7
  }
37
8
 
38
- declare interface BillingAddress {
39
- city?: string;
40
- country?: string;
41
- line1?: string;
42
- line2?: string;
43
- postal_code?: string;
44
- state?: string;
45
- }
46
-
47
- declare interface BraintreeConfig extends IButtonActionsHandler {
48
- authorization: string;
49
- }
50
-
51
- declare class BraintreeService {
52
- private client;
53
- private venmoInstance;
54
- private deviceData;
55
- init(config: BraintreeConfig): Promise<void>;
56
- createVenmo(config?: Partial<VenmoConfig>): Promise<Venmo>;
57
- isBrowserSupported(): boolean;
58
- hasTokenizationResult(): boolean;
59
- tokenize(): Promise<VenmoTokenizePayload>;
60
- }
61
-
62
9
  export declare enum CardType {
63
10
  Visa = "visa",
64
11
  Mastercard = "mastercard"
65
12
  }
66
13
 
67
- declare interface CheckoutConfig {
68
- type: PaymentMethod;
69
- order: number;
70
- is_active: boolean;
71
- }
72
-
73
- declare interface CheckoutConfig_2 {
74
- service: {
75
- ev: EvService;
76
- paypal: PayPalService;
77
- braintree: BraintreeService;
78
- };
79
- state: ICheckoutState;
80
- }
81
-
82
14
  export declare interface CheckoutError {
83
15
  status: DeclineStatus;
84
16
  status_reason: {
@@ -88,19 +20,6 @@ export declare interface CheckoutError {
88
20
  };
89
21
  }
90
22
 
91
- declare class CheckoutModule {
92
- private readonly config;
93
- private component;
94
- private sentry;
95
- constructor(config: CheckoutConfig_2);
96
- init(): Promise<void>;
97
- mount(): Promise<HTMLElement>;
98
- }
99
-
100
- declare class CheckoutState extends State<PayNextConfig> {
101
- constructor(state?: PayNextConfig);
102
- }
103
-
104
23
  export declare interface CheckoutTranslate {
105
24
  card: {
106
25
  required: string;
@@ -191,26 +110,6 @@ declare interface CheckoutTranslateOverrides {
191
110
  };
192
111
  }
193
112
 
194
- declare interface CheckoutTranslateState {
195
- overrides?: CheckoutTranslateOverrides;
196
- messages: CheckoutTranslate;
197
- locale: Locale;
198
- }
199
-
200
- export declare class Core {
201
- readonly ev: EvService;
202
- readonly paypal: PayPalService;
203
- readonly braintree: BraintreeService;
204
- readonly state: {
205
- translate: TranslateState;
206
- checkout: CheckoutState;
207
- transaction: TransactionState;
208
- styles: StylesState;
209
- };
210
- readonly checkout: CheckoutModule;
211
- clearState(): void;
212
- }
213
-
214
113
  declare type CSSProperties = Record<string, string>;
215
114
 
216
115
  declare enum DeclineCode {
@@ -235,50 +134,6 @@ export declare type DeepPartial<T> = T extends object ? {
235
134
  [P in keyof T]?: DeepPartial<T[P]>;
236
135
  } : T;
237
136
 
238
- declare interface EvConfig {
239
- teamId: string;
240
- appId: string;
241
- }
242
-
243
- declare class EvService {
244
- isReady: boolean;
245
- private ev;
246
- private apple;
247
- private google;
248
- private threeDs;
249
- private readonly events;
250
- private isShouldLoad;
251
- preloadEvervault(config: EvConfig): Promise<void>;
252
- initEv(config: EvConfig): Promise<void>;
253
- initThreeDs(config: ThreeDsConfig): Promise<void>;
254
- initApple(config: ApplePayConfig, options?: IApplePayButtonStyles): Promise<void>;
255
- initGoogle(config: GooglePayConfig, options?: IGooglePayButtonStyles): Promise<void>;
256
- isAppleAvailable(): boolean;
257
- addEventListener(event: keyof EvService['events'], listener: Listener<void>): Unsubscribe;
258
- renderApple(parent: HTMLElement): Promise<void | undefined>;
259
- renderGoogle(parent: HTMLElement): Promise<void | undefined>;
260
- getEv(): EvervaultInstance;
261
- }
262
-
263
- declare type GooglePayButtonLocale = 'en' | 'ar' | 'bg' | 'ca' | 'cs' | 'da' | 'de' | 'el' | 'es' | 'et' | 'fi' | 'fr' | 'hr' | 'id' | 'it' | 'ja' | 'ko' | 'ms' | 'nl' | 'no' | 'pl' | 'pt' | 'ru' | 'sk' | 'sl' | 'sr' | 'sv' | 'th' | 'tr' | 'uk' | 'zh';
264
-
265
- declare interface GooglePayConfig extends IButtonActionsHandler<EncryptedGooglePayData> {
266
- transaction: GooglePayTransaction;
267
- locale?: GooglePayButtonLocale;
268
- onPaymentAttempt?: (result: AttemptResult) => void;
269
- }
270
-
271
- declare interface GooglePayTransaction {
272
- amount: number;
273
- currency: string;
274
- country: string;
275
- merchantId: string;
276
- lineItems: Array<{
277
- label: string;
278
- amount: number;
279
- }>;
280
- }
281
-
282
137
  export declare type HTMLStyles = {
283
138
  styles?: CSSProperties;
284
139
  className?: string;
@@ -288,20 +143,6 @@ export declare interface IApplePayButtonStyles {
288
143
  styles?: Partial<Pick<ApplePayOptions, 'type' | 'style' | 'padding' | 'borderRadius' | 'size'>>;
289
144
  }
290
145
 
291
- declare interface IButtonActionsHandler<TSuccess = void> {
292
- onReady?: () => void;
293
- onError?: (err: PaymentError) => void;
294
- onCancel?: () => void;
295
- onSuccess?: (data?: TSuccess) => void;
296
- }
297
-
298
- declare interface ICheckoutState {
299
- translate: TranslateState;
300
- checkout: CheckoutState;
301
- transaction: TransactionState;
302
- styles: StylesState;
303
- }
304
-
305
146
  export declare interface IGooglePayButtonStyles {
306
147
  styles?: Partial<Pick<GooglePayOptions, 'type' | 'color' | 'borderRadius' | 'size'>>;
307
148
  }
@@ -326,8 +167,6 @@ export declare interface ISubmitButtonStyles extends HTMLStyles {
326
167
  iconSvg?: string;
327
168
  }
328
169
 
329
- declare type Listener<TData> = (data: TData) => void;
330
-
331
170
  export declare interface LoadedResult {
332
171
  success: boolean;
333
172
  error?: CheckoutError;
@@ -335,11 +174,6 @@ export declare interface LoadedResult {
335
174
 
336
175
  export declare type Locale = 'ar' | 'en' | 'bg' | 'cs' | 'da' | 'de' | 'el' | 'es' | 'et' | 'fi' | 'fil' | 'fr' | 'hr' | 'hu' | 'id' | 'it' | 'ja' | 'ko' | 'lt' | 'lv' | 'ms' | 'ru' | 'mt' | 'no' | 'nl' | 'pl' | 'pt' | 'ro' | 'uk' | 'sk' | 'sl' | 'sv' | 'th' | 'tr' | 'vi' | 'zh';
337
176
 
338
- declare interface PaymentError {
339
- e?: unknown;
340
- paymentMethod?: PaymentMethod;
341
- }
342
-
343
177
  export declare enum PaymentMethod {
344
178
  PAYPAL = "PAYPAL",
345
179
  APPLE_PAY = "APPLEPAY",
@@ -513,13 +347,72 @@ declare enum PaymentStatus {
513
347
  CANCELLED = "CANCELLED"
514
348
  }
515
349
 
516
- export declare class PayNextCheckout {
517
- private core;
518
- private parentId;
350
+ /**
351
+ * PayNext SDK - CDN Loader
352
+ *
353
+ * This file provides a smart wrapper that automatically loads the SDK from CDN.
354
+ * When users install via npm, they get the latest version from CDN automatically.
355
+ *
356
+ * Benefits:
357
+ * - Always up-to-date (loads from CDN)
358
+ * - Smaller npm package size
359
+ * - Automatic CSS injection
360
+ * - Browser caching benefits
361
+ */
362
+ /**
363
+ * PayNextCheckout Proxy Class
364
+ *
365
+ * This class acts as a proxy that loads the actual implementation from CDN.
366
+ * Users can use it immediately, and the CDN version will be loaded on demand.
367
+ */
368
+ declare class PayNextCheckout {
369
+ private cdnInstance;
370
+ private initPromise;
519
371
  constructor();
520
- mount(componentId: string, config: PayNextConfig): Promise<void>;
372
+ /**
373
+ * Initialize SDK from CDN
374
+ */
375
+ private initialize;
376
+ /**
377
+ * Wait for SDK to be ready
378
+ */
379
+ private waitForReady;
380
+ /**
381
+ * Mount checkout to DOM element
382
+ *
383
+ * @param containerId - DOM element ID
384
+ * @param config - Checkout configuration
385
+ */
386
+ mount(containerId: string, config: any): Promise<void>;
387
+ /**
388
+ * Unmount checkout from DOM
389
+ */
521
390
  unmount(): Promise<void>;
522
- }
391
+ /**
392
+ * Update checkout configuration
393
+ *
394
+ * @param config - New configuration
395
+ */
396
+ updateConfig(config: any): Promise<void>;
397
+ /**
398
+ * Get SDK version
399
+ */
400
+ static getVersion(): string;
401
+ /**
402
+ * Get CDN URL
403
+ */
404
+ static getCDNUrl(): string;
405
+ /**
406
+ * Check if SDK is loaded
407
+ */
408
+ static isLoaded(): boolean;
409
+ /**
410
+ * Preload SDK (optional optimization)
411
+ */
412
+ static preload(): Promise<void>;
413
+ }
414
+ export { PayNextCheckout }
415
+ export default PayNextCheckout;
523
416
 
524
417
  export declare interface PayNextConfig {
525
418
  clientToken: string;
@@ -536,23 +429,15 @@ export declare interface PayNextConfig {
536
429
  onCheckoutFail?: (error: CheckoutError) => void;
537
430
  }
538
431
 
539
- declare class PayPalService {
540
- private paypal;
541
- init(config: PayPalScriptOptions): Promise<void>;
542
- isLoaded(): boolean;
543
- render(parent: HTMLElement, options?: PayPalButtonsComponentOptions): Promise<void>;
544
- }
545
-
546
- declare abstract class State<TState> {
547
- private readonly initialState;
548
- private state;
549
- private readonly observer;
550
- constructor(state: TState);
551
- getState(): TState;
552
- setState(state: TState): void;
553
- clearState(): void;
554
- subscribe(listener: Listener<TState>): Unsubscribe;
555
- }
432
+ /**
433
+ * Export utilities
434
+ */
435
+ export declare const PayNextSDK: {
436
+ version: string;
437
+ cdnUrl: string;
438
+ preload: typeof PayNextCheckout.preload;
439
+ isLoaded: typeof PayNextCheckout.isLoaded;
440
+ };
556
441
 
557
442
  export declare interface StylesConfig {
558
443
  Input?: InputStyles;
@@ -565,86 +450,6 @@ export declare interface StylesConfig {
565
450
  BackButton?: HTMLStyles;
566
451
  }
567
452
 
568
- declare class StylesState extends State<StylesConfig> {
569
- constructor(state?: StylesConfig);
570
- }
571
-
572
453
  declare type TEnvironment = 'develop' | 'sandbox' | 'production';
573
454
 
574
- declare interface ThreeDsConfig {
575
- readonly threeDsId: string;
576
- readonly onReady?: () => void;
577
- readonly onSuccess?: () => void;
578
- readonly onError?: () => void;
579
- }
580
-
581
- declare interface TransactionConfig {
582
- amount: number;
583
- currency: string;
584
- country: string;
585
- merchant_id: string;
586
- apple_pay_info: {
587
- line_items: Array<{
588
- label: string;
589
- amount: 99;
590
- }>;
591
- };
592
- paypal_info?: {
593
- client_id: string;
594
- environment: 'sandbox' | 'production';
595
- };
596
- checkout_config: CheckoutConfig[];
597
- evervault: {
598
- app_id: string;
599
- team_id: string;
600
- };
601
- brain_tree_info?: {
602
- client_token: string;
603
- };
604
- }
605
-
606
- declare interface TransactionConfigResponse extends TransactionConfig {
607
- code: number;
608
- success: boolean;
609
- error?: string;
610
- }
611
-
612
- declare class TransactionState extends State<TransactionConfig | null> {
613
- private clientToken;
614
- constructor(state?: TransactionConfig);
615
- updateTransaction(clientToken: string, environment: TEnvironment, apiVersion: string): Promise<TransactionConfigResponse>;
616
- }
617
-
618
- declare class TranslateState extends State<CheckoutTranslateState> {
619
- constructor();
620
- setMessages(overrides: CheckoutTranslateOverrides): void;
621
- setLocale(locale: Locale): void;
622
- overrides(): CheckoutTranslateOverrides | undefined;
623
- messages(): CheckoutTranslate;
624
- locale(): Locale;
625
- dir(): 'rtl' | 'ltr';
626
- }
627
-
628
- declare type Unsubscribe = () => void;
629
-
630
- declare interface VenmoConfig {
631
- client: Client;
632
- allowDesktop?: boolean;
633
- allowDesktopWebLogin?: boolean;
634
- paymentMethodUsage?: 'single_use' | 'multi_use';
635
- mobileWebFallBack?: boolean;
636
- allowNewBrowserTab?: boolean;
637
- deepLinkReturnUrl?: string;
638
- }
639
-
640
- declare interface VenmoTokenizePayload {
641
- nonce: string;
642
- type: string;
643
- details: {
644
- username: string;
645
- };
646
- device_data?: string;
647
- billing_address?: BillingAddress;
648
- }
649
-
650
455
  export { }