epic-collection-gateway-sdk 1.0.2 → 1.0.4

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/README.md CHANGED
@@ -1,248 +1,132 @@
1
- # Epic Pay Collection Payment Gateway SDK (Demo)
1
+ # Epic Collection Gateway SDK
2
2
 
3
- A lightweight demo SDK exposing a payment sheet with three flows: Pay by Card, Pay by Bank, and Pay by Epic Pay. Intended for integration demos and sandbox presentations.
3
+ A lightweight TypeScript/JavaScript SDK for integrating **Epic Collections Web Checkout** into your web storefront. It handles authentication and redirect-flow initiation.
4
4
 
5
- ## Features
5
+ ---
6
6
 
7
- - Minimal, framework-agnostic checkout modal
8
- - Three demo payment methods: `card`, `bank`, `epic`
9
- - Simple event callbacks via `onEvent`
10
- - Zero backend required (simulated success/failure)
7
+ ## Features
11
8
 
12
- ## Installation
9
+ - **`startEpicCollectionPayment`** – Authenticate with the Epic Collections API and get the redirect URL to the hosted payment portal in one call.
10
+ - **`redirectToPortal`** – Build a portal redirect URL manually.
11
+ - Zero dependencies, ESM-only, full TypeScript types included.
13
12
 
14
- Published name: `epic-pay-sdk` (demo).
13
+ ---
15
14
 
16
- Install from npm:
15
+ ## Installation
17
16
 
18
17
  ```bash
19
- npm i epic-pay-sdk
20
- ```
21
-
22
- ## Quick start
23
-
24
- ```ts
25
- import { initEpicPay, openPaymentSheet } from "epic-pay-sdk";
26
-
27
- initEpicPay({ environment: "sandbox" });
28
-
29
- // Trigger at checkout
30
- const result = await openPaymentSheet({ amount: 999, currency: "₦" });
31
- if (result.status === "succeeded") {
32
- console.log("Paid", result.transactionId);
33
- }
18
+ npm install epic-collection-gateway-sdk
34
19
  ```
35
20
 
36
- ## Usage
21
+ ---
37
22
 
38
- ### ESM (bundlers like Vite, Webpack, Next.js)
23
+ ## Quick Start
39
24
 
40
25
  ```ts
41
- import EpicPay, {
42
- initEpicPay,
43
- openPaymentSheet,
44
- closePaymentSheet,
45
- } from "epic-pay-sdk";
46
-
47
- initEpicPay({
48
- merchantId: "demo_merchant_123",
49
- environment: "sandbox",
50
- onEvent: (e) => console.log("[EpicPay event]", e),
51
- });
26
+ import { startEpicCollectionPayment } from "epic-collection-gateway-sdk";
52
27
 
53
- // On checkout
54
- const result = await openPaymentSheet({
55
- amount: 999,
56
- currency: "",
57
- paymentMethods: ["card", "bank", "epic"],
28
+ const url = await startEpicCollectionPayment({
29
+ environment: "sandbox",
30
+ clientId: "YOUR_CLIENT_ID",
31
+ clientSecret: "YOUR_CLIENT_SECRET",
32
+ redirectUrl: "https://your-site.com/order-result",
33
+ amount: 2500,
34
+ sessionId: "unique_order_session_id",
35
+ customerDetails: { email: "user@example.com" },
58
36
  });
59
- if (result.status === "succeeded") {
60
- console.log("Paid", result.transactionId);
61
- }
62
37
 
63
- // You can programmatically close the sheet if needed
64
- closePaymentSheet();
38
+ // Navigate the user to the hosted payment portal
39
+ window.location.assign(url);
65
40
  ```
66
41
 
67
- ### Vanilla JS (no framework)
68
-
69
- Import via your bundler/ESM pipeline and call from regular scripts:
70
-
71
- ```js
72
- import { initEpicPay, openPaymentSheet, closePaymentSheet } from "epic-pay-sdk";
73
-
74
- initEpicPay({ environment: "sandbox" });
75
- document.getElementById("pay-btn").addEventListener("click", async () => {
76
- try {
77
- const res = await openPaymentSheet({ amount: 500, currency: "₦" });
78
- console.log(res);
79
- } catch (err) {
80
- console.error(err);
81
- }
82
- });
83
- ```
84
-
85
- ## API
86
-
87
- - **`initEpicPay(options)`**
88
-
89
- - `merchantId?: string`
90
- - `environment?: 'sandbox' | 'production'` (default: `sandbox`)
91
- - `onEvent?: (event) => void` event callback
92
-
93
- - **`openPaymentSheet(params)` -> `Promise<PaymentResult>`**
94
-
95
- - `amount: number` (required)
96
- - `currency?: string` (default: `₦`)
97
- - `customer?: Record<string, any>`
98
- - `paymentMethods?: ('card' | 'bank' | 'epic')[]` (default: all)
99
-
100
- Notes:
101
-
102
- - Must be called in a browser environment (uses DOM to render a modal sheet).
103
- - Prevents multiple concurrent sheets; rejects if one is already open.
104
-
105
- - **`closePaymentSheet()`** closes the sheet.
106
-
107
- ### Events
108
-
109
- Events emitted to `onEvent`:
42
+ ---
110
43
 
111
- - `payment_opened`
112
- - `payment_initiated`
113
- - `payment_succeeded`
114
- - `payment_failed`
115
- - `payment_closed`
44
+ ## API Reference
116
45
 
117
- ## TypeScript
46
+ ### `startEpicCollectionPayment(options)` → `Promise<string>`
118
47
 
119
- Type definitions are included at `epic-pay-sdk/index.d.ts`.
48
+ Authenticates your session with the Epic Collections backend and returns the fully-qualified portal redirect URL. This is the **primary integration function** for most storefronts.
120
49
 
121
- - `EpicPayInitOptions`
122
- - `OpenPaymentSheetParams`
123
- - `PaymentResult` union with `succeeded | cancelled | failed`
50
+ | Option | Type | Required | Description |
51
+ |---|---|---|---|
52
+ | `environment` | `string` | | Environment (sandbox or production). |
53
+ | `clientId` | `string` | ✅ | Issued from the Epic Collections Admin Portal (min 16 chars). |
54
+ | `clientSecret` | `string` | ✅ | Issued from the Epic Collections Admin Portal (min 16 chars). |
55
+ | `redirectUrl` | `string` | ✅ | Merchant callback URL — where the user lands after payment or cancellation. |
56
+ | `amount` | `number` | ✅ | Checkout amount (e.g. `2500` for ₦2,500). |
57
+ | `sessionId` | `string` | ✅ | Unique identifier for this checkout session / order (min 16 chars). |
58
+ | `customerDetails` | `EpicCollectioncustomerDetails` | — | Optional customer info forwarded to the portal. |
124
59
 
125
- Importing with types:
60
+ **`EpicCollectioncustomerDetails`**
126
61
 
127
62
  ```ts
128
- import type { OpenPaymentSheetParams, PaymentResult } from "epic-pay-sdk";
63
+ interface EpicCollectioncustomerDetails {
64
+ name?: string;
65
+ email?: string;
66
+ phone?: string;
67
+ }
129
68
  ```
130
69
 
131
- ## Demo app
132
-
133
- A simple integration demo is available in this repo at `epic-demo/`.
134
-
135
- ## Notes
70
+ ---
136
71
 
137
- - This is a front-end only demo. No real payments are processed.
138
- - Success is simulated (~90% chance).
139
- - Styles are injected dynamically by the SDK.
72
+ ### `redirectToPortal(params)` `string`
140
73
 
141
- ## Redirect-only integration (new flow)
74
+ Builds and returns the portal URL without making an auth API call.
142
75
 
143
- If you want a redirect-only flow (the SDK only performs the redirect to your hosted portal and helps parse the return), initialize with `redirectUrl` and optional `clientId`/`clientSecret`:
76
+ | Param | Type | Required | Description |
77
+ |---|---|---|---|
78
+ | `amount` | `number` | ✅ | Checkout amount. |
79
+ | `sessionId` | `string` | ✅ | Unique checkout session ID. |
80
+ | `redirectUrl` | `string` | — | Overrides the default redirect URL. |
81
+ | `customerDetails` | `EpicCollectioncustomerDetails` | — | Optional customer metadata. |
82
+ | `additionalParams` | `Record<string, string \| number \| boolean>` | — | Any extra query params to append to the URL. |
144
83
 
145
84
  ```ts
146
- import { initEpicPay, redirectToPortal, parsePaymentResponseFromUrl } from 'epic-pay-sdk';
85
+ import { redirectToPortal } from "epic-collection-gateway-sdk";
147
86
 
148
- initEpicPay({
149
- redirectUrl: 'https://pay.your-portal.com/checkout',
150
- clientId: 'your_public_client_id',
151
- });
152
-
153
- // When user clicks "Proceed to pay" on the integrator page:
154
- redirectToPortal({
87
+ const url = redirectToPortal({
155
88
  amount: 2300,
156
- currency: 'NGN',
157
- customerEmail: 'user@example.com', // optional
158
- sessionId: 'sess_123456789',
159
- returnUrl: 'https://merchant.example.com/order-success',
89
+ sessionId: "sess_123456789",
90
+ redirectUrl: "https://your-site.com/order-result",
91
+ customerDetails: { email: "user@example.com" },
160
92
  });
161
93
 
162
- // On your returnUrl page, parse the response:
163
- const res = parsePaymentResponseFromUrl();
164
- // res may contain: sessionId, paymentRef, status, and any other keys your portal includes
165
- console.log(res);
94
+ window.location.assign(url);
166
95
  ```
167
96
 
168
- ## License
97
+ ---
169
98
 
170
- MIT
99
+ ## TypeScript Types
171
100
 
172
- ---
101
+ All types are exported from the package root:
173
102
 
174
- ## Epic Collections Web Checkout integration (React example)
175
-
176
- This is a concrete example of how a React storefront (like `eCommerceFE`) integrates with this SDK for the Epic Collections Web Checkout flow.
177
-
178
- ### Example: Checkout button in a React header/cart component
179
-
180
- ```tsx
181
- import { startEpicCollectionPayment } from '@naderepic/epic-collection-payment-gateway-sdk';
182
-
183
- function CheckoutButton({ cartItems }) {
184
- const [paying, setPaying] = useState(false);
185
- const total = cartItems.reduce((sum, i) => sum + i.price * i.quantity, 0);
186
-
187
- const handleCheckout = async () => {
188
- if (cartItems.length === 0) return;
189
- try {
190
- setPaying(true);
191
- const sessionId = '2349283949994959000345340212778'; // generate per order in production
192
-
193
- const url = await startEpicCollectionPayment({
194
- clientId: '3cEePs32ipRTQkBRn0c33gAb7UOqcLPwMBMNhDgK',
195
- clientSecret: 'mye008uvYFzqWUQEjLGBbIuWd8eEJmhSRUPy1IlmsZlCa84apHxNrsDGvSLVVL5z',
196
- redirectUrl: 'https://your-site.com/order-result',
197
- amount: total,
198
- sessionId,
199
- customerDetails: {
200
- email: 'user@gmail.com',
201
- },
202
- });
203
-
204
- window.location.assign(url);
205
- } finally {
206
- setPaying(false);
207
- }
208
- };
209
-
210
- return (
211
- <button
212
- onClick={handleCheckout}
213
- disabled={cartItems.length === 0 || paying}
214
- >
215
- {paying ? 'Processing...' : `Proceed to Pay ( ₦${total.toFixed(2)})`}
216
- </button>
217
- );
218
- }
103
+ ```ts
104
+ import type {
105
+ EpicPayEnvironment,
106
+ StartEpicCollectionPaymentOptions,
107
+ EpicCollectioncustomerDetails,
108
+ RedirectToPortalParams,
109
+ EpicPayConfig,
110
+ PaymentEvent,
111
+ PaymentResult,
112
+ CustomerInfo,
113
+ } from "epic-collection-gateway-sdk";
219
114
  ```
220
115
 
221
- ### Options passed from frontend to the SDK
116
+ ---
222
117
 
223
- The options object passed to `startEpicCollectionPayment` has the following shape on the **frontend**:
118
+ ## Default Export
224
119
 
225
- ```json
226
- {
227
- "clientId": "<clientId>",
228
- "clientSecret": "<clientSecret>",
229
- "redirectUrl": "https://your-site.com/order-result",
230
- "amount": <amount>,
231
- "sessionId": "<sessionId>",
232
- "customerDetails": {
233
- "email": "user@example.com"
234
- }
235
- }
120
+ A convenience object is available as the default export:
121
+
122
+ ```ts
123
+ import EpicCollectionSdk from "epic-collection-gateway-sdk";
124
+
125
+ const { startEpicCollectionPayment, redirectToPortal } = EpicCollectionSdk;
236
126
  ```
237
127
 
238
- - `clientId`, `clientSecret` – provided by the Epic Collections Admin Portal.
239
- - `redirectUrl` – **merchant callback URL** where the shopper is sent back after payment/cancel.
240
- - `amount` – total amount for this checkout (computed from cart).
241
- - `sessionId` – unique per checkout session/order.
242
- - `customerDetails` – optional customer metadata forwarded as query params (`clientEmail`, `clientName`, `clientPhone`).
128
+ ---
243
129
 
244
- The SDK uses this **frontend** payload to:
245
- - Call the Epic backend `/web-checkout/auth` with `clientId`, `clientSecret`, `sessionId`, `amount`, `redirectUrl`, and any `customerDetails`.
246
- - Build and return the final redirect URL for the **Collections payment portal** (from `VITE_PORTAL_URL` / `VITE_EPIC_COLLECTION_PORTAL_URL` inside the SDK), which your frontend then navigates to with `window.location.assign(url)` (or your router of choice).
130
+ ## License
247
131
 
248
- > Note: For this Epic Collections Web Checkout flow you **do not need to call `initEpicPay`**. The payment portal URL is resolved inside the SDK from environment variables.
132
+ MIT
@@ -1,21 +1,6 @@
1
1
  export type EpicPayEnvironment = 'sandbox' | 'production';
2
- export interface EpicPayInitOptions {
3
- merchantId?: string;
4
- environment?: EpicPayEnvironment;
5
- onEvent?: (event: {
6
- type: string;
7
- payload?: any;
8
- timestamp: number;
9
- }) => void;
10
- apiBase?: string;
11
- headers?: Record<string, string>;
12
- paymentMethodsUrl?: string;
13
- theme?: Record<string, string>;
14
- redirectUrl?: string;
15
- clientId?: string;
16
- clientSecret?: string;
17
- }
18
2
  export interface RedirectToPortalParams {
3
+ environment?: EpicPayEnvironment;
19
4
  amount: number;
20
5
  sessionId: string;
21
6
  additionalParams?: Record<string, string | number | boolean>;
@@ -28,6 +13,7 @@ export interface EpicCollectioncustomerDetails {
28
13
  phone?: string;
29
14
  }
30
15
  export interface StartEpicCollectionPaymentOptions {
16
+ environment?: EpicPayEnvironment;
31
17
  clientId: string;
32
18
  clientSecret: string;
33
19
  /** Merchant callback URL where the shopper is sent back after payment/cancel */
@@ -38,5 +24,3 @@ export interface StartEpicCollectionPaymentOptions {
38
24
  }
39
25
  export declare function redirectToPortal(params: RedirectToPortalParams): string;
40
26
  export declare function startEpicCollectionPayment(options: StartEpicCollectionPaymentOptions): Promise<string>;
41
- export declare function parsePaymentResponseFromUrl(raw?: string): Record<string, string>;
42
- export declare function initEpicPay(options?: EpicPayInitOptions): void;
@@ -0,0 +1,5 @@
1
+ export declare const EPIC_PORTAL_URL = "https://checkout.epicpay.co";
2
+ export declare const EPIC_API_BASE = "https://zppicbcegi.execute-api.af-south-1.amazonaws.com/prod/api/v1";
3
+ export declare const EPIC_HEADERS: {
4
+ grabbersbeware: string;
5
+ };
@@ -2,4 +2,3 @@ import { EpicPayConfig } from './types';
2
2
 
3
3
  export declare const epicConfig: EpicPayConfig;
4
4
  export declare function setConfig(config: Partial<EpicPayConfig>): void;
5
- export declare function emit(type: string, payload?: any): void;
@@ -10,52 +10,4 @@ export interface EpicPayConfig {
10
10
  clientSecret?: string;
11
11
  /** If true, do not actually redirect; only log what would happen. */
12
12
  dryRun?: boolean;
13
- onEvent?: (event: PaymentEvent) => void;
14
- }
15
- export interface ThemeConfig {
16
- colorPrimaryViolet?: string;
17
- borderColor?: string;
18
- fontColor?: string;
19
- black?: string;
20
- white?: string;
21
- inputBackground?: string;
22
- tabBackground?: string;
23
- }
24
- export interface PaymentMethod {
25
- identityKey: string;
26
- methodName: string;
27
- icon?: string;
28
- }
29
- export interface PaymentSheetProps {
30
- amount: number;
31
- currency?: string;
32
- customer?: CustomerInfo;
33
- paymentMethods?: PaymentMethod[] | 'auto';
34
- onSuccess?: (result: PaymentResult) => void;
35
- onError?: (error: PaymentError) => void;
36
- onClose?: () => void;
37
- }
38
- export interface CustomerInfo {
39
- id?: string;
40
- email?: string;
41
- name?: string;
42
- phone?: string;
43
- }
44
- export interface PaymentResult {
45
- status: 'succeeded' | 'failed' | 'cancelled';
46
- method?: string;
47
- amount?: number;
48
- currency?: string;
49
- transactionId?: string;
50
- error?: string;
51
- }
52
- export interface PaymentError {
53
- status: 'failed';
54
- method?: string;
55
- error: string;
56
- }
57
- export interface PaymentEvent {
58
- type: string;
59
- payload: any;
60
- timestamp: number;
61
13
  }
package/dist/index.d.ts CHANGED
@@ -1,13 +1,11 @@
1
- import { initEpicPay, redirectToPortal, parsePaymentResponseFromUrl, startEpicCollectionPayment } from './core/api';
1
+ import { redirectToPortal, startEpicCollectionPayment } from './core/api';
2
2
  export { setConfig, epicConfig } from './core/epicConfig';
3
3
  export * from './core/types';
4
- export { initEpicPay, redirectToPortal, parsePaymentResponseFromUrl, startEpicCollectionPayment } from './core/api';
5
- export type { EpicPayInitOptions, EpicPayEnvironment } from './core/api';
4
+ export { redirectToPortal, startEpicCollectionPayment } from './core/api';
5
+ export type { EpicPayEnvironment } from './core/api';
6
6
  export type { RedirectToPortalParams, StartEpicCollectionPaymentOptions, EpicCollectioncustomerDetails } from './core/api';
7
7
  declare const EpicCollectionSdk: {
8
- initEpicPay: typeof initEpicPay;
9
8
  redirectToPortal: typeof redirectToPortal;
10
- parsePaymentResponseFromUrl: typeof parsePaymentResponseFromUrl;
11
9
  startEpicCollectionPayment: typeof startEpicCollectionPayment;
12
10
  };
13
11
  export default EpicCollectionSdk;
package/dist/index.js CHANGED
@@ -1,114 +1,90 @@
1
- const f = { BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 }, m = f.VITE_PORTAL_URL || "https://checkout.epicpay.co", E = f.VITE_PORTAL_URL || "https://zppicbcegi.execute-api.af-south-1.amazonaws.com/prod/api/v1", y = f.VITE_EPIC_ENVIRONMENT || "", s = {
2
- environment: y,
3
- apiBase: E,
1
+ const u = "https://checkout.epicpay.co", g = "https://zppicbcegi.execute-api.af-south-1.amazonaws.com/prod/api/v1", m = {
2
+ grabbersbeware: "getthehellout989898"
3
+ }, c = {
4
+ environment: "",
5
+ apiBase: g,
4
6
  headers: {},
5
- redirectUrl: m,
7
+ redirectUrl: u,
6
8
  clientId: "",
7
9
  clientSecret: "",
8
- dryRun: !0,
9
- onEvent: void 0
10
+ dryRun: !0
10
11
  };
11
- function p(e) {
12
- Object.assign(s, e);
12
+ function w(l) {
13
+ Object.assign(c, l);
13
14
  }
14
- function u(e) {
15
- const { amount: n, sessionId: i, additionalParams: c, redirectUrl: o } = e, r = s.redirectUrl || s.apiBase;
16
- if (!r)
15
+ function p(l) {
16
+ const { environment: a, amount: r, sessionId: n, additionalParams: i, redirectUrl: d } = l, t = c.redirectUrl || c.apiBase;
17
+ if (!t)
17
18
  throw new Error('No redirectUrl configured. Call initEpicPay({ redirectUrl: "https://..." }).');
18
- const t = {
19
- amount: String(n),
20
- sessionId: i
19
+ const e = {
20
+ amount: String(r),
21
+ sessionId: n
21
22
  };
22
- o && (t.redirectUrl = String(o)), s.clientId && (t.clientId = s.clientId), s.clientSecret && (t.clientSecret = s.clientSecret), c && Object.keys(c).forEach((a) => {
23
- t[a] = String(c[a]);
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]);
24
25
  });
25
- const l = Object.keys(t).map((a) => `${encodeURIComponent(a)}=${encodeURIComponent(t[a])}`).join("&"), h = r + (r.includes("?") ? "&" : "?") + l;
26
+ const s = Object.keys(e).map((o) => `${encodeURIComponent(o)}=${encodeURIComponent(e[o])}`).join("&"), f = t + (t.includes("?") ? "&" : "?") + s;
26
27
  try {
27
- console.log("[EpicPay] redirectToPortal", { portal: r, amount: n, sessionId: i });
28
+ console.log("[EpicPay] redirectToPortal", { portal: t, amount: r, sessionId: n });
28
29
  } catch {
29
30
  }
30
31
  try {
31
- console.log("[EpicPay] redirectToPortal URL:", h);
32
+ console.log("[EpicPay] redirectToPortal URL:", f);
32
33
  } catch {
33
34
  }
34
- return h;
35
+ return f;
35
36
  }
36
- async function g(e) {
37
- const { clientId: n, clientSecret: i, redirectUrl: c, amount: o, sessionId: r, customerDetails: t } = e;
38
- if (!n || typeof n != "string" || n.length < 16)
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")
40
+ throw new Error("Invalid environment");
41
+ if (!r || typeof r != "string" || r.length < 16)
39
42
  throw new Error("Invalid clientId");
40
- if (!i || typeof i != "string" || i.length < 16)
43
+ if (!n || typeof n != "string" || n.length < 16)
41
44
  throw new Error("Invalid clientSecret");
42
- if (!r || typeof r != "string" || r.length < 16)
45
+ if (!t || typeof t != "string" || t.length < 16)
43
46
  throw new Error("Invalid sessionId");
44
- if (!c || typeof c != "string")
47
+ if (!i || typeof i != "string")
45
48
  throw new Error("Invalid redirectUrl");
46
- p({
47
- clientId: n,
48
- clientSecret: i
49
+ w({
50
+ environment: a,
51
+ clientId: r,
52
+ clientSecret: n
49
53
  });
50
- const l = s.apiBase;
51
- if (!l)
54
+ const s = c.apiBase;
55
+ if (!s)
52
56
  throw new Error("No API base configured for authentication");
53
- const h = (l.endsWith("/") ? l.slice(0, -1) : l) + "/web-checkout/auth", a = await fetch(h, {
57
+ const f = (s.endsWith("/") ? s.slice(0, -1) : s) + "/web-checkout/auth", o = await fetch(f, {
54
58
  method: "POST",
55
- headers: { "Content-Type": "application/json", grabbersbeware: "getthehellout989898" },
59
+ headers: { "Content-Type": "application/json", ...m },
56
60
  body: JSON.stringify({
57
- clientId: n,
58
- clientSecret: i,
59
- sessionId: r,
60
- amount: o,
61
- redirectUrl: c,
62
- customerDetails: t
61
+ clientId: r,
62
+ clientSecret: n,
63
+ sessionId: t,
64
+ amount: d,
65
+ redirectUrl: i,
66
+ customerDetails: e
63
67
  })
64
68
  });
65
- if (!a.ok)
69
+ if (!o.ok)
66
70
  throw new Error("Authentication request failed");
67
71
  try {
68
- await a.json();
69
- } catch {
70
- }
71
- const d = {};
72
- return d.clientSecret = i, t && (t.name && (d.clientName = String(t.name)), t.email && (d.clientEmail = String(t.email)), t.phone && (d.clientPhone = String(t.phone))), u({
73
- amount: o,
74
- sessionId: r,
75
- additionalParams: d,
76
- redirectUrl: c
77
- });
78
- }
79
- function w(e) {
80
- const n = e ?? (typeof window < "u" ? window.location.search || window.location.hash : ""), i = n.startsWith("?") || n.startsWith("#") ? n.substring(1) : n, c = new URLSearchParams(i), o = {};
81
- c.forEach((r, t) => {
82
- o[t] = r;
83
- });
84
- try {
85
- console.log("[EpicPay] parsePaymentResponseFromUrl", o);
72
+ await o.json();
86
73
  } catch {
87
74
  }
88
- return o;
89
- }
90
- function I(e = {}) {
91
- p({
92
- environment: e.environment ?? "sandbox",
93
- apiBase: e.apiBase,
94
- headers: e.headers,
95
- onEvent: e.onEvent,
96
- redirectUrl: e.redirectUrl,
97
- clientId: e.clientId,
98
- clientSecret: e.clientSecret
75
+ const h = {};
76
+ 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({
77
+ amount: d,
78
+ sessionId: t,
79
+ additionalParams: h,
80
+ redirectUrl: i
99
81
  });
100
- try {
101
- console.log("[EpicPay] initEpicPay", { environment: e.environment ?? "sandbox", redirectUrl: e.redirectUrl, clientId: e.clientId, clientSecret: e.clientSecret });
102
- } catch {
103
- }
104
82
  }
105
- const S = { initEpicPay: I, redirectToPortal: u, parsePaymentResponseFromUrl: w, startEpicCollectionPayment: g };
83
+ const I = { redirectToPortal: p, startEpicCollectionPayment: E };
106
84
  export {
107
- S as default,
108
- s as epicConfig,
109
- I as initEpicPay,
110
- w as parsePaymentResponseFromUrl,
111
- u as redirectToPortal,
112
- p as setConfig,
113
- g as startEpicCollectionPayment
85
+ I as default,
86
+ c as epicConfig,
87
+ p as redirectToPortal,
88
+ w as setConfig,
89
+ E as startEpicCollectionPayment
114
90
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "epic-collection-gateway-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",