@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.mjs
CHANGED
|
@@ -1832,6 +1832,130 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
1832
1832
|
}));
|
|
1833
1833
|
}
|
|
1834
1834
|
/**
|
|
1835
|
+
* Get all available coupons
|
|
1836
|
+
*
|
|
1837
|
+
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
1838
|
+
* @returns Promise with all available coupons
|
|
1839
|
+
* @example
|
|
1840
|
+
* ```typescript
|
|
1841
|
+
* // Get all available coupons
|
|
1842
|
+
* const { data, error } = await sdk.cart.getAvailableCoupons();
|
|
1843
|
+
*
|
|
1844
|
+
* if (error) {
|
|
1845
|
+
* console.error("Failed to get available coupons:", error.message);
|
|
1846
|
+
* } else {
|
|
1847
|
+
* const coupons = data.coupons || [];
|
|
1848
|
+
* console.log("Available coupons:", coupons.length);
|
|
1849
|
+
* coupons.forEach(coupon => {
|
|
1850
|
+
* console.log("Coupon:", coupon.code, "Discount:", coupon.discount_amount);
|
|
1851
|
+
* });
|
|
1852
|
+
* }
|
|
1853
|
+
*
|
|
1854
|
+
* // Override customer group ID for this specific request
|
|
1855
|
+
* const { data: overrideData, error: overrideError } = await sdk.cart.getAvailableCoupons({
|
|
1856
|
+
* "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
|
|
1857
|
+
* });
|
|
1858
|
+
* ```
|
|
1859
|
+
*/
|
|
1860
|
+
async getAvailableCoupons(headers) {
|
|
1861
|
+
const mergedHeaders = this.mergeHeaders(headers);
|
|
1862
|
+
return this.executeRequest(() => this.client.GET("/carts/available-coupons", { params: { header: mergedHeaders } }));
|
|
1863
|
+
}
|
|
1864
|
+
/**
|
|
1865
|
+
* Get all available promotions
|
|
1866
|
+
*
|
|
1867
|
+
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
1868
|
+
* @returns Promise with all available promotions
|
|
1869
|
+
* @example
|
|
1870
|
+
* ```typescript
|
|
1871
|
+
* // Get all available promotions
|
|
1872
|
+
* const { data, error } = await sdk.cart.getAvailablePromotions();
|
|
1873
|
+
*
|
|
1874
|
+
* if (error) {
|
|
1875
|
+
* console.error("Failed to get available promotions:", error.message);
|
|
1876
|
+
* } else {
|
|
1877
|
+
* const promotions = data.promotions || [];
|
|
1878
|
+
* console.log("Available promotions:", promotions.length);
|
|
1879
|
+
* promotions.forEach(promotion => {
|
|
1880
|
+
* console.log("Promotion:", promotion.name, "Type:", promotion.promotion_type);
|
|
1881
|
+
* });
|
|
1882
|
+
* }
|
|
1883
|
+
*
|
|
1884
|
+
* // Override customer group ID for this specific request
|
|
1885
|
+
* const { data: overrideData, error: overrideError } = await sdk.cart.getAvailablePromotions({
|
|
1886
|
+
* "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
|
|
1887
|
+
* });
|
|
1888
|
+
* ```
|
|
1889
|
+
*/
|
|
1890
|
+
async getAvailablePromotions(headers) {
|
|
1891
|
+
const mergedHeaders = this.mergeHeaders(headers);
|
|
1892
|
+
return this.executeRequest(() => this.client.GET("/carts/available-promotions", { params: { header: mergedHeaders } }));
|
|
1893
|
+
}
|
|
1894
|
+
/**
|
|
1895
|
+
* Evaluate promotions
|
|
1896
|
+
*
|
|
1897
|
+
* @param cartId - The ID of the cart
|
|
1898
|
+
* @returns Promise with evaluated promotions
|
|
1899
|
+
* @example
|
|
1900
|
+
* ```typescript
|
|
1901
|
+
* const { data, error } = await sdk.cart.evaluatePromotions({
|
|
1902
|
+
* id: "01H9CART12345ABCDE"
|
|
1903
|
+
* });
|
|
1904
|
+
*
|
|
1905
|
+
* if (error) {
|
|
1906
|
+
* console.error("Failed to evaluate promotions:", error.message);
|
|
1907
|
+
* } else {
|
|
1908
|
+
* const applicable = data.applicable_promotions || [];
|
|
1909
|
+
* const inapplicable = data.inapplicable_promotions || [];
|
|
1910
|
+
*
|
|
1911
|
+
* console.log("Applicable promotions:", applicable.length);
|
|
1912
|
+
* applicable.forEach(promo => {
|
|
1913
|
+
* console.log(`- ${promo.name}: ${promo.savings_message}`);
|
|
1914
|
+
* });
|
|
1915
|
+
*
|
|
1916
|
+
* console.log("Inapplicable promotions:", inapplicable.length);
|
|
1917
|
+
* inapplicable.forEach(promo => {
|
|
1918
|
+
* console.log(`- ${promo.name}: ${promo.reason}`);
|
|
1919
|
+
* });
|
|
1920
|
+
* }
|
|
1921
|
+
* ```
|
|
1922
|
+
*/
|
|
1923
|
+
async evaluatePromotions(cartId) {
|
|
1924
|
+
return this.executeRequest(() => this.client.GET("/carts/{id}/evaluate-promotions", { params: { path: cartId } }));
|
|
1925
|
+
}
|
|
1926
|
+
/**
|
|
1927
|
+
* Evaluate coupons
|
|
1928
|
+
*
|
|
1929
|
+
* @param cartId - The ID of the cart
|
|
1930
|
+
* @returns Promise with evaluated coupons
|
|
1931
|
+
* @example
|
|
1932
|
+
* ```typescript
|
|
1933
|
+
* const { data, error } = await sdk.cart.evaluateCoupons({
|
|
1934
|
+
* id: "01H9CART12345ABCDE"
|
|
1935
|
+
* });
|
|
1936
|
+
*
|
|
1937
|
+
* if (error) {
|
|
1938
|
+
* console.error("Failed to evaluate coupons:", error.message);
|
|
1939
|
+
* } else {
|
|
1940
|
+
* const applicable = data.applicable_coupons || [];
|
|
1941
|
+
* const inapplicable = data.inapplicable_coupons || [];
|
|
1942
|
+
*
|
|
1943
|
+
* console.log("Applicable coupons:", applicable.length);
|
|
1944
|
+
* applicable.forEach(coupon => {
|
|
1945
|
+
* console.log(`- ${coupon.code}: Save $${coupon.estimated_discount}`);
|
|
1946
|
+
* });
|
|
1947
|
+
*
|
|
1948
|
+
* console.log("Inapplicable coupons:", inapplicable.length);
|
|
1949
|
+
* inapplicable.forEach(coupon => {
|
|
1950
|
+
* console.log(`- ${coupon.code}: ${coupon.reason}`);
|
|
1951
|
+
* });
|
|
1952
|
+
* }
|
|
1953
|
+
* ```
|
|
1954
|
+
*/
|
|
1955
|
+
async evaluateCoupons(cartId) {
|
|
1956
|
+
return this.executeRequest(() => this.client.GET("/carts/{id}/evaluate-coupons", { params: { path: cartId } }));
|
|
1957
|
+
}
|
|
1958
|
+
/**
|
|
1835
1959
|
* Redeem loyalty points
|
|
1836
1960
|
*
|
|
1837
1961
|
* @param cartId - The ID of the cart
|
|
@@ -1890,12 +2014,18 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
1890
2014
|
* @returns Promise with updated cart
|
|
1891
2015
|
* @example
|
|
1892
2016
|
* ```typescript
|
|
2017
|
+
* // For delivery fulfillment with shipments
|
|
1893
2018
|
* const { data, error } = await sdk.cart.updateFulfillmentPreference(
|
|
1894
2019
|
* { id: "01H9CART12345ABCDE" },
|
|
1895
2020
|
* {
|
|
1896
2021
|
* fulfillment_type: "delivery",
|
|
1897
|
-
*
|
|
1898
|
-
*
|
|
2022
|
+
* shipments: [
|
|
2023
|
+
* {
|
|
2024
|
+
* id: "01H9SHIP12345ABCDE",
|
|
2025
|
+
* shipping_provider_id: "01H9PROV12345FAST",
|
|
2026
|
+
* courier_company_id: "01H9COY12345FAST" // Optional
|
|
2027
|
+
* }
|
|
2028
|
+
* ]
|
|
1899
2029
|
* }
|
|
1900
2030
|
* );
|
|
1901
2031
|
*
|
|
@@ -1905,6 +2035,15 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
1905
2035
|
* console.log("Fulfillment preference updated:", data.cart.fulfillment_preference?.fulfillment_type);
|
|
1906
2036
|
* console.log("Shipping cost:", data.cart.shipping_amount);
|
|
1907
2037
|
* }
|
|
2038
|
+
*
|
|
2039
|
+
* // For collect-in-store fulfillment
|
|
2040
|
+
* const { data: collectData, error: collectError } = await sdk.cart.updateFulfillmentPreference(
|
|
2041
|
+
* { id: "01H9CART12345ABCDE" },
|
|
2042
|
+
* {
|
|
2043
|
+
* fulfillment_type: "collect-in-store",
|
|
2044
|
+
* pickup_location_id: "01H9STORE12345ABC"
|
|
2045
|
+
* }
|
|
2046
|
+
* );
|
|
1908
2047
|
* ```
|
|
1909
2048
|
*/
|
|
1910
2049
|
async updateFulfillmentPreference(cartId, body) {
|
|
@@ -1914,6 +2053,100 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
1914
2053
|
}));
|
|
1915
2054
|
}
|
|
1916
2055
|
/**
|
|
2056
|
+
* Check fulfillment serviceability
|
|
2057
|
+
*
|
|
2058
|
+
* Checks if fulfillment (delivery or collect-in-store) is available to the specified pincode
|
|
2059
|
+
* based on shipping zones and inventories.
|
|
2060
|
+
*
|
|
2061
|
+
* @param body - Fulfillment check body (cart-based or items-based)
|
|
2062
|
+
* @returns Promise with fulfillment serviceability result
|
|
2063
|
+
* @example
|
|
2064
|
+
* ```typescript
|
|
2065
|
+
* // Cart-based fulfillment check
|
|
2066
|
+
* const { data, error } = await sdk.cart.checkPincodeDeliverability({
|
|
2067
|
+
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
2068
|
+
* delivery_pincode: "400001",
|
|
2069
|
+
* fulfillment_type: "delivery" // optional: "delivery" | "collect-in-store"
|
|
2070
|
+
* });
|
|
2071
|
+
*
|
|
2072
|
+
* // Items-based fulfillment check
|
|
2073
|
+
* const { data, error } = await sdk.cart.checkPincodeDeliverability({
|
|
2074
|
+
* delivery_pincode: "400001",
|
|
2075
|
+
* items: [
|
|
2076
|
+
* { product_id: "prod_123", variant_id: "var_456" },
|
|
2077
|
+
* { product_id: "prod_789", variant_id: null }
|
|
2078
|
+
* ]
|
|
2079
|
+
* // fulfillment_type is optional
|
|
2080
|
+
* });
|
|
2081
|
+
*
|
|
2082
|
+
* if (error) {
|
|
2083
|
+
* console.error("Failed to check fulfillment serviceability:", error.message);
|
|
2084
|
+
* } else {
|
|
2085
|
+
* console.log("Serviceable:", data.is_serviceable);
|
|
2086
|
+
*
|
|
2087
|
+
* if (!data.is_serviceable && data.unserviceable_items) {
|
|
2088
|
+
* data.unserviceable_items.forEach(item => {
|
|
2089
|
+
* console.log(`Unserviceable: ${item.product_name}, max available: ${item.max_available_quantity}`);
|
|
2090
|
+
* });
|
|
2091
|
+
* }
|
|
2092
|
+
* }
|
|
2093
|
+
* ```
|
|
2094
|
+
*/
|
|
2095
|
+
async checkPincodeDeliverability(body) {
|
|
2096
|
+
return this.executeRequest(() => this.client.POST("/fulfillment/serviceability", { body }));
|
|
2097
|
+
}
|
|
2098
|
+
/**
|
|
2099
|
+
* Get fulfillment options for an order
|
|
2100
|
+
*
|
|
2101
|
+
* @param body - Fulfillment options body containing cart_id and delivery_pincode
|
|
2102
|
+
* @returns Promise with fulfillment options including collect and delivery methods
|
|
2103
|
+
* @example
|
|
2104
|
+
* ```typescript
|
|
2105
|
+
* const { data, error } = await sdk.cart.getFulfillmentOptions({
|
|
2106
|
+
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
2107
|
+
* delivery_pincode: "400001"
|
|
2108
|
+
* });
|
|
2109
|
+
*
|
|
2110
|
+
* if (error) {
|
|
2111
|
+
* console.error("Failed to get fulfillment options:", error.message);
|
|
2112
|
+
* } else {
|
|
2113
|
+
* // Check summary information
|
|
2114
|
+
* console.log("Collect available:", data.summary.collect_available);
|
|
2115
|
+
* console.log("Deliver available:", data.summary.deliver_available);
|
|
2116
|
+
* console.log("Recommended fulfillment type:", data.summary.recommended_fulfillment_type);
|
|
2117
|
+
*
|
|
2118
|
+
* // Access collect options
|
|
2119
|
+
* if (data.collect && data.collect.length > 0) {
|
|
2120
|
+
* console.log("Available stores for collection:");
|
|
2121
|
+
* data.collect.forEach(store => {
|
|
2122
|
+
* console.log(`${store.name} - ${store.distance_km}km away, ETA: ${store.collect_eta_minutes} minutes`);
|
|
2123
|
+
* });
|
|
2124
|
+
* }
|
|
2125
|
+
*
|
|
2126
|
+
* // Access delivery options (with shipments)
|
|
2127
|
+
* if (data.deliver && data.deliver.is_serviceable) {
|
|
2128
|
+
* console.log("Available shipments and shipping methods:");
|
|
2129
|
+
* data.deliver.shipments.forEach(shipment => {
|
|
2130
|
+
* console.log(`Shipment ${shipment.id}:`);
|
|
2131
|
+
* console.log(` Items: ${shipment.items.length}`);
|
|
2132
|
+
* shipment.shipping_methods.forEach(method => {
|
|
2133
|
+
* console.log(` - ${method.name}: ${method.shipping_amount}, ${method.estimated_delivery_days} days`);
|
|
2134
|
+
* // Access courier companies for auto shipping methods
|
|
2135
|
+
* if (method.courier_companies) {
|
|
2136
|
+
* method.courier_companies.forEach(courier => {
|
|
2137
|
+
* console.log(` Courier: ${courier.name} - ${courier.shipping_amount}, ${courier.estimated_delivery_days} days`);
|
|
2138
|
+
* });
|
|
2139
|
+
* }
|
|
2140
|
+
* });
|
|
2141
|
+
* });
|
|
2142
|
+
* }
|
|
2143
|
+
* }
|
|
2144
|
+
* ```
|
|
2145
|
+
*/
|
|
2146
|
+
async getFulfillmentOptions(body) {
|
|
2147
|
+
return this.executeRequest(() => this.client.POST("/carts/fulfillment-options", { body }));
|
|
2148
|
+
}
|
|
2149
|
+
/**
|
|
1917
2150
|
* Use credit balance
|
|
1918
2151
|
*
|
|
1919
2152
|
* @param cartId - The ID of the cart
|
|
@@ -2049,130 +2282,6 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
2049
2282
|
body
|
|
2050
2283
|
}));
|
|
2051
2284
|
}
|
|
2052
|
-
/**
|
|
2053
|
-
* Get all available coupons
|
|
2054
|
-
*
|
|
2055
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
2056
|
-
* @returns Promise with all available coupons
|
|
2057
|
-
* @example
|
|
2058
|
-
* ```typescript
|
|
2059
|
-
* // Get all available coupons
|
|
2060
|
-
* const { data, error } = await sdk.cart.getAvailableCoupons();
|
|
2061
|
-
*
|
|
2062
|
-
* if (error) {
|
|
2063
|
-
* console.error("Failed to get available coupons:", error.message);
|
|
2064
|
-
* } else {
|
|
2065
|
-
* const coupons = data.coupons || [];
|
|
2066
|
-
* console.log("Available coupons:", coupons.length);
|
|
2067
|
-
* coupons.forEach(coupon => {
|
|
2068
|
-
* console.log("Coupon:", coupon.code, "Discount:", coupon.discount_amount);
|
|
2069
|
-
* });
|
|
2070
|
-
* }
|
|
2071
|
-
*
|
|
2072
|
-
* // Override customer group ID for this specific request
|
|
2073
|
-
* const { data: overrideData, error: overrideError } = await sdk.cart.getAvailableCoupons({
|
|
2074
|
-
* "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
|
|
2075
|
-
* });
|
|
2076
|
-
* ```
|
|
2077
|
-
*/
|
|
2078
|
-
async getAvailableCoupons(headers) {
|
|
2079
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
2080
|
-
return this.executeRequest(() => this.client.GET("/carts/available-coupons", { params: { header: mergedHeaders } }));
|
|
2081
|
-
}
|
|
2082
|
-
/**
|
|
2083
|
-
* Get all available promotions
|
|
2084
|
-
*
|
|
2085
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
2086
|
-
* @returns Promise with all available promotions
|
|
2087
|
-
* @example
|
|
2088
|
-
* ```typescript
|
|
2089
|
-
* // Get all available promotions
|
|
2090
|
-
* const { data, error } = await sdk.cart.getAvailablePromotions();
|
|
2091
|
-
*
|
|
2092
|
-
* if (error) {
|
|
2093
|
-
* console.error("Failed to get available promotions:", error.message);
|
|
2094
|
-
* } else {
|
|
2095
|
-
* const promotions = data.promotions || [];
|
|
2096
|
-
* console.log("Available promotions:", promotions.length);
|
|
2097
|
-
* promotions.forEach(promotion => {
|
|
2098
|
-
* console.log("Promotion:", promotion.name, "Type:", promotion.promotion_type);
|
|
2099
|
-
* });
|
|
2100
|
-
* }
|
|
2101
|
-
*
|
|
2102
|
-
* // Override customer group ID for this specific request
|
|
2103
|
-
* const { data: overrideData, error: overrideError } = await sdk.cart.getAvailablePromotions({
|
|
2104
|
-
* "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
|
|
2105
|
-
* });
|
|
2106
|
-
* ```
|
|
2107
|
-
*/
|
|
2108
|
-
async getAvailablePromotions(headers) {
|
|
2109
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
2110
|
-
return this.executeRequest(() => this.client.GET("/carts/available-promotions", { params: { header: mergedHeaders } }));
|
|
2111
|
-
}
|
|
2112
|
-
/**
|
|
2113
|
-
* Evaluate promotions
|
|
2114
|
-
*
|
|
2115
|
-
* @param cartId - The ID of the cart
|
|
2116
|
-
* @returns Promise with evaluated promotions
|
|
2117
|
-
* @example
|
|
2118
|
-
* ```typescript
|
|
2119
|
-
* const { data, error } = await sdk.cart.evaluatePromotions({
|
|
2120
|
-
* id: "01H9CART12345ABCDE"
|
|
2121
|
-
* });
|
|
2122
|
-
*
|
|
2123
|
-
* if (error) {
|
|
2124
|
-
* console.error("Failed to evaluate promotions:", error.message);
|
|
2125
|
-
* } else {
|
|
2126
|
-
* const applicable = data.applicable_promotions || [];
|
|
2127
|
-
* const inapplicable = data.inapplicable_promotions || [];
|
|
2128
|
-
*
|
|
2129
|
-
* console.log("Applicable promotions:", applicable.length);
|
|
2130
|
-
* applicable.forEach(promo => {
|
|
2131
|
-
* console.log(`- ${promo.name}: ${promo.savings_message}`);
|
|
2132
|
-
* });
|
|
2133
|
-
*
|
|
2134
|
-
* console.log("Inapplicable promotions:", inapplicable.length);
|
|
2135
|
-
* inapplicable.forEach(promo => {
|
|
2136
|
-
* console.log(`- ${promo.name}: ${promo.reason}`);
|
|
2137
|
-
* });
|
|
2138
|
-
* }
|
|
2139
|
-
* ```
|
|
2140
|
-
*/
|
|
2141
|
-
async evaluatePromotions(cartId) {
|
|
2142
|
-
return this.executeRequest(() => this.client.GET("/carts/{id}/evaluate-promotions", { params: { path: cartId } }));
|
|
2143
|
-
}
|
|
2144
|
-
/**
|
|
2145
|
-
* Evaluate coupons
|
|
2146
|
-
*
|
|
2147
|
-
* @param cartId - The ID of the cart
|
|
2148
|
-
* @returns Promise with evaluated coupons
|
|
2149
|
-
* @example
|
|
2150
|
-
* ```typescript
|
|
2151
|
-
* const { data, error } = await sdk.cart.evaluateCoupons({
|
|
2152
|
-
* id: "01H9CART12345ABCDE"
|
|
2153
|
-
* });
|
|
2154
|
-
*
|
|
2155
|
-
* if (error) {
|
|
2156
|
-
* console.error("Failed to evaluate coupons:", error.message);
|
|
2157
|
-
* } else {
|
|
2158
|
-
* const applicable = data.applicable_coupons || [];
|
|
2159
|
-
* const inapplicable = data.inapplicable_coupons || [];
|
|
2160
|
-
*
|
|
2161
|
-
* console.log("Applicable coupons:", applicable.length);
|
|
2162
|
-
* applicable.forEach(coupon => {
|
|
2163
|
-
* console.log(`- ${coupon.code}: Save $${coupon.estimated_discount}`);
|
|
2164
|
-
* });
|
|
2165
|
-
*
|
|
2166
|
-
* console.log("Inapplicable coupons:", inapplicable.length);
|
|
2167
|
-
* inapplicable.forEach(coupon => {
|
|
2168
|
-
* console.log(`- ${coupon.code}: ${coupon.reason}`);
|
|
2169
|
-
* });
|
|
2170
|
-
* }
|
|
2171
|
-
* ```
|
|
2172
|
-
*/
|
|
2173
|
-
async evaluateCoupons(cartId) {
|
|
2174
|
-
return this.executeRequest(() => this.client.GET("/carts/{id}/evaluate-coupons", { params: { path: cartId } }));
|
|
2175
|
-
}
|
|
2176
2285
|
};
|
|
2177
2286
|
|
|
2178
2287
|
//#endregion
|
|
@@ -3220,10 +3329,14 @@ var PaymentsClient = class extends StorefrontAPIClient {
|
|
|
3220
3329
|
/**
|
|
3221
3330
|
* List all available payment methods
|
|
3222
3331
|
*
|
|
3332
|
+
* @param queryParams - Query parameters containing the payment method type and payment provider slug
|
|
3223
3333
|
* @returns Promise with list of payment methods
|
|
3224
3334
|
* @example
|
|
3225
3335
|
* ```typescript
|
|
3226
|
-
* const { data, error } = await sdk.payments.listPaymentMethods(
|
|
3336
|
+
* const { data, error } = await sdk.payments.listPaymentMethods({
|
|
3337
|
+
* payment_method_type: "card",
|
|
3338
|
+
* payment_provider_slug: "payu"
|
|
3339
|
+
* });
|
|
3227
3340
|
*
|
|
3228
3341
|
* if (error) {
|
|
3229
3342
|
* console.error("Failed to list payment methods:", error.message);
|
|
@@ -3237,8 +3350,8 @@ var PaymentsClient = class extends StorefrontAPIClient {
|
|
|
3237
3350
|
* }
|
|
3238
3351
|
* ```
|
|
3239
3352
|
*/
|
|
3240
|
-
async listPaymentMethods() {
|
|
3241
|
-
return this.executeRequest(() => this.client.GET("/payments/payment-methods", {}));
|
|
3353
|
+
async listPaymentMethods(queryParams) {
|
|
3354
|
+
return this.executeRequest(() => this.client.GET("/payments/payment-methods", { params: { query: queryParams } }));
|
|
3242
3355
|
}
|
|
3243
3356
|
/**
|
|
3244
3357
|
* Verify a UPI Virtual Payment Address (VPA)
|
|
@@ -3273,6 +3386,29 @@ var PaymentsClient = class extends StorefrontAPIClient {
|
|
|
3273
3386
|
return this.executeRequest(() => this.client.GET("/payments/verify-vpa", { params: { query: queryParams } }));
|
|
3274
3387
|
}
|
|
3275
3388
|
/**
|
|
3389
|
+
* Get card information
|
|
3390
|
+
*
|
|
3391
|
+
* Retrieves card information based on the initial 9 digits (card BIN) of the card number.
|
|
3392
|
+
*
|
|
3393
|
+
* @param queryParams - Query parameters containing the card BIN
|
|
3394
|
+
* @returns Promise with card information
|
|
3395
|
+
* @example
|
|
3396
|
+
* ```typescript
|
|
3397
|
+
* const { data, error } = await sdk.payments.getCardInfo({
|
|
3398
|
+
* cardbin: "411111111"
|
|
3399
|
+
* });
|
|
3400
|
+
*
|
|
3401
|
+
* if (error) {
|
|
3402
|
+
* console.error("Failed to get card information:", error.message);
|
|
3403
|
+
* } else {
|
|
3404
|
+
* console.log("Card information:", data.card_info);
|
|
3405
|
+
* }
|
|
3406
|
+
* ```
|
|
3407
|
+
*/
|
|
3408
|
+
async getCardInfo(queryParams) {
|
|
3409
|
+
return this.executeRequest(() => this.client.GET("/payments/card-info", { params: { query: queryParams } }));
|
|
3410
|
+
}
|
|
3411
|
+
/**
|
|
3276
3412
|
* Authenticate a direct OTP for payment verification
|
|
3277
3413
|
*
|
|
3278
3414
|
* @description Used to authenticate OTP during payment flows that require 2FA verification.
|
|
@@ -3331,82 +3467,6 @@ var PaymentsClient = class extends StorefrontAPIClient {
|
|
|
3331
3467
|
}
|
|
3332
3468
|
};
|
|
3333
3469
|
|
|
3334
|
-
//#endregion
|
|
3335
|
-
//#region src/lib/shipping.ts
|
|
3336
|
-
/**
|
|
3337
|
-
* Client for interacting with shipping endpoints
|
|
3338
|
-
*/
|
|
3339
|
-
var ShippingClient = class extends StorefrontAPIClient {
|
|
3340
|
-
/**
|
|
3341
|
-
* Check pincode deliverability
|
|
3342
|
-
*
|
|
3343
|
-
* @param pathParams - Path parameters
|
|
3344
|
-
* @returns Promise with pincode deliverability result
|
|
3345
|
-
* @example
|
|
3346
|
-
* ```typescript
|
|
3347
|
-
* const { data, error } = await sdk.shipping.checkPincodeDeliverability({
|
|
3348
|
-
* pincode: "400001"
|
|
3349
|
-
* });
|
|
3350
|
-
*
|
|
3351
|
-
* if (error) {
|
|
3352
|
-
* console.error("Failed to check pincode serviceability:", error.message);
|
|
3353
|
-
* } else {
|
|
3354
|
-
* console.log("Pincode serviceable:", data.is_serviceable);
|
|
3355
|
-
*
|
|
3356
|
-
* if (data.is_serviceable) {
|
|
3357
|
-
* console.log("Delivery is available to this pincode");
|
|
3358
|
-
* } else {
|
|
3359
|
-
* console.log("Delivery is not available to this pincode");
|
|
3360
|
-
* }
|
|
3361
|
-
* }
|
|
3362
|
-
* ```
|
|
3363
|
-
*/
|
|
3364
|
-
async checkPincodeDeliverability(pathParams) {
|
|
3365
|
-
return this.executeRequest(() => this.client.GET("/shipping/serviceability/{pincode}", { params: { path: pathParams } }));
|
|
3366
|
-
}
|
|
3367
|
-
/**
|
|
3368
|
-
* Get fulfillment options for an order
|
|
3369
|
-
*
|
|
3370
|
-
* @param body - Fulfillment options body containing cart_id and delivery_pincode
|
|
3371
|
-
* @returns Promise with fulfillment options including collect and delivery methods
|
|
3372
|
-
* @example
|
|
3373
|
-
* ```typescript
|
|
3374
|
-
* const { data, error } = await sdk.shipping.getFulfillmentOptions({
|
|
3375
|
-
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
3376
|
-
* delivery_pincode: "400001"
|
|
3377
|
-
* });
|
|
3378
|
-
*
|
|
3379
|
-
* if (error) {
|
|
3380
|
-
* console.error("Failed to get fulfillment options:", error.message);
|
|
3381
|
-
* } else {
|
|
3382
|
-
* // Check summary information
|
|
3383
|
-
* console.log("Collect available:", data.summary.collect_available);
|
|
3384
|
-
* console.log("Deliver available:", data.summary.deliver_available);
|
|
3385
|
-
* console.log("Recommended fulfillment type:", data.summary.recommended_fulfillment_type);
|
|
3386
|
-
*
|
|
3387
|
-
* // Access collect options
|
|
3388
|
-
* if (data.collect && data.collect.length > 0) {
|
|
3389
|
-
* console.log("Available stores for collection:");
|
|
3390
|
-
* data.collect.forEach(store => {
|
|
3391
|
-
* console.log(`${store.name} - ${store.distance_km}km away, ETA: ${store.collect_eta_minutes} minutes`);
|
|
3392
|
-
* });
|
|
3393
|
-
* }
|
|
3394
|
-
*
|
|
3395
|
-
* // Access delivery options
|
|
3396
|
-
* if (data.deliver && data.deliver.is_serviceable) {
|
|
3397
|
-
* console.log("Available shipping methods:");
|
|
3398
|
-
* data.deliver.shipping_methods.forEach(method => {
|
|
3399
|
-
* console.log(`${method.name} - ${method.shipping_amount}, ${method.estimated_delivery_days} days`);
|
|
3400
|
-
* });
|
|
3401
|
-
* }
|
|
3402
|
-
* }
|
|
3403
|
-
* ```
|
|
3404
|
-
*/
|
|
3405
|
-
async getFulfillmentOptions(body) {
|
|
3406
|
-
return this.executeRequest(() => this.client.POST("/shipping/fulfillment-options", { body }));
|
|
3407
|
-
}
|
|
3408
|
-
};
|
|
3409
|
-
|
|
3410
3470
|
//#endregion
|
|
3411
3471
|
//#region src/lib/helper.ts
|
|
3412
3472
|
/**
|
|
@@ -3864,6 +3924,29 @@ var CustomerClient = class extends StorefrontAPIClient {
|
|
|
3864
3924
|
async listSavedPaymentMethods(pathParams) {
|
|
3865
3925
|
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/payment-methods", { params: { path: pathParams } }));
|
|
3866
3926
|
}
|
|
3927
|
+
/**
|
|
3928
|
+
* List all saved cards for a customer
|
|
3929
|
+
*
|
|
3930
|
+
* @param pathParams - Path parameters
|
|
3931
|
+
* @returns Promise with cards
|
|
3932
|
+
*
|
|
3933
|
+
* @example
|
|
3934
|
+
* ```typescript
|
|
3935
|
+
* const { data, error } = await sdk.customer.listCustomerCards({
|
|
3936
|
+
* customer_id: "customer_123"
|
|
3937
|
+
* });
|
|
3938
|
+
*
|
|
3939
|
+
* if (error) {
|
|
3940
|
+
* console.error("Failed to list customer cards:", error);
|
|
3941
|
+
* return;
|
|
3942
|
+
* }
|
|
3943
|
+
*
|
|
3944
|
+
* console.log("Customer cards:", data.cards);
|
|
3945
|
+
* ```
|
|
3946
|
+
*/
|
|
3947
|
+
async listCustomerCards(pathParams) {
|
|
3948
|
+
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/cards", { params: { path: pathParams } }));
|
|
3949
|
+
}
|
|
3867
3950
|
};
|
|
3868
3951
|
|
|
3869
3952
|
//#endregion
|
|
@@ -3926,10 +4009,6 @@ var StorefrontSDK = class {
|
|
|
3926
4009
|
*/
|
|
3927
4010
|
helpers;
|
|
3928
4011
|
/**
|
|
3929
|
-
* Client for shipping-related endpoints
|
|
3930
|
-
*/
|
|
3931
|
-
shipping;
|
|
3932
|
-
/**
|
|
3933
4012
|
* Client for order-related endpoints
|
|
3934
4013
|
*/
|
|
3935
4014
|
order;
|
|
@@ -3972,7 +4051,6 @@ var StorefrontSDK = class {
|
|
|
3972
4051
|
this.auth = new AuthClient(config);
|
|
3973
4052
|
this.customer = new CustomerClient(config);
|
|
3974
4053
|
this.helpers = new HelpersClient(config);
|
|
3975
|
-
this.shipping = new ShippingClient(config);
|
|
3976
4054
|
this.order = new OrderClient(config);
|
|
3977
4055
|
this.payments = new PaymentsClient(config);
|
|
3978
4056
|
this.store = new StoreConfigClient(config);
|
|
@@ -3993,7 +4071,6 @@ var StorefrontSDK = class {
|
|
|
3993
4071
|
await this.auth.setTokens(accessToken, refreshToken);
|
|
3994
4072
|
await this.customer.setTokens(accessToken, refreshToken);
|
|
3995
4073
|
await this.helpers.setTokens(accessToken, refreshToken);
|
|
3996
|
-
await this.shipping.setTokens(accessToken, refreshToken);
|
|
3997
4074
|
await this.order.setTokens(accessToken, refreshToken);
|
|
3998
4075
|
await this.payments.setTokens(accessToken, refreshToken);
|
|
3999
4076
|
await this.store.setTokens(accessToken, refreshToken);
|
|
@@ -4011,7 +4088,6 @@ var StorefrontSDK = class {
|
|
|
4011
4088
|
await this.auth.clearTokens();
|
|
4012
4089
|
await this.customer.clearTokens();
|
|
4013
4090
|
await this.helpers.clearTokens();
|
|
4014
|
-
await this.shipping.clearTokens();
|
|
4015
4091
|
await this.order.clearTokens();
|
|
4016
4092
|
await this.payments.clearTokens();
|
|
4017
4093
|
await this.store.clearTokens();
|
|
@@ -4027,7 +4103,6 @@ var StorefrontSDK = class {
|
|
|
4027
4103
|
this.auth.setApiKey(apiKey);
|
|
4028
4104
|
this.customer.setApiKey(apiKey);
|
|
4029
4105
|
this.helpers.setApiKey(apiKey);
|
|
4030
|
-
this.shipping.setApiKey(apiKey);
|
|
4031
4106
|
this.order.setApiKey(apiKey);
|
|
4032
4107
|
this.payments.setApiKey(apiKey);
|
|
4033
4108
|
this.store.setApiKey(apiKey);
|
|
@@ -4041,7 +4116,6 @@ var StorefrontSDK = class {
|
|
|
4041
4116
|
this.auth.clearApiKey();
|
|
4042
4117
|
this.customer.clearApiKey();
|
|
4043
4118
|
this.helpers.clearApiKey();
|
|
4044
|
-
this.shipping.clearApiKey();
|
|
4045
4119
|
this.order.clearApiKey();
|
|
4046
4120
|
this.payments.clearApiKey();
|
|
4047
4121
|
this.store.clearApiKey();
|
|
@@ -4120,7 +4194,6 @@ var StorefrontSDK = class {
|
|
|
4120
4194
|
this.auth.setDefaultHeaders(headers);
|
|
4121
4195
|
this.customer.setDefaultHeaders(headers);
|
|
4122
4196
|
this.helpers.setDefaultHeaders(headers);
|
|
4123
|
-
this.shipping.setDefaultHeaders(headers);
|
|
4124
4197
|
this.order.setDefaultHeaders(headers);
|
|
4125
4198
|
this.payments.setDefaultHeaders(headers);
|
|
4126
4199
|
this.store.setDefaultHeaders(headers);
|
|
@@ -4137,5 +4210,5 @@ var StorefrontSDK = class {
|
|
|
4137
4210
|
var src_default = StorefrontSDK;
|
|
4138
4211
|
|
|
4139
4212
|
//#endregion
|
|
4140
|
-
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, PaymentsClient, ResponseUtils,
|
|
4213
|
+
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, PaymentsClient, ResponseUtils, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, src_default as default };
|
|
4141
4214
|
//# sourceMappingURL=index.mjs.map
|