@commercengine/storefront-sdk 0.10.1 → 0.11.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.
@@ -11,12 +11,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
11
11
  return Math.random().toString(36).slice(2, 11);
12
12
  }
13
13
  function createClient(clientOptions) {
14
- let { baseUrl = "", Request: CustomRequest = globalThis.Request, fetch: baseFetch = globalThis.fetch, querySerializer: globalQuerySerializer, bodySerializer: globalBodySerializer, headers: baseHeaders, requestInitExt = void 0,...baseOptions } = { ...clientOptions };
14
+ let { baseUrl = "", Request: CustomRequest = globalThis.Request, fetch: baseFetch = globalThis.fetch, querySerializer: globalQuerySerializer, bodySerializer: globalBodySerializer, headers: baseHeaders, requestInitExt = void 0, ...baseOptions } = { ...clientOptions };
15
15
  requestInitExt = supportsRequestInitExt() ? requestInitExt : void 0;
16
16
  baseUrl = removeTrailingSlash(baseUrl);
17
17
  const middlewares = [];
18
18
  async function coreFetch(schemaPath, fetchOptions) {
19
- const { baseUrl: localBaseUrl, fetch: fetch$1 = baseFetch, Request: Request$1 = CustomRequest, headers, params = {}, parseAs = "json", querySerializer: requestQuerySerializer, bodySerializer = globalBodySerializer ?? defaultBodySerializer, body,...init } = fetchOptions || {};
19
+ const { baseUrl: localBaseUrl, fetch: fetch$1 = baseFetch, Request: Request$1 = CustomRequest, headers, params = {}, parseAs = "json", querySerializer: requestQuerySerializer, bodySerializer = globalBodySerializer ?? defaultBodySerializer, body, ...init } = fetchOptions || {};
20
20
  let finalBaseUrl = baseUrl;
21
21
  if (localBaseUrl) finalBaseUrl = removeTrailingSlash(localBaseUrl) ?? baseUrl;
22
22
  let querySerializer = typeof globalQuerySerializer === "function" ? globalQuerySerializer : createQuerySerializer(globalQuerySerializer);
@@ -762,15 +762,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
762
762
  getDefaultHeaders() {
763
763
  return this.config.defaultHeaders;
764
764
  }
765
- /**
766
- * Add middleware to the client
767
- * This allows SDK extensions to add custom middleware like authentication
768
- *
769
- * @param middleware - Middleware to add to the client
770
- */
771
- use(middleware) {
772
- this.client.use(middleware);
773
- }
774
765
  };
775
766
  /**
776
767
  * Generic URL utility functions for any SDK
@@ -788,13 +779,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
788
779
  }
789
780
 
790
781
  //#endregion
791
- //#region ../../node_modules/.pnpm/jose@6.0.13/node_modules/jose/dist/webapi/lib/buffer_utils.js
782
+ //#region ../../node_modules/.pnpm/jose@6.1.3/node_modules/jose/dist/webapi/lib/buffer_utils.js
792
783
  const encoder = new TextEncoder();
793
784
  const decoder = new TextDecoder();
794
785
  const MAX_INT32 = 2 ** 32;
795
786
 
796
787
  //#endregion
797
- //#region ../../node_modules/.pnpm/jose@6.0.13/node_modules/jose/dist/webapi/lib/base64.js
788
+ //#region ../../node_modules/.pnpm/jose@6.1.3/node_modules/jose/dist/webapi/lib/base64.js
798
789
  function decodeBase64(encoded) {
799
790
  if (Uint8Array.fromBase64) return Uint8Array.fromBase64(encoded);
800
791
  const binary = atob(encoded);
@@ -804,12 +795,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
804
795
  }
805
796
 
806
797
  //#endregion
807
- //#region ../../node_modules/.pnpm/jose@6.0.13/node_modules/jose/dist/webapi/util/base64url.js
798
+ //#region ../../node_modules/.pnpm/jose@6.1.3/node_modules/jose/dist/webapi/util/base64url.js
808
799
  function decode(input) {
809
800
  if (Uint8Array.fromBase64) return Uint8Array.fromBase64(typeof input === "string" ? input : decoder.decode(input), { alphabet: "base64url" });
810
801
  let encoded = input;
811
802
  if (encoded instanceof Uint8Array) encoded = decoder.decode(encoded);
812
- encoded = encoded.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
803
+ encoded = encoded.replace(/-/g, "+").replace(/_/g, "/");
813
804
  try {
814
805
  return decodeBase64(encoded);
815
806
  } catch {
@@ -818,7 +809,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
818
809
  }
819
810
 
820
811
  //#endregion
821
- //#region ../../node_modules/.pnpm/jose@6.0.13/node_modules/jose/dist/webapi/util/errors.js
812
+ //#region ../../node_modules/.pnpm/jose@6.1.3/node_modules/jose/dist/webapi/util/errors.js
822
813
  var JOSEError = class extends Error {
823
814
  static code = "ERR_JOSE_GENERIC";
824
815
  code = "ERR_JOSE_GENERIC";
@@ -842,20 +833,18 @@ Object.defineProperty(exports, '__esModule', { value: true });
842
833
  };
843
834
 
844
835
  //#endregion
845
- //#region ../../node_modules/.pnpm/jose@6.0.13/node_modules/jose/dist/webapi/lib/is_object.js
846
- function isObjectLike(value) {
847
- return typeof value === "object" && value !== null;
848
- }
849
- var is_object_default = (input) => {
836
+ //#region ../../node_modules/.pnpm/jose@6.1.3/node_modules/jose/dist/webapi/lib/is_object.js
837
+ const isObjectLike = (value) => typeof value === "object" && value !== null;
838
+ function isObject(input) {
850
839
  if (!isObjectLike(input) || Object.prototype.toString.call(input) !== "[object Object]") return false;
851
840
  if (Object.getPrototypeOf(input) === null) return true;
852
841
  let proto = input;
853
842
  while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
854
843
  return Object.getPrototypeOf(input) === proto;
855
- };
844
+ }
856
845
 
857
846
  //#endregion
858
- //#region ../../node_modules/.pnpm/jose@6.0.13/node_modules/jose/dist/webapi/util/decode_jwt.js
847
+ //#region ../../node_modules/.pnpm/jose@6.1.3/node_modules/jose/dist/webapi/util/decode_jwt.js
859
848
  function decodeJwt(jwt) {
860
849
  if (typeof jwt !== "string") throw new JWTInvalid("JWTs must use Compact JWS serialization, JWT must be a string");
861
850
  const { 1: payload, length } = jwt.split(".");
@@ -874,7 +863,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
874
863
  } catch {
875
864
  throw new JWTInvalid("Failed to parse the decoded payload as JSON");
876
865
  }
877
- if (!is_object_default(result)) throw new JWTInvalid("Invalid JWT Claims Set");
866
+ if (!isObject(result)) throw new JWTInvalid("Invalid JWT Claims Set");
878
867
  return result;
879
868
  }
880
869
 
@@ -922,9 +911,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
922
911
  try {
923
912
  const payload = decodeJwt(token);
924
913
  if (!payload.exp) return true;
925
- const currentTime = Math.floor(Date.now() / 1e3);
926
- const expiryTime = payload.exp;
927
- return currentTime >= expiryTime - bufferSeconds;
914
+ return Math.floor(Date.now() / 1e3) >= payload.exp - bufferSeconds;
928
915
  } catch (error) {
929
916
  console.warn("Failed to decode JWT token:", error);
930
917
  return true;
@@ -1260,9 +1247,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
1260
1247
  * Helper function to create auth middleware with sensible defaults
1261
1248
  */
1262
1249
  function createDefaultAuthMiddleware(options) {
1263
- const tokenStorage = options.tokenStorage || (typeof localStorage !== "undefined" ? new BrowserTokenStorage() : new MemoryTokenStorage());
1264
1250
  return createAuthMiddleware({
1265
- tokenStorage,
1251
+ tokenStorage: options.tokenStorage || (typeof localStorage !== "undefined" ? new BrowserTokenStorage() : new MemoryTokenStorage()),
1266
1252
  apiKey: options.apiKey,
1267
1253
  baseUrl: options.baseUrl,
1268
1254
  onTokensUpdated: options.onTokensUpdated,
@@ -1354,8 +1340,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
1354
1340
  config.refreshToken = void 0;
1355
1341
  }
1356
1342
  } else this.client.use({ onRequest: async ({ request }) => {
1357
- const pathname = getPathnameFromUrl(request.url);
1358
- if (isAnonymousAuthEndpoint(pathname)) {
1343
+ if (isAnonymousAuthEndpoint(getPathnameFromUrl(request.url))) {
1359
1344
  if (config.apiKey) request.headers.set("X-Api-Key", config.apiKey);
1360
1345
  if (config.accessToken) request.headers.set("Authorization", `Bearer ${config.accessToken}`);
1361
1346
  return request;
@@ -2353,7 +2338,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
2353
2338
  }));
2354
2339
  }
2355
2340
  /**
2356
- * Update shipping method
2341
+ * Update fulfillment preference
2357
2342
  *
2358
2343
  * @param cartId - The ID of the cart
2359
2344
  * @param body - The body of the request
@@ -3349,27 +3334,80 @@ Object.defineProperty(exports, '__esModule', { value: true });
3349
3334
  * @returns Promise with order details
3350
3335
  * @example
3351
3336
  * ```typescript
3352
- * // Example with PayU payment gateway
3337
+ * // Juspay Hyper Checkout - Redirects to hosted payment page
3353
3338
  * const { data, error } = await sdk.order.createOrder({
3354
3339
  * cart_id: "cart_01H9XYZ12345ABCDE",
3355
- * payment_gateway: "PAYU",
3356
- * payment_gateway_params: {
3357
- * payment_gateway: "PAYU",
3358
- * furl: "https://yourapp.com/payment/failure",
3359
- * surl: "https://yourapp.com/payment/success"
3340
+ * payment_method: {
3341
+ * payment_provider_slug: "juspay",
3342
+ * integration_type: "hyper-checkout",
3343
+ * gateway_reference_id: "gateway_ref_123",
3344
+ * return_url: "https://yourapp.com/payment/return",
3345
+ * action: "paymentPage"
3360
3346
  * }
3361
3347
  * });
3362
3348
  *
3363
- * // Example with Juspay payment gateway
3349
+ * // Juspay Express Checkout - New Card
3364
3350
  * const { data, error } = await sdk.order.createOrder({
3365
3351
  * cart_id: "cart_01H9XYZ12345ABCDE",
3366
- * payment_gateway: "JUSPAY",
3367
- * payment_gateway_params: {
3368
- * payment_gateway: "JUSPAY",
3369
- * action: "paymentPage",
3370
- * integration_type: "hyper-checkout",
3352
+ * payment_method: {
3353
+ * payment_provider_slug: "juspay",
3354
+ * integration_type: "express-checkout",
3355
+ * gateway_reference_id: "gateway_ref_123",
3356
+ * return_url: "https://yourapp.com/payment/return",
3357
+ * payment_method_type: "CARD",
3358
+ * payment_method: "VISA",
3359
+ * auth_type: "OTP",
3360
+ * save_to_locker: true,
3361
+ * card_number: "4111111111111111",
3362
+ * card_exp_month: "12",
3363
+ * card_exp_year: "2025",
3364
+ * name_on_card: "John Doe",
3365
+ * card_security_code: "123"
3366
+ * }
3367
+ * });
3368
+ *
3369
+ * // Juspay Express Checkout - Saved Card Token
3370
+ * const { data, error } = await sdk.order.createOrder({
3371
+ * cart_id: "cart_01H9XYZ12345ABCDE",
3372
+ * payment_method: {
3373
+ * payment_provider_slug: "juspay",
3374
+ * integration_type: "express-checkout",
3375
+ * gateway_reference_id: "gateway_ref_123",
3376
+ * return_url: "https://yourapp.com/payment/return",
3377
+ * get_client_auth_token: true,
3378
+ * payment_method_type: "CARD",
3379
+ * payment_method: "VISA",
3380
+ * auth_type: "OTP",
3381
+ * save_to_locker: false,
3382
+ * card_token: "token_abc123",
3383
+ * card_security_code: "123"
3384
+ * }
3385
+ * });
3386
+ *
3387
+ * // Juspay Express Checkout - UPI Collect
3388
+ * const { data, error } = await sdk.order.createOrder({
3389
+ * cart_id: "cart_01H9XYZ12345ABCDE",
3390
+ * payment_method: {
3391
+ * payment_provider_slug: "juspay",
3392
+ * integration_type: "express-checkout",
3393
+ * gateway_reference_id: "gateway_ref_123",
3371
3394
  * return_url: "https://yourapp.com/payment/return",
3372
- * gateway_reference_id: "juspay_gateway_ref_123"
3395
+ * payment_method_type: "UPI",
3396
+ * payment_method: "UPI_COLLECT",
3397
+ * upi_vpa: "user@upi"
3398
+ * }
3399
+ * });
3400
+ *
3401
+ * // Juspay Express Checkout - Net Banking
3402
+ * const { data, error } = await sdk.order.createOrder({
3403
+ * cart_id: "cart_01H9XYZ12345ABCDE",
3404
+ * payment_method: {
3405
+ * payment_provider_slug: "juspay",
3406
+ * integration_type: "express-checkout",
3407
+ * gateway_reference_id: "gateway_ref_123",
3408
+ * return_url: "https://yourapp.com/payment/return",
3409
+ * payment_method_type: "NB",
3410
+ * payment_method: "NB_HDFC"
3373
3411
  * }
3374
3412
  * });
3375
3413
  *
@@ -3379,6 +3417,17 @@ Object.defineProperty(exports, '__esModule', { value: true });
3379
3417
  * console.log("Order created:", data.order.id);
3380
3418
  * console.log("Payment required:", data.payment_required);
3381
3419
  * console.log("Payment info:", data.payment_info);
3420
+ *
3421
+ * // For hyper-checkout, redirect to payment page
3422
+ * if ("payment_links" in data.payment_info) {
3423
+ * window.location.href = data.payment_info.payment_links?.web;
3424
+ * }
3425
+ *
3426
+ * // For express-checkout with OTP authentication
3427
+ * if ("payment" in data.payment_info && data.payment_info.payment?.authentication?.params) {
3428
+ * const { id: txn_id, challenge_id } = data.payment_info.payment.authentication.params;
3429
+ * // Use txn_id and challenge_id with sdk.payments.authenticateDirectOtp()
3430
+ * }
3382
3431
  * }
3383
3432
  * ```
3384
3433
  */
@@ -3566,28 +3615,32 @@ Object.defineProperty(exports, '__esModule', { value: true });
3566
3615
  * @returns Promise with payment information
3567
3616
  * @example
3568
3617
  * ```typescript
3569
- * // Example with PayU payment gateway
3618
+ * // Juspay Hyper Checkout - Redirects to hosted payment page
3570
3619
  * const { data, error } = await sdk.order.retryOrderPayment(
3571
3620
  * { order_number: "ORD-2024-001" },
3572
3621
  * {
3573
- * payment_gateway_params: {
3574
- * payment_gateway: "PAYU",
3575
- * furl: "https://yourapp.com/payment/failure",
3576
- * surl: "https://yourapp.com/payment/success"
3622
+ * payment_method: {
3623
+ * payment_provider_slug: "juspay",
3624
+ * integration_type: "hyper-checkout",
3625
+ * gateway_reference_id: "gateway_ref_123",
3626
+ * return_url: "https://yourapp.com/payment/return",
3627
+ * action: "paymentPage"
3577
3628
  * }
3578
3629
  * }
3579
3630
  * );
3580
3631
  *
3581
- * // Example with Juspay payment gateway
3632
+ * // Juspay Express Checkout - UPI Collect
3582
3633
  * const { data, error } = await sdk.order.retryOrderPayment(
3583
3634
  * { order_number: "ORD-2024-001" },
3584
3635
  * {
3585
- * payment_gateway_params: {
3586
- * payment_gateway: "JUSPAY",
3587
- * action: "paymentPage",
3588
- * integration_type: "hyper-checkout",
3636
+ * payment_method: {
3637
+ * payment_provider_slug: "juspay",
3638
+ * integration_type: "express-checkout",
3639
+ * gateway_reference_id: "gateway_ref_123",
3589
3640
  * return_url: "https://yourapp.com/payment/return",
3590
- * gateway_reference_id: "juspay_gateway_ref_123"
3641
+ * payment_method_type: "UPI",
3642
+ * payment_method: "UPI_COLLECT",
3643
+ * upi_vpa: "user@upi"
3591
3644
  * }
3592
3645
  * }
3593
3646
  * );
@@ -3597,7 +3650,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
3597
3650
  * } else {
3598
3651
  * console.log("Payment retry initiated");
3599
3652
  * console.log("Payment info:", data.payment_info);
3600
- * console.log("Transaction ID:", data.payment_info.transaction_id);
3653
+ *
3654
+ * // For hyper-checkout, redirect to payment page
3655
+ * if ("payment_links" in data.payment_info) {
3656
+ * window.location.href = data.payment_info.payment_links?.web;
3657
+ * }
3601
3658
  * }
3602
3659
  * ```
3603
3660
  */
@@ -3610,45 +3667,131 @@ Object.defineProperty(exports, '__esModule', { value: true });
3610
3667
  };
3611
3668
 
3612
3669
  //#endregion
3613
- //#region src/lib/shipping.ts
3670
+ //#region src/lib/payments.ts
3614
3671
  /**
3615
- * Client for interacting with shipping endpoints
3672
+ * Client for interacting with payment endpoints
3616
3673
  */
3617
- var ShippingClient = class extends StorefrontAPIClient {
3674
+ var PaymentsClient = class extends StorefrontAPIClient {
3675
+ /**
3676
+ * List all available payment methods
3677
+ *
3678
+ * @returns Promise with list of payment methods
3679
+ * @example
3680
+ * ```typescript
3681
+ * const { data, error } = await sdk.payments.listPaymentMethods();
3682
+ *
3683
+ * if (error) {
3684
+ * console.error("Failed to list payment methods:", error.message);
3685
+ * } else {
3686
+ * console.log("Payment methods:", data.payment_methods);
3687
+ *
3688
+ * data.payment_methods?.forEach(method => {
3689
+ * console.log("Payment method:", method.name);
3690
+ * console.log("Gateway:", method.payment_gateway);
3691
+ * });
3692
+ * }
3693
+ * ```
3694
+ */
3695
+ async listPaymentMethods() {
3696
+ return this.executeRequest(() => this.client.GET("/payments/payment-methods", {}));
3697
+ }
3618
3698
  /**
3619
- * Get shipping options for an order
3699
+ * Verify a UPI Virtual Payment Address (VPA)
3700
+ *
3701
+ * @description The Virtual Payment Address or VPA is a unique ID given to an individual
3702
+ * using the Unified Payment Interface (UPI) service to send or receive money.
3703
+ * Validating the VPA helps reduce payment failure rates due to incorrect VPA.
3620
3704
  *
3621
- * @param body - Shipping methods body
3622
- * @returns Promise with shipping options
3705
+ * @param queryParams - Query parameters containing the VPA to verify
3706
+ * @returns Promise with VPA verification result
3623
3707
  * @example
3624
3708
  * ```typescript
3625
- * const { data, error } = await sdk.shipping.getShippingMethods({
3626
- * delivery_pincode: "400001",
3627
- * cart_id: "cart_01H9XYZ12345ABCDE"
3709
+ * const { data, error } = await sdk.payments.verifyVpa({
3710
+ * vpa: "user@upi"
3628
3711
  * });
3629
3712
  *
3630
3713
  * if (error) {
3631
- * console.error("Failed to get shipping methods:", error.message);
3714
+ * console.error("Failed to verify VPA:", error.message);
3632
3715
  * } else {
3633
- * console.log("Is serviceable:", data.is_serviceable);
3634
- * console.log("Available shipping methods:", data.shipping_methods?.length || 0);
3716
+ * console.log("VPA:", data.vpa);
3717
+ * console.log("Status:", data.status);
3635
3718
  *
3636
- * data.shipping_methods?.forEach(method => {
3637
- * console.log(`Method: ${method.name} (${method.shipping_type})`);
3638
- * console.log(`Shipping cost: ${method.shipping_amount}`);
3639
- * console.log(`Estimated delivery: ${method.estimated_delivery_days} days`);
3719
+ * if (data.status === "VALID") {
3720
+ * console.log("VPA is valid and can be used for UPI payments");
3721
+ * } else {
3722
+ * console.log("VPA is invalid, please check and try again");
3723
+ * }
3724
+ * }
3725
+ * ```
3726
+ */
3727
+ async verifyVpa(queryParams) {
3728
+ return this.executeRequest(() => this.client.GET("/payments/verify-vpa", { params: { query: queryParams } }));
3729
+ }
3730
+ /**
3731
+ * Authenticate a direct OTP for payment verification
3640
3732
  *
3641
- * method.courier_companies?.forEach(courier => {
3642
- * console.log(` - ${courier.name}: ${courier.shipping_amount} (${courier.mode})`);
3643
- * console.log(` Rating: ${courier.rating}/5, Recommended: ${courier.is_recommended}`);
3644
- * });
3645
- * });
3733
+ * @description Used to authenticate OTP during payment flows that require 2FA verification.
3734
+ * The txn_id and challenge_id can be obtained from the create order API response
3735
+ * under the payment_info.authentication.params object.
3736
+ *
3737
+ * @param body - OTP authentication request body
3738
+ * @returns Promise with authentication result
3739
+ * @example
3740
+ * ```typescript
3741
+ * // After creating an order, if OTP authentication is required:
3742
+ * const { data, error } = await sdk.payments.authenticateDirectOtp({
3743
+ * txn_id: "txn_01H9XYZ12345ABCDE",
3744
+ * challenge_id: "challenge_01H9XYZ12345ABCDE",
3745
+ * otp: "123456"
3746
+ * });
3747
+ *
3748
+ * if (error) {
3749
+ * console.error("OTP authentication failed:", error.message);
3750
+ * } else {
3751
+ * console.log("Authentication success:", data.success);
3752
+ * console.log("Message:", data.message);
3753
+ * }
3754
+ * ```
3755
+ */
3756
+ async authenticateDirectOtp(body) {
3757
+ return this.executeRequest(() => this.client.POST("/payments/authenticate-direct-otp", { body }));
3758
+ }
3759
+ /**
3760
+ * Resend a direct OTP for payment verification
3761
+ *
3762
+ * @description Used to resend OTP during payment flows that require 2FA verification.
3763
+ * The txn_id and challenge_id can be obtained from the create order API response
3764
+ * under the payment_info.authentication.params object.
3765
+ *
3766
+ * @param body - OTP resend request body
3767
+ * @returns Promise with new payment info containing updated OTP challenge
3768
+ * @example
3769
+ * ```typescript
3770
+ * // If user didn't receive OTP or it expired:
3771
+ * const { data, error } = await sdk.payments.resendDirectOtp({
3772
+ * txn_id: "txn_01H9XYZ12345ABCDE",
3773
+ * challenge_id: "challenge_01H9XYZ12345ABCDE"
3774
+ * });
3775
+ *
3776
+ * if (error) {
3777
+ * console.error("Failed to resend OTP:", error.message);
3778
+ * } else {
3779
+ * console.log("OTP resent successfully");
3780
+ * console.log("New payment info:", data.payment_info);
3646
3781
  * }
3647
3782
  * ```
3648
3783
  */
3649
- async getShippingMethods(body) {
3650
- return this.executeRequest(() => this.client.POST("/shipping/shipping-methods", { body }));
3784
+ async resendDirectOtp(body) {
3785
+ return this.executeRequest(() => this.client.POST("/payments/resend-direct-otp", { body }));
3651
3786
  }
3787
+ };
3788
+
3789
+ //#endregion
3790
+ //#region src/lib/shipping.ts
3791
+ /**
3792
+ * Client for interacting with shipping endpoints
3793
+ */
3794
+ var ShippingClient = class extends StorefrontAPIClient {
3652
3795
  /**
3653
3796
  * Check pincode deliverability
3654
3797
  *
@@ -3676,6 +3819,47 @@ Object.defineProperty(exports, '__esModule', { value: true });
3676
3819
  async checkPincodeDeliverability(pathParams) {
3677
3820
  return this.executeRequest(() => this.client.GET("/shipping/serviceability/{pincode}", { params: { path: pathParams } }));
3678
3821
  }
3822
+ /**
3823
+ * Get fulfillment options for an order
3824
+ *
3825
+ * @param body - Fulfillment options body containing cart_id and delivery_pincode
3826
+ * @returns Promise with fulfillment options including collect and delivery methods
3827
+ * @example
3828
+ * ```typescript
3829
+ * const { data, error } = await sdk.shipping.getFulfillmentOptions({
3830
+ * cart_id: "cart_01H9XYZ12345ABCDE",
3831
+ * delivery_pincode: "400001"
3832
+ * });
3833
+ *
3834
+ * if (error) {
3835
+ * console.error("Failed to get fulfillment options:", error.message);
3836
+ * } else {
3837
+ * // Check summary information
3838
+ * console.log("Collect available:", data.summary.collect_available);
3839
+ * console.log("Deliver available:", data.summary.deliver_available);
3840
+ * console.log("Recommended fulfillment type:", data.summary.recommended_fulfillment_type);
3841
+ *
3842
+ * // Access collect options
3843
+ * if (data.collect && data.collect.length > 0) {
3844
+ * console.log("Available stores for collection:");
3845
+ * data.collect.forEach(store => {
3846
+ * console.log(`${store.name} - ${store.distance_km}km away, ETA: ${store.collect_eta_minutes} minutes`);
3847
+ * });
3848
+ * }
3849
+ *
3850
+ * // Access delivery options
3851
+ * if (data.deliver && data.deliver.is_serviceable) {
3852
+ * console.log("Available shipping methods:");
3853
+ * data.deliver.shipping_methods.forEach(method => {
3854
+ * console.log(`${method.name} - ${method.shipping_amount}, ${method.estimated_delivery_days} days`);
3855
+ * });
3856
+ * }
3857
+ * }
3858
+ * ```
3859
+ */
3860
+ async getFulfillmentOptions(body) {
3861
+ return this.executeRequest(() => this.client.POST("/shipping/fulfillment-options", { body }));
3862
+ }
3679
3863
  };
3680
3864
 
3681
3865
  //#endregion
@@ -4112,6 +4296,29 @@ Object.defineProperty(exports, '__esModule', { value: true });
4112
4296
  async listCustomerReviews(pathParams) {
4113
4297
  return this.executeRequest(() => this.client.GET("/customers/{user_id}/reviews", { params: { path: pathParams } }));
4114
4298
  }
4299
+ /**
4300
+ * List all saved payment methods for a customer
4301
+ *
4302
+ * @param pathParams - Path parameters
4303
+ * @returns Promise with payment methods
4304
+ *
4305
+ * @example
4306
+ * ```typescript
4307
+ * const { data, error } = await sdk.customer.listSavedPaymentMethods({
4308
+ * customer_id: "customer_123"
4309
+ * });
4310
+ *
4311
+ * if (error) {
4312
+ * console.error("Failed to list saved payment methods:", error);
4313
+ * return;
4314
+ * }
4315
+ *
4316
+ * console.log("Saved payment methods:", data.saved_payment_methods);
4317
+ * ```
4318
+ */
4319
+ async listSavedPaymentMethods(pathParams) {
4320
+ return this.executeRequest(() => this.client.GET("/customers/{customer_id}/payment-methods", { params: { path: pathParams } }));
4321
+ }
4115
4322
  };
4116
4323
 
4117
4324
  //#endregion
@@ -4182,6 +4389,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
4182
4389
  */
4183
4390
  order;
4184
4391
  /**
4392
+ * Client for payment-related endpoints
4393
+ */
4394
+ payments;
4395
+ /**
4185
4396
  * Client for store config-related endpoints
4186
4397
  */
4187
4398
  store;
@@ -4218,6 +4429,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4218
4429
  this.helpers = new HelpersClient(config);
4219
4430
  this.shipping = new ShippingClient(config);
4220
4431
  this.order = new OrderClient(config);
4432
+ this.payments = new PaymentsClient(config);
4221
4433
  this.store = new StoreConfigClient(config);
4222
4434
  }
4223
4435
  /**
@@ -4238,6 +4450,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4238
4450
  await this.helpers.setTokens(accessToken, refreshToken);
4239
4451
  await this.shipping.setTokens(accessToken, refreshToken);
4240
4452
  await this.order.setTokens(accessToken, refreshToken);
4453
+ await this.payments.setTokens(accessToken, refreshToken);
4241
4454
  await this.store.setTokens(accessToken, refreshToken);
4242
4455
  }
4243
4456
  /**
@@ -4255,6 +4468,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4255
4468
  await this.helpers.clearTokens();
4256
4469
  await this.shipping.clearTokens();
4257
4470
  await this.order.clearTokens();
4471
+ await this.payments.clearTokens();
4258
4472
  await this.store.clearTokens();
4259
4473
  }
4260
4474
  /**
@@ -4270,6 +4484,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4270
4484
  this.helpers.setApiKey(apiKey);
4271
4485
  this.shipping.setApiKey(apiKey);
4272
4486
  this.order.setApiKey(apiKey);
4487
+ this.payments.setApiKey(apiKey);
4273
4488
  this.store.setApiKey(apiKey);
4274
4489
  }
4275
4490
  /**
@@ -4283,6 +4498,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4283
4498
  this.helpers.clearApiKey();
4284
4499
  this.shipping.clearApiKey();
4285
4500
  this.order.clearApiKey();
4501
+ this.payments.clearApiKey();
4286
4502
  this.store.clearApiKey();
4287
4503
  }
4288
4504
  /**
@@ -4361,6 +4577,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4361
4577
  this.helpers.setDefaultHeaders(headers);
4362
4578
  this.shipping.setDefaultHeaders(headers);
4363
4579
  this.order.setDefaultHeaders(headers);
4580
+ this.payments.setDefaultHeaders(headers);
4364
4581
  this.store.setDefaultHeaders(headers);
4365
4582
  }
4366
4583
  /**
@@ -4385,6 +4602,7 @@ exports.Environment = Environment;
4385
4602
  exports.HelpersClient = HelpersClient;
4386
4603
  exports.MemoryTokenStorage = MemoryTokenStorage;
4387
4604
  exports.OrderClient = OrderClient;
4605
+ exports.PaymentsClient = PaymentsClient;
4388
4606
  exports.ResponseUtils = ResponseUtils;
4389
4607
  exports.ShippingClient = ShippingClient;
4390
4608
  exports.StoreConfigClient = StoreConfigClient;