@paynext/sdk 1.0.19 → 1.0.21
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 +22 -1
- package/dist/index.es.js +84 -84
- package/dist/index.umd.js +1 -1
- package/package.json +3 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
import { PayPalButtonStyle } from '@paypal/paypal-js';
|
|
2
2
|
|
|
3
|
+
export declare interface ApplePayRecurringPaymentLineItem {
|
|
4
|
+
label: string;
|
|
5
|
+
amount: string;
|
|
6
|
+
paymentTiming: 'immediate' | 'recurring';
|
|
7
|
+
recurringPaymentStartDate?: Date;
|
|
8
|
+
recurringPaymentEndDate?: Date;
|
|
9
|
+
recurringPaymentIntervalUnit?: 'year' | 'month' | 'day' | 'hour' | 'minute';
|
|
10
|
+
recurringPaymentIntervalCount?: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export declare interface ApplePayRecurringPaymentRequest {
|
|
14
|
+
paymentDescription: string;
|
|
15
|
+
regularBilling: ApplePayRecurringPaymentLineItem;
|
|
16
|
+
trialBilling?: ApplePayRecurringPaymentLineItem;
|
|
17
|
+
billingAgreement?: string;
|
|
18
|
+
managementURL: string;
|
|
19
|
+
tokenNotificationURL?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
3
22
|
export declare interface AttemptResult {
|
|
4
23
|
paymentMethod: PaymentMethod;
|
|
5
24
|
cardType: string;
|
|
@@ -485,6 +504,8 @@ export declare interface PayNextConfig {
|
|
|
485
504
|
errorMessageText?: string;
|
|
486
505
|
returnUrl?: string;
|
|
487
506
|
paymentsEnabled?: boolean;
|
|
507
|
+
applePayMpanEnabled?: boolean;
|
|
508
|
+
applePayRecurringPaymentRequest?: ApplePayRecurringPaymentRequest;
|
|
488
509
|
onCheckoutLoaded?: (result: LoadedResult) => void;
|
|
489
510
|
onCheckoutAttempt?: (result: AttemptResult) => void;
|
|
490
511
|
beforeCheckoutAttempt?: (result: AttemptResult) => boolean | Promise<boolean>;
|
|
@@ -512,7 +533,7 @@ export declare interface StylesConfig {
|
|
|
512
533
|
cssVariables?: CSSVariablesConfig;
|
|
513
534
|
}
|
|
514
535
|
|
|
515
|
-
export declare type TEnvironment = 'develop' | 'preview1' | 'preview2' | 'preview3' | 'staging' | 'sandbox' | 'production';
|
|
536
|
+
export declare type TEnvironment = 'develop' | 'preview1' | 'preview2' | 'preview3' | 'preview4' | 'staging' | 'staging_preview1' | 'sandbox' | 'production';
|
|
516
537
|
|
|
517
538
|
export declare type ThemeMode = 'light' | 'dark' | 'system';
|
|
518
539
|
|
package/dist/index.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var C = (n, e, t) => e in n ?
|
|
1
|
+
var x = Object.defineProperty;
|
|
2
|
+
var C = (n, e, t) => e in n ? x(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
3
|
var d = (n, e, t) => C(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
const
|
|
5
|
-
let
|
|
6
|
-
function
|
|
4
|
+
const T = "https://cdn-sdk-dev.paynext.com/index.cdn.js", k = "https://cdn-sdk.paynext.com/index.cdn.js";
|
|
5
|
+
let y = null, w = null;
|
|
6
|
+
function g() {
|
|
7
7
|
const n = navigator.connection || navigator.mozConnection || navigator.webkitConnection, e = {
|
|
8
8
|
online: navigator.onLine,
|
|
9
9
|
documentHidden: document.hidden,
|
|
@@ -12,107 +12,107 @@ function T() {
|
|
|
12
12
|
};
|
|
13
13
|
return n && (e.connectionType = n.type, e.effectiveType = n.effectiveType, e.downlink = n.downlink, e.rtt = n.rtt, e.saveData = n.saveData), navigator.onLine ? document.hidden ? e.likelyCause = "background_tab" : n?.effectiveType === "slow-2g" || n?.effectiveType === "2g" ? e.likelyCause = "slow_connection" : n?.downlink !== void 0 && n.downlink < 0.5 && (e.likelyCause = "poor_bandwidth") : e.likelyCause = "offline", e;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function K(n) {
|
|
16
16
|
const e = [];
|
|
17
17
|
return n.likelyCause && e.push(`cause=${n.likelyCause}`), e.push(`online=${n.online}`), e.push(`hidden=${n.documentHidden}`), n.effectiveType && e.push(`net=${n.effectiveType}`), n.downlink !== void 0 && e.push(`downlink=${n.downlink}Mbps`), n.rtt !== void 0 && e.push(`rtt=${n.rtt}ms`), e.join(", ");
|
|
18
18
|
}
|
|
19
|
-
class
|
|
20
|
-
constructor(t,
|
|
21
|
-
const
|
|
22
|
-
super(
|
|
19
|
+
class r extends Error {
|
|
20
|
+
constructor(t, o = !0, i = !1) {
|
|
21
|
+
const s = i && typeof window < "u" ? g() : null, D = s ? `${t} [${K(s)}]` : t;
|
|
22
|
+
super(D);
|
|
23
23
|
d(this, "diagnostics");
|
|
24
|
-
this.retryable =
|
|
24
|
+
this.retryable = o, this.name = "SDKLoadError", this.diagnostics = s;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
const
|
|
27
|
+
const v = "PayNextSDK";
|
|
28
28
|
function p() {
|
|
29
|
-
return typeof window > "u" ? null : window[
|
|
29
|
+
return typeof window > "u" ? null : window[v];
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
typeof window > "u" || (window[
|
|
31
|
+
function L(n) {
|
|
32
|
+
typeof window > "u" || (window[v] = n);
|
|
33
33
|
}
|
|
34
34
|
function S(n) {
|
|
35
35
|
return new Promise((e) => setTimeout(e, n));
|
|
36
36
|
}
|
|
37
|
-
async function
|
|
37
|
+
async function _(n = 5e3) {
|
|
38
38
|
const t = Math.ceil(n / 50);
|
|
39
|
-
for (let
|
|
39
|
+
for (let o = 0; o < t; o++) {
|
|
40
40
|
const i = p();
|
|
41
41
|
if (i)
|
|
42
42
|
return i;
|
|
43
43
|
await S(50);
|
|
44
44
|
}
|
|
45
|
-
throw new
|
|
45
|
+
throw new r("PayNextSDK not found in window after waiting", !0, !0);
|
|
46
46
|
}
|
|
47
|
-
async function
|
|
48
|
-
const
|
|
47
|
+
async function A(n, e = 1) {
|
|
48
|
+
const t = n?.toLowerCase(), i = (t?.includes("develop") || t?.includes("staging") || t?.includes("preview") ? "develop" : "production") === "develop" ? T : k;
|
|
49
49
|
try {
|
|
50
|
-
const
|
|
51
|
-
return
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
50
|
+
const s = p();
|
|
51
|
+
return s || (await new Promise((h, u) => {
|
|
52
|
+
const c = document.querySelector(`script[src="${i}"]`);
|
|
53
|
+
if (c) {
|
|
54
54
|
if (p()) {
|
|
55
|
-
|
|
55
|
+
h();
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
-
const
|
|
59
|
-
|
|
58
|
+
const f = setTimeout(() => {
|
|
59
|
+
c.removeEventListener("load", l), c.removeEventListener("error", E), u(new r("Existing SDK script loading timeout", !0, !0));
|
|
60
60
|
}, 15e3), l = () => {
|
|
61
|
-
clearTimeout(
|
|
61
|
+
clearTimeout(f), c.removeEventListener("load", l), c.removeEventListener("error", E), h();
|
|
62
62
|
}, E = () => {
|
|
63
|
-
clearTimeout(
|
|
63
|
+
clearTimeout(f), c.removeEventListener("load", l), c.removeEventListener("error", E), u(new r("Existing SDK script failed to load", !0, !0));
|
|
64
64
|
};
|
|
65
|
-
|
|
65
|
+
c.addEventListener("load", l), c.addEventListener("error", E);
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
|
-
const
|
|
69
|
-
m(),
|
|
70
|
-
}, 15e3),
|
|
71
|
-
|
|
68
|
+
const N = setTimeout(() => {
|
|
69
|
+
m(), u(new r("SDK script loading timeout", !0, !0));
|
|
70
|
+
}, 15e3), a = document.createElement("script");
|
|
71
|
+
a.src = i, a.crossOrigin = "anonymous", a.async = !0, a.setAttribute("data-paynext-sdk", "true");
|
|
72
72
|
const m = () => {
|
|
73
|
-
clearTimeout(
|
|
73
|
+
clearTimeout(N), a.onload = null, a.onerror = null;
|
|
74
74
|
};
|
|
75
|
-
|
|
76
|
-
m(),
|
|
77
|
-
},
|
|
78
|
-
console.error("[PayNext CDN] Script load error:",
|
|
75
|
+
a.onload = () => {
|
|
76
|
+
m(), h();
|
|
77
|
+
}, a.onerror = (f) => {
|
|
78
|
+
console.error("[PayNext CDN] Script load error:", f), m();
|
|
79
79
|
try {
|
|
80
|
-
|
|
80
|
+
a.parentNode && a.parentNode.removeChild(a);
|
|
81
81
|
} catch (l) {
|
|
82
82
|
console.warn("[PayNext CDN] Failed to remove script:", l);
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
u(new r("Failed to load SDK script from CDN", !0, !0));
|
|
85
85
|
};
|
|
86
86
|
try {
|
|
87
|
-
document.head.appendChild(
|
|
87
|
+
document.head.appendChild(a);
|
|
88
88
|
} catch {
|
|
89
|
-
m(),
|
|
89
|
+
m(), u(new r("Failed to append script to document", !1));
|
|
90
90
|
}
|
|
91
|
-
}), await
|
|
92
|
-
} catch (
|
|
93
|
-
if ((
|
|
94
|
-
return console.warn(`[PayNext CDN] Load attempt ${e} failed, retrying in 1500ms...`,
|
|
95
|
-
throw console.error(`[PayNext CDN] Failed to load SDK after ${e} attempts:`,
|
|
91
|
+
}), await _(5e3));
|
|
92
|
+
} catch (s) {
|
|
93
|
+
if ((s instanceof r ? s.retryable : !0) && e < 5)
|
|
94
|
+
return console.warn(`[PayNext CDN] Load attempt ${e} failed, retrying in 1500ms...`, s), await S(1500 * e), A(n, e + 1);
|
|
95
|
+
throw console.error(`[PayNext CDN] Failed to load SDK after ${e} attempts:`, s), s;
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
async function
|
|
99
|
-
if (h)
|
|
100
|
-
return h;
|
|
98
|
+
async function P(n) {
|
|
101
99
|
if (w)
|
|
102
100
|
return w;
|
|
101
|
+
if (y)
|
|
102
|
+
return y;
|
|
103
103
|
if (typeof window > "u")
|
|
104
|
-
throw new
|
|
104
|
+
throw new r("PayNext SDK can only be loaded in browser environment", !1);
|
|
105
105
|
const e = p();
|
|
106
|
-
return e ? (
|
|
106
|
+
return e ? (w = e, w) : (y = (async () => {
|
|
107
107
|
try {
|
|
108
|
-
const t = await
|
|
109
|
-
return
|
|
108
|
+
const t = await A(n);
|
|
109
|
+
return w = t, L(t), t;
|
|
110
110
|
} catch (t) {
|
|
111
|
-
throw
|
|
111
|
+
throw y = null, t;
|
|
112
112
|
}
|
|
113
|
-
})(),
|
|
113
|
+
})(), y);
|
|
114
114
|
}
|
|
115
|
-
class
|
|
115
|
+
class I {
|
|
116
116
|
constructor() {
|
|
117
117
|
d(this, "cdnInstance", null);
|
|
118
118
|
d(this, "initPromise", null);
|
|
@@ -125,8 +125,8 @@ class _ {
|
|
|
125
125
|
}
|
|
126
126
|
// handle error
|
|
127
127
|
handleError(e, t) {
|
|
128
|
-
const
|
|
129
|
-
if (console.error(
|
|
128
|
+
const o = `[PayNext SDK Error - ${t}]: ${e.message}`;
|
|
129
|
+
if (console.error(o, e), this.errorBoundary)
|
|
130
130
|
try {
|
|
131
131
|
this.errorBoundary(e);
|
|
132
132
|
} catch (i) {
|
|
@@ -136,17 +136,17 @@ class _ {
|
|
|
136
136
|
// initialize
|
|
137
137
|
async initialize(e) {
|
|
138
138
|
if (this.isDestroyed)
|
|
139
|
-
throw new
|
|
139
|
+
throw new r("Cannot initialize destroyed SDK instance", !1);
|
|
140
140
|
return this.initPromise ? this.initPromise : (this.initPromise = (async () => {
|
|
141
141
|
try {
|
|
142
|
-
const t = await
|
|
142
|
+
const t = await P(e);
|
|
143
143
|
if (!t || !t.PayNextCheckout)
|
|
144
|
-
throw new
|
|
144
|
+
throw new r("PayNextCheckout not found in loaded SDK module", !1);
|
|
145
145
|
try {
|
|
146
146
|
this.cdnInstance = new t.PayNextCheckout();
|
|
147
|
-
} catch (
|
|
148
|
-
throw new
|
|
149
|
-
`Failed to instantiate PayNextCheckout: ${
|
|
147
|
+
} catch (o) {
|
|
148
|
+
throw new r(
|
|
149
|
+
`Failed to instantiate PayNextCheckout: ${o instanceof Error ? o.message : "Unknown error"}`,
|
|
150
150
|
!1
|
|
151
151
|
);
|
|
152
152
|
}
|
|
@@ -158,25 +158,25 @@ class _ {
|
|
|
158
158
|
// assert ready
|
|
159
159
|
assertReady() {
|
|
160
160
|
if (this.isDestroyed)
|
|
161
|
-
throw new
|
|
161
|
+
throw new r("SDK instance has been destroyed", !1);
|
|
162
162
|
if (!this.initPromise)
|
|
163
|
-
throw new
|
|
163
|
+
throw new r("SDK initialization not started", !1);
|
|
164
164
|
if (!this.cdnInstance)
|
|
165
|
-
throw new
|
|
165
|
+
throw new r("SDK instance not created", !1);
|
|
166
166
|
}
|
|
167
167
|
// mount
|
|
168
168
|
async mount(e, t) {
|
|
169
169
|
try {
|
|
170
170
|
if (!e || typeof e != "string")
|
|
171
|
-
throw new
|
|
171
|
+
throw new r("Invalid containerId provided", !1);
|
|
172
172
|
if (!t || !t.environment)
|
|
173
|
-
throw new
|
|
173
|
+
throw new r("Invalid config provided", !1);
|
|
174
174
|
if (!document.getElementById(e))
|
|
175
|
-
throw new
|
|
175
|
+
throw new r(`Container element with id "${e}" not found`, !1);
|
|
176
176
|
await this.initialize(t.environment), this.assertReady(), await this.cdnInstance.mount(e, t);
|
|
177
|
-
} catch (
|
|
178
|
-
const i =
|
|
179
|
-
|
|
177
|
+
} catch (o) {
|
|
178
|
+
const i = o instanceof r ? o : new r(
|
|
179
|
+
o instanceof Error ? o.message : "Unknown mount error",
|
|
180
180
|
!0
|
|
181
181
|
);
|
|
182
182
|
throw this.handleError(i, "mount"), i;
|
|
@@ -195,8 +195,8 @@ class _ {
|
|
|
195
195
|
}
|
|
196
196
|
typeof this.cdnInstance.setPaymentsEnabled == "function" && this.cdnInstance.setPaymentsEnabled(e);
|
|
197
197
|
} catch (t) {
|
|
198
|
-
const
|
|
199
|
-
this.handleError(
|
|
198
|
+
const o = t instanceof Error ? t : new Error(String(t));
|
|
199
|
+
this.handleError(o, "setPaymentsEnabled");
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
// unmount
|
|
@@ -225,18 +225,18 @@ class _ {
|
|
|
225
225
|
// preload SDK
|
|
226
226
|
static async preload(e) {
|
|
227
227
|
try {
|
|
228
|
-
await
|
|
228
|
+
await P(e);
|
|
229
229
|
} catch (t) {
|
|
230
230
|
throw console.error("[PayNext SDK] Preload failed:", t), t;
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
|
-
const
|
|
235
|
-
preload:
|
|
234
|
+
const b = {
|
|
235
|
+
preload: I.preload
|
|
236
236
|
};
|
|
237
|
-
var
|
|
237
|
+
var M = /* @__PURE__ */ ((n) => (n.PAYPAL = "PAYPAL", n.APPLE_PAY = "APPLEPAY", n.GOOGLE_PAY = "GPAY", n.CARD = "CARD", n.VENMO = "VENMO", n.CASHAPP = "CASHAPP", n.AMAZONPAY = "AMAZONPAY", n.PIX_AUTOMATICO = "PIX_AUTOMATICO", n))(M || {});
|
|
238
238
|
export {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
239
|
+
I as PayNextCheckout,
|
|
240
|
+
b as PayNextSDK,
|
|
241
|
+
M as PaymentMethod
|
|
242
242
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(s
|
|
1
|
+
(function(i,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(i=typeof globalThis<"u"?globalThis:i||self,s(i["PayNext SDK"]={}))})(this,(function(i){"use strict";var b=Object.defineProperty;var R=(i,s,u)=>s in i?b(i,s,{enumerable:!0,configurable:!0,writable:!0,value:u}):i[s]=u;var y=(i,s,u)=>R(i,typeof s!="symbol"?s+"":s,u);const s="https://cdn-sdk-dev.paynext.com/index.cdn.js",u="https://cdn-sdk.paynext.com/index.cdn.js";let h=null,w=null;function g(){const n=navigator.connection||navigator.mozConnection||navigator.webkitConnection,e={online:navigator.onLine,documentHidden:document.hidden,userAgent:navigator.userAgent,timestamp:new Date().toISOString()};return n&&(e.connectionType=n.type,e.effectiveType=n.effectiveType,e.downlink=n.downlink,e.rtt=n.rtt,e.saveData=n.saveData),navigator.onLine?document.hidden?e.likelyCause="background_tab":n?.effectiveType==="slow-2g"||n?.effectiveType==="2g"?e.likelyCause="slow_connection":n?.downlink!==void 0&&n.downlink<.5&&(e.likelyCause="poor_bandwidth"):e.likelyCause="offline",e}function K(n){const e=[];return n.likelyCause&&e.push(`cause=${n.likelyCause}`),e.push(`online=${n.online}`),e.push(`hidden=${n.documentHidden}`),n.effectiveType&&e.push(`net=${n.effectiveType}`),n.downlink!==void 0&&e.push(`downlink=${n.downlink}Mbps`),n.rtt!==void 0&&e.push(`rtt=${n.rtt}ms`),e.join(", ")}class r extends Error{constructor(t,o=!0,a=!1){const c=a&&typeof window<"u"?g():null,v=c?`${t} [${K(c)}]`:t;super(v);y(this,"diagnostics");this.retryable=o,this.name="SDKLoadError",this.diagnostics=c}}const A="PayNextSDK";function E(){return typeof window>"u"?null:window[A]}function L(n){typeof window>"u"||(window[A]=n)}function N(n){return new Promise(e=>setTimeout(e,n))}async function _(n=5e3){const t=Math.ceil(n/50);for(let o=0;o<t;o++){const a=E();if(a)return a;await N(50)}throw new r("PayNextSDK not found in window after waiting",!0,!0)}async function T(n,e=1){const t=n?.toLowerCase(),a=(t?.includes("develop")||t?.includes("staging")||t?.includes("preview")?"develop":"production")==="develop"?s:u;try{const c=E();return c||(await new Promise((P,m)=>{const l=document.querySelector(`script[src="${a}"]`);if(l){if(E()){P();return}const p=setTimeout(()=>{l.removeEventListener("load",f),l.removeEventListener("error",S),m(new r("Existing SDK script loading timeout",!0,!0))},15e3),f=()=>{clearTimeout(p),l.removeEventListener("load",f),l.removeEventListener("error",S),P()},S=()=>{clearTimeout(p),l.removeEventListener("load",f),l.removeEventListener("error",S),m(new r("Existing SDK script failed to load",!0,!0))};l.addEventListener("load",f),l.addEventListener("error",S);return}const M=setTimeout(()=>{D(),m(new r("SDK script loading timeout",!0,!0))},15e3),d=document.createElement("script");d.src=a,d.crossOrigin="anonymous",d.async=!0,d.setAttribute("data-paynext-sdk","true");const D=()=>{clearTimeout(M),d.onload=null,d.onerror=null};d.onload=()=>{D(),P()},d.onerror=p=>{console.error("[PayNext CDN] Script load error:",p),D();try{d.parentNode&&d.parentNode.removeChild(d)}catch(f){console.warn("[PayNext CDN] Failed to remove script:",f)}m(new r("Failed to load SDK script from CDN",!0,!0))};try{document.head.appendChild(d)}catch{D(),m(new r("Failed to append script to document",!1))}}),await _(5e3))}catch(c){if((c instanceof r?c.retryable:!0)&&e<5)return console.warn(`[PayNext CDN] Load attempt ${e} failed, retrying in 1500ms...`,c),await N(1500*e),T(n,e+1);throw console.error(`[PayNext CDN] Failed to load SDK after ${e} attempts:`,c),c}}async function x(n){if(w)return w;if(h)return h;if(typeof window>"u")throw new r("PayNext SDK can only be loaded in browser environment",!1);const e=E();return e?(w=e,w):(h=(async()=>{try{const t=await T(n);return w=t,L(t),t}catch(t){throw h=null,t}})(),h)}class C{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 o=`[PayNext SDK Error - ${t}]: ${e.message}`;if(console.error(o,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 x(e);if(!t||!t.PayNextCheckout)throw new r("PayNextCheckout not found in loaded SDK module",!1);try{this.cdnInstance=new t.PayNextCheckout}catch(o){throw new r(`Failed to instantiate PayNextCheckout: ${o instanceof Error?o.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(o){const a=o instanceof r?o:new r(o instanceof Error?o.message:"Unknown mount error",!0);throw this.handleError(a,"mount"),a}}setPaymentsEnabled(e){try{if(this.isDestroyed){console.warn("[PayNext SDK] setPaymentsEnabled called on destroyed instance");return}if(!this.cdnInstance){console.warn("[PayNext SDK] setPaymentsEnabled called before mount");return}typeof this.cdnInstance.setPaymentsEnabled=="function"&&this.cdnInstance.setPaymentsEnabled(e)}catch(t){const o=t instanceof Error?t:new Error(String(t));this.handleError(o,"setPaymentsEnabled")}}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 x(e)}catch(t){throw console.error("[PayNext SDK] Preload failed:",t),t}}}const I={preload:C.preload};var k=(n=>(n.PAYPAL="PAYPAL",n.APPLE_PAY="APPLEPAY",n.GOOGLE_PAY="GPAY",n.CARD="CARD",n.VENMO="VENMO",n.CASHAPP="CASHAPP",n.AMAZONPAY="AMAZONPAY",n.PIX_AUTOMATICO="PIX_AUTOMATICO",n))(k||{});i.PayNextCheckout=C,i.PayNextSDK=I,i.PaymentMethod=k,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paynext/sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.21",
|
|
4
4
|
"description": "PayNext SDK - Payment processing with automatic CDN loading",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.es.js",
|
|
@@ -86,8 +86,10 @@
|
|
|
86
86
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
87
87
|
"eslint-plugin-react-refresh": "^0.4.24",
|
|
88
88
|
"globals": "^16.5.0",
|
|
89
|
+
"happy-dom": "^20.10.6",
|
|
89
90
|
"json5": "^2.2.3",
|
|
90
91
|
"motion": "^12.23.24",
|
|
92
|
+
"msw": "^2.14.6",
|
|
91
93
|
"prettier": "^3.6.2",
|
|
92
94
|
"prettier-plugin-tailwindcss": "^0.6.9",
|
|
93
95
|
"react": "^19.2.0",
|