@paynext/sdk 1.0.6 → 1.0.8

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/index.d.ts CHANGED
@@ -58,10 +58,21 @@ export declare interface CheckoutTranslate {
58
58
  button: string;
59
59
  };
60
60
  };
61
+ savedPaymentMethod: {
62
+ change: {
63
+ button: string;
64
+ select: string;
65
+ };
66
+ pay: {
67
+ button: string;
68
+ };
69
+ separator: string;
70
+ };
61
71
  status: {
62
72
  error: string;
63
73
  invalidSession: string;
64
74
  authenticationFailed: string;
75
+ errorSavedPaymentMethod: string;
65
76
  };
66
77
  }
67
78
 
@@ -104,15 +115,48 @@ declare interface CheckoutTranslateOverrides {
104
115
  button?: string;
105
116
  };
106
117
  };
118
+ savedPaymentMethod?: {
119
+ change?: {
120
+ button?: string;
121
+ select?: string;
122
+ };
123
+ pay?: {
124
+ button?: string;
125
+ };
126
+ separator?: string;
127
+ };
107
128
  status?: {
108
129
  error?: string;
109
130
  invalidSession?: string;
110
131
  authenticationFailed?: string;
132
+ errorSavedPaymentMethod?: string;
111
133
  };
112
134
  }
113
135
 
114
136
  declare type CSSProperties = Record<string, string>;
115
137
 
138
+ export declare interface CSSVariablesConfig {
139
+ '--paynext-sdk-bg'?: string;
140
+ '--paynext-sdk-text'?: string;
141
+ '--paynext-sdk-border'?: string;
142
+ '--paynext-sdk-border-focus'?: string;
143
+ '--paynext-sdk-border-radius'?: string;
144
+ '--paynext-sdk-input-bg'?: string;
145
+ '--paynext-sdk-input-text'?: string;
146
+ '--paynext-sdk-input-focus-shadow'?: string;
147
+ '--paynext-sdk-placeholder'?: string;
148
+ '--paynext-sdk-error'?: string;
149
+ '--paynext-sdk-error-border'?: string;
150
+ '--paynext-sdk-disabled-bg'?: string;
151
+ '--paynext-sdk-disabled-text'?: string;
152
+ '--paynext-sdk-button-bg'?: string;
153
+ '--paynext-sdk-button-text'?: string;
154
+ '--paynext-sdk-button-hover-bg'?: string;
155
+ '--paynext-sdk-button-hover-opacity'?: string;
156
+ '--paynext-sdk-card-bg'?: string;
157
+ '--paynext-sdk-card-icon'?: string;
158
+ }
159
+
116
160
  declare enum DeclineCode {
117
161
  INSUFFICIENT_FUNDS = "insufficient_funds",
118
162
  AUTHENTICATION_REQUIRED = "authentication_required",
@@ -377,11 +421,11 @@ export declare interface PayNextConfig {
377
421
  translate?: CheckoutTranslateOverrides;
378
422
  locale?: Locale;
379
423
  errorMessageText?: string;
424
+ returnUrl?: string;
380
425
  onCheckoutLoaded?: (result: LoadedResult) => void;
381
426
  onCheckoutAttempt?: (result: AttemptResult) => void;
382
427
  onCheckoutComplete?: (result: PaymentResult) => void;
383
428
  onCheckoutFail?: (error: CheckoutError) => void;
384
- _themeExplicit?: boolean;
385
429
  }
386
430
 
387
431
  export declare const PayNextSDK: {
@@ -398,6 +442,7 @@ export declare interface StylesConfig {
398
442
  BraintreeButton?: HTMLStyles;
399
443
  CashAppButton?: HTMLStyles;
400
444
  BackButton?: HTMLStyles;
445
+ cssVariables?: CSSVariablesConfig;
401
446
  }
402
447
 
403
448
  export declare type TEnvironment = 'develop' | 'staging' | 'sandbox' | 'production';
package/dist/index.es.js CHANGED
@@ -1,87 +1,86 @@
1
- var E = Object.defineProperty;
2
- var x = (n, e, t) => e in n ? E(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var a = (n, e, t) => x(n, typeof e != "symbol" ? e + "" : e, t);
4
- const p = "https://cdn-sdk-dev.paynext.com/index.cdn.js", C = "https://cdn-sdk.paynext.com/index.cdn.js";
5
- let c = null, l = null;
6
- class r extends Error {
1
+ var p = Object.defineProperty;
2
+ var N = (r, e, t) => e in r ? p(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var a = (r, e, t) => N(r, typeof e != "symbol" ? e + "" : e, t);
4
+ const x = "https://cdn-sdk-dev.paynext.com/index.cdn.js", A = "https://cdn-sdk.paynext.com/index.cdn.js";
5
+ let c = null, d = null;
6
+ class n extends Error {
7
7
  constructor(e, t = !0) {
8
8
  super(e), this.retryable = t, this.name = "SDKLoadError";
9
9
  }
10
10
  }
11
- const P = "PayNextSDK";
12
- function w() {
13
- return typeof window > "u" ? null : window[P];
11
+ const D = "PayNextSDK";
12
+ function y() {
13
+ return typeof window > "u" ? null : window[D];
14
14
  }
15
- function K(n) {
16
- typeof window > "u" || (window[P] = n);
15
+ function C(r) {
16
+ typeof window > "u" || (window[D] = r);
17
17
  }
18
- function g(n) {
19
- return new Promise((e) => setTimeout(e, n));
18
+ function K(r) {
19
+ return new Promise((e) => setTimeout(e, r));
20
20
  }
21
- async function S(n, e = 1) {
22
- const o = (n?.toLowerCase()?.includes("develop") || n?.toLowerCase()?.includes("staging") ? "develop" : "production") === "develop" ? p : C;
21
+ async function P(r, e = 1) {
22
+ const o = (r?.toLowerCase()?.includes("develop") || r?.toLowerCase()?.includes("staging") ? "develop" : "production") === "develop" ? x : A;
23
23
  try {
24
- console.log(`[PayNext CDN] Loading SDK (attempt ${e}/3)...`);
25
- const s = w();
26
- if (s)
27
- return console.log("[PayNext CDN] SDK already loaded"), s;
28
- await new Promise((y, h) => {
24
+ const i = y();
25
+ if (i)
26
+ return i;
27
+ await new Promise((h, w) => {
29
28
  if (document.querySelector(`script[src="${o}"]`)) {
30
- console.log("[PayNext CDN] Script exists, waiting for SDK..."), y();
29
+ h();
31
30
  return;
32
31
  }
33
- const m = setTimeout(() => {
34
- d(), h(new r("SDK script loading timeout", !0));
35
- }, 1e4), i = document.createElement("script");
36
- i.src = o, i.crossOrigin = "anonymous", i.async = !0, i.setAttribute("data-paynext-sdk", "true");
37
- const d = () => {
38
- clearTimeout(m), i.onload = null, i.onerror = null;
32
+ const E = setTimeout(() => {
33
+ l(), w(new n("SDK script loading timeout", !0));
34
+ }, 1e4), s = document.createElement("script");
35
+ s.src = o, s.crossOrigin = "anonymous", s.async = !0, s.setAttribute("data-paynext-sdk", "true");
36
+ const l = () => {
37
+ clearTimeout(E), s.onload = null, s.onerror = null;
39
38
  };
40
- i.onload = () => {
41
- console.log("[PayNext CDN] Script loaded successfully"), d(), y();
42
- }, i.onerror = (f) => {
43
- console.error("[PayNext CDN] Script load error:", f), d();
39
+ s.onload = () => {
40
+ l(), h();
41
+ }, s.onerror = (f) => {
42
+ console.error("[PayNext CDN] Script load error:", f), l();
44
43
  try {
45
- i.parentNode && i.parentNode.removeChild(i);
46
- } catch (N) {
47
- console.warn("[PayNext CDN] Failed to remove script:", N);
44
+ s.parentNode && s.parentNode.removeChild(s);
45
+ } catch (S) {
46
+ console.warn("[PayNext CDN] Failed to remove script:", S);
48
47
  }
49
- h(new r("Failed to load SDK script from CDN", !0));
48
+ w(new n("Failed to load SDK script from CDN", !0));
50
49
  };
51
50
  try {
52
- document.head.appendChild(i);
51
+ document.head.appendChild(s);
53
52
  } catch {
54
- d(), h(new r("Failed to append script to document", !1));
53
+ l(), w(new n("Failed to append script to document", !1));
55
54
  }
56
55
  });
57
- const u = w();
56
+ const u = y();
58
57
  if (!u)
59
- throw new r("PayNextSDK not found in window after load", !0);
60
- return console.log("[PayNext CDN] SDK loaded successfully"), u;
61
- } catch (s) {
62
- if ((s instanceof r ? s.retryable : !0) && e < 3)
63
- return console.warn(`[PayNext CDN] Load attempt ${e} failed, retrying in 1000ms...`, s), await g(1e3 * e), S(n, e + 1);
64
- throw console.error(`[PayNext CDN] Failed to load SDK after ${e} attempts:`, s), s;
58
+ throw new n("PayNextSDK not found in window after load", !0);
59
+ return u;
60
+ } catch (i) {
61
+ if ((i instanceof n ? i.retryable : !0) && e < 3)
62
+ return console.warn(`[PayNext CDN] Load attempt ${e} failed, retrying in 1000ms...`, i), await K(1e3 * e), P(r, e + 1);
63
+ throw console.error(`[PayNext CDN] Failed to load SDK after ${e} attempts:`, i), i;
65
64
  }
66
65
  }
67
- async function D(n) {
68
- if (l)
69
- return console.log("[PayNext CDN] Returning cached SDK module"), l;
66
+ async function m(r) {
67
+ if (d)
68
+ return d;
70
69
  if (c)
71
- return console.log("[PayNext CDN] Load already in progress, waiting..."), c;
70
+ return c;
72
71
  if (typeof window > "u")
73
- throw new r("PayNext SDK can only be loaded in browser environment", !1);
74
- const e = w();
75
- return e ? (console.log("[PayNext CDN] SDK already loaded in isolated namespace"), l = e, l) : (c = (async () => {
72
+ throw new n("PayNext SDK can only be loaded in browser environment", !1);
73
+ const e = y();
74
+ return e ? (d = e, d) : (c = (async () => {
76
75
  try {
77
- const t = await S(n);
78
- return l = t, K(t), t;
76
+ const t = await P(r);
77
+ return d = t, C(t), t;
79
78
  } catch (t) {
80
79
  throw c = null, t;
81
80
  }
82
81
  })(), c);
83
82
  }
84
- class A {
83
+ class R {
85
84
  constructor() {
86
85
  a(this, "cdnInstance", null);
87
86
  a(this, "initPromise", null);
@@ -98,28 +97,27 @@ class A {
98
97
  if (console.error(o, e), this.errorBoundary)
99
98
  try {
100
99
  this.errorBoundary(e);
101
- } catch (s) {
102
- console.error("[PayNext SDK] Error in custom error handler:", s);
100
+ } catch (i) {
101
+ console.error("[PayNext SDK] Error in custom error handler:", i);
103
102
  }
104
103
  }
105
104
  // initialize
106
105
  async initialize(e) {
107
106
  if (this.isDestroyed)
108
- throw new r("Cannot initialize destroyed SDK instance", !1);
107
+ throw new n("Cannot initialize destroyed SDK instance", !1);
109
108
  return this.initPromise ? this.initPromise : (this.initPromise = (async () => {
110
109
  try {
111
- const t = await D(e);
110
+ const t = await m(e);
112
111
  if (!t || !t.PayNextCheckout)
113
- throw new r("PayNextCheckout not found in loaded SDK module", !1);
112
+ throw new n("PayNextCheckout not found in loaded SDK module", !1);
114
113
  try {
115
114
  this.cdnInstance = new t.PayNextCheckout();
116
115
  } catch (o) {
117
- throw new r(
116
+ throw new n(
118
117
  `Failed to instantiate PayNextCheckout: ${o instanceof Error ? o.message : "Unknown error"}`,
119
118
  !1
120
119
  );
121
120
  }
122
- console.log("[PayNext SDK] Initialized successfully");
123
121
  } catch (t) {
124
122
  throw this.initPromise = null, t;
125
123
  }
@@ -128,28 +126,28 @@ class A {
128
126
  // assert ready
129
127
  assertReady() {
130
128
  if (this.isDestroyed)
131
- throw new r("SDK instance has been destroyed", !1);
129
+ throw new n("SDK instance has been destroyed", !1);
132
130
  if (!this.initPromise)
133
- throw new r("SDK initialization not started", !1);
131
+ throw new n("SDK initialization not started", !1);
134
132
  if (!this.cdnInstance)
135
- throw new r("SDK instance not created", !1);
133
+ throw new n("SDK instance not created", !1);
136
134
  }
137
135
  // mount
138
136
  async mount(e, t) {
139
137
  try {
140
138
  if (!e || typeof e != "string")
141
- throw new r("Invalid containerId provided", !1);
139
+ throw new n("Invalid containerId provided", !1);
142
140
  if (!t || !t.environment)
143
- throw new r("Invalid config provided", !1);
141
+ throw new n("Invalid config provided", !1);
144
142
  if (!document.getElementById(e))
145
- throw new r(`Container element with id "${e}" not found`, !1);
143
+ throw new n(`Container element with id "${e}" not found`, !1);
146
144
  await this.initialize(t.environment), this.assertReady(), await this.cdnInstance.mount(e, t);
147
145
  } catch (o) {
148
- const s = o instanceof r ? o : new r(
146
+ const i = o instanceof n ? o : new n(
149
147
  o instanceof Error ? o.message : "Unknown mount error",
150
148
  !0
151
149
  );
152
- throw this.handleError(s, "mount"), s;
150
+ throw this.handleError(i, "mount"), i;
153
151
  }
154
152
  }
155
153
  // unmount
@@ -178,18 +176,18 @@ class A {
178
176
  // preload SDK
179
177
  static async preload(e) {
180
178
  try {
181
- await D(e), console.log("[PayNext SDK] Preload successful");
179
+ await m(e);
182
180
  } catch (t) {
183
181
  throw console.error("[PayNext SDK] Preload failed:", t), t;
184
182
  }
185
183
  }
186
184
  }
187
- const L = {
188
- preload: A.preload
185
+ const T = {
186
+ preload: R.preload
189
187
  };
190
- var R = /* @__PURE__ */ ((n) => (n.PAYPAL = "PAYPAL", n.APPLE_PAY = "APPLEPAY", n.GOOGLE_PAY = "GPAY", n.CARD = "CARD", n.VENMO = "VENMO", n.CASHAPP = "CASHAPP", n))(R || {});
188
+ var _ = /* @__PURE__ */ ((r) => (r.PAYPAL = "PAYPAL", r.APPLE_PAY = "APPLEPAY", r.GOOGLE_PAY = "GPAY", r.CARD = "CARD", r.VENMO = "VENMO", r.CASHAPP = "CASHAPP", r))(_ || {});
191
189
  export {
192
- A as PayNextCheckout,
193
- L as PayNextSDK,
194
- R as PaymentMethod
190
+ R as PayNextCheckout,
191
+ T as PayNextSDK,
192
+ _ as PaymentMethod
195
193
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(r,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(r=typeof globalThis<"u"?globalThis:r||self,s(r["PayNext SDK"]={}))})(this,(function(r){"use strict";var T=Object.defineProperty;var _=(r,s,l)=>s in r?T(r,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):r[s]=l;var y=(r,s,l)=>_(r,typeof s!="symbol"?s+"":s,l);const s="https://cdn-sdk-dev.paynext.com/index.cdn.js",l="https://cdn-sdk.paynext.com/index.cdn.js";let d=null,u=null;class o extends Error{constructor(e,t=!0){super(e),this.retryable=t,this.name="SDKLoadError"}}const S="PayNextSDK";function h(){return typeof window>"u"?null:window[S]}function K(n){typeof window>"u"||(window[S]=n)}function g(n){return new Promise(e=>setTimeout(e,n))}async function m(n,e=1){const i=(n?.toLowerCase()?.includes("develop")||n?.toLowerCase()?.includes("staging")?"develop":"production")==="develop"?s:l;try{console.log(`[PayNext CDN] Loading SDK (attempt ${e}/3)...`);const a=h();if(a)return console.log("[PayNext CDN] SDK already loaded"),a;await new Promise((D,P)=>{if(document.querySelector(`script[src="${i}"]`)){console.log("[PayNext CDN] Script exists, waiting for SDK..."),D();return}const A=setTimeout(()=>{f(),P(new o("SDK script loading timeout",!0))},1e4),c=document.createElement("script");c.src=i,c.crossOrigin="anonymous",c.async=!0,c.setAttribute("data-paynext-sdk","true");const f=()=>{clearTimeout(A),c.onload=null,c.onerror=null};c.onload=()=>{console.log("[PayNext CDN] Script loaded successfully"),f(),D()},c.onerror=x=>{console.error("[PayNext CDN] Script load error:",x),f();try{c.parentNode&&c.parentNode.removeChild(c)}catch(R){console.warn("[PayNext CDN] Failed to remove script:",R)}P(new o("Failed to load SDK script from CDN",!0))};try{document.head.appendChild(c)}catch{f(),P(new o("Failed to append script to document",!1))}});const w=h();if(!w)throw new o("PayNextSDK not found in window after load",!0);return console.log("[PayNext CDN] SDK loaded successfully"),w}catch(a){if((a instanceof o?a.retryable:!0)&&e<3)return console.warn(`[PayNext CDN] Load attempt ${e} failed, retrying in 1000ms...`,a),await g(1e3*e),m(n,e+1);throw console.error(`[PayNext CDN] Failed to load SDK after ${e} attempts:`,a),a}}async function N(n){if(u)return console.log("[PayNext CDN] Returning cached SDK module"),u;if(d)return console.log("[PayNext CDN] Load already in progress, waiting..."),d;if(typeof window>"u")throw new o("PayNext SDK can only be loaded in browser environment",!1);const e=h();return e?(console.log("[PayNext CDN] SDK already loaded in isolated namespace"),u=e,u):(d=(async()=>{try{const t=await m(n);return u=t,K(t),t}catch(t){throw d=null,t}})(),d)}class E{constructor(){y(this,"cdnInstance",null);y(this,"initPromise",null);y(this,"isDestroyed",!1);y(this,"errorBoundary",null)}setErrorHandler(e){this.errorBoundary=e}handleError(e,t){const i=`[PayNext SDK Error - ${t}]: ${e.message}`;if(console.error(i,e),this.errorBoundary)try{this.errorBoundary(e)}catch(a){console.error("[PayNext SDK] Error in custom error handler:",a)}}async initialize(e){if(this.isDestroyed)throw new o("Cannot initialize destroyed SDK instance",!1);return this.initPromise?this.initPromise:(this.initPromise=(async()=>{try{const t=await N(e);if(!t||!t.PayNextCheckout)throw new o("PayNextCheckout not found in loaded SDK module",!1);try{this.cdnInstance=new t.PayNextCheckout}catch(i){throw new o(`Failed to instantiate PayNextCheckout: ${i instanceof Error?i.message:"Unknown error"}`,!1)}console.log("[PayNext SDK] Initialized successfully")}catch(t){throw this.initPromise=null,t}})(),this.initPromise)}assertReady(){if(this.isDestroyed)throw new o("SDK instance has been destroyed",!1);if(!this.initPromise)throw new o("SDK initialization not started",!1);if(!this.cdnInstance)throw new o("SDK instance not created",!1)}async mount(e,t){try{if(!e||typeof e!="string")throw new o("Invalid containerId provided",!1);if(!t||!t.environment)throw new o("Invalid config provided",!1);if(!document.getElementById(e))throw new o(`Container element with id "${e}" not found`,!1);await this.initialize(t.environment),this.assertReady(),await this.cdnInstance.mount(e,t)}catch(i){const a=i instanceof o?i:new o(i instanceof Error?i.message:"Unknown mount error",!0);throw this.handleError(a,"mount"),a}}async unmount(){try{if(this.isDestroyed){console.warn("[PayNext SDK] Instance already destroyed");return}if(!this.cdnInstance){console.warn("[PayNext SDK] No instance to unmount");return}try{typeof this.cdnInstance.unmount=="function"&&await this.cdnInstance.unmount()}catch(e){const t=e instanceof Error?e:new Error(String(e));this.handleError(t,"unmount")}this.cdnInstance=null,this.initPromise=null}catch(e){const t=e instanceof Error?e:new Error(String(e));this.handleError(t,"unmount")}}static async preload(e){try{await N(e),console.log("[PayNext SDK] Preload successful")}catch(t){throw console.error("[PayNext SDK] Preload failed:",t),t}}}const C={preload:E.preload};var p=(n=>(n.PAYPAL="PAYPAL",n.APPLE_PAY="APPLEPAY",n.GOOGLE_PAY="GPAY",n.CARD="CARD",n.VENMO="VENMO",n.CASHAPP="CASHAPP",n))(p||{});r.PayNextCheckout=E,r.PayNextSDK=C,r.PaymentMethod=p,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(o,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(o=typeof globalThis<"u"?globalThis:o||self,i(o["PayNext SDK"]={}))})(this,(function(o){"use strict";var T=Object.defineProperty;var g=(o,i,d)=>i in o?T(o,i,{enumerable:!0,configurable:!0,writable:!0,value:d}):o[i]=d;var h=(o,i,d)=>g(o,typeof i!="symbol"?i+"":i,d);const i="https://cdn-sdk-dev.paynext.com/index.cdn.js",d="https://cdn-sdk.paynext.com/index.cdn.js";let l=null,u=null;class r extends Error{constructor(e,t=!0){super(e),this.retryable=t,this.name="SDKLoadError"}}const D="PayNextSDK";function y(){return typeof window>"u"?null:window[D]}function A(n){typeof window>"u"||(window[D]=n)}function K(n){return new Promise(e=>setTimeout(e,n))}async function S(n,e=1){const s=(n?.toLowerCase()?.includes("develop")||n?.toLowerCase()?.includes("staging")?"develop":"production")==="develop"?i:d;try{const a=y();if(a)return a;await new Promise((m,P)=>{if(document.querySelector(`script[src="${s}"]`)){m();return}const R=setTimeout(()=>{f(),P(new r("SDK script loading timeout",!0))},1e4),c=document.createElement("script");c.src=s,c.crossOrigin="anonymous",c.async=!0,c.setAttribute("data-paynext-sdk","true");const f=()=>{clearTimeout(R),c.onload=null,c.onerror=null};c.onload=()=>{f(),m()},c.onerror=x=>{console.error("[PayNext CDN] Script load error:",x),f();try{c.parentNode&&c.parentNode.removeChild(c)}catch(_){console.warn("[PayNext CDN] Failed to remove script:",_)}P(new r("Failed to load SDK script from CDN",!0))};try{document.head.appendChild(c)}catch{f(),P(new r("Failed to append script to document",!1))}});const w=y();if(!w)throw new r("PayNextSDK not found in window after load",!0);return w}catch(a){if((a instanceof r?a.retryable:!0)&&e<3)return console.warn(`[PayNext CDN] Load attempt ${e} failed, retrying in 1000ms...`,a),await K(1e3*e),S(n,e+1);throw console.error(`[PayNext CDN] Failed to load SDK after ${e} attempts:`,a),a}}async function E(n){if(u)return u;if(l)return l;if(typeof window>"u")throw new r("PayNext SDK can only be loaded in browser environment",!1);const e=y();return e?(u=e,u):(l=(async()=>{try{const t=await S(n);return u=t,A(t),t}catch(t){throw l=null,t}})(),l)}class p{constructor(){h(this,"cdnInstance",null);h(this,"initPromise",null);h(this,"isDestroyed",!1);h(this,"errorBoundary",null)}setErrorHandler(e){this.errorBoundary=e}handleError(e,t){const s=`[PayNext SDK Error - ${t}]: ${e.message}`;if(console.error(s,e),this.errorBoundary)try{this.errorBoundary(e)}catch(a){console.error("[PayNext SDK] Error in custom error handler:",a)}}async initialize(e){if(this.isDestroyed)throw new r("Cannot initialize destroyed SDK instance",!1);return this.initPromise?this.initPromise:(this.initPromise=(async()=>{try{const t=await E(e);if(!t||!t.PayNextCheckout)throw new r("PayNextCheckout not found in loaded SDK module",!1);try{this.cdnInstance=new t.PayNextCheckout}catch(s){throw new r(`Failed to instantiate PayNextCheckout: ${s instanceof Error?s.message:"Unknown error"}`,!1)}}catch(t){throw this.initPromise=null,t}})(),this.initPromise)}assertReady(){if(this.isDestroyed)throw new r("SDK instance has been destroyed",!1);if(!this.initPromise)throw new r("SDK initialization not started",!1);if(!this.cdnInstance)throw new r("SDK instance not created",!1)}async mount(e,t){try{if(!e||typeof e!="string")throw new r("Invalid containerId provided",!1);if(!t||!t.environment)throw new r("Invalid config provided",!1);if(!document.getElementById(e))throw new r(`Container element with id "${e}" not found`,!1);await this.initialize(t.environment),this.assertReady(),await this.cdnInstance.mount(e,t)}catch(s){const a=s instanceof r?s:new r(s instanceof Error?s.message:"Unknown mount error",!0);throw this.handleError(a,"mount"),a}}async unmount(){try{if(this.isDestroyed){console.warn("[PayNext SDK] Instance already destroyed");return}if(!this.cdnInstance){console.warn("[PayNext SDK] No instance to unmount");return}try{typeof this.cdnInstance.unmount=="function"&&await this.cdnInstance.unmount()}catch(e){const t=e instanceof Error?e:new Error(String(e));this.handleError(t,"unmount")}this.cdnInstance=null,this.initPromise=null}catch(e){const t=e instanceof Error?e:new Error(String(e));this.handleError(t,"unmount")}}static async preload(e){try{await E(e)}catch(t){throw console.error("[PayNext SDK] Preload failed:",t),t}}}const C={preload:p.preload};var N=(n=>(n.PAYPAL="PAYPAL",n.APPLE_PAY="APPLEPAY",n.GOOGLE_PAY="GPAY",n.CARD="CARD",n.VENMO="VENMO",n.CASHAPP="CASHAPP",n))(N||{});o.PayNextCheckout=p,o.PayNextSDK=C,o.PaymentMethod=N,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paynext/sdk",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "PayNext SDK - Payment processing with automatic CDN loading",
5
5
  "type": "module",
6
6
  "main": "dist/index.es.js",