@commercengine/storefront-sdk 0.14.4 → 0.15.0
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.mts +7372 -3933
- package/dist/index.iife.js +403 -20
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +393 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -7
package/dist/index.iife.js
CHANGED
|
@@ -156,54 +156,63 @@ var CE_SDK = (function(exports) {
|
|
|
156
156
|
method: method.toUpperCase()
|
|
157
157
|
});
|
|
158
158
|
},
|
|
159
|
+
/** Call a GET endpoint */
|
|
159
160
|
GET(url, init) {
|
|
160
161
|
return coreFetch(url, {
|
|
161
162
|
...init,
|
|
162
163
|
method: "GET"
|
|
163
164
|
});
|
|
164
165
|
},
|
|
166
|
+
/** Call a PUT endpoint */
|
|
165
167
|
PUT(url, init) {
|
|
166
168
|
return coreFetch(url, {
|
|
167
169
|
...init,
|
|
168
170
|
method: "PUT"
|
|
169
171
|
});
|
|
170
172
|
},
|
|
173
|
+
/** Call a POST endpoint */
|
|
171
174
|
POST(url, init) {
|
|
172
175
|
return coreFetch(url, {
|
|
173
176
|
...init,
|
|
174
177
|
method: "POST"
|
|
175
178
|
});
|
|
176
179
|
},
|
|
180
|
+
/** Call a DELETE endpoint */
|
|
177
181
|
DELETE(url, init) {
|
|
178
182
|
return coreFetch(url, {
|
|
179
183
|
...init,
|
|
180
184
|
method: "DELETE"
|
|
181
185
|
});
|
|
182
186
|
},
|
|
187
|
+
/** Call a OPTIONS endpoint */
|
|
183
188
|
OPTIONS(url, init) {
|
|
184
189
|
return coreFetch(url, {
|
|
185
190
|
...init,
|
|
186
191
|
method: "OPTIONS"
|
|
187
192
|
});
|
|
188
193
|
},
|
|
194
|
+
/** Call a HEAD endpoint */
|
|
189
195
|
HEAD(url, init) {
|
|
190
196
|
return coreFetch(url, {
|
|
191
197
|
...init,
|
|
192
198
|
method: "HEAD"
|
|
193
199
|
});
|
|
194
200
|
},
|
|
201
|
+
/** Call a PATCH endpoint */
|
|
195
202
|
PATCH(url, init) {
|
|
196
203
|
return coreFetch(url, {
|
|
197
204
|
...init,
|
|
198
205
|
method: "PATCH"
|
|
199
206
|
});
|
|
200
207
|
},
|
|
208
|
+
/** Call a TRACE endpoint */
|
|
201
209
|
TRACE(url, init) {
|
|
202
210
|
return coreFetch(url, {
|
|
203
211
|
...init,
|
|
204
212
|
method: "TRACE"
|
|
205
213
|
});
|
|
206
214
|
},
|
|
215
|
+
/** Register middleware */
|
|
207
216
|
use(...middleware) {
|
|
208
217
|
for (const m of middleware) {
|
|
209
218
|
if (!m) continue;
|
|
@@ -211,6 +220,7 @@ var CE_SDK = (function(exports) {
|
|
|
211
220
|
globalMiddlewares.push(m);
|
|
212
221
|
}
|
|
213
222
|
},
|
|
223
|
+
/** Unregister middleware */
|
|
214
224
|
eject(...middleware) {
|
|
215
225
|
for (const m of middleware) {
|
|
216
226
|
const i = globalMiddlewares.indexOf(m);
|
|
@@ -828,9 +838,8 @@ var CE_SDK = (function(exports) {
|
|
|
828
838
|
*/
|
|
829
839
|
function buildStorefrontURL(config) {
|
|
830
840
|
if (config.baseUrl) return config.baseUrl;
|
|
831
|
-
switch (config.environment ||
|
|
832
|
-
case
|
|
833
|
-
case Environment.Production:
|
|
841
|
+
switch (config.environment || "production") {
|
|
842
|
+
case "staging": return `https://staging.api.commercengine.io/api/v1/${config.storeId}/storefront`;
|
|
834
843
|
default: return `https://prod.api.commercengine.io/api/v1/${config.storeId}/storefront`;
|
|
835
844
|
}
|
|
836
845
|
}
|
|
@@ -990,6 +999,17 @@ var CE_SDK = (function(exports) {
|
|
|
990
999
|
};
|
|
991
1000
|
}
|
|
992
1001
|
/**
|
|
1002
|
+
* Resolve the current customer ID from explicit parameters or the active session.
|
|
1003
|
+
*
|
|
1004
|
+
* @param explicitCustomerId - Optional customer ID supplied by the caller
|
|
1005
|
+
* @returns The resolved customer ID
|
|
1006
|
+
* @throws When the user is anonymous or no session can be established
|
|
1007
|
+
*/
|
|
1008
|
+
async resolveCurrentCustomerId(explicitCustomerId) {
|
|
1009
|
+
if (explicitCustomerId) return explicitCustomerId;
|
|
1010
|
+
return this.config.sessionManager.ensureCustomerId();
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
993
1013
|
* Resolve path parameters that require `customer_id`.
|
|
994
1014
|
*
|
|
995
1015
|
* @param pathParams - Path parameters with an optional `customer_id`
|
|
@@ -999,7 +1019,7 @@ var CE_SDK = (function(exports) {
|
|
|
999
1019
|
async resolveCustomerPathParams(pathParams) {
|
|
1000
1020
|
return {
|
|
1001
1021
|
...pathParams,
|
|
1002
|
-
customer_id:
|
|
1022
|
+
customer_id: await this.resolveCurrentCustomerId(pathParams.customer_id)
|
|
1003
1023
|
};
|
|
1004
1024
|
}
|
|
1005
1025
|
};
|
|
@@ -1611,6 +1631,35 @@ var CE_SDK = (function(exports) {
|
|
|
1611
1631
|
}
|
|
1612
1632
|
};
|
|
1613
1633
|
//#endregion
|
|
1634
|
+
//#region src/lib/shared/form-data-utils.ts
|
|
1635
|
+
/**
|
|
1636
|
+
* Multipart form-data helpers for the Storefront SDK
|
|
1637
|
+
*/
|
|
1638
|
+
/**
|
|
1639
|
+
* Serialize a request body object into a `FormData` instance.
|
|
1640
|
+
*
|
|
1641
|
+
* Binary fields are generated as `string` (OpenAPI `format: binary`), so callers pass
|
|
1642
|
+
* `File`/`Blob` values. Array fields are appended once per entry under the same key,
|
|
1643
|
+
* which is what the API expects for repeated uploads such as `images` and `videos`.
|
|
1644
|
+
* Everything else is coerced with `String()`.
|
|
1645
|
+
*
|
|
1646
|
+
* @param body - Request body object to serialize
|
|
1647
|
+
* @returns A `FormData` instance ready to be sent as `multipart/form-data`
|
|
1648
|
+
*/
|
|
1649
|
+
function toFormData(body) {
|
|
1650
|
+
const formData = new FormData();
|
|
1651
|
+
if (body === void 0 || body === null) return formData;
|
|
1652
|
+
for (const [key, value] of Object.entries(body)) {
|
|
1653
|
+
if (value === void 0 || value === null) continue;
|
|
1654
|
+
const entries = Array.isArray(value) ? value : [value];
|
|
1655
|
+
for (const entry of entries) {
|
|
1656
|
+
if (entry === void 0 || entry === null) continue;
|
|
1657
|
+
formData.append(key, entry instanceof Blob ? entry : String(entry));
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
return formData;
|
|
1661
|
+
}
|
|
1662
|
+
//#endregion
|
|
1614
1663
|
//#region src/lib/catalog.ts
|
|
1615
1664
|
/**
|
|
1616
1665
|
* Client for interacting with catalog endpoints
|
|
@@ -1655,12 +1704,7 @@ var CE_SDK = (function(exports) {
|
|
|
1655
1704
|
return this.executeRequest(() => this.client.POST("/catalog/products/{product_id}/reviews", {
|
|
1656
1705
|
params: { path: pathParams },
|
|
1657
1706
|
body: formData,
|
|
1658
|
-
bodySerializer: (body) =>
|
|
1659
|
-
const fd = new FormData();
|
|
1660
|
-
for (const [key, value] of Object.entries(body)) if (value !== void 0 && value !== null) if (value instanceof File || value instanceof Blob) fd.append(key, value);
|
|
1661
|
-
else fd.append(key, String(value));
|
|
1662
|
-
return fd;
|
|
1663
|
-
}
|
|
1707
|
+
bodySerializer: (body) => toFormData(body)
|
|
1664
1708
|
}));
|
|
1665
1709
|
}
|
|
1666
1710
|
};
|
|
@@ -2842,11 +2886,7 @@ var CE_SDK = (function(exports) {
|
|
|
2842
2886
|
return this.executeRequest(() => this.client.POST("/auth/user/{id}/profile-image", {
|
|
2843
2887
|
params: { path: pathParams },
|
|
2844
2888
|
body: formData,
|
|
2845
|
-
bodySerializer: (body) =>
|
|
2846
|
-
const fd = new FormData();
|
|
2847
|
-
for (const [key, value] of Object.entries(body)) if (value !== void 0 && value !== null) fd.append(key, value);
|
|
2848
|
-
return fd;
|
|
2849
|
-
}
|
|
2889
|
+
bodySerializer: (body) => toFormData(body)
|
|
2850
2890
|
}));
|
|
2851
2891
|
}
|
|
2852
2892
|
/**
|
|
@@ -2876,11 +2916,7 @@ var CE_SDK = (function(exports) {
|
|
|
2876
2916
|
return this.executeRequest(() => this.client.PUT("/auth/user/{id}/profile-image", {
|
|
2877
2917
|
params: { path: pathParams },
|
|
2878
2918
|
body: formData,
|
|
2879
|
-
bodySerializer: (body) =>
|
|
2880
|
-
const fd = new FormData();
|
|
2881
|
-
for (const [key, value] of Object.entries(body)) if (value !== void 0 && value !== null) fd.append(key, value);
|
|
2882
|
-
return fd;
|
|
2883
|
-
}
|
|
2919
|
+
bodySerializer: (body) => toFormData(body)
|
|
2884
2920
|
}));
|
|
2885
2921
|
}
|
|
2886
2922
|
/**
|
|
@@ -3146,6 +3182,44 @@ var CE_SDK = (function(exports) {
|
|
|
3146
3182
|
return this.executeRequest(() => this.client.GET("/orders", { params: { query: resolvedQueryParams } }));
|
|
3147
3183
|
}
|
|
3148
3184
|
/**
|
|
3185
|
+
* List previously purchased items for the authenticated user
|
|
3186
|
+
*
|
|
3187
|
+
* @description Lists items previously purchased across paid orders (orders with a `payment_status`
|
|
3188
|
+
* of `pending` or `failed` are excluded). Results are deduplicated by `product_id`, returning the
|
|
3189
|
+
* most recent purchase for each product. Use this to power a "Buy it again" carousel.
|
|
3190
|
+
*
|
|
3191
|
+
* @param queryParams - Optional query parameters for pagination and seller filtering
|
|
3192
|
+
* @returns Promise with previously purchased items
|
|
3193
|
+
* @example
|
|
3194
|
+
* ```typescript
|
|
3195
|
+
* // Basic usage
|
|
3196
|
+
* const { data, error } = await sdk.order.listBuyItAgainItems();
|
|
3197
|
+
*
|
|
3198
|
+
* // With pagination and marketplace seller filtering
|
|
3199
|
+
* const { data, error } = await sdk.order.listBuyItAgainItems({
|
|
3200
|
+
* page: 1,
|
|
3201
|
+
* limit: 20,
|
|
3202
|
+
* seller_id: "seller_a,seller_b"
|
|
3203
|
+
* });
|
|
3204
|
+
*
|
|
3205
|
+
* if (error) {
|
|
3206
|
+
* console.error("Failed to list buy-it-again items:", error.message);
|
|
3207
|
+
* } else {
|
|
3208
|
+
* console.log("Items found:", data.items.length);
|
|
3209
|
+
* console.log("Pagination:", data.pagination);
|
|
3210
|
+
*
|
|
3211
|
+
* data.items.forEach(item => {
|
|
3212
|
+
* console.log(`${item.product_name} (${item.product_id})`);
|
|
3213
|
+
* console.log("Variant:", item.variant_name);
|
|
3214
|
+
* console.log("Selling price:", item.selling_price);
|
|
3215
|
+
* });
|
|
3216
|
+
* }
|
|
3217
|
+
* ```
|
|
3218
|
+
*/
|
|
3219
|
+
async listBuyItAgainItems(queryParams) {
|
|
3220
|
+
return this.executeRequest(() => this.client.GET("/orders/buy-it-again", { params: { query: queryParams } }));
|
|
3221
|
+
}
|
|
3222
|
+
/**
|
|
3149
3223
|
* Get payment status for an order
|
|
3150
3224
|
*
|
|
3151
3225
|
* @param orderNumber - Order number
|
|
@@ -3367,6 +3441,184 @@ var CE_SDK = (function(exports) {
|
|
|
3367
3441
|
body
|
|
3368
3442
|
}));
|
|
3369
3443
|
}
|
|
3444
|
+
/**
|
|
3445
|
+
* List all return requests for an order
|
|
3446
|
+
*
|
|
3447
|
+
* @param pathParams - Order number path parameters
|
|
3448
|
+
* @returns Promise with return requests
|
|
3449
|
+
* @example
|
|
3450
|
+
* ```typescript
|
|
3451
|
+
* const { data, error } = await sdk.order.listOrderReturns({
|
|
3452
|
+
* order_number: "ORD-2024-001"
|
|
3453
|
+
* });
|
|
3454
|
+
*
|
|
3455
|
+
* if (error) {
|
|
3456
|
+
* console.error("Failed to list order returns:", error.message);
|
|
3457
|
+
* } else {
|
|
3458
|
+
* console.log("Returns found:", data.returns?.length || 0);
|
|
3459
|
+
*
|
|
3460
|
+
* data.returns?.forEach(orderReturn => {
|
|
3461
|
+
* console.log(`Return ${orderReturn.request_number}: ${orderReturn.status}`);
|
|
3462
|
+
* console.log("Created at:", orderReturn.created_at);
|
|
3463
|
+
* console.log("Items:", orderReturn.items?.length || 0);
|
|
3464
|
+
* });
|
|
3465
|
+
* }
|
|
3466
|
+
* ```
|
|
3467
|
+
*/
|
|
3468
|
+
async listOrderReturns(pathParams) {
|
|
3469
|
+
return this.executeRequest(() => this.client.GET("/orders/{order_number}/returns", { params: { path: pathParams } }));
|
|
3470
|
+
}
|
|
3471
|
+
/**
|
|
3472
|
+
* Create a return request for delivered items in an order
|
|
3473
|
+
*
|
|
3474
|
+
* @description Specify how the return should be settled via `requested_settlement` and list the
|
|
3475
|
+
* delivered line items to return. Each item is keyed by its shipment (`shipment_number`) and
|
|
3476
|
+
* product. Only shipments with `is_return_allowed` set to `true` can be returned.
|
|
3477
|
+
*
|
|
3478
|
+
* @param pathParams - Order number path parameters
|
|
3479
|
+
* @param body - Return request body
|
|
3480
|
+
* @returns Promise with the created return request
|
|
3481
|
+
* @example
|
|
3482
|
+
* ```typescript
|
|
3483
|
+
* const { data, error } = await sdk.order.createOrderReturn(
|
|
3484
|
+
* { order_number: "ORD-2024-001" },
|
|
3485
|
+
* {
|
|
3486
|
+
* requested_settlement: "refund",
|
|
3487
|
+
* items: [
|
|
3488
|
+
* {
|
|
3489
|
+
* shipment_number: "SHIP-2024-001",
|
|
3490
|
+
* product_id: "prod_01H9XYZ12345",
|
|
3491
|
+
* variant_id: "var_01H9XYZ12345",
|
|
3492
|
+
* quantity: 1,
|
|
3493
|
+
* return_reason: "Product arrived damaged"
|
|
3494
|
+
* }
|
|
3495
|
+
* ]
|
|
3496
|
+
* }
|
|
3497
|
+
* );
|
|
3498
|
+
*
|
|
3499
|
+
* // Request a replacement instead of a refund
|
|
3500
|
+
* const { data: replacement } = await sdk.order.createOrderReturn(
|
|
3501
|
+
* { order_number: "ORD-2024-001" },
|
|
3502
|
+
* {
|
|
3503
|
+
* requested_settlement: "replacement",
|
|
3504
|
+
* items: [
|
|
3505
|
+
* {
|
|
3506
|
+
* shipment_number: "SHIP-2024-001",
|
|
3507
|
+
* product_id: "prod_01H9XYZ12345",
|
|
3508
|
+
* variant_id: null,
|
|
3509
|
+
* quantity: 2,
|
|
3510
|
+
* return_reason: "Wrong size delivered"
|
|
3511
|
+
* }
|
|
3512
|
+
* ]
|
|
3513
|
+
* }
|
|
3514
|
+
* );
|
|
3515
|
+
*
|
|
3516
|
+
* if (error) {
|
|
3517
|
+
* console.error("Failed to create return:", error.message);
|
|
3518
|
+
* } else {
|
|
3519
|
+
* console.log("Return created:", data.order_return?.request_number);
|
|
3520
|
+
* console.log("Return status:", data.order_return?.status);
|
|
3521
|
+
* }
|
|
3522
|
+
* ```
|
|
3523
|
+
*/
|
|
3524
|
+
async createOrderReturn(pathParams, body) {
|
|
3525
|
+
return this.executeRequest(() => this.client.POST("/orders/{order_number}/returns", {
|
|
3526
|
+
params: { path: pathParams },
|
|
3527
|
+
body
|
|
3528
|
+
}));
|
|
3529
|
+
}
|
|
3530
|
+
/**
|
|
3531
|
+
* Get the full detail of a return request
|
|
3532
|
+
*
|
|
3533
|
+
* @description Returns the return request along with its linked return order, replacement order,
|
|
3534
|
+
* refunds, and signed URLs for any uploaded attachments.
|
|
3535
|
+
*
|
|
3536
|
+
* @param pathParams - Order number and return number path parameters
|
|
3537
|
+
* @returns Promise with return request details
|
|
3538
|
+
* @example
|
|
3539
|
+
* ```typescript
|
|
3540
|
+
* const { data, error } = await sdk.order.getOrderReturnDetails({
|
|
3541
|
+
* order_number: "ORD-2024-001",
|
|
3542
|
+
* return_number: "RET-2024-001"
|
|
3543
|
+
* });
|
|
3544
|
+
*
|
|
3545
|
+
* if (error) {
|
|
3546
|
+
* console.error("Failed to get return details:", error.message);
|
|
3547
|
+
* } else {
|
|
3548
|
+
* const orderReturn = data.order_return;
|
|
3549
|
+
* console.log("Return status:", orderReturn?.status);
|
|
3550
|
+
* console.log("Return order:", orderReturn?.return_order?.order_number);
|
|
3551
|
+
* console.log("Replacement order:", orderReturn?.replacement_order?.order_number);
|
|
3552
|
+
* console.log("Refunds:", orderReturn?.refund?.length || 0);
|
|
3553
|
+
* console.log("Attachment images:", orderReturn?.attachments?.images);
|
|
3554
|
+
* }
|
|
3555
|
+
* ```
|
|
3556
|
+
*/
|
|
3557
|
+
async getOrderReturnDetails(pathParams) {
|
|
3558
|
+
return this.executeRequest(() => this.client.GET("/orders/{order_number}/returns/{return_number}", { params: { path: pathParams } }));
|
|
3559
|
+
}
|
|
3560
|
+
/**
|
|
3561
|
+
* Upload supporting attachments for a return request
|
|
3562
|
+
*
|
|
3563
|
+
* @description Uploads images and videos that evidence the condition of the returned items.
|
|
3564
|
+
*
|
|
3565
|
+
* @param pathParams - Order number and return number path parameters
|
|
3566
|
+
* @param formData - Form data containing image and video files
|
|
3567
|
+
* @returns Promise with upload confirmation
|
|
3568
|
+
* @example
|
|
3569
|
+
* ```typescript
|
|
3570
|
+
* const imageFiles = Array.from(document.getElementById('image-input').files);
|
|
3571
|
+
*
|
|
3572
|
+
* const { data, error } = await sdk.order.uploadOrderReturnAttachments(
|
|
3573
|
+
* { order_number: "ORD-2024-001", return_number: "RET-2024-001" },
|
|
3574
|
+
* {
|
|
3575
|
+
* images: imageFiles,
|
|
3576
|
+
* videos: [new File(["video data"], "damage.mp4", { type: "video/mp4" })]
|
|
3577
|
+
* }
|
|
3578
|
+
* );
|
|
3579
|
+
*
|
|
3580
|
+
* if (error) {
|
|
3581
|
+
* console.error("Failed to upload attachments:", error.message);
|
|
3582
|
+
* } else {
|
|
3583
|
+
* console.log("Attachments uploaded:", data.success);
|
|
3584
|
+
* console.log("Message:", data.message);
|
|
3585
|
+
* }
|
|
3586
|
+
* ```
|
|
3587
|
+
*/
|
|
3588
|
+
async uploadOrderReturnAttachments(pathParams, formData) {
|
|
3589
|
+
return this.executeRequest(() => this.client.POST("/orders/{order_number}/returns/{return_number}/attachments", {
|
|
3590
|
+
params: { path: pathParams },
|
|
3591
|
+
body: formData,
|
|
3592
|
+
bodySerializer: (body) => toFormData(body)
|
|
3593
|
+
}));
|
|
3594
|
+
}
|
|
3595
|
+
/**
|
|
3596
|
+
* Cancel a return request
|
|
3597
|
+
*
|
|
3598
|
+
* @param pathParams - Order number and return number path parameters
|
|
3599
|
+
* @param body - Cancellation request body
|
|
3600
|
+
* @returns Promise with the updated return request
|
|
3601
|
+
* @example
|
|
3602
|
+
* ```typescript
|
|
3603
|
+
* const { data, error } = await sdk.order.cancelOrderReturn(
|
|
3604
|
+
* { order_number: "ORD-2024-001", return_number: "RET-2024-001" },
|
|
3605
|
+
* { reason: "Decided to keep the product" }
|
|
3606
|
+
* );
|
|
3607
|
+
*
|
|
3608
|
+
* if (error) {
|
|
3609
|
+
* console.error("Failed to cancel return:", error.message);
|
|
3610
|
+
* } else {
|
|
3611
|
+
* console.log("Return cancelled");
|
|
3612
|
+
* console.log("Updated status:", data.order_return?.status);
|
|
3613
|
+
* }
|
|
3614
|
+
* ```
|
|
3615
|
+
*/
|
|
3616
|
+
async cancelOrderReturn(pathParams, body) {
|
|
3617
|
+
return this.executeRequest(() => this.client.POST("/orders/{order_number}/returns/{return_number}/cancel", {
|
|
3618
|
+
params: { path: pathParams },
|
|
3619
|
+
body
|
|
3620
|
+
}));
|
|
3621
|
+
}
|
|
3370
3622
|
};
|
|
3371
3623
|
//#endregion
|
|
3372
3624
|
//#region src/lib/payments.ts
|
|
@@ -3513,6 +3765,33 @@ var CE_SDK = (function(exports) {
|
|
|
3513
3765
|
async resendDirectOtp(body) {
|
|
3514
3766
|
return this.executeRequest(() => this.client.POST("/payments/resend-direct-otp", { body }));
|
|
3515
3767
|
}
|
|
3768
|
+
/**
|
|
3769
|
+
* Verify an IFSC code and resolve its bank branch details
|
|
3770
|
+
*
|
|
3771
|
+
* @description Resolves an 11-character Indian Financial System Code (IFSC) to bank,
|
|
3772
|
+
* branch, and supported payment rail details. Useful for validating user-entered IFSC
|
|
3773
|
+
* codes before creating bank accounts or mandates.
|
|
3774
|
+
*
|
|
3775
|
+
* @param pathParams - Path parameters containing the IFSC code
|
|
3776
|
+
* @returns Promise with IFSC details
|
|
3777
|
+
* @example
|
|
3778
|
+
* ```typescript
|
|
3779
|
+
* const { data, error } = await sdk.payments.verifyIfscCode({
|
|
3780
|
+
* ifsc_code: "HDFC0001234"
|
|
3781
|
+
* });
|
|
3782
|
+
*
|
|
3783
|
+
* if (error) {
|
|
3784
|
+
* console.error("Failed to verify IFSC:", error.message);
|
|
3785
|
+
* } else {
|
|
3786
|
+
* console.log("Bank:", data.ifsc.bank);
|
|
3787
|
+
* console.log("Branch:", data.ifsc.branch);
|
|
3788
|
+
* console.log("Supports UPI:", data.ifsc.upi);
|
|
3789
|
+
* }
|
|
3790
|
+
* ```
|
|
3791
|
+
*/
|
|
3792
|
+
async verifyIfscCode(pathParams) {
|
|
3793
|
+
return this.executeRequest(() => this.client.GET("/payments/ifsc-lookup/{ifsc_code}", { params: { path: pathParams } }));
|
|
3794
|
+
}
|
|
3516
3795
|
};
|
|
3517
3796
|
//#endregion
|
|
3518
3797
|
//#region src/lib/shared/helper.ts
|
|
@@ -3718,6 +3997,110 @@ var CE_SDK = (function(exports) {
|
|
|
3718
3997
|
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
3719
3998
|
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/cards", { params: { path: resolvedPathParams } }));
|
|
3720
3999
|
}
|
|
4000
|
+
async listBankAccounts(pathParamsOrQuery, queryParams) {
|
|
4001
|
+
const hasPathParams = queryParams !== void 0 || !!pathParamsOrQuery && typeof pathParamsOrQuery === "object" && "customer_id" in pathParamsOrQuery;
|
|
4002
|
+
const pathParams = hasPathParams ? pathParamsOrQuery : {};
|
|
4003
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
4004
|
+
const resolvedQueryParams = hasPathParams ? queryParams : pathParamsOrQuery;
|
|
4005
|
+
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/bank-accounts", { params: {
|
|
4006
|
+
path: resolvedPathParams,
|
|
4007
|
+
query: resolvedQueryParams
|
|
4008
|
+
} }));
|
|
4009
|
+
}
|
|
4010
|
+
async createBankAccount(pathParamsOrBody, maybeBody) {
|
|
4011
|
+
const pathParams = maybeBody ? pathParamsOrBody : {};
|
|
4012
|
+
const body = maybeBody ?? pathParamsOrBody;
|
|
4013
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
4014
|
+
return this.executeRequest(() => this.client.POST("/customers/{customer_id}/bank-accounts", {
|
|
4015
|
+
params: { path: resolvedPathParams },
|
|
4016
|
+
body
|
|
4017
|
+
}));
|
|
4018
|
+
}
|
|
4019
|
+
async getBankAccount(pathParams) {
|
|
4020
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
4021
|
+
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/bank-accounts/{account_id}", { params: { path: resolvedPathParams } }));
|
|
4022
|
+
}
|
|
4023
|
+
async updateBankAccount(pathParams, body) {
|
|
4024
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
4025
|
+
return this.executeRequest(() => this.client.PUT("/customers/{customer_id}/bank-accounts/{account_id}", {
|
|
4026
|
+
params: { path: resolvedPathParams },
|
|
4027
|
+
body
|
|
4028
|
+
}));
|
|
4029
|
+
}
|
|
4030
|
+
async deleteBankAccount(pathParams) {
|
|
4031
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
4032
|
+
return this.executeRequest(() => this.client.DELETE("/customers/{customer_id}/bank-accounts/{account_id}", { params: { path: resolvedPathParams } }));
|
|
4033
|
+
}
|
|
4034
|
+
async verifyBankAccount(pathParams, body) {
|
|
4035
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
4036
|
+
return this.executeRequest(() => this.client.POST("/customers/{customer_id}/bank-accounts/{account_id}/verify", {
|
|
4037
|
+
params: { path: resolvedPathParams },
|
|
4038
|
+
body
|
|
4039
|
+
}));
|
|
4040
|
+
}
|
|
4041
|
+
async getCreditLineBalance(pathParams = {}) {
|
|
4042
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
4043
|
+
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/credit-line-balance", { params: { path: resolvedPathParams } }));
|
|
4044
|
+
}
|
|
4045
|
+
async listMandates(pathParams = {}) {
|
|
4046
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
4047
|
+
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/mandates", { params: { path: resolvedPathParams } }));
|
|
4048
|
+
}
|
|
4049
|
+
async createMandate(pathParamsOrBody, maybeBody) {
|
|
4050
|
+
const pathParams = maybeBody ? pathParamsOrBody : {};
|
|
4051
|
+
const body = maybeBody ?? pathParamsOrBody;
|
|
4052
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
4053
|
+
return this.executeRequest(() => this.client.POST("/customers/{customer_id}/mandates", {
|
|
4054
|
+
params: { path: resolvedPathParams },
|
|
4055
|
+
body
|
|
4056
|
+
}));
|
|
4057
|
+
}
|
|
4058
|
+
async getMandate(pathParams, queryParams) {
|
|
4059
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
4060
|
+
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/mandates/{mandate_id}", { params: {
|
|
4061
|
+
path: resolvedPathParams,
|
|
4062
|
+
query: queryParams
|
|
4063
|
+
} }));
|
|
4064
|
+
}
|
|
4065
|
+
async updateMandate(pathParams, body) {
|
|
4066
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
4067
|
+
return this.executeRequest(() => this.client.PUT("/customers/{customer_id}/mandates/{mandate_id}", {
|
|
4068
|
+
params: { path: resolvedPathParams },
|
|
4069
|
+
body
|
|
4070
|
+
}));
|
|
4071
|
+
}
|
|
4072
|
+
async pauseMandate(pathParams) {
|
|
4073
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
4074
|
+
return this.executeRequest(() => this.client.POST("/customers/{customer_id}/mandates/{mandate_id}/pause", { params: { path: resolvedPathParams } }));
|
|
4075
|
+
}
|
|
4076
|
+
async resumeMandate(pathParams) {
|
|
4077
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
4078
|
+
return this.executeRequest(() => this.client.POST("/customers/{customer_id}/mandates/{mandate_id}/resume", { params: { path: resolvedPathParams } }));
|
|
4079
|
+
}
|
|
4080
|
+
async revokeMandate(pathParams) {
|
|
4081
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
4082
|
+
return this.executeRequest(() => this.client.POST("/customers/{customer_id}/mandates/{mandate_id}/revoke", { params: { path: resolvedPathParams } }));
|
|
4083
|
+
}
|
|
4084
|
+
async listMandateDebitSchedules(pathParamsOrQuery, queryParams) {
|
|
4085
|
+
const hasPathParams = queryParams !== void 0 || !!pathParamsOrQuery && typeof pathParamsOrQuery === "object" && "customer_id" in pathParamsOrQuery;
|
|
4086
|
+
const pathParams = hasPathParams ? pathParamsOrQuery : {};
|
|
4087
|
+
const resolvedPathParams = await this.resolveCustomerPathParams(pathParams);
|
|
4088
|
+
const resolvedQueryParams = hasPathParams ? queryParams : pathParamsOrQuery;
|
|
4089
|
+
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/mandate-debit-schedules", { params: {
|
|
4090
|
+
path: resolvedPathParams,
|
|
4091
|
+
query: resolvedQueryParams
|
|
4092
|
+
} }));
|
|
4093
|
+
}
|
|
4094
|
+
async listAuthorizedSellers(pathParamsOrQuery, queryParams) {
|
|
4095
|
+
const hasPathParams = queryParams !== void 0 || !!pathParamsOrQuery && typeof pathParamsOrQuery === "object" && "id" in pathParamsOrQuery;
|
|
4096
|
+
const pathParams = hasPathParams ? pathParamsOrQuery : {};
|
|
4097
|
+
const resolvedPathParams = { id: await this.resolveCurrentCustomerId(pathParams.id) };
|
|
4098
|
+
const resolvedQueryParams = hasPathParams ? queryParams : pathParamsOrQuery;
|
|
4099
|
+
return this.executeRequest(() => this.client.GET("/customers/{id}/authorized-sellers", { params: {
|
|
4100
|
+
path: resolvedPathParams,
|
|
4101
|
+
query: resolvedQueryParams
|
|
4102
|
+
} }));
|
|
4103
|
+
}
|
|
3721
4104
|
};
|
|
3722
4105
|
//#endregion
|
|
3723
4106
|
//#region src/lib/shared/store-config.ts
|