@commercengine/storefront-sdk 0.11.1 → 0.12.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 +785 -389
- package/dist/index.iife.js +288 -216
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +289 -216
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.iife.js
CHANGED
|
@@ -2291,6 +2291,130 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2291
2291
|
}));
|
|
2292
2292
|
}
|
|
2293
2293
|
/**
|
|
2294
|
+
* Get all available coupons
|
|
2295
|
+
*
|
|
2296
|
+
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
2297
|
+
* @returns Promise with all available coupons
|
|
2298
|
+
* @example
|
|
2299
|
+
* ```typescript
|
|
2300
|
+
* // Get all available coupons
|
|
2301
|
+
* const { data, error } = await sdk.cart.getAvailableCoupons();
|
|
2302
|
+
*
|
|
2303
|
+
* if (error) {
|
|
2304
|
+
* console.error("Failed to get available coupons:", error.message);
|
|
2305
|
+
* } else {
|
|
2306
|
+
* const coupons = data.coupons || [];
|
|
2307
|
+
* console.log("Available coupons:", coupons.length);
|
|
2308
|
+
* coupons.forEach(coupon => {
|
|
2309
|
+
* console.log("Coupon:", coupon.code, "Discount:", coupon.discount_amount);
|
|
2310
|
+
* });
|
|
2311
|
+
* }
|
|
2312
|
+
*
|
|
2313
|
+
* // Override customer group ID for this specific request
|
|
2314
|
+
* const { data: overrideData, error: overrideError } = await sdk.cart.getAvailableCoupons({
|
|
2315
|
+
* "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
|
|
2316
|
+
* });
|
|
2317
|
+
* ```
|
|
2318
|
+
*/
|
|
2319
|
+
async getAvailableCoupons(headers) {
|
|
2320
|
+
const mergedHeaders = this.mergeHeaders(headers);
|
|
2321
|
+
return this.executeRequest(() => this.client.GET("/carts/available-coupons", { params: { header: mergedHeaders } }));
|
|
2322
|
+
}
|
|
2323
|
+
/**
|
|
2324
|
+
* Get all available promotions
|
|
2325
|
+
*
|
|
2326
|
+
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
2327
|
+
* @returns Promise with all available promotions
|
|
2328
|
+
* @example
|
|
2329
|
+
* ```typescript
|
|
2330
|
+
* // Get all available promotions
|
|
2331
|
+
* const { data, error } = await sdk.cart.getAvailablePromotions();
|
|
2332
|
+
*
|
|
2333
|
+
* if (error) {
|
|
2334
|
+
* console.error("Failed to get available promotions:", error.message);
|
|
2335
|
+
* } else {
|
|
2336
|
+
* const promotions = data.promotions || [];
|
|
2337
|
+
* console.log("Available promotions:", promotions.length);
|
|
2338
|
+
* promotions.forEach(promotion => {
|
|
2339
|
+
* console.log("Promotion:", promotion.name, "Type:", promotion.promotion_type);
|
|
2340
|
+
* });
|
|
2341
|
+
* }
|
|
2342
|
+
*
|
|
2343
|
+
* // Override customer group ID for this specific request
|
|
2344
|
+
* const { data: overrideData, error: overrideError } = await sdk.cart.getAvailablePromotions({
|
|
2345
|
+
* "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
|
|
2346
|
+
* });
|
|
2347
|
+
* ```
|
|
2348
|
+
*/
|
|
2349
|
+
async getAvailablePromotions(headers) {
|
|
2350
|
+
const mergedHeaders = this.mergeHeaders(headers);
|
|
2351
|
+
return this.executeRequest(() => this.client.GET("/carts/available-promotions", { params: { header: mergedHeaders } }));
|
|
2352
|
+
}
|
|
2353
|
+
/**
|
|
2354
|
+
* Evaluate promotions
|
|
2355
|
+
*
|
|
2356
|
+
* @param cartId - The ID of the cart
|
|
2357
|
+
* @returns Promise with evaluated promotions
|
|
2358
|
+
* @example
|
|
2359
|
+
* ```typescript
|
|
2360
|
+
* const { data, error } = await sdk.cart.evaluatePromotions({
|
|
2361
|
+
* id: "01H9CART12345ABCDE"
|
|
2362
|
+
* });
|
|
2363
|
+
*
|
|
2364
|
+
* if (error) {
|
|
2365
|
+
* console.error("Failed to evaluate promotions:", error.message);
|
|
2366
|
+
* } else {
|
|
2367
|
+
* const applicable = data.applicable_promotions || [];
|
|
2368
|
+
* const inapplicable = data.inapplicable_promotions || [];
|
|
2369
|
+
*
|
|
2370
|
+
* console.log("Applicable promotions:", applicable.length);
|
|
2371
|
+
* applicable.forEach(promo => {
|
|
2372
|
+
* console.log(`- ${promo.name}: ${promo.savings_message}`);
|
|
2373
|
+
* });
|
|
2374
|
+
*
|
|
2375
|
+
* console.log("Inapplicable promotions:", inapplicable.length);
|
|
2376
|
+
* inapplicable.forEach(promo => {
|
|
2377
|
+
* console.log(`- ${promo.name}: ${promo.reason}`);
|
|
2378
|
+
* });
|
|
2379
|
+
* }
|
|
2380
|
+
* ```
|
|
2381
|
+
*/
|
|
2382
|
+
async evaluatePromotions(cartId) {
|
|
2383
|
+
return this.executeRequest(() => this.client.GET("/carts/{id}/evaluate-promotions", { params: { path: cartId } }));
|
|
2384
|
+
}
|
|
2385
|
+
/**
|
|
2386
|
+
* Evaluate coupons
|
|
2387
|
+
*
|
|
2388
|
+
* @param cartId - The ID of the cart
|
|
2389
|
+
* @returns Promise with evaluated coupons
|
|
2390
|
+
* @example
|
|
2391
|
+
* ```typescript
|
|
2392
|
+
* const { data, error } = await sdk.cart.evaluateCoupons({
|
|
2393
|
+
* id: "01H9CART12345ABCDE"
|
|
2394
|
+
* });
|
|
2395
|
+
*
|
|
2396
|
+
* if (error) {
|
|
2397
|
+
* console.error("Failed to evaluate coupons:", error.message);
|
|
2398
|
+
* } else {
|
|
2399
|
+
* const applicable = data.applicable_coupons || [];
|
|
2400
|
+
* const inapplicable = data.inapplicable_coupons || [];
|
|
2401
|
+
*
|
|
2402
|
+
* console.log("Applicable coupons:", applicable.length);
|
|
2403
|
+
* applicable.forEach(coupon => {
|
|
2404
|
+
* console.log(`- ${coupon.code}: Save $${coupon.estimated_discount}`);
|
|
2405
|
+
* });
|
|
2406
|
+
*
|
|
2407
|
+
* console.log("Inapplicable coupons:", inapplicable.length);
|
|
2408
|
+
* inapplicable.forEach(coupon => {
|
|
2409
|
+
* console.log(`- ${coupon.code}: ${coupon.reason}`);
|
|
2410
|
+
* });
|
|
2411
|
+
* }
|
|
2412
|
+
* ```
|
|
2413
|
+
*/
|
|
2414
|
+
async evaluateCoupons(cartId) {
|
|
2415
|
+
return this.executeRequest(() => this.client.GET("/carts/{id}/evaluate-coupons", { params: { path: cartId } }));
|
|
2416
|
+
}
|
|
2417
|
+
/**
|
|
2294
2418
|
* Redeem loyalty points
|
|
2295
2419
|
*
|
|
2296
2420
|
* @param cartId - The ID of the cart
|
|
@@ -2349,12 +2473,18 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2349
2473
|
* @returns Promise with updated cart
|
|
2350
2474
|
* @example
|
|
2351
2475
|
* ```typescript
|
|
2476
|
+
* // For delivery fulfillment with shipments
|
|
2352
2477
|
* const { data, error } = await sdk.cart.updateFulfillmentPreference(
|
|
2353
2478
|
* { id: "01H9CART12345ABCDE" },
|
|
2354
2479
|
* {
|
|
2355
2480
|
* fulfillment_type: "delivery",
|
|
2356
|
-
*
|
|
2357
|
-
*
|
|
2481
|
+
* shipments: [
|
|
2482
|
+
* {
|
|
2483
|
+
* id: "01H9SHIP12345ABCDE",
|
|
2484
|
+
* shipping_provider_id: "01H9PROV12345FAST",
|
|
2485
|
+
* courier_company_id: "01H9COY12345FAST" // Optional
|
|
2486
|
+
* }
|
|
2487
|
+
* ]
|
|
2358
2488
|
* }
|
|
2359
2489
|
* );
|
|
2360
2490
|
*
|
|
@@ -2364,6 +2494,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2364
2494
|
* console.log("Fulfillment preference updated:", data.cart.fulfillment_preference?.fulfillment_type);
|
|
2365
2495
|
* console.log("Shipping cost:", data.cart.shipping_amount);
|
|
2366
2496
|
* }
|
|
2497
|
+
*
|
|
2498
|
+
* // For collect-in-store fulfillment
|
|
2499
|
+
* const { data: collectData, error: collectError } = await sdk.cart.updateFulfillmentPreference(
|
|
2500
|
+
* { id: "01H9CART12345ABCDE" },
|
|
2501
|
+
* {
|
|
2502
|
+
* fulfillment_type: "collect-in-store",
|
|
2503
|
+
* pickup_location_id: "01H9STORE12345ABC"
|
|
2504
|
+
* }
|
|
2505
|
+
* );
|
|
2367
2506
|
* ```
|
|
2368
2507
|
*/
|
|
2369
2508
|
async updateFulfillmentPreference(cartId, body) {
|
|
@@ -2373,6 +2512,100 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2373
2512
|
}));
|
|
2374
2513
|
}
|
|
2375
2514
|
/**
|
|
2515
|
+
* Check fulfillment serviceability
|
|
2516
|
+
*
|
|
2517
|
+
* Checks if fulfillment (delivery or collect-in-store) is available to the specified pincode
|
|
2518
|
+
* based on shipping zones and inventories.
|
|
2519
|
+
*
|
|
2520
|
+
* @param body - Fulfillment check body (cart-based or items-based)
|
|
2521
|
+
* @returns Promise with fulfillment serviceability result
|
|
2522
|
+
* @example
|
|
2523
|
+
* ```typescript
|
|
2524
|
+
* // Cart-based fulfillment check
|
|
2525
|
+
* const { data, error } = await sdk.cart.checkPincodeDeliverability({
|
|
2526
|
+
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
2527
|
+
* delivery_pincode: "400001",
|
|
2528
|
+
* fulfillment_type: "delivery" // optional: "delivery" | "collect-in-store"
|
|
2529
|
+
* });
|
|
2530
|
+
*
|
|
2531
|
+
* // Items-based fulfillment check
|
|
2532
|
+
* const { data, error } = await sdk.cart.checkPincodeDeliverability({
|
|
2533
|
+
* delivery_pincode: "400001",
|
|
2534
|
+
* items: [
|
|
2535
|
+
* { product_id: "prod_123", variant_id: "var_456" },
|
|
2536
|
+
* { product_id: "prod_789", variant_id: null }
|
|
2537
|
+
* ]
|
|
2538
|
+
* // fulfillment_type is optional
|
|
2539
|
+
* });
|
|
2540
|
+
*
|
|
2541
|
+
* if (error) {
|
|
2542
|
+
* console.error("Failed to check fulfillment serviceability:", error.message);
|
|
2543
|
+
* } else {
|
|
2544
|
+
* console.log("Serviceable:", data.is_serviceable);
|
|
2545
|
+
*
|
|
2546
|
+
* if (!data.is_serviceable && data.unserviceable_items) {
|
|
2547
|
+
* data.unserviceable_items.forEach(item => {
|
|
2548
|
+
* console.log(`Unserviceable: ${item.product_name}, max available: ${item.max_available_quantity}`);
|
|
2549
|
+
* });
|
|
2550
|
+
* }
|
|
2551
|
+
* }
|
|
2552
|
+
* ```
|
|
2553
|
+
*/
|
|
2554
|
+
async checkPincodeDeliverability(body) {
|
|
2555
|
+
return this.executeRequest(() => this.client.POST("/fulfillment/serviceability", { body }));
|
|
2556
|
+
}
|
|
2557
|
+
/**
|
|
2558
|
+
* Get fulfillment options for an order
|
|
2559
|
+
*
|
|
2560
|
+
* @param body - Fulfillment options body containing cart_id and delivery_pincode
|
|
2561
|
+
* @returns Promise with fulfillment options including collect and delivery methods
|
|
2562
|
+
* @example
|
|
2563
|
+
* ```typescript
|
|
2564
|
+
* const { data, error } = await sdk.cart.getFulfillmentOptions({
|
|
2565
|
+
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
2566
|
+
* delivery_pincode: "400001"
|
|
2567
|
+
* });
|
|
2568
|
+
*
|
|
2569
|
+
* if (error) {
|
|
2570
|
+
* console.error("Failed to get fulfillment options:", error.message);
|
|
2571
|
+
* } else {
|
|
2572
|
+
* // Check summary information
|
|
2573
|
+
* console.log("Collect available:", data.summary.collect_available);
|
|
2574
|
+
* console.log("Deliver available:", data.summary.deliver_available);
|
|
2575
|
+
* console.log("Recommended fulfillment type:", data.summary.recommended_fulfillment_type);
|
|
2576
|
+
*
|
|
2577
|
+
* // Access collect options
|
|
2578
|
+
* if (data.collect && data.collect.length > 0) {
|
|
2579
|
+
* console.log("Available stores for collection:");
|
|
2580
|
+
* data.collect.forEach(store => {
|
|
2581
|
+
* console.log(`${store.name} - ${store.distance_km}km away, ETA: ${store.collect_eta_minutes} minutes`);
|
|
2582
|
+
* });
|
|
2583
|
+
* }
|
|
2584
|
+
*
|
|
2585
|
+
* // Access delivery options (with shipments)
|
|
2586
|
+
* if (data.deliver && data.deliver.is_serviceable) {
|
|
2587
|
+
* console.log("Available shipments and shipping methods:");
|
|
2588
|
+
* data.deliver.shipments.forEach(shipment => {
|
|
2589
|
+
* console.log(`Shipment ${shipment.id}:`);
|
|
2590
|
+
* console.log(` Items: ${shipment.items.length}`);
|
|
2591
|
+
* shipment.shipping_methods.forEach(method => {
|
|
2592
|
+
* console.log(` - ${method.name}: ${method.shipping_amount}, ${method.estimated_delivery_days} days`);
|
|
2593
|
+
* // Access courier companies for auto shipping methods
|
|
2594
|
+
* if (method.courier_companies) {
|
|
2595
|
+
* method.courier_companies.forEach(courier => {
|
|
2596
|
+
* console.log(` Courier: ${courier.name} - ${courier.shipping_amount}, ${courier.estimated_delivery_days} days`);
|
|
2597
|
+
* });
|
|
2598
|
+
* }
|
|
2599
|
+
* });
|
|
2600
|
+
* });
|
|
2601
|
+
* }
|
|
2602
|
+
* }
|
|
2603
|
+
* ```
|
|
2604
|
+
*/
|
|
2605
|
+
async getFulfillmentOptions(body) {
|
|
2606
|
+
return this.executeRequest(() => this.client.POST("/carts/fulfillment-options", { body }));
|
|
2607
|
+
}
|
|
2608
|
+
/**
|
|
2376
2609
|
* Use credit balance
|
|
2377
2610
|
*
|
|
2378
2611
|
* @param cartId - The ID of the cart
|
|
@@ -2508,130 +2741,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2508
2741
|
body
|
|
2509
2742
|
}));
|
|
2510
2743
|
}
|
|
2511
|
-
/**
|
|
2512
|
-
* Get all available coupons
|
|
2513
|
-
*
|
|
2514
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
2515
|
-
* @returns Promise with all available coupons
|
|
2516
|
-
* @example
|
|
2517
|
-
* ```typescript
|
|
2518
|
-
* // Get all available coupons
|
|
2519
|
-
* const { data, error } = await sdk.cart.getAvailableCoupons();
|
|
2520
|
-
*
|
|
2521
|
-
* if (error) {
|
|
2522
|
-
* console.error("Failed to get available coupons:", error.message);
|
|
2523
|
-
* } else {
|
|
2524
|
-
* const coupons = data.coupons || [];
|
|
2525
|
-
* console.log("Available coupons:", coupons.length);
|
|
2526
|
-
* coupons.forEach(coupon => {
|
|
2527
|
-
* console.log("Coupon:", coupon.code, "Discount:", coupon.discount_amount);
|
|
2528
|
-
* });
|
|
2529
|
-
* }
|
|
2530
|
-
*
|
|
2531
|
-
* // Override customer group ID for this specific request
|
|
2532
|
-
* const { data: overrideData, error: overrideError } = await sdk.cart.getAvailableCoupons({
|
|
2533
|
-
* "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
|
|
2534
|
-
* });
|
|
2535
|
-
* ```
|
|
2536
|
-
*/
|
|
2537
|
-
async getAvailableCoupons(headers) {
|
|
2538
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
2539
|
-
return this.executeRequest(() => this.client.GET("/carts/available-coupons", { params: { header: mergedHeaders } }));
|
|
2540
|
-
}
|
|
2541
|
-
/**
|
|
2542
|
-
* Get all available promotions
|
|
2543
|
-
*
|
|
2544
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
2545
|
-
* @returns Promise with all available promotions
|
|
2546
|
-
* @example
|
|
2547
|
-
* ```typescript
|
|
2548
|
-
* // Get all available promotions
|
|
2549
|
-
* const { data, error } = await sdk.cart.getAvailablePromotions();
|
|
2550
|
-
*
|
|
2551
|
-
* if (error) {
|
|
2552
|
-
* console.error("Failed to get available promotions:", error.message);
|
|
2553
|
-
* } else {
|
|
2554
|
-
* const promotions = data.promotions || [];
|
|
2555
|
-
* console.log("Available promotions:", promotions.length);
|
|
2556
|
-
* promotions.forEach(promotion => {
|
|
2557
|
-
* console.log("Promotion:", promotion.name, "Type:", promotion.promotion_type);
|
|
2558
|
-
* });
|
|
2559
|
-
* }
|
|
2560
|
-
*
|
|
2561
|
-
* // Override customer group ID for this specific request
|
|
2562
|
-
* const { data: overrideData, error: overrideError } = await sdk.cart.getAvailablePromotions({
|
|
2563
|
-
* "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
|
|
2564
|
-
* });
|
|
2565
|
-
* ```
|
|
2566
|
-
*/
|
|
2567
|
-
async getAvailablePromotions(headers) {
|
|
2568
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
2569
|
-
return this.executeRequest(() => this.client.GET("/carts/available-promotions", { params: { header: mergedHeaders } }));
|
|
2570
|
-
}
|
|
2571
|
-
/**
|
|
2572
|
-
* Evaluate promotions
|
|
2573
|
-
*
|
|
2574
|
-
* @param cartId - The ID of the cart
|
|
2575
|
-
* @returns Promise with evaluated promotions
|
|
2576
|
-
* @example
|
|
2577
|
-
* ```typescript
|
|
2578
|
-
* const { data, error } = await sdk.cart.evaluatePromotions({
|
|
2579
|
-
* id: "01H9CART12345ABCDE"
|
|
2580
|
-
* });
|
|
2581
|
-
*
|
|
2582
|
-
* if (error) {
|
|
2583
|
-
* console.error("Failed to evaluate promotions:", error.message);
|
|
2584
|
-
* } else {
|
|
2585
|
-
* const applicable = data.applicable_promotions || [];
|
|
2586
|
-
* const inapplicable = data.inapplicable_promotions || [];
|
|
2587
|
-
*
|
|
2588
|
-
* console.log("Applicable promotions:", applicable.length);
|
|
2589
|
-
* applicable.forEach(promo => {
|
|
2590
|
-
* console.log(`- ${promo.name}: ${promo.savings_message}`);
|
|
2591
|
-
* });
|
|
2592
|
-
*
|
|
2593
|
-
* console.log("Inapplicable promotions:", inapplicable.length);
|
|
2594
|
-
* inapplicable.forEach(promo => {
|
|
2595
|
-
* console.log(`- ${promo.name}: ${promo.reason}`);
|
|
2596
|
-
* });
|
|
2597
|
-
* }
|
|
2598
|
-
* ```
|
|
2599
|
-
*/
|
|
2600
|
-
async evaluatePromotions(cartId) {
|
|
2601
|
-
return this.executeRequest(() => this.client.GET("/carts/{id}/evaluate-promotions", { params: { path: cartId } }));
|
|
2602
|
-
}
|
|
2603
|
-
/**
|
|
2604
|
-
* Evaluate coupons
|
|
2605
|
-
*
|
|
2606
|
-
* @param cartId - The ID of the cart
|
|
2607
|
-
* @returns Promise with evaluated coupons
|
|
2608
|
-
* @example
|
|
2609
|
-
* ```typescript
|
|
2610
|
-
* const { data, error } = await sdk.cart.evaluateCoupons({
|
|
2611
|
-
* id: "01H9CART12345ABCDE"
|
|
2612
|
-
* });
|
|
2613
|
-
*
|
|
2614
|
-
* if (error) {
|
|
2615
|
-
* console.error("Failed to evaluate coupons:", error.message);
|
|
2616
|
-
* } else {
|
|
2617
|
-
* const applicable = data.applicable_coupons || [];
|
|
2618
|
-
* const inapplicable = data.inapplicable_coupons || [];
|
|
2619
|
-
*
|
|
2620
|
-
* console.log("Applicable coupons:", applicable.length);
|
|
2621
|
-
* applicable.forEach(coupon => {
|
|
2622
|
-
* console.log(`- ${coupon.code}: Save $${coupon.estimated_discount}`);
|
|
2623
|
-
* });
|
|
2624
|
-
*
|
|
2625
|
-
* console.log("Inapplicable coupons:", inapplicable.length);
|
|
2626
|
-
* inapplicable.forEach(coupon => {
|
|
2627
|
-
* console.log(`- ${coupon.code}: ${coupon.reason}`);
|
|
2628
|
-
* });
|
|
2629
|
-
* }
|
|
2630
|
-
* ```
|
|
2631
|
-
*/
|
|
2632
|
-
async evaluateCoupons(cartId) {
|
|
2633
|
-
return this.executeRequest(() => this.client.GET("/carts/{id}/evaluate-coupons", { params: { path: cartId } }));
|
|
2634
|
-
}
|
|
2635
2744
|
};
|
|
2636
2745
|
|
|
2637
2746
|
//#endregion
|
|
@@ -3679,10 +3788,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3679
3788
|
/**
|
|
3680
3789
|
* List all available payment methods
|
|
3681
3790
|
*
|
|
3791
|
+
* @param queryParams - Query parameters containing the payment method type and payment provider slug
|
|
3682
3792
|
* @returns Promise with list of payment methods
|
|
3683
3793
|
* @example
|
|
3684
3794
|
* ```typescript
|
|
3685
|
-
* const { data, error } = await sdk.payments.listPaymentMethods(
|
|
3795
|
+
* const { data, error } = await sdk.payments.listPaymentMethods({
|
|
3796
|
+
* payment_method_type: "card",
|
|
3797
|
+
* payment_provider_slug: "payu"
|
|
3798
|
+
* });
|
|
3686
3799
|
*
|
|
3687
3800
|
* if (error) {
|
|
3688
3801
|
* console.error("Failed to list payment methods:", error.message);
|
|
@@ -3696,8 +3809,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3696
3809
|
* }
|
|
3697
3810
|
* ```
|
|
3698
3811
|
*/
|
|
3699
|
-
async listPaymentMethods() {
|
|
3700
|
-
return this.executeRequest(() => this.client.GET("/payments/payment-methods", {}));
|
|
3812
|
+
async listPaymentMethods(queryParams) {
|
|
3813
|
+
return this.executeRequest(() => this.client.GET("/payments/payment-methods", { params: { query: queryParams } }));
|
|
3701
3814
|
}
|
|
3702
3815
|
/**
|
|
3703
3816
|
* Verify a UPI Virtual Payment Address (VPA)
|
|
@@ -3732,6 +3845,29 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3732
3845
|
return this.executeRequest(() => this.client.GET("/payments/verify-vpa", { params: { query: queryParams } }));
|
|
3733
3846
|
}
|
|
3734
3847
|
/**
|
|
3848
|
+
* Get card information
|
|
3849
|
+
*
|
|
3850
|
+
* Retrieves card information based on the initial 9 digits (card BIN) of the card number.
|
|
3851
|
+
*
|
|
3852
|
+
* @param queryParams - Query parameters containing the card BIN
|
|
3853
|
+
* @returns Promise with card information
|
|
3854
|
+
* @example
|
|
3855
|
+
* ```typescript
|
|
3856
|
+
* const { data, error } = await sdk.payments.getCardInfo({
|
|
3857
|
+
* cardbin: "411111111"
|
|
3858
|
+
* });
|
|
3859
|
+
*
|
|
3860
|
+
* if (error) {
|
|
3861
|
+
* console.error("Failed to get card information:", error.message);
|
|
3862
|
+
* } else {
|
|
3863
|
+
* console.log("Card information:", data.card_info);
|
|
3864
|
+
* }
|
|
3865
|
+
* ```
|
|
3866
|
+
*/
|
|
3867
|
+
async getCardInfo(queryParams) {
|
|
3868
|
+
return this.executeRequest(() => this.client.GET("/payments/card-info", { params: { query: queryParams } }));
|
|
3869
|
+
}
|
|
3870
|
+
/**
|
|
3735
3871
|
* Authenticate a direct OTP for payment verification
|
|
3736
3872
|
*
|
|
3737
3873
|
* @description Used to authenticate OTP during payment flows that require 2FA verification.
|
|
@@ -3790,82 +3926,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3790
3926
|
}
|
|
3791
3927
|
};
|
|
3792
3928
|
|
|
3793
|
-
//#endregion
|
|
3794
|
-
//#region src/lib/shipping.ts
|
|
3795
|
-
/**
|
|
3796
|
-
* Client for interacting with shipping endpoints
|
|
3797
|
-
*/
|
|
3798
|
-
var ShippingClient = class extends StorefrontAPIClient {
|
|
3799
|
-
/**
|
|
3800
|
-
* Check pincode deliverability
|
|
3801
|
-
*
|
|
3802
|
-
* @param pathParams - Path parameters
|
|
3803
|
-
* @returns Promise with pincode deliverability result
|
|
3804
|
-
* @example
|
|
3805
|
-
* ```typescript
|
|
3806
|
-
* const { data, error } = await sdk.shipping.checkPincodeDeliverability({
|
|
3807
|
-
* pincode: "400001"
|
|
3808
|
-
* });
|
|
3809
|
-
*
|
|
3810
|
-
* if (error) {
|
|
3811
|
-
* console.error("Failed to check pincode serviceability:", error.message);
|
|
3812
|
-
* } else {
|
|
3813
|
-
* console.log("Pincode serviceable:", data.is_serviceable);
|
|
3814
|
-
*
|
|
3815
|
-
* if (data.is_serviceable) {
|
|
3816
|
-
* console.log("Delivery is available to this pincode");
|
|
3817
|
-
* } else {
|
|
3818
|
-
* console.log("Delivery is not available to this pincode");
|
|
3819
|
-
* }
|
|
3820
|
-
* }
|
|
3821
|
-
* ```
|
|
3822
|
-
*/
|
|
3823
|
-
async checkPincodeDeliverability(pathParams) {
|
|
3824
|
-
return this.executeRequest(() => this.client.GET("/shipping/serviceability/{pincode}", { params: { path: pathParams } }));
|
|
3825
|
-
}
|
|
3826
|
-
/**
|
|
3827
|
-
* Get fulfillment options for an order
|
|
3828
|
-
*
|
|
3829
|
-
* @param body - Fulfillment options body containing cart_id and delivery_pincode
|
|
3830
|
-
* @returns Promise with fulfillment options including collect and delivery methods
|
|
3831
|
-
* @example
|
|
3832
|
-
* ```typescript
|
|
3833
|
-
* const { data, error } = await sdk.shipping.getFulfillmentOptions({
|
|
3834
|
-
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
3835
|
-
* delivery_pincode: "400001"
|
|
3836
|
-
* });
|
|
3837
|
-
*
|
|
3838
|
-
* if (error) {
|
|
3839
|
-
* console.error("Failed to get fulfillment options:", error.message);
|
|
3840
|
-
* } else {
|
|
3841
|
-
* // Check summary information
|
|
3842
|
-
* console.log("Collect available:", data.summary.collect_available);
|
|
3843
|
-
* console.log("Deliver available:", data.summary.deliver_available);
|
|
3844
|
-
* console.log("Recommended fulfillment type:", data.summary.recommended_fulfillment_type);
|
|
3845
|
-
*
|
|
3846
|
-
* // Access collect options
|
|
3847
|
-
* if (data.collect && data.collect.length > 0) {
|
|
3848
|
-
* console.log("Available stores for collection:");
|
|
3849
|
-
* data.collect.forEach(store => {
|
|
3850
|
-
* console.log(`${store.name} - ${store.distance_km}km away, ETA: ${store.collect_eta_minutes} minutes`);
|
|
3851
|
-
* });
|
|
3852
|
-
* }
|
|
3853
|
-
*
|
|
3854
|
-
* // Access delivery options
|
|
3855
|
-
* if (data.deliver && data.deliver.is_serviceable) {
|
|
3856
|
-
* console.log("Available shipping methods:");
|
|
3857
|
-
* data.deliver.shipping_methods.forEach(method => {
|
|
3858
|
-
* console.log(`${method.name} - ${method.shipping_amount}, ${method.estimated_delivery_days} days`);
|
|
3859
|
-
* });
|
|
3860
|
-
* }
|
|
3861
|
-
* }
|
|
3862
|
-
* ```
|
|
3863
|
-
*/
|
|
3864
|
-
async getFulfillmentOptions(body) {
|
|
3865
|
-
return this.executeRequest(() => this.client.POST("/shipping/fulfillment-options", { body }));
|
|
3866
|
-
}
|
|
3867
|
-
};
|
|
3868
|
-
|
|
3869
3929
|
//#endregion
|
|
3870
3930
|
//#region src/lib/helper.ts
|
|
3871
3931
|
/**
|
|
@@ -4323,6 +4383,29 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4323
4383
|
async listSavedPaymentMethods(pathParams) {
|
|
4324
4384
|
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/payment-methods", { params: { path: pathParams } }));
|
|
4325
4385
|
}
|
|
4386
|
+
/**
|
|
4387
|
+
* List all saved cards for a customer
|
|
4388
|
+
*
|
|
4389
|
+
* @param pathParams - Path parameters
|
|
4390
|
+
* @returns Promise with cards
|
|
4391
|
+
*
|
|
4392
|
+
* @example
|
|
4393
|
+
* ```typescript
|
|
4394
|
+
* const { data, error } = await sdk.customer.listCustomerCards({
|
|
4395
|
+
* customer_id: "customer_123"
|
|
4396
|
+
* });
|
|
4397
|
+
*
|
|
4398
|
+
* if (error) {
|
|
4399
|
+
* console.error("Failed to list customer cards:", error);
|
|
4400
|
+
* return;
|
|
4401
|
+
* }
|
|
4402
|
+
*
|
|
4403
|
+
* console.log("Customer cards:", data.cards);
|
|
4404
|
+
* ```
|
|
4405
|
+
*/
|
|
4406
|
+
async listCustomerCards(pathParams) {
|
|
4407
|
+
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/cards", { params: { path: pathParams } }));
|
|
4408
|
+
}
|
|
4326
4409
|
};
|
|
4327
4410
|
|
|
4328
4411
|
//#endregion
|
|
@@ -4385,10 +4468,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4385
4468
|
*/
|
|
4386
4469
|
helpers;
|
|
4387
4470
|
/**
|
|
4388
|
-
* Client for shipping-related endpoints
|
|
4389
|
-
*/
|
|
4390
|
-
shipping;
|
|
4391
|
-
/**
|
|
4392
4471
|
* Client for order-related endpoints
|
|
4393
4472
|
*/
|
|
4394
4473
|
order;
|
|
@@ -4431,7 +4510,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4431
4510
|
this.auth = new AuthClient(config);
|
|
4432
4511
|
this.customer = new CustomerClient(config);
|
|
4433
4512
|
this.helpers = new HelpersClient(config);
|
|
4434
|
-
this.shipping = new ShippingClient(config);
|
|
4435
4513
|
this.order = new OrderClient(config);
|
|
4436
4514
|
this.payments = new PaymentsClient(config);
|
|
4437
4515
|
this.store = new StoreConfigClient(config);
|
|
@@ -4452,7 +4530,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4452
4530
|
await this.auth.setTokens(accessToken, refreshToken);
|
|
4453
4531
|
await this.customer.setTokens(accessToken, refreshToken);
|
|
4454
4532
|
await this.helpers.setTokens(accessToken, refreshToken);
|
|
4455
|
-
await this.shipping.setTokens(accessToken, refreshToken);
|
|
4456
4533
|
await this.order.setTokens(accessToken, refreshToken);
|
|
4457
4534
|
await this.payments.setTokens(accessToken, refreshToken);
|
|
4458
4535
|
await this.store.setTokens(accessToken, refreshToken);
|
|
@@ -4470,7 +4547,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4470
4547
|
await this.auth.clearTokens();
|
|
4471
4548
|
await this.customer.clearTokens();
|
|
4472
4549
|
await this.helpers.clearTokens();
|
|
4473
|
-
await this.shipping.clearTokens();
|
|
4474
4550
|
await this.order.clearTokens();
|
|
4475
4551
|
await this.payments.clearTokens();
|
|
4476
4552
|
await this.store.clearTokens();
|
|
@@ -4486,7 +4562,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4486
4562
|
this.auth.setApiKey(apiKey);
|
|
4487
4563
|
this.customer.setApiKey(apiKey);
|
|
4488
4564
|
this.helpers.setApiKey(apiKey);
|
|
4489
|
-
this.shipping.setApiKey(apiKey);
|
|
4490
4565
|
this.order.setApiKey(apiKey);
|
|
4491
4566
|
this.payments.setApiKey(apiKey);
|
|
4492
4567
|
this.store.setApiKey(apiKey);
|
|
@@ -4500,7 +4575,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4500
4575
|
this.auth.clearApiKey();
|
|
4501
4576
|
this.customer.clearApiKey();
|
|
4502
4577
|
this.helpers.clearApiKey();
|
|
4503
|
-
this.shipping.clearApiKey();
|
|
4504
4578
|
this.order.clearApiKey();
|
|
4505
4579
|
this.payments.clearApiKey();
|
|
4506
4580
|
this.store.clearApiKey();
|
|
@@ -4579,7 +4653,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4579
4653
|
this.auth.setDefaultHeaders(headers);
|
|
4580
4654
|
this.customer.setDefaultHeaders(headers);
|
|
4581
4655
|
this.helpers.setDefaultHeaders(headers);
|
|
4582
|
-
this.shipping.setDefaultHeaders(headers);
|
|
4583
4656
|
this.order.setDefaultHeaders(headers);
|
|
4584
4657
|
this.payments.setDefaultHeaders(headers);
|
|
4585
4658
|
this.store.setDefaultHeaders(headers);
|
|
@@ -4608,7 +4681,6 @@ exports.MemoryTokenStorage = MemoryTokenStorage;
|
|
|
4608
4681
|
exports.OrderClient = OrderClient;
|
|
4609
4682
|
exports.PaymentsClient = PaymentsClient;
|
|
4610
4683
|
exports.ResponseUtils = ResponseUtils;
|
|
4611
|
-
exports.ShippingClient = ShippingClient;
|
|
4612
4684
|
exports.StoreConfigClient = StoreConfigClient;
|
|
4613
4685
|
exports.StorefrontAPIClient = StorefrontAPIClient;
|
|
4614
4686
|
exports.StorefrontSDK = StorefrontSDK;
|