@paynext/sdk 0.0.146 → 0.0.148
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 +2 -2
- package/dist/index.es.js +69 -64
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +5 -2
package/dist/index.d.ts
CHANGED
|
@@ -350,7 +350,7 @@ declare enum PaymentStatus {
|
|
|
350
350
|
export declare class PayNextCheckout {
|
|
351
351
|
private cdnInstance;
|
|
352
352
|
private initPromise;
|
|
353
|
-
constructor();
|
|
353
|
+
constructor(envType: 'develop' | 'staging' | 'sandbox' | 'production');
|
|
354
354
|
private initialize;
|
|
355
355
|
private waitForReady;
|
|
356
356
|
mount(containerId: string, config: PayNextConfig): Promise<void>;
|
|
@@ -359,7 +359,7 @@ export declare class PayNextCheckout {
|
|
|
359
359
|
static getVersion(): string;
|
|
360
360
|
static getCDNUrl(): string;
|
|
361
361
|
static isLoaded(): boolean;
|
|
362
|
-
static preload(): Promise<void>;
|
|
362
|
+
static preload(envType: 'develop' | 'staging' | 'sandbox' | 'production'): Promise<void>;
|
|
363
363
|
}
|
|
364
364
|
|
|
365
365
|
export declare interface PayNextConfig {
|
package/dist/index.es.js
CHANGED
|
@@ -1,73 +1,78 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var m = Object.defineProperty;
|
|
2
|
+
var y = (t, n, o) => n in t ? m(t, n, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[n] = o;
|
|
3
|
+
var w = (t, n, o) => y(t, typeof n != "symbol" ? n + "" : n, o);
|
|
4
|
+
var r = (t, n, o) => new Promise((c, e) => {
|
|
5
|
+
var i = (a) => {
|
|
6
6
|
try {
|
|
7
|
-
|
|
8
|
-
} catch (
|
|
9
|
-
|
|
7
|
+
l(o.next(a));
|
|
8
|
+
} catch (u) {
|
|
9
|
+
e(u);
|
|
10
10
|
}
|
|
11
|
-
},
|
|
11
|
+
}, C = (a) => {
|
|
12
12
|
try {
|
|
13
|
-
|
|
14
|
-
} catch (
|
|
15
|
-
|
|
13
|
+
l(o.throw(a));
|
|
14
|
+
} catch (u) {
|
|
15
|
+
e(u);
|
|
16
16
|
}
|
|
17
|
-
},
|
|
18
|
-
|
|
17
|
+
}, l = (a) => a.done ? c(a.value) : Promise.resolve(a.value).then(i, C);
|
|
18
|
+
l((o = o.apply(t, n)).next());
|
|
19
19
|
});
|
|
20
|
-
const
|
|
21
|
-
let
|
|
22
|
-
function
|
|
23
|
-
return
|
|
24
|
-
|
|
20
|
+
const N = "https://paynext-sdk-dev.ableapp.workers.dev/index.cdn.js", f = "https://paynext-sdk.ableapp.workers.dev/index.cdn.js", D = "1.0.0";
|
|
21
|
+
let s = null, d = null;
|
|
22
|
+
function P(t) {
|
|
23
|
+
return r(this, null, function* () {
|
|
24
|
+
if (d)
|
|
25
|
+
return d;
|
|
26
|
+
if (s)
|
|
27
|
+
return s;
|
|
28
|
+
const n = (t == null ? void 0 : t.toLowerCase()) === "develop" || (t == null ? void 0 : t.toLowerCase()) === "staging" ? "develop" : "production";
|
|
29
|
+
return s = new Promise((o, c) => {
|
|
25
30
|
if (typeof window == "undefined") {
|
|
26
|
-
|
|
31
|
+
c(new Error("PayNext SDK can only be loaded in browser environment"));
|
|
27
32
|
return;
|
|
28
33
|
}
|
|
29
34
|
if (window.PayNextSDK) {
|
|
30
|
-
console.log("[PayNext CDN] SDK already loaded from cache"),
|
|
35
|
+
console.log("[PayNext CDN] SDK already loaded from cache"), d = window.PayNextSDK, o(d);
|
|
31
36
|
return;
|
|
32
37
|
}
|
|
33
|
-
const
|
|
34
|
-
|
|
38
|
+
const e = document.createElement("script");
|
|
39
|
+
e.src = n === "develop" ? N : f, e.crossOrigin = "anonymous", e.async = !0, e.onload = () => {
|
|
35
40
|
setTimeout(() => {
|
|
36
|
-
const
|
|
37
|
-
if (!
|
|
38
|
-
console.error("[PayNext CDN] PayNextSDK not found in window after load"),
|
|
41
|
+
const i = window.PayNextSDK;
|
|
42
|
+
if (!i) {
|
|
43
|
+
console.error("[PayNext CDN] PayNextSDK not found in window after load"), s = null, document.head.removeChild(e), c(new Error("PayNextSDK not found in global scope after loading"));
|
|
39
44
|
return;
|
|
40
45
|
}
|
|
41
|
-
|
|
46
|
+
d = i, o(i);
|
|
42
47
|
}, 10);
|
|
43
|
-
},
|
|
44
|
-
console.error("[PayNext CDN] Failed to load script:",
|
|
45
|
-
}, document.head.appendChild(
|
|
46
|
-
}),
|
|
48
|
+
}, e.onerror = (i) => {
|
|
49
|
+
console.error("[PayNext CDN] Failed to load script:", i), s = null, document.head.removeChild(e), c(new Error("Failed to load PayNext SDK script from CDN"));
|
|
50
|
+
}, document.head.appendChild(e);
|
|
51
|
+
}), s;
|
|
47
52
|
});
|
|
48
53
|
}
|
|
49
|
-
class
|
|
50
|
-
constructor() {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
this.initPromise = this.initialize();
|
|
54
|
+
class h {
|
|
55
|
+
constructor(n) {
|
|
56
|
+
w(this, "cdnInstance", null);
|
|
57
|
+
w(this, "initPromise", null);
|
|
58
|
+
this.initPromise = this.initialize(n);
|
|
54
59
|
}
|
|
55
60
|
// initialize
|
|
56
|
-
initialize() {
|
|
57
|
-
return
|
|
61
|
+
initialize(n) {
|
|
62
|
+
return r(this, null, function* () {
|
|
58
63
|
try {
|
|
59
|
-
const
|
|
60
|
-
if (!
|
|
64
|
+
const o = yield P(n);
|
|
65
|
+
if (!o.PayNextCheckout)
|
|
61
66
|
throw new Error("PayNextCheckout not found in CDN module");
|
|
62
|
-
this.cdnInstance = new
|
|
63
|
-
} catch (
|
|
64
|
-
throw console.error("[PayNext CDN] Failed to initialize:",
|
|
67
|
+
this.cdnInstance = new o.PayNextCheckout();
|
|
68
|
+
} catch (o) {
|
|
69
|
+
throw console.error("[PayNext CDN] Failed to initialize:", o), o;
|
|
65
70
|
}
|
|
66
71
|
});
|
|
67
72
|
}
|
|
68
73
|
// wait for ready
|
|
69
74
|
waitForReady() {
|
|
70
|
-
return
|
|
75
|
+
return r(this, null, function* () {
|
|
71
76
|
if (!this.initPromise)
|
|
72
77
|
throw new Error("SDK initialization not started");
|
|
73
78
|
if (yield this.initPromise, !this.cdnInstance)
|
|
@@ -75,54 +80,54 @@ class P {
|
|
|
75
80
|
});
|
|
76
81
|
}
|
|
77
82
|
// mount
|
|
78
|
-
mount(n,
|
|
79
|
-
return
|
|
80
|
-
return yield this.waitForReady(), this.cdnInstance.mount(n,
|
|
83
|
+
mount(n, o) {
|
|
84
|
+
return r(this, null, function* () {
|
|
85
|
+
return console.log("[PayNext CDN] mount(): ", o.environment), yield this.waitForReady(), this.cdnInstance.mount(n, o);
|
|
81
86
|
});
|
|
82
87
|
}
|
|
83
88
|
// unmount
|
|
84
89
|
unmount() {
|
|
85
|
-
return
|
|
90
|
+
return r(this, null, function* () {
|
|
86
91
|
if (yield this.waitForReady(), this.cdnInstance.unmount)
|
|
87
92
|
return this.cdnInstance.unmount();
|
|
88
93
|
});
|
|
89
94
|
}
|
|
90
95
|
// update config
|
|
91
96
|
updateConfig(n) {
|
|
92
|
-
return
|
|
97
|
+
return r(this, null, function* () {
|
|
93
98
|
if (yield this.waitForReady(), this.cdnInstance.updateConfig)
|
|
94
99
|
return this.cdnInstance.updateConfig(n);
|
|
95
100
|
});
|
|
96
101
|
}
|
|
97
102
|
// get version
|
|
98
103
|
static getVersion() {
|
|
99
|
-
return
|
|
104
|
+
return D;
|
|
100
105
|
}
|
|
101
106
|
// get CDN url
|
|
102
107
|
static getCDNUrl() {
|
|
103
|
-
return
|
|
108
|
+
return N;
|
|
104
109
|
}
|
|
105
110
|
// check if loaded
|
|
106
111
|
static isLoaded() {
|
|
107
|
-
return
|
|
112
|
+
return d !== null;
|
|
108
113
|
}
|
|
109
114
|
// preload (optional optimization)
|
|
110
|
-
static preload() {
|
|
111
|
-
return
|
|
112
|
-
yield
|
|
115
|
+
static preload(n) {
|
|
116
|
+
return r(this, null, function* () {
|
|
117
|
+
yield P(n);
|
|
113
118
|
});
|
|
114
119
|
}
|
|
115
120
|
}
|
|
116
|
-
const
|
|
117
|
-
version:
|
|
118
|
-
cdnUrl:
|
|
119
|
-
preload:
|
|
120
|
-
isLoaded:
|
|
121
|
+
const E = {
|
|
122
|
+
version: D,
|
|
123
|
+
cdnUrl: N,
|
|
124
|
+
preload: h.preload,
|
|
125
|
+
isLoaded: h.isLoaded
|
|
121
126
|
};
|
|
122
|
-
var
|
|
127
|
+
var x = /* @__PURE__ */ ((t) => (t.PAYPAL = "PAYPAL", t.APPLE_PAY = "APPLEPAY", t.GOOGLE_PAY = "GPAY", t.CARD = "CARD", t.VENMO = "VENMO", t))(x || {});
|
|
123
128
|
export {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
129
|
+
h as PayNextCheckout,
|
|
130
|
+
E as PayNextSDK,
|
|
131
|
+
x as PaymentMethod
|
|
127
132
|
};
|
|
128
133
|
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/app/sdk-pkg/sdk.pkg.ts","../src/pkg/checkout-api/constants/enums.ts"],"sourcesContent":["import type { PayNextConfig } from \"@/core/modules/checkout/checkout.interface\"\n\n// CDN configuration\nconst CDN_URL_DEV = 'https://paynext-sdk.
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/app/sdk-pkg/sdk.pkg.ts","../src/pkg/checkout-api/constants/enums.ts"],"sourcesContent":["import type { PayNextConfig } from \"@/core/modules/checkout/checkout.interface\"\n\n// CDN configuration\nconst CDN_URL_DEV = 'https://paynext-sdk-dev.ableapp.workers.dev/index.cdn.js'\nconst CDN_URL_PROD = 'https://paynext-sdk.ableapp.workers.dev/index.cdn.js'\nconst CDN_VERSION = '1.0.0'\n\n// cache for loaded SDK\nlet sdkPromise: Promise<any> | null = null\nlet sdkModule: any = null\n\n// dynamically load SDK from CDN\nasync function loadSDKFromCDN(envType: 'develop' | 'staging' | 'sandbox' | 'production'): Promise<any> {\n if (sdkModule) {\n return sdkModule\n }\n\n if (sdkPromise) {\n return sdkPromise\n }\n\n const environment = (envType?.toLowerCase() === 'develop' || envType?.toLowerCase() === 'staging') ? 'develop' : 'production'\n\n sdkPromise = new Promise((resolve, reject) => {\n if (typeof window === 'undefined') {\n reject(new Error('PayNext SDK can only be loaded in browser environment'))\n return\n }\n\n if ((window as any).PayNextSDK) {\n console.log('[PayNext CDN] SDK already loaded from cache')\n sdkModule = (window as any).PayNextSDK\n resolve(sdkModule)\n return\n }\n \n const script = document.createElement('script')\n script.src = environment === 'develop' ? CDN_URL_DEV : CDN_URL_PROD\n script.crossOrigin = 'anonymous'\n script.async = true\n \n script.onload = () => { \n setTimeout(() => {\n const module = (window as any).PayNextSDK\n \n if (!module) {\n console.error('[PayNext CDN] PayNextSDK not found in window after load')\n sdkPromise = null\n document.head.removeChild(script)\n reject(new Error('PayNextSDK not found in global scope after loading'))\n return\n }\n \n sdkModule = module\n resolve(module)\n }, 10)\n }\n \n script.onerror = (error) => {\n console.error('[PayNext CDN] Failed to load script:', error)\n sdkPromise = null\n document.head.removeChild(script)\n reject(new Error('Failed to load PayNext SDK script from CDN'))\n }\n \n document.head.appendChild(script)\n })\n\n return sdkPromise\n}\n\n// checkout proxy class\nexport class PayNextCheckout {\n private cdnInstance: any = null\n private initPromise: Promise<void> | null = null\n\n constructor(envType: 'develop' | 'staging' | 'sandbox' | 'production') {\n \n\n this.initPromise = this.initialize(envType)\n }\n\n // initialize\n private async initialize(envType: 'develop' | 'staging' | 'sandbox' | 'production'): Promise<void> {\n try {\n const sdk = await loadSDKFromCDN(envType)\n \n if (!sdk.PayNextCheckout) {\n throw new Error('PayNextCheckout not found in CDN module')\n }\n \n this.cdnInstance = new sdk.PayNextCheckout()\n } catch (error) {\n console.error('[PayNext CDN] Failed to initialize:', error)\n throw error\n }\n }\n\n // wait for ready\n private async waitForReady(): Promise<void> {\n if (!this.initPromise) {\n throw new Error('SDK initialization not started')\n }\n await this.initPromise\n if (!this.cdnInstance) {\n throw new Error('SDK instance not created')\n }\n }\n\n // mount\n async mount(containerId: string, config: PayNextConfig): Promise<void> {\n console.log('[PayNext CDN] mount(): ', config.environment)\n await this.waitForReady()\n return this.cdnInstance.mount(containerId, config)\n }\n\n // unmount\n async unmount(): Promise<void> {\n await this.waitForReady()\n if (this.cdnInstance.unmount) {\n return this.cdnInstance.unmount()\n }\n }\n\n // update config\n async updateConfig(config: any): Promise<void> {\n await this.waitForReady()\n if (this.cdnInstance.updateConfig) {\n return this.cdnInstance.updateConfig(config)\n }\n }\n\n // get version\n static getVersion(): string {\n return CDN_VERSION\n }\n\n // get CDN url\n static getCDNUrl(): string {\n return CDN_URL_DEV\n }\n\n // check if loaded\n static isLoaded(): boolean {\n return sdkModule !== null\n }\n\n // preload (optional optimization)\n static async preload(envType: 'develop' | 'staging' | 'sandbox' | 'production'): Promise<void> {\n await loadSDKFromCDN(envType)\n }\n}\n\n// export\nexport const PayNextSDK = {\n version: CDN_VERSION,\n cdnUrl: CDN_URL_DEV,\n preload: PayNextCheckout.preload,\n isLoaded: PayNextCheckout.isLoaded,\n}\n\nexport default PayNextCheckout\n\n","export enum PaymentMethod {\n PAYPAL = 'PAYPAL',\n APPLE_PAY = 'APPLEPAY',\n GOOGLE_PAY = 'GPAY',\n CARD = 'CARD',\n VENMO = 'VENMO',\n}\n\nexport enum PaymentStatus {\n PENDING = 'PENDING',\n FAILED = 'FAILED',\n AUTHORIZED = 'AUTHORIZED',\n SETTLING = 'SETTLING',\n SETTLED = 'SETTLED',\n DECLINED = 'DECLINED',\n CANCELLED = 'CANCELLED',\n}\n\nexport enum DeclineCode {\n INSUFFICIENT_FUNDS = 'insufficient_funds',\n AUTHENTICATION_REQUIRED = 'authentication_required',\n CARD_ISSUER_DECLINE = 'card_issuer_decline',\n GENERIC_DECLINE = 'generic_decline',\n WITHDRAWAL_LIMIT_EXCEEDED = 'withdrawal_limit_exceeded',\n DO_NOT_HONOR = 'do_not_honor',\n EXPIRED_CARD = 'expired_card',\n SUSPECTED_FRAUD = 'suspected_fraud',\n INCORRECT_CVC = 'incorrect_cvc',\n INVALID_CARD_NUMBER = 'invalid_card_number',\n ISSUER_UNAVAILABLE = 'issuer_unavailable',\n CARD_LOST_OR_STOLEN = 'card_lost_or_stolen',\n CARD_DECLINED = 'card_declined',\n}\n"],"names":["CDN_URL_DEV","CDN_URL_PROD","CDN_VERSION","sdkPromise","sdkModule","loadSDKFromCDN","envType","__async","environment","resolve","reject","script","module","error","PayNextCheckout","__publicField","sdk","containerId","config","PayNextSDK","PaymentMethod"],"mappings":";;;;;;;;;;;;;;;;;;;AAGA,MAAMA,IAAc,4DACdC,IAAe,wDACfC,IAAc;AAGpB,IAAIC,IAAkC,MAClCC,IAAiB;AAGrB,SAAeC,EAAeC,GAAyE;AAAA,SAAAC,EAAA;AACrG,QAAIH;AACF,aAAOA;AAGT,QAAID;AACF,aAAOA;AAGT,UAAMK,KAAeF,KAAA,gBAAAA,EAAS,mBAAkB,cAAaA,KAAA,gBAAAA,EAAS,mBAAkB,YAAa,YAAY;AAEjH,WAAAH,IAAa,IAAI,QAAQ,CAACM,GAASC,MAAW;AAC5C,UAAI,OAAO,UAAW,aAAa;AACjC,QAAAA,EAAO,IAAI,MAAM,uDAAuD,CAAC;AACzE;AAAA,MACF;AAEA,UAAK,OAAe,YAAY;AAC9B,gBAAQ,IAAI,6CAA6C,GACzDN,IAAa,OAAe,YAC5BK,EAAQL,CAAS;AACjB;AAAA,MACF;AAEA,YAAMO,IAAS,SAAS,cAAc,QAAQ;AAC9C,MAAAA,EAAO,MAAMH,MAAgB,YAAYR,IAAcC,GACvDU,EAAO,cAAc,aACrBA,EAAO,QAAQ,IAEfA,EAAO,SAAS,MAAM;AACpB,mBAAW,MAAM;AACf,gBAAMC,IAAU,OAAe;AAE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A,GACJ,KAAK,YAAY,MAAMD,GAAaC,CAAM;AAAA,IACnD;AAAA;AAAA;AAAA,EAGM,UAAyB;AAAA,WAAAX,EAAA;AAE7B,UADA,MAAM,KAAK,aAAA,GACP,KAAK,YAAY;AACnB,eAAO,KAAK,YAAY,QAAA;AAAA,IAE5B;AAAA;AAAA;AAAA,EAGM,aAAaW,GAA4B;AAAA,WAAAX,EAAA;AAE7C,UADA,MAAM,KAAK,aAAA,GACP,KAAK,YAAY;AACnB,eAAO,KAAK,YAAY,aAAaW,CAAM;AAAA,IAE/C;AAAA;AAAA;AAAA,EAGA,OAAO,aAAqB;AAC1B,WAAOhB;AAAA,EACT;AAAA;AAAA,EAGA,OAAO,YAAoB;AACzB,WAAOF;AAAA,EACT;AAAA;AAAA,EAGA,OAAO,WAAoB;AACzB,WAAOI,MAAc;AAAA,EACvB;AAAA;AAAA,EAGA,OAAa,QAAQE,GAA0E;AAAA,WAAAC,EAAA;AAC7F,YAAMF,EAAeC,CAAO;AAAA,IAC9B;AAAA;AACF;AAGO,MAAMa,IAAa;AAAA,EACxB,SAASjB;AAAA,EACT,QAAQF;AAAA,EACR,SAASc,EAAgB;AAAA,EACzB,UAAUA,EAAgB;AAC5B;AC/JO,IAAKM,sBAAAA,OACVA,EAAA,SAAS,UACTA,EAAA,YAAY,YACZA,EAAA,aAAa,QACbA,EAAA,OAAO,QACPA,EAAA,QAAQ,SALEA,IAAAA,KAAA,CAAA,CAAA;"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(t
|
|
1
|
+
(function(e,t){typeof exports=="object"&&typeof module!="undefined"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,t(e["PayNext SDK"]={}))})(this,function(e){"use strict";var D=Object.defineProperty;var m=(e,t,o)=>t in e?D(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var y=(e,t,o)=>m(e,typeof t!="symbol"?t+"":t,o);var l=(e,t,o)=>new Promise((N,a)=>{var d=s=>{try{u(o.next(s))}catch(w){a(w)}},f=s=>{try{u(o.throw(s))}catch(w){a(w)}},u=s=>s.done?N(s.value):Promise.resolve(s.value).then(d,f);u((o=o.apply(e,t)).next())});const t="https://paynext-sdk-dev.ableapp.workers.dev/index.cdn.js",o="https://paynext-sdk.ableapp.workers.dev/index.cdn.js",N="1.0.0";let a=null,d=null;function f(n){return l(this,null,function*(){if(d)return d;if(a)return a;const i=(n==null?void 0:n.toLowerCase())==="develop"||(n==null?void 0:n.toLowerCase())==="staging"?"develop":"production";return a=new Promise((r,h)=>{if(typeof window=="undefined"){h(new Error("PayNext SDK can only be loaded in browser environment"));return}if(window.PayNextSDK){console.log("[PayNext CDN] SDK already loaded from cache"),d=window.PayNextSDK,r(d);return}const c=document.createElement("script");c.src=i==="develop"?t:o,c.crossOrigin="anonymous",c.async=!0,c.onload=()=>{setTimeout(()=>{const P=window.PayNextSDK;if(!P){console.error("[PayNext CDN] PayNextSDK not found in window after load"),a=null,document.head.removeChild(c),h(new Error("PayNextSDK not found in global scope after loading"));return}d=P,r(P)},10)},c.onerror=P=>{console.error("[PayNext CDN] Failed to load script:",P),a=null,document.head.removeChild(c),h(new Error("Failed to load PayNext SDK script from CDN"))},document.head.appendChild(c)}),a})}class u{constructor(i){y(this,"cdnInstance",null);y(this,"initPromise",null);this.initPromise=this.initialize(i)}initialize(i){return l(this,null,function*(){try{const r=yield f(i);if(!r.PayNextCheckout)throw new Error("PayNextCheckout not found in CDN module");this.cdnInstance=new r.PayNextCheckout}catch(r){throw console.error("[PayNext CDN] Failed to initialize:",r),r}})}waitForReady(){return l(this,null,function*(){if(!this.initPromise)throw new Error("SDK initialization not started");if(yield this.initPromise,!this.cdnInstance)throw new Error("SDK instance not created")})}mount(i,r){return l(this,null,function*(){return console.log("[PayNext CDN] mount(): ",r.environment),yield this.waitForReady(),this.cdnInstance.mount(i,r)})}unmount(){return l(this,null,function*(){if(yield this.waitForReady(),this.cdnInstance.unmount)return this.cdnInstance.unmount()})}updateConfig(i){return l(this,null,function*(){if(yield this.waitForReady(),this.cdnInstance.updateConfig)return this.cdnInstance.updateConfig(i)})}static getVersion(){return N}static getCDNUrl(){return t}static isLoaded(){return d!==null}static preload(i){return l(this,null,function*(){yield f(i)})}}const s={version:N,cdnUrl:t,preload:u.preload,isLoaded:u.isLoaded};var w=(n=>(n.PAYPAL="PAYPAL",n.APPLE_PAY="APPLEPAY",n.GOOGLE_PAY="GPAY",n.CARD="CARD",n.VENMO="VENMO",n))(w||{});e.PayNextCheckout=u,e.PayNextSDK=s,e.PaymentMethod=w,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/app/sdk-pkg/sdk.pkg.ts","../src/pkg/checkout-api/constants/enums.ts"],"sourcesContent":["import type { PayNextConfig } from \"@/core/modules/checkout/checkout.interface\"\n\n// CDN configuration\nconst CDN_URL_DEV = 'https://paynext-sdk.
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/app/sdk-pkg/sdk.pkg.ts","../src/pkg/checkout-api/constants/enums.ts"],"sourcesContent":["import type { PayNextConfig } from \"@/core/modules/checkout/checkout.interface\"\n\n// CDN configuration\nconst CDN_URL_DEV = 'https://paynext-sdk-dev.ableapp.workers.dev/index.cdn.js'\nconst CDN_URL_PROD = 'https://paynext-sdk.ableapp.workers.dev/index.cdn.js'\nconst CDN_VERSION = '1.0.0'\n\n// cache for loaded SDK\nlet sdkPromise: Promise<any> | null = null\nlet sdkModule: any = null\n\n// dynamically load SDK from CDN\nasync function loadSDKFromCDN(envType: 'develop' | 'staging' | 'sandbox' | 'production'): Promise<any> {\n if (sdkModule) {\n return sdkModule\n }\n\n if (sdkPromise) {\n return sdkPromise\n }\n\n const environment = (envType?.toLowerCase() === 'develop' || envType?.toLowerCase() === 'staging') ? 'develop' : 'production'\n\n sdkPromise = new Promise((resolve, reject) => {\n if (typeof window === 'undefined') {\n reject(new Error('PayNext SDK can only be loaded in browser environment'))\n return\n }\n\n if ((window as any).PayNextSDK) {\n console.log('[PayNext CDN] SDK already loaded from cache')\n sdkModule = (window as any).PayNextSDK\n resolve(sdkModule)\n return\n }\n \n const script = document.createElement('script')\n script.src = environment === 'develop' ? CDN_URL_DEV : CDN_URL_PROD\n script.crossOrigin = 'anonymous'\n script.async = true\n \n script.onload = () => { \n setTimeout(() => {\n const module = (window as any).PayNextSDK\n \n if (!module) {\n console.error('[PayNext CDN] PayNextSDK not found in window after load')\n sdkPromise = null\n document.head.removeChild(script)\n reject(new Error('PayNextSDK not found in global scope after loading'))\n return\n }\n \n sdkModule = module\n resolve(module)\n }, 10)\n }\n \n script.onerror = (error) => {\n console.error('[PayNext CDN] Failed to load script:', error)\n sdkPromise = null\n document.head.removeChild(script)\n reject(new Error('Failed to load PayNext SDK script from CDN'))\n }\n \n document.head.appendChild(script)\n })\n\n return sdkPromise\n}\n\n// checkout proxy class\nexport class PayNextCheckout {\n private cdnInstance: any = null\n private initPromise: Promise<void> | null = null\n\n constructor(envType: 'develop' | 'staging' | 'sandbox' | 'production') {\n \n\n this.initPromise = this.initialize(envType)\n }\n\n // initialize\n private async initialize(envType: 'develop' | 'staging' | 'sandbox' | 'production'): Promise<void> {\n try {\n const sdk = await loadSDKFromCDN(envType)\n \n if (!sdk.PayNextCheckout) {\n throw new Error('PayNextCheckout not found in CDN module')\n }\n \n this.cdnInstance = new sdk.PayNextCheckout()\n } catch (error) {\n console.error('[PayNext CDN] Failed to initialize:', error)\n throw error\n }\n }\n\n // wait for ready\n private async waitForReady(): Promise<void> {\n if (!this.initPromise) {\n throw new Error('SDK initialization not started')\n }\n await this.initPromise\n if (!this.cdnInstance) {\n throw new Error('SDK instance not created')\n }\n }\n\n // mount\n async mount(containerId: string, config: PayNextConfig): Promise<void> {\n console.log('[PayNext CDN] mount(): ', config.environment)\n await this.waitForReady()\n return this.cdnInstance.mount(containerId, config)\n }\n\n // unmount\n async unmount(): Promise<void> {\n await this.waitForReady()\n if (this.cdnInstance.unmount) {\n return this.cdnInstance.unmount()\n }\n }\n\n // update config\n async updateConfig(config: any): Promise<void> {\n await this.waitForReady()\n if (this.cdnInstance.updateConfig) {\n return this.cdnInstance.updateConfig(config)\n }\n }\n\n // get version\n static getVersion(): string {\n return CDN_VERSION\n }\n\n // get CDN url\n static getCDNUrl(): string {\n return CDN_URL_DEV\n }\n\n // check if loaded\n static isLoaded(): boolean {\n return sdkModule !== null\n }\n\n // preload (optional optimization)\n static async preload(envType: 'develop' | 'staging' | 'sandbox' | 'production'): Promise<void> {\n await loadSDKFromCDN(envType)\n }\n}\n\n// export\nexport const PayNextSDK = {\n version: CDN_VERSION,\n cdnUrl: CDN_URL_DEV,\n preload: PayNextCheckout.preload,\n isLoaded: PayNextCheckout.isLoaded,\n}\n\nexport default PayNextCheckout\n\n","export enum PaymentMethod {\n PAYPAL = 'PAYPAL',\n APPLE_PAY = 'APPLEPAY',\n GOOGLE_PAY = 'GPAY',\n CARD = 'CARD',\n VENMO = 'VENMO',\n}\n\nexport enum PaymentStatus {\n PENDING = 'PENDING',\n FAILED = 'FAILED',\n AUTHORIZED = 'AUTHORIZED',\n SETTLING = 'SETTLING',\n SETTLED = 'SETTLED',\n DECLINED = 'DECLINED',\n CANCELLED = 'CANCELLED',\n}\n\nexport enum DeclineCode {\n INSUFFICIENT_FUNDS = 'insufficient_funds',\n AUTHENTICATION_REQUIRED = 'authentication_required',\n CARD_ISSUER_DECLINE = 'card_issuer_decline',\n GENERIC_DECLINE = 'generic_decline',\n WITHDRAWAL_LIMIT_EXCEEDED = 'withdrawal_limit_exceeded',\n DO_NOT_HONOR = 'do_not_honor',\n EXPIRED_CARD = 'expired_card',\n SUSPECTED_FRAUD = 'suspected_fraud',\n INCORRECT_CVC = 'incorrect_cvc',\n INVALID_CARD_NUMBER = 'invalid_card_number',\n ISSUER_UNAVAILABLE = 'issuer_unavailable',\n CARD_LOST_OR_STOLEN = 'card_lost_or_stolen',\n CARD_DECLINED = 'card_declined',\n}\n"],"names":["CDN_URL_DEV","CDN_URL_PROD","CDN_VERSION","sdkPromise","sdkModule","loadSDKFromCDN","envType","__async","environment","resolve","reject","script","module","error","PayNextCheckout","__publicField","sdk","containerId","config","PayNextSDK","PaymentMethod"],"mappings":"ymBAGA,MAAMA,EAAc,2DACdC,EAAe,uDACfC,EAAc,QAGpB,IAAIC,EAAkC,KAClCC,EAAiB,KAGrB,SAAeC,EAAeC,EAAyE,QAAAC,EAAA,sBACrG,GAAIH,EACF,OAAOA,EAGT,GAAID,EACF,OAAOA,EAGT,MAAMK,GAAeF,GAAA,YAAAA,EAAS,iBAAkB,YAAaA,GAAA,YAAAA,EAAS,iBAAkB,UAAa,UAAY,aAEjH,OAAAH,EAAa,IAAI,QAAQ,CAACM,EAASC,IAAW,CAC5C,GAAI,OAAO,QAAW,YAAa,CACjCA,EAAO,IAAI,MAAM,uDAAuD,CAAC,EACzE,MACF,CAEA,GAAK,OAAe,WAAY,CAC9B,QAAQ,IAAI,6CAA6C,EACzDN,EAAa,OAAe,WAC5BK,EAAQL,CAAS,EACjB,MACF,CAEA,MAAMO,EAAS,SAAS,cAAc,QAAQ,EAC9CA,EAAO,IAAMH,IAAgB,UAAYR,EAAcC,EACvDU,EAAO,YAAc,YACrBA,EAAO,MAAQ,GAEfA,EAAO,OAAS,IAAM,CACpB,WAAW,IAAM,CACf,MAAMC,EAAU,OAAe,WAE/B,GAAI,CAACA,EAAQ,CACX,QAAQ,MAAM,yDAAyD,EACvET,EAAa,KACb,SAAS,KAAK,YAAYQ,CAAM,EAChCD,EAAO,IAAI,MAAM,oDAAoD,CAAC,EACtE,MACF,CAEAN,EAAYQ,EACZH,EAAQG,CAAM,CAChB,EAAG,EAAE,CACP,EAEAD,EAAO,QAAWE,GAAU,CAC1B,QAAQ,MAAM,uCAAwCA,CA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AAC,EAAA,sBAC7F,MAAMF,EAAeC,CAAO,CAC9B,GACF,CAGO,MAAMa,EAAa,CACxB,QAASjB,EACT,OAAQF,EACR,QAASc,EAAgB,QACzB,SAAUA,EAAgB,QAC5B,EC/JO,IAAKM,GAAAA,IACVA,EAAA,OAAS,SACTA,EAAA,UAAY,WACZA,EAAA,WAAa,OACbA,EAAA,KAAO,OACPA,EAAA,MAAQ,QALEA,IAAAA,GAAA,CAAA,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paynext/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.148",
|
|
4
4
|
"description": "PayNext SDK - Payment processing with automatic CDN loading",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.es.js",
|
|
@@ -106,5 +106,8 @@
|
|
|
106
106
|
"> 0.2%",
|
|
107
107
|
"defaults"
|
|
108
108
|
],
|
|
109
|
-
"packageManager": "yarn@1.22.22"
|
|
109
|
+
"packageManager": "yarn@1.22.22",
|
|
110
|
+
"dependencies": {
|
|
111
|
+
"@paynext/sdk": "0.0.147"
|
|
112
|
+
}
|
|
110
113
|
}
|