epic-collection-gateway-sdk 1.0.6 → 1.0.7

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.
Files changed (2) hide show
  1. package/dist/index.js +24 -22
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const u = "https://checkout.epicpay.co", g = "https://zppicbcegi.execute-api.af-south-1.amazonaws.com/prod/api/v1", m = {
2
2
  grabbersbeware: "getthehellout989898"
3
- }, c = {
3
+ }, a = {
4
4
  environment: "",
5
5
  apiBase: g,
6
6
  headers: {},
@@ -10,22 +10,22 @@ const u = "https://checkout.epicpay.co", g = "https://zppicbcegi.execute-api.af-
10
10
  dryRun: !0
11
11
  };
12
12
  function w(l) {
13
- Object.assign(c, l);
13
+ Object.assign(a, l);
14
14
  }
15
15
  function p(l) {
16
- const { environment: a, amount: r, sessionId: n, additionalParams: i, redirectUrl: d } = l, t = c.redirectUrl || c.apiBase;
16
+ const { environment: r, amount: i, sessionId: n, additionalParams: o, redirectUrl: d } = l, t = a.redirectUrl || a.apiBase;
17
17
  if (!t)
18
18
  throw new Error('No redirectUrl configured. Call initEpicPay({ redirectUrl: "https://..." }).');
19
19
  const e = {
20
- amount: String(r),
20
+ amount: String(i),
21
21
  sessionId: n
22
22
  };
23
- d && (e.redirectUrl = String(d)), c.clientId && (e.clientId = c.clientId), c.clientSecret && (e.clientSecret = c.clientSecret), a && (e.environment = String(a)), i && Object.keys(i).forEach((o) => {
24
- e[o] = String(i[o]);
23
+ d && (e.redirectUrl = String(d)), a.clientId && (e.clientId = a.clientId), a.clientSecret && (e.clientSecret = a.clientSecret), r && (e.environment = String(r)), o && Object.keys(o).forEach((c) => {
24
+ e[c] = String(o[c]);
25
25
  });
26
- const s = Object.keys(e).map((o) => `${encodeURIComponent(o)}=${encodeURIComponent(e[o])}`).join("&"), f = t + (t.includes("?") ? "&" : "?") + s;
26
+ const s = Object.keys(e).map((c) => `${encodeURIComponent(c)}=${encodeURIComponent(e[c])}`).join("&"), f = t + (t.includes("?") ? "&" : "?") + s;
27
27
  try {
28
- console.log("[EpicPay] redirectToPortal", { portal: t, amount: r, sessionId: n });
28
+ console.log("[EpicPay] redirectToPortal", { portal: t, amount: i, sessionId: n });
29
29
  } catch {
30
30
  }
31
31
  try {
@@ -35,55 +35,57 @@ function p(l) {
35
35
  return f;
36
36
  }
37
37
  async function E(l) {
38
- const { environment: a, clientId: r, clientSecret: n, redirectUrl: i, amount: d, sessionId: t, customerDetails: e } = l;
39
- if (!a || typeof a != "string")
38
+ const { environment: r, clientId: i, clientSecret: n, redirectUrl: o, amount: d, sessionId: t, customerDetails: e } = l;
39
+ if (!r || typeof r != "string")
40
40
  throw new Error("Invalid environment");
41
- if (!r || typeof r != "string" || r.length < 16)
41
+ if (!i || typeof i != "string" || i.length < 16)
42
42
  throw new Error("Invalid clientId");
43
43
  if (!n || typeof n != "string" || n.length < 16)
44
44
  throw new Error("Invalid clientSecret");
45
45
  if (!t || typeof t != "string" || t.length < 16)
46
46
  throw new Error("Invalid sessionId");
47
- if (!i || typeof i != "string")
47
+ if (!o || typeof o != "string")
48
48
  throw new Error("Invalid redirectUrl");
49
49
  w({
50
- environment: a,
51
- clientId: r,
50
+ environment: r,
51
+ clientId: i,
52
52
  clientSecret: n
53
53
  });
54
- const s = c.apiBase;
54
+ const s = a.apiBase;
55
55
  if (!s)
56
56
  throw new Error("No API base configured for authentication");
57
- const f = (s.endsWith("/") ? s.slice(0, -1) : s) + "/web-checkout/auth", o = await fetch(f, {
57
+ const f = (s.endsWith("/") ? s.slice(0, -1) : s) + "/web-checkout/auth", c = await fetch(f, {
58
58
  method: "POST",
59
59
  headers: { "Content-Type": "application/json", ...m },
60
60
  body: JSON.stringify({
61
- clientId: r,
61
+ environment: r,
62
+ clientId: i,
62
63
  clientSecret: n,
63
64
  sessionId: t,
64
65
  amount: d,
65
- redirectUrl: i,
66
+ redirectUrl: o,
66
67
  customerDetails: e
67
68
  })
68
69
  });
69
- if (!o.ok)
70
+ if (!c.ok)
70
71
  throw new Error("Authentication request failed");
71
72
  try {
72
- await o.json();
73
+ await c.json();
73
74
  } catch {
74
75
  }
75
76
  const h = {};
76
77
  return h.clientSecret = n, e && (e.name && (h.clientName = String(e.name)), e.email && (h.clientEmail = String(e.email)), e.phone && (h.clientPhone = String(e.phone))), p({
78
+ environment: r,
77
79
  amount: d,
78
80
  sessionId: t,
79
81
  additionalParams: h,
80
- redirectUrl: i
82
+ redirectUrl: o
81
83
  });
82
84
  }
83
85
  const I = { redirectToPortal: p, startEpicCollectionPayment: E };
84
86
  export {
85
87
  I as default,
86
- c as epicConfig,
88
+ a as epicConfig,
87
89
  p as redirectToPortal,
88
90
  w as setConfig,
89
91
  E as startEpicCollectionPayment
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "epic-collection-gateway-sdk",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",