@basedone/core 0.2.5 → 0.2.6
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/{chunk-P5C65GIG.mjs → chunk-CAU4QLVH.mjs} +18 -0
- package/dist/ecommerce.d.mts +48 -12
- package/dist/ecommerce.d.ts +48 -12
- package/dist/ecommerce.js +18 -0
- package/dist/ecommerce.mjs +1 -1
- package/dist/index.js +18 -0
- package/dist/index.mjs +1 -1
- package/lib/ecommerce/client/customer.ts +18 -0
- package/lib/ecommerce/types/entities.ts +20 -8
- package/lib/ecommerce/types/requests.ts +17 -4
- package/package.json +1 -1
|
@@ -387,11 +387,28 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
387
387
|
*
|
|
388
388
|
* Supports multi-merchant checkout - automatically splits orders by merchant.
|
|
389
389
|
*
|
|
390
|
+
* **IMPORTANT: Shipping Cost Security**
|
|
391
|
+
* - Use `shippingRateId` to specify the selected shipping rate
|
|
392
|
+
* - The server calculates shipping cost from the rate ID (never trust frontend costs)
|
|
393
|
+
* - Get available rates from `calculateShippingOptions()` first
|
|
394
|
+
*
|
|
390
395
|
* @param request - Order creation request
|
|
391
396
|
* @returns Created order(s) with payment instructions
|
|
392
397
|
*
|
|
393
398
|
* @example
|
|
394
399
|
* ```typescript
|
|
400
|
+
* // Step 1: Calculate available shipping options
|
|
401
|
+
* const shippingOptions = await client.calculateShippingOptions({
|
|
402
|
+
* merchantId: "merchant_123",
|
|
403
|
+
* destinationCountry: "US",
|
|
404
|
+
* cartItems: [{ productId: "prod_123", quantity: 2, priceUSDC: 29.99 }],
|
|
405
|
+
* orderSubtotal: 59.98
|
|
406
|
+
* });
|
|
407
|
+
*
|
|
408
|
+
* // Step 2: Let user select a shipping option, get the rateId
|
|
409
|
+
* const selectedRateId = shippingOptions.shippingOptions[0].rateId;
|
|
410
|
+
*
|
|
411
|
+
* // Step 3: Create order with shippingRateId (server validates and calculates cost)
|
|
395
412
|
* const result = await client.createOrder({
|
|
396
413
|
* items: [
|
|
397
414
|
* { productId: "prod_123", quantity: 2 },
|
|
@@ -407,6 +424,7 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
407
424
|
* postalCode: "10001",
|
|
408
425
|
* country: "US"
|
|
409
426
|
* },
|
|
427
|
+
* shippingRateId: selectedRateId, // Server validates and calculates cost
|
|
410
428
|
* couponCode: "SAVE10"
|
|
411
429
|
* });
|
|
412
430
|
*
|
package/dist/ecommerce.d.mts
CHANGED
|
@@ -1241,18 +1241,30 @@ interface ShippingRate extends BaseEntity {
|
|
|
1241
1241
|
}
|
|
1242
1242
|
/**
|
|
1243
1243
|
* Shipping option (calculated for checkout)
|
|
1244
|
+
*
|
|
1245
|
+
* Use `rateId` when creating orders - the server will validate and calculate cost.
|
|
1244
1246
|
*/
|
|
1245
1247
|
interface ShippingOption {
|
|
1246
|
-
/** Rate ID */
|
|
1247
|
-
|
|
1248
|
-
/** Rate name */
|
|
1249
|
-
name: string;
|
|
1250
|
-
/** Calculated cost in USDC */
|
|
1251
|
-
cost: number;
|
|
1252
|
-
/** Estimated delivery string */
|
|
1253
|
-
estimatedDelivery: string;
|
|
1248
|
+
/** Rate ID - use this when creating orders */
|
|
1249
|
+
rateId: string;
|
|
1254
1250
|
/** Zone name */
|
|
1255
1251
|
zoneName: string;
|
|
1252
|
+
/** Rate name (e.g., "Standard", "Express") */
|
|
1253
|
+
rateName: string;
|
|
1254
|
+
/** Base rate in USDC */
|
|
1255
|
+
baseRate: number;
|
|
1256
|
+
/** Per-kg rate in USDC */
|
|
1257
|
+
perKgRate: number;
|
|
1258
|
+
/** Calculated total cost in USDC (for display only - server recalculates) */
|
|
1259
|
+
calculatedCost: number;
|
|
1260
|
+
/** Whether free shipping applies */
|
|
1261
|
+
isFree: boolean;
|
|
1262
|
+
/** Estimated delivery string (e.g., "5-7 business days") */
|
|
1263
|
+
estimatedDelivery: string | null;
|
|
1264
|
+
/** Minimum delivery days */
|
|
1265
|
+
minDeliveryDays: number | null;
|
|
1266
|
+
/** Maximum delivery days */
|
|
1267
|
+
maxDeliveryDays: number | null;
|
|
1256
1268
|
}
|
|
1257
1269
|
|
|
1258
1270
|
/**
|
|
@@ -1386,13 +1398,19 @@ interface CreateOrderRequest {
|
|
|
1386
1398
|
couponCode?: string;
|
|
1387
1399
|
/** Idempotency key */
|
|
1388
1400
|
idempotencyKey?: string;
|
|
1389
|
-
/**
|
|
1401
|
+
/**
|
|
1402
|
+
* Selected shipping rate ID (from shipping calculator)
|
|
1403
|
+
* The server will validate this rate and calculate the cost server-side.
|
|
1404
|
+
* SECURITY: The cost is never trusted from the frontend.
|
|
1405
|
+
*/
|
|
1406
|
+
shippingRateId?: string;
|
|
1407
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
1390
1408
|
shippingMethod?: string;
|
|
1391
|
-
/**
|
|
1409
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
1392
1410
|
shippingCost?: number;
|
|
1393
|
-
/**
|
|
1411
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
1394
1412
|
shippingZone?: string;
|
|
1395
|
-
/**
|
|
1413
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
1396
1414
|
estimatedDelivery?: string;
|
|
1397
1415
|
}
|
|
1398
1416
|
/**
|
|
@@ -3198,11 +3216,28 @@ declare class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
3198
3216
|
*
|
|
3199
3217
|
* Supports multi-merchant checkout - automatically splits orders by merchant.
|
|
3200
3218
|
*
|
|
3219
|
+
* **IMPORTANT: Shipping Cost Security**
|
|
3220
|
+
* - Use `shippingRateId` to specify the selected shipping rate
|
|
3221
|
+
* - The server calculates shipping cost from the rate ID (never trust frontend costs)
|
|
3222
|
+
* - Get available rates from `calculateShippingOptions()` first
|
|
3223
|
+
*
|
|
3201
3224
|
* @param request - Order creation request
|
|
3202
3225
|
* @returns Created order(s) with payment instructions
|
|
3203
3226
|
*
|
|
3204
3227
|
* @example
|
|
3205
3228
|
* ```typescript
|
|
3229
|
+
* // Step 1: Calculate available shipping options
|
|
3230
|
+
* const shippingOptions = await client.calculateShippingOptions({
|
|
3231
|
+
* merchantId: "merchant_123",
|
|
3232
|
+
* destinationCountry: "US",
|
|
3233
|
+
* cartItems: [{ productId: "prod_123", quantity: 2, priceUSDC: 29.99 }],
|
|
3234
|
+
* orderSubtotal: 59.98
|
|
3235
|
+
* });
|
|
3236
|
+
*
|
|
3237
|
+
* // Step 2: Let user select a shipping option, get the rateId
|
|
3238
|
+
* const selectedRateId = shippingOptions.shippingOptions[0].rateId;
|
|
3239
|
+
*
|
|
3240
|
+
* // Step 3: Create order with shippingRateId (server validates and calculates cost)
|
|
3206
3241
|
* const result = await client.createOrder({
|
|
3207
3242
|
* items: [
|
|
3208
3243
|
* { productId: "prod_123", quantity: 2 },
|
|
@@ -3218,6 +3253,7 @@ declare class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
3218
3253
|
* postalCode: "10001",
|
|
3219
3254
|
* country: "US"
|
|
3220
3255
|
* },
|
|
3256
|
+
* shippingRateId: selectedRateId, // Server validates and calculates cost
|
|
3221
3257
|
* couponCode: "SAVE10"
|
|
3222
3258
|
* });
|
|
3223
3259
|
*
|
package/dist/ecommerce.d.ts
CHANGED
|
@@ -1241,18 +1241,30 @@ interface ShippingRate extends BaseEntity {
|
|
|
1241
1241
|
}
|
|
1242
1242
|
/**
|
|
1243
1243
|
* Shipping option (calculated for checkout)
|
|
1244
|
+
*
|
|
1245
|
+
* Use `rateId` when creating orders - the server will validate and calculate cost.
|
|
1244
1246
|
*/
|
|
1245
1247
|
interface ShippingOption {
|
|
1246
|
-
/** Rate ID */
|
|
1247
|
-
|
|
1248
|
-
/** Rate name */
|
|
1249
|
-
name: string;
|
|
1250
|
-
/** Calculated cost in USDC */
|
|
1251
|
-
cost: number;
|
|
1252
|
-
/** Estimated delivery string */
|
|
1253
|
-
estimatedDelivery: string;
|
|
1248
|
+
/** Rate ID - use this when creating orders */
|
|
1249
|
+
rateId: string;
|
|
1254
1250
|
/** Zone name */
|
|
1255
1251
|
zoneName: string;
|
|
1252
|
+
/** Rate name (e.g., "Standard", "Express") */
|
|
1253
|
+
rateName: string;
|
|
1254
|
+
/** Base rate in USDC */
|
|
1255
|
+
baseRate: number;
|
|
1256
|
+
/** Per-kg rate in USDC */
|
|
1257
|
+
perKgRate: number;
|
|
1258
|
+
/** Calculated total cost in USDC (for display only - server recalculates) */
|
|
1259
|
+
calculatedCost: number;
|
|
1260
|
+
/** Whether free shipping applies */
|
|
1261
|
+
isFree: boolean;
|
|
1262
|
+
/** Estimated delivery string (e.g., "5-7 business days") */
|
|
1263
|
+
estimatedDelivery: string | null;
|
|
1264
|
+
/** Minimum delivery days */
|
|
1265
|
+
minDeliveryDays: number | null;
|
|
1266
|
+
/** Maximum delivery days */
|
|
1267
|
+
maxDeliveryDays: number | null;
|
|
1256
1268
|
}
|
|
1257
1269
|
|
|
1258
1270
|
/**
|
|
@@ -1386,13 +1398,19 @@ interface CreateOrderRequest {
|
|
|
1386
1398
|
couponCode?: string;
|
|
1387
1399
|
/** Idempotency key */
|
|
1388
1400
|
idempotencyKey?: string;
|
|
1389
|
-
/**
|
|
1401
|
+
/**
|
|
1402
|
+
* Selected shipping rate ID (from shipping calculator)
|
|
1403
|
+
* The server will validate this rate and calculate the cost server-side.
|
|
1404
|
+
* SECURITY: The cost is never trusted from the frontend.
|
|
1405
|
+
*/
|
|
1406
|
+
shippingRateId?: string;
|
|
1407
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
1390
1408
|
shippingMethod?: string;
|
|
1391
|
-
/**
|
|
1409
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
1392
1410
|
shippingCost?: number;
|
|
1393
|
-
/**
|
|
1411
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
1394
1412
|
shippingZone?: string;
|
|
1395
|
-
/**
|
|
1413
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
1396
1414
|
estimatedDelivery?: string;
|
|
1397
1415
|
}
|
|
1398
1416
|
/**
|
|
@@ -3198,11 +3216,28 @@ declare class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
3198
3216
|
*
|
|
3199
3217
|
* Supports multi-merchant checkout - automatically splits orders by merchant.
|
|
3200
3218
|
*
|
|
3219
|
+
* **IMPORTANT: Shipping Cost Security**
|
|
3220
|
+
* - Use `shippingRateId` to specify the selected shipping rate
|
|
3221
|
+
* - The server calculates shipping cost from the rate ID (never trust frontend costs)
|
|
3222
|
+
* - Get available rates from `calculateShippingOptions()` first
|
|
3223
|
+
*
|
|
3201
3224
|
* @param request - Order creation request
|
|
3202
3225
|
* @returns Created order(s) with payment instructions
|
|
3203
3226
|
*
|
|
3204
3227
|
* @example
|
|
3205
3228
|
* ```typescript
|
|
3229
|
+
* // Step 1: Calculate available shipping options
|
|
3230
|
+
* const shippingOptions = await client.calculateShippingOptions({
|
|
3231
|
+
* merchantId: "merchant_123",
|
|
3232
|
+
* destinationCountry: "US",
|
|
3233
|
+
* cartItems: [{ productId: "prod_123", quantity: 2, priceUSDC: 29.99 }],
|
|
3234
|
+
* orderSubtotal: 59.98
|
|
3235
|
+
* });
|
|
3236
|
+
*
|
|
3237
|
+
* // Step 2: Let user select a shipping option, get the rateId
|
|
3238
|
+
* const selectedRateId = shippingOptions.shippingOptions[0].rateId;
|
|
3239
|
+
*
|
|
3240
|
+
* // Step 3: Create order with shippingRateId (server validates and calculates cost)
|
|
3206
3241
|
* const result = await client.createOrder({
|
|
3207
3242
|
* items: [
|
|
3208
3243
|
* { productId: "prod_123", quantity: 2 },
|
|
@@ -3218,6 +3253,7 @@ declare class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
3218
3253
|
* postalCode: "10001",
|
|
3219
3254
|
* country: "US"
|
|
3220
3255
|
* },
|
|
3256
|
+
* shippingRateId: selectedRateId, // Server validates and calculates cost
|
|
3221
3257
|
* couponCode: "SAVE10"
|
|
3222
3258
|
* });
|
|
3223
3259
|
*
|
package/dist/ecommerce.js
CHANGED
|
@@ -397,11 +397,28 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
397
397
|
*
|
|
398
398
|
* Supports multi-merchant checkout - automatically splits orders by merchant.
|
|
399
399
|
*
|
|
400
|
+
* **IMPORTANT: Shipping Cost Security**
|
|
401
|
+
* - Use `shippingRateId` to specify the selected shipping rate
|
|
402
|
+
* - The server calculates shipping cost from the rate ID (never trust frontend costs)
|
|
403
|
+
* - Get available rates from `calculateShippingOptions()` first
|
|
404
|
+
*
|
|
400
405
|
* @param request - Order creation request
|
|
401
406
|
* @returns Created order(s) with payment instructions
|
|
402
407
|
*
|
|
403
408
|
* @example
|
|
404
409
|
* ```typescript
|
|
410
|
+
* // Step 1: Calculate available shipping options
|
|
411
|
+
* const shippingOptions = await client.calculateShippingOptions({
|
|
412
|
+
* merchantId: "merchant_123",
|
|
413
|
+
* destinationCountry: "US",
|
|
414
|
+
* cartItems: [{ productId: "prod_123", quantity: 2, priceUSDC: 29.99 }],
|
|
415
|
+
* orderSubtotal: 59.98
|
|
416
|
+
* });
|
|
417
|
+
*
|
|
418
|
+
* // Step 2: Let user select a shipping option, get the rateId
|
|
419
|
+
* const selectedRateId = shippingOptions.shippingOptions[0].rateId;
|
|
420
|
+
*
|
|
421
|
+
* // Step 3: Create order with shippingRateId (server validates and calculates cost)
|
|
405
422
|
* const result = await client.createOrder({
|
|
406
423
|
* items: [
|
|
407
424
|
* { productId: "prod_123", quantity: 2 },
|
|
@@ -417,6 +434,7 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
417
434
|
* postalCode: "10001",
|
|
418
435
|
* country: "US"
|
|
419
436
|
* },
|
|
437
|
+
* shippingRateId: selectedRateId, // Server validates and calculates cost
|
|
420
438
|
* couponCode: "SAVE10"
|
|
421
439
|
* });
|
|
422
440
|
*
|
package/dist/ecommerce.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { BannerType, BaseEcommerceClient, CustomerEcommerceClient, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, InventoryAuditAction, MerchantEcommerceClient, MerchantStatus, OrderStatus, PaymentMethod, PaymentStatus, ProductSortBy, ReturnStatus, ReviewSortBy, ReviewStatus, ShipmentStatus, SortOrder, TaxBehavior, TaxReportPeriodType, TaxReportStatus, TaxType, buildQueryString, calculateDiscountAmount, calculateFinalPrice, formatPrice, getBackoffDelay, isRetryableError, isValidAddress, isValidEmail, parseError, retryWithBackoff, sleep, truncateAddress } from './chunk-
|
|
1
|
+
export { BannerType, BaseEcommerceClient, CustomerEcommerceClient, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, InventoryAuditAction, MerchantEcommerceClient, MerchantStatus, OrderStatus, PaymentMethod, PaymentStatus, ProductSortBy, ReturnStatus, ReviewSortBy, ReviewStatus, ShipmentStatus, SortOrder, TaxBehavior, TaxReportPeriodType, TaxReportStatus, TaxType, buildQueryString, calculateDiscountAmount, calculateFinalPrice, formatPrice, getBackoffDelay, isRetryableError, isValidAddress, isValidEmail, parseError, retryWithBackoff, sleep, truncateAddress } from './chunk-CAU4QLVH.mjs';
|
|
2
2
|
import './chunk-4UEJOM6W.mjs';
|
package/dist/index.js
CHANGED
|
@@ -42723,11 +42723,28 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42723
42723
|
*
|
|
42724
42724
|
* Supports multi-merchant checkout - automatically splits orders by merchant.
|
|
42725
42725
|
*
|
|
42726
|
+
* **IMPORTANT: Shipping Cost Security**
|
|
42727
|
+
* - Use `shippingRateId` to specify the selected shipping rate
|
|
42728
|
+
* - The server calculates shipping cost from the rate ID (never trust frontend costs)
|
|
42729
|
+
* - Get available rates from `calculateShippingOptions()` first
|
|
42730
|
+
*
|
|
42726
42731
|
* @param request - Order creation request
|
|
42727
42732
|
* @returns Created order(s) with payment instructions
|
|
42728
42733
|
*
|
|
42729
42734
|
* @example
|
|
42730
42735
|
* ```typescript
|
|
42736
|
+
* // Step 1: Calculate available shipping options
|
|
42737
|
+
* const shippingOptions = await client.calculateShippingOptions({
|
|
42738
|
+
* merchantId: "merchant_123",
|
|
42739
|
+
* destinationCountry: "US",
|
|
42740
|
+
* cartItems: [{ productId: "prod_123", quantity: 2, priceUSDC: 29.99 }],
|
|
42741
|
+
* orderSubtotal: 59.98
|
|
42742
|
+
* });
|
|
42743
|
+
*
|
|
42744
|
+
* // Step 2: Let user select a shipping option, get the rateId
|
|
42745
|
+
* const selectedRateId = shippingOptions.shippingOptions[0].rateId;
|
|
42746
|
+
*
|
|
42747
|
+
* // Step 3: Create order with shippingRateId (server validates and calculates cost)
|
|
42731
42748
|
* const result = await client.createOrder({
|
|
42732
42749
|
* items: [
|
|
42733
42750
|
* { productId: "prod_123", quantity: 2 },
|
|
@@ -42743,6 +42760,7 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42743
42760
|
* postalCode: "10001",
|
|
42744
42761
|
* country: "US"
|
|
42745
42762
|
* },
|
|
42763
|
+
* shippingRateId: selectedRateId, // Server validates and calculates cost
|
|
42746
42764
|
* couponCode: "SAVE10"
|
|
42747
42765
|
* });
|
|
42748
42766
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { BannerType, BaseEcommerceClient, CustomerEcommerceClient, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, InventoryAuditAction, MerchantEcommerceClient, MerchantStatus, OrderStatus, PaymentMethod, PaymentStatus, ProductSortBy, ReturnStatus, ReviewSortBy, ReviewStatus, ShipmentStatus, SortOrder, TaxBehavior, TaxReportPeriodType, TaxReportStatus, TaxType, buildQueryString, calculateDiscountAmount, calculateFinalPrice, formatPrice, getBackoffDelay, isRetryableError, isValidAddress, isValidEmail, parseError, retryWithBackoff, sleep, truncateAddress } from './chunk-
|
|
1
|
+
export { BannerType, BaseEcommerceClient, CustomerEcommerceClient, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, InventoryAuditAction, MerchantEcommerceClient, MerchantStatus, OrderStatus, PaymentMethod, PaymentStatus, ProductSortBy, ReturnStatus, ReviewSortBy, ReviewStatus, ShipmentStatus, SortOrder, TaxBehavior, TaxReportPeriodType, TaxReportStatus, TaxType, buildQueryString, calculateDiscountAmount, calculateFinalPrice, formatPrice, getBackoffDelay, isRetryableError, isValidAddress, isValidEmail, parseError, retryWithBackoff, sleep, truncateAddress } from './chunk-CAU4QLVH.mjs';
|
|
2
2
|
export { AssetIdUtils, InstrumentClient } from './chunk-VBC6EQ7Q.mjs';
|
|
3
3
|
import { __glob } from './chunk-4UEJOM6W.mjs';
|
|
4
4
|
import Decimal, { Decimal as Decimal$1 } from 'decimal.js';
|
|
@@ -178,11 +178,28 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
178
178
|
*
|
|
179
179
|
* Supports multi-merchant checkout - automatically splits orders by merchant.
|
|
180
180
|
*
|
|
181
|
+
* **IMPORTANT: Shipping Cost Security**
|
|
182
|
+
* - Use `shippingRateId` to specify the selected shipping rate
|
|
183
|
+
* - The server calculates shipping cost from the rate ID (never trust frontend costs)
|
|
184
|
+
* - Get available rates from `calculateShippingOptions()` first
|
|
185
|
+
*
|
|
181
186
|
* @param request - Order creation request
|
|
182
187
|
* @returns Created order(s) with payment instructions
|
|
183
188
|
*
|
|
184
189
|
* @example
|
|
185
190
|
* ```typescript
|
|
191
|
+
* // Step 1: Calculate available shipping options
|
|
192
|
+
* const shippingOptions = await client.calculateShippingOptions({
|
|
193
|
+
* merchantId: "merchant_123",
|
|
194
|
+
* destinationCountry: "US",
|
|
195
|
+
* cartItems: [{ productId: "prod_123", quantity: 2, priceUSDC: 29.99 }],
|
|
196
|
+
* orderSubtotal: 59.98
|
|
197
|
+
* });
|
|
198
|
+
*
|
|
199
|
+
* // Step 2: Let user select a shipping option, get the rateId
|
|
200
|
+
* const selectedRateId = shippingOptions.shippingOptions[0].rateId;
|
|
201
|
+
*
|
|
202
|
+
* // Step 3: Create order with shippingRateId (server validates and calculates cost)
|
|
186
203
|
* const result = await client.createOrder({
|
|
187
204
|
* items: [
|
|
188
205
|
* { productId: "prod_123", quantity: 2 },
|
|
@@ -198,6 +215,7 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
198
215
|
* postalCode: "10001",
|
|
199
216
|
* country: "US"
|
|
200
217
|
* },
|
|
218
|
+
* shippingRateId: selectedRateId, // Server validates and calculates cost
|
|
201
219
|
* couponCode: "SAVE10"
|
|
202
220
|
* });
|
|
203
221
|
*
|
|
@@ -869,17 +869,29 @@ export interface ShippingRate extends BaseEntity {
|
|
|
869
869
|
|
|
870
870
|
/**
|
|
871
871
|
* Shipping option (calculated for checkout)
|
|
872
|
+
*
|
|
873
|
+
* Use `rateId` when creating orders - the server will validate and calculate cost.
|
|
872
874
|
*/
|
|
873
875
|
export interface ShippingOption {
|
|
874
|
-
/** Rate ID */
|
|
875
|
-
|
|
876
|
-
/** Rate name */
|
|
877
|
-
name: string;
|
|
878
|
-
/** Calculated cost in USDC */
|
|
879
|
-
cost: number;
|
|
880
|
-
/** Estimated delivery string */
|
|
881
|
-
estimatedDelivery: string;
|
|
876
|
+
/** Rate ID - use this when creating orders */
|
|
877
|
+
rateId: string;
|
|
882
878
|
/** Zone name */
|
|
883
879
|
zoneName: string;
|
|
880
|
+
/** Rate name (e.g., "Standard", "Express") */
|
|
881
|
+
rateName: string;
|
|
882
|
+
/** Base rate in USDC */
|
|
883
|
+
baseRate: number;
|
|
884
|
+
/** Per-kg rate in USDC */
|
|
885
|
+
perKgRate: number;
|
|
886
|
+
/** Calculated total cost in USDC (for display only - server recalculates) */
|
|
887
|
+
calculatedCost: number;
|
|
888
|
+
/** Whether free shipping applies */
|
|
889
|
+
isFree: boolean;
|
|
890
|
+
/** Estimated delivery string (e.g., "5-7 business days") */
|
|
891
|
+
estimatedDelivery: string | null;
|
|
892
|
+
/** Minimum delivery days */
|
|
893
|
+
minDeliveryDays: number | null;
|
|
894
|
+
/** Maximum delivery days */
|
|
895
|
+
maxDeliveryDays: number | null;
|
|
884
896
|
}
|
|
885
897
|
|
|
@@ -150,13 +150,26 @@ export interface CreateOrderRequest {
|
|
|
150
150
|
couponCode?: string;
|
|
151
151
|
/** Idempotency key */
|
|
152
152
|
idempotencyKey?: string;
|
|
153
|
-
/**
|
|
153
|
+
/**
|
|
154
|
+
* Selected shipping rate ID (from shipping calculator)
|
|
155
|
+
* The server will validate this rate and calculate the cost server-side.
|
|
156
|
+
* SECURITY: The cost is never trusted from the frontend.
|
|
157
|
+
*/
|
|
158
|
+
shippingRateId?: string;
|
|
159
|
+
|
|
160
|
+
// =====================================================
|
|
161
|
+
// DEPRECATED FIELDS - Do not use
|
|
162
|
+
// These fields are ignored by the server for security reasons.
|
|
163
|
+
// Shipping cost must be calculated server-side using shippingRateId.
|
|
164
|
+
// =====================================================
|
|
165
|
+
|
|
166
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
154
167
|
shippingMethod?: string;
|
|
155
|
-
/**
|
|
168
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
156
169
|
shippingCost?: number;
|
|
157
|
-
/**
|
|
170
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
158
171
|
shippingZone?: string;
|
|
159
|
-
/**
|
|
172
|
+
/** @deprecated Use shippingRateId instead. This value is ignored by the server. */
|
|
160
173
|
estimatedDelivery?: string;
|
|
161
174
|
}
|
|
162
175
|
|