@paynext/sdk 0.0.151 → 0.0.152
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 +1 -4
- package/dist/index.es.js +58 -66
- 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 +2 -5
package/dist/index.d.ts
CHANGED
|
@@ -350,14 +350,12 @@ declare enum PaymentStatus {
|
|
|
350
350
|
export declare class PayNextCheckout {
|
|
351
351
|
private cdnInstance;
|
|
352
352
|
private initPromise;
|
|
353
|
-
constructor(
|
|
353
|
+
constructor();
|
|
354
354
|
private initialize;
|
|
355
355
|
private waitForReady;
|
|
356
356
|
mount(containerId: string, config: PayNextConfig): Promise<void>;
|
|
357
357
|
unmount(): Promise<void>;
|
|
358
358
|
updateConfig(config: any): Promise<void>;
|
|
359
|
-
static getVersion(): string;
|
|
360
|
-
static getCDNUrl(): string;
|
|
361
359
|
static isLoaded(): boolean;
|
|
362
360
|
static preload(envType: 'develop' | 'staging' | 'sandbox' | 'production'): Promise<void>;
|
|
363
361
|
}
|
|
@@ -379,7 +377,6 @@ export declare interface PayNextConfig {
|
|
|
379
377
|
|
|
380
378
|
export declare const PayNextSDK: {
|
|
381
379
|
version: string;
|
|
382
|
-
cdnUrl: string;
|
|
383
380
|
preload: typeof PayNextCheckout.preload;
|
|
384
381
|
isLoaded: typeof PayNextCheckout.isLoaded;
|
|
385
382
|
};
|
package/dist/index.es.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var D = Object.defineProperty;
|
|
2
|
+
var m = (t, n, o) => n in t ? D(t, n, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[n] = o;
|
|
3
|
+
var P = (t, n, o) => m(t, typeof n != "symbol" ? n + "" : n, o);
|
|
4
|
+
var s = (t, n, o) => new Promise((r, l) => {
|
|
5
|
+
var u = (a) => {
|
|
6
6
|
try {
|
|
7
|
-
|
|
8
|
-
} catch (
|
|
9
|
-
|
|
7
|
+
i(o.next(a));
|
|
8
|
+
} catch (w) {
|
|
9
|
+
l(w);
|
|
10
10
|
}
|
|
11
|
-
},
|
|
11
|
+
}, e = (a) => {
|
|
12
12
|
try {
|
|
13
|
-
|
|
14
|
-
} catch (
|
|
15
|
-
|
|
13
|
+
i(o.throw(a));
|
|
14
|
+
} catch (w) {
|
|
15
|
+
l(w);
|
|
16
16
|
}
|
|
17
|
-
},
|
|
18
|
-
|
|
17
|
+
}, i = (a) => a.done ? r(a.value) : Promise.resolve(a.value).then(u, e);
|
|
18
|
+
i((o = o.apply(t, n)).next());
|
|
19
19
|
});
|
|
20
|
-
const
|
|
21
|
-
let
|
|
22
|
-
function
|
|
23
|
-
return
|
|
20
|
+
const C = "https://paynext-sdk-dev.ableapp.workers.dev/index.cdn.js", f = "https://cdn-sdk.paynext.com/index.cdn.js", x = "1.0.0";
|
|
21
|
+
let d = null, c = null;
|
|
22
|
+
function h(t) {
|
|
23
|
+
return s(this, null, function* () {
|
|
24
|
+
var o, r;
|
|
25
|
+
if (c)
|
|
26
|
+
return c;
|
|
24
27
|
if (d)
|
|
25
28
|
return d;
|
|
26
|
-
|
|
27
|
-
|
|
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) => {
|
|
29
|
+
const n = (o = t == null ? void 0 : t.toLowerCase()) != null && o.includes("develop") || (r = t == null ? void 0 : t.toLowerCase()) != null && r.includes("staging") ? "develop" : "production";
|
|
30
|
+
return d = new Promise((l, u) => {
|
|
30
31
|
if (typeof window == "undefined") {
|
|
31
|
-
|
|
32
|
+
u(new Error("PayNext SDK can only be loaded in browser environment"));
|
|
32
33
|
return;
|
|
33
34
|
}
|
|
34
35
|
if (window.PayNextSDK) {
|
|
35
|
-
console.log("[PayNext CDN] SDK already loaded from cache"),
|
|
36
|
+
console.log("[PayNext CDN] SDK already loaded from cache"), c = window.PayNextSDK, l(c);
|
|
36
37
|
return;
|
|
37
38
|
}
|
|
38
39
|
const e = document.createElement("script");
|
|
39
|
-
e.src = n === "develop" ?
|
|
40
|
+
e.src = n === "develop" ? C : f, e.crossOrigin = "*", e.async = !0, e.onload = () => {
|
|
40
41
|
setTimeout(() => {
|
|
41
42
|
const i = window.PayNextSDK;
|
|
42
43
|
if (!i) {
|
|
43
|
-
console.error("[PayNext CDN] PayNextSDK not found in window after load"),
|
|
44
|
+
console.error("[PayNext CDN] PayNextSDK not found in window after load"), d = null, document.head.removeChild(e), u(new Error("PayNextSDK not found in global scope after loading"));
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
+
c = i, l(i);
|
|
47
48
|
}, 10);
|
|
48
49
|
}, e.onerror = (i) => {
|
|
49
|
-
console.error("[PayNext CDN] Failed to load script:", i),
|
|
50
|
+
console.error("[PayNext CDN] Failed to load script:", i), d = null, document.head.removeChild(e), u(new Error("Failed to load PayNext SDK script from CDN"));
|
|
50
51
|
}, document.head.appendChild(e);
|
|
51
|
-
}),
|
|
52
|
+
}), d;
|
|
52
53
|
});
|
|
53
54
|
}
|
|
54
|
-
class
|
|
55
|
-
constructor(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
this
|
|
55
|
+
class N {
|
|
56
|
+
// constructor(envType: 'develop' | 'staging' | 'sandbox' | 'production') {
|
|
57
|
+
constructor() {
|
|
58
|
+
P(this, "cdnInstance", null);
|
|
59
|
+
P(this, "initPromise", null);
|
|
59
60
|
}
|
|
60
61
|
// initialize
|
|
61
62
|
initialize(n) {
|
|
62
|
-
return
|
|
63
|
+
return s(this, null, function* () {
|
|
63
64
|
try {
|
|
64
|
-
|
|
65
|
-
if (!o.PayNextCheckout)
|
|
65
|
+
if (this.initPromise = yield h(n), !this.initPromise.PayNextCheckout)
|
|
66
66
|
throw new Error("PayNextCheckout not found in CDN module");
|
|
67
|
-
this.cdnInstance = new
|
|
67
|
+
this.cdnInstance = new this.initPromise.PayNextCheckout();
|
|
68
68
|
} catch (o) {
|
|
69
69
|
throw console.error("[PayNext CDN] Failed to initialize:", o), o;
|
|
70
70
|
}
|
|
@@ -72,61 +72,53 @@ class h {
|
|
|
72
72
|
}
|
|
73
73
|
// wait for ready
|
|
74
74
|
waitForReady() {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
throw new Error("SDK instance not created");
|
|
80
|
-
});
|
|
75
|
+
if (!this.initPromise)
|
|
76
|
+
throw new Error("SDK initialization not started");
|
|
77
|
+
if (!this.cdnInstance)
|
|
78
|
+
throw new Error("SDK instance not created");
|
|
81
79
|
}
|
|
82
80
|
// mount
|
|
83
81
|
mount(n, o) {
|
|
84
|
-
return
|
|
85
|
-
|
|
82
|
+
return s(this, null, function* () {
|
|
83
|
+
var r;
|
|
84
|
+
return yield this.initialize(o.environment), this.waitForReady(), (r = this.cdnInstance) == null ? void 0 : r.mount(n, o);
|
|
86
85
|
});
|
|
87
86
|
}
|
|
88
87
|
// unmount
|
|
89
88
|
unmount() {
|
|
90
|
-
return
|
|
91
|
-
|
|
89
|
+
return s(this, null, function* () {
|
|
90
|
+
var n;
|
|
91
|
+
if (this.waitForReady(), (n = this.cdnInstance) != null && n.unmount)
|
|
92
92
|
return this.cdnInstance.unmount();
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
// update config
|
|
96
96
|
updateConfig(n) {
|
|
97
|
-
return
|
|
98
|
-
|
|
97
|
+
return s(this, null, function* () {
|
|
98
|
+
var o;
|
|
99
|
+
if (this.waitForReady(), (o = this.cdnInstance) != null && o.updateConfig)
|
|
99
100
|
return this.cdnInstance.updateConfig(n);
|
|
100
101
|
});
|
|
101
102
|
}
|
|
102
|
-
// get version
|
|
103
|
-
static getVersion() {
|
|
104
|
-
return D;
|
|
105
|
-
}
|
|
106
|
-
// get CDN url
|
|
107
|
-
static getCDNUrl() {
|
|
108
|
-
return N;
|
|
109
|
-
}
|
|
110
103
|
// check if loaded
|
|
111
104
|
static isLoaded() {
|
|
112
|
-
return
|
|
105
|
+
return c !== null;
|
|
113
106
|
}
|
|
114
107
|
// preload (optional optimization)
|
|
115
108
|
static preload(n) {
|
|
116
|
-
return
|
|
117
|
-
yield
|
|
109
|
+
return s(this, null, function* () {
|
|
110
|
+
yield h(n);
|
|
118
111
|
});
|
|
119
112
|
}
|
|
120
113
|
}
|
|
121
114
|
const E = {
|
|
122
|
-
version:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
isLoaded: h.isLoaded
|
|
115
|
+
version: x,
|
|
116
|
+
preload: N.preload,
|
|
117
|
+
isLoaded: N.isLoaded
|
|
126
118
|
};
|
|
127
119
|
var y = /* @__PURE__ */ ((t) => (t.PAYPAL = "PAYPAL", t.APPLE_PAY = "APPLEPAY", t.GOOGLE_PAY = "GPAY", t.CARD = "CARD", t.VENMO = "VENMO", t))(y || {});
|
|
128
120
|
export {
|
|
129
|
-
|
|
121
|
+
N as PayNextCheckout,
|
|
130
122
|
E as PayNextSDK,
|
|
131
123
|
y as PaymentMethod
|
|
132
124
|
};
|
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-dev.ableapp.workers.dev/index.cdn.js'\nconst CDN_URL_PROD = 'https://cdn-sdk.paynext.com/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()
|
|
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://cdn-sdk.paynext.com/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()?.includes('develop') || envType?.toLowerCase()?.includes('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 = '*'\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: any | null = null\n\n // constructor(envType: 'develop' | 'staging' | 'sandbox' | 'production') {\n constructor() {\n // this.initPromise = this.initialize(envType)\n }\n\n // initialize\n private async initialize(envType: 'develop' | 'staging' | 'sandbox' | 'production'): Promise<void> {\n try {\n this.initPromise = await loadSDKFromCDN(envType)\n \n if (!this.initPromise.PayNextCheckout) {\n throw new Error('PayNextCheckout not found in CDN module')\n }\n \n this.cdnInstance = new this.initPromise.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 waitForReady(): void {\n if (!this.initPromise) {\n throw new Error('SDK initialization not started')\n }\n\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 await this.initialize(config.environment)\n this.waitForReady()\n return this.cdnInstance?.mount(containerId, config)\n }\n\n // unmount\n async unmount(): Promise<void> {\n 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 this.waitForReady()\n if (this.cdnInstance?.updateConfig) {\n return this.cdnInstance.updateConfig(config)\n }\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 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","_a","_b","environment","resolve","reject","script","module","error","PayNextCheckout","__publicField","containerId","config","PayNextSDK","PaymentMethod"],"mappings":";;;;;;;;;;;;;;;;;;;AAGA,MAAMA,IAAc,4DACdC,IAAe,4CACfC,IAAc;AAGpB,IAAIC,IAAkC,MAClCC,IAAiB;AAGrB,SAAeC,EAAeC,GAAyE;AAAA,SAAAC,EAAA;AATvG,QAAAC,GAAAC;AAUE,QAAIL;AACF,aAAOA;AAGT,QAAID;AACF,aAAOA;AAGT,UAAMO,KAAeF,IAAAF,KAAA,gBAAAA,EAAS,kBAAT,QAAAE,EAAwB,SAAS,eAAcC,IAAAH,KAAA,gBAAAA,EAAS,kBAAT,QAAAG,EAAwB,SAAS,aAAc,YAAY;AAE/H,WAAAN,IAAa,IAAI,QAAQ,CAACQ,GAASC,MAAW;AAC5C,UAAI,OAAO,UAAW,aAAa;AACjC,QAAAA,EAAO,IAAI,MAAM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exports=="object"&&typeof module!="undefined"?n(exports):typeof define=="function"&&define.amd?define(["exports"],n):(t=typeof globalThis!="undefined"?globalThis:t||self,n(t["PayNext SDK"]={}))})(this,(function(t){"use strict";var C=Object.defineProperty;var x=(t,n,i)=>n in t?C(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i;var y=(t,n,i)=>x(t,typeof n!="symbol"?n+"":n,i);var u=(t,n,i)=>new Promise((N,a)=>{var s=d=>{try{l(i.next(d))}catch(P){a(P)}},w=d=>{try{l(i.throw(d))}catch(P){a(P)}},l=d=>d.done?N(d.value):Promise.resolve(d.value).then(s,w);l((i=i.apply(t,n)).next())});const n="https://paynext-sdk-dev.ableapp.workers.dev/index.cdn.js",i="https://cdn-sdk.paynext.com/index.cdn.js",N="1.0.0";let a=null,s=null;function w(e){return u(this,null,function*(){var r,f;if(s)return s;if(a)return a;const o=(r=e==null?void 0:e.toLowerCase())!=null&&r.includes("develop")||(f=e==null?void 0:e.toLowerCase())!=null&&f.includes("staging")?"develop":"production";return a=new Promise((D,m)=>{if(typeof window=="undefined"){m(new Error("PayNext SDK can only be loaded in browser environment"));return}if(window.PayNextSDK){console.log("[PayNext CDN] SDK already loaded from cache"),s=window.PayNextSDK,D(s);return}const c=document.createElement("script");c.src=o==="develop"?n:i,c.crossOrigin="*",c.async=!0,c.onload=()=>{setTimeout(()=>{const h=window.PayNextSDK;if(!h){console.error("[PayNext CDN] PayNextSDK not found in window after load"),a=null,document.head.removeChild(c),m(new Error("PayNextSDK not found in global scope after loading"));return}s=h,D(h)},10)},c.onerror=h=>{console.error("[PayNext CDN] Failed to load script:",h),a=null,document.head.removeChild(c),m(new Error("Failed to load PayNext SDK script from CDN"))},document.head.appendChild(c)}),a})}class l{constructor(){y(this,"cdnInstance",null);y(this,"initPromise",null)}initialize(o){return u(this,null,function*(){try{if(this.initPromise=yield w(o),!this.initPromise.PayNextCheckout)throw new Error("PayNextCheckout not found in CDN module");this.cdnInstance=new this.initPromise.PayNextCheckout}catch(r){throw console.error("[PayNext CDN] Failed to initialize:",r),r}})}waitForReady(){if(!this.initPromise)throw new Error("SDK initialization not started");if(!this.cdnInstance)throw new Error("SDK instance not created")}mount(o,r){return u(this,null,function*(){var f;return yield this.initialize(r.environment),this.waitForReady(),(f=this.cdnInstance)==null?void 0:f.mount(o,r)})}unmount(){return u(this,null,function*(){var o;if(this.waitForReady(),(o=this.cdnInstance)!=null&&o.unmount)return this.cdnInstance.unmount()})}updateConfig(o){return u(this,null,function*(){var r;if(this.waitForReady(),(r=this.cdnInstance)!=null&&r.updateConfig)return this.cdnInstance.updateConfig(o)})}static isLoaded(){return s!==null}static preload(o){return u(this,null,function*(){yield w(o)})}}const d={version:N,preload:l.preload,isLoaded:l.isLoaded};var P=(e=>(e.PAYPAL="PAYPAL",e.APPLE_PAY="APPLEPAY",e.GOOGLE_PAY="GPAY",e.CARD="CARD",e.VENMO="VENMO",e))(P||{});t.PayNextCheckout=l,t.PayNextSDK=d,t.PaymentMethod=P,Object.defineProperty(t,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-dev.ableapp.workers.dev/index.cdn.js'\nconst CDN_URL_PROD = 'https://cdn-sdk.paynext.com/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()
|
|
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://cdn-sdk.paynext.com/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()?.includes('develop') || envType?.toLowerCase()?.includes('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 = '*'\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: any | null = null\n\n // constructor(envType: 'develop' | 'staging' | 'sandbox' | 'production') {\n constructor() {\n // this.initPromise = this.initialize(envType)\n }\n\n // initialize\n private async initialize(envType: 'develop' | 'staging' | 'sandbox' | 'production'): Promise<void> {\n try {\n this.initPromise = await loadSDKFromCDN(envType)\n \n if (!this.initPromise.PayNextCheckout) {\n throw new Error('PayNextCheckout not found in CDN module')\n }\n \n this.cdnInstance = new this.initPromise.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 waitForReady(): void {\n if (!this.initPromise) {\n throw new Error('SDK initialization not started')\n }\n\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 await this.initialize(config.environment)\n this.waitForReady()\n return this.cdnInstance?.mount(containerId, config)\n }\n\n // unmount\n async unmount(): Promise<void> {\n 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 this.waitForReady()\n if (this.cdnInstance?.updateConfig) {\n return this.cdnInstance.updateConfig(config)\n }\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 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","_a","_b","resolve","reject","script","module","error","PayNextCheckout","__publicField","containerId","config","PayNextSDK","PaymentMethod"],"mappings":"0mBAGA,MAAMA,EAAc,2DACdC,EAAe,2CACfC,EAAc,QAGpB,IAAIC,EAAkC,KAClCC,EAAiB,KAGrB,SAAeC,EAAeC,EAAyE,QAAAC,EAAA,8BACrG,GAAIH,EACF,OAAOA,EAGT,GAAID,EACF,OAAOA,EAGT,MAAMK,GAAeC,EAAAH,GAAA,YAAAA,EAAS,gBAAT,MAAAG,EAAwB,SAAS,aAAcC,EAAAJ,GAAA,YAAAA,EAAS,gBAAT,MAAAI,EAAwB,SAAS,WAAc,UAAY,aAE/H,OAAAP,EAAa,IAAI,QAAQ,CAACQ,EAASC,IAAW,CAC5C,GAAI,OAAO,QAAW,YAAa,CACjCA,EAAO,IAAI,MAAM,uDAAuD,CAAC,EACzE,MACF,CAEA,GAAK,OAAe,WAAY,CAC9B,QAAQ,IAAI,6CAA6C,EACzDR,EAAa,OAAe,WAC5BO,EAAQP,CA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AMS,EAAaC,EAC9C,GAGM,SAAyB,QAAAZ,EAAA,4BAE7B,GADA,KAAK,aAAA,GACDE,EAAA,KAAK,cAAL,MAAAA,EAAkB,QACpB,OAAO,KAAK,YAAY,QAAA,CAE5B,GAGM,aAAaU,EAA4B,QAAAZ,EAAA,4BAE7C,GADA,KAAK,aAAA,GACDE,EAAA,KAAK,cAAL,MAAAA,EAAkB,aACpB,OAAO,KAAK,YAAY,aAAaU,CAAM,CAE/C,GAGA,OAAO,UAAoB,CACzB,OAAOf,IAAc,IACvB,CAGA,OAAa,QAAQE,EAA0E,QAAAC,EAAA,sBAC7F,MAAMF,EAAeC,CAAO,CAC9B,GACF,CAGO,MAAMc,EAAa,CACxB,QAASlB,EACT,QAASc,EAAgB,QACzB,SAAUA,EAAgB,QAC5B,ECnJO,IAAKK,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.152",
|
|
4
4
|
"description": "PayNext SDK - Payment processing with automatic CDN loading",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.es.js",
|
|
@@ -106,8 +106,5 @@
|
|
|
106
106
|
"> 0.2%",
|
|
107
107
|
"defaults"
|
|
108
108
|
],
|
|
109
|
-
"packageManager": "yarn@1.22.22"
|
|
110
|
-
"dependencies": {
|
|
111
|
-
"@paynext/sdk": "0.0.150"
|
|
112
|
-
}
|
|
109
|
+
"packageManager": "yarn@1.22.22"
|
|
113
110
|
}
|