@sazito/client-sdk 1.2.6 → 1.2.8

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 CHANGED
@@ -478,14 +478,69 @@ interface ShippingAssignment {
478
478
  * Order-related types
479
479
  */
480
480
 
481
+ type OrderPublicId = number | string;
482
+ interface OrderInvoiceItem {
483
+ productVariantId: OrderPublicId;
484
+ name: string;
485
+ image?: {
486
+ url?: string;
487
+ };
488
+ variantAttributes: Array<{
489
+ name: string;
490
+ value: string;
491
+ }>;
492
+ singleItemPrice: number;
493
+ noOfItems: number;
494
+ totalItemsPrice: number;
495
+ customerProfit?: number;
496
+ formAttributes?: unknown;
497
+ bookingAttributes?: unknown;
498
+ productVariant: {
499
+ commercialFiles?: Array<{
500
+ id: OrderPublicId;
501
+ }>;
502
+ product: {
503
+ productType: string;
504
+ };
505
+ };
506
+ }
507
+ interface OrderShippingItem {
508
+ id: OrderPublicId;
509
+ invoiceItemIds: OrderPublicId[];
510
+ rate: {
511
+ id?: OrderPublicId;
512
+ name: string;
513
+ price: number;
514
+ type?: string;
515
+ icon?: string;
516
+ color?: string;
517
+ };
518
+ }
519
+ interface OrderInvoice {
520
+ invoiceItems: OrderInvoiceItem[];
521
+ shippingItems: OrderShippingItem[];
522
+ netTotal: number;
523
+ finalTotal: number;
524
+ shippingTotal?: number;
525
+ discountTotal?: number;
526
+ creditTotal?: number;
527
+ vat?: number;
528
+ vatPercent?: number;
529
+ itemsTotalRawPrice?: number;
530
+ itemsDiscount?: number;
531
+ customerProfit?: number;
532
+ customerProfitPercentage?: number;
533
+ discountUsages?: Array<{
534
+ discountCode?: {
535
+ code?: string;
536
+ };
537
+ }>;
538
+ }
481
539
  interface Order {
482
- id: number;
483
- orderNumber: string;
540
+ id: OrderPublicId;
541
+ orderNumber: OrderPublicId;
484
542
  orderIdentifier: string;
485
- invoice: {
486
- shippingItems: JsonObject[];
487
- invoiceItems: InvoiceItem[];
488
- };
543
+ invoice: OrderInvoice;
489
544
  }
490
545
  interface OrdersListResponse {
491
546
  orders: Order[];
@@ -535,14 +590,33 @@ interface Payment {
535
590
  };
536
591
  amount: number;
537
592
  }
538
- interface PaymentAction {
539
- action: 'POST' | 'REDIRECT' | 'UPLOAD' | 'pending' | 'showOrder' | 'StockViolated' | 'FAIL';
540
- address?: string;
541
- payload?: JsonObject;
542
- order?: Order;
543
- time?: number;
593
+ interface PaymentActionBase {
544
594
  message?: string;
545
595
  }
596
+ type PaymentAction = PaymentActionBase & ({
597
+ action: 'POST';
598
+ address: string;
599
+ payload: Record<string, string | number>;
600
+ } | {
601
+ action: 'REDIRECT';
602
+ address: string;
603
+ } | {
604
+ action: 'UPLOAD';
605
+ time?: number;
606
+ } | {
607
+ action: 'show_otp_modal';
608
+ time?: number;
609
+ } | {
610
+ action: 'show_order';
611
+ order: Order;
612
+ } | {
613
+ action: 'pending';
614
+ order: Order;
615
+ } | {
616
+ action: 'payment_fail_error' | 'show_error' | 'FAIL';
617
+ } | {
618
+ action: 'StockViolated';
619
+ });
546
620
  interface PaymentCredentials {
547
621
  id: number;
548
622
  identifier: string;
@@ -553,7 +627,9 @@ interface CreatePaymentInput {
553
627
  paymentType: number;
554
628
  }
555
629
  interface PaymentStepInput {
630
+ /** Payment ID supplied by Sazito's gateway-return path. */
556
631
  id?: number;
632
+ /** Payment identifier supplied by Sazito's gateway-return path. */
557
633
  paymentIdentifier?: string;
558
634
  payload?: JsonObject;
559
635
  tatoken?: string;
@@ -861,7 +937,9 @@ declare class HttpClient {
861
937
  /**
862
938
  * POST request
863
939
  */
864
- post<T>(endpoint: string, body?: any, options?: RequestOptions): Promise<SazitoResponse<T>>;
940
+ post<T>(endpoint: string, body?: any, options?: RequestOptions & {
941
+ skipRequestTransform?: boolean;
942
+ }): Promise<SazitoResponse<T>>;
865
943
  /**
866
944
  * PUT request
867
945
  */
@@ -1069,7 +1147,7 @@ declare class OrdersAPI {
1069
1147
  /**
1070
1148
  * Get single order by ID (requires authentication)
1071
1149
  */
1072
- get(orderId: number, options?: RequestOptions): Promise<SazitoResponse<Order>>;
1150
+ get(orderId: OrderPublicId, options?: RequestOptions): Promise<SazitoResponse<Order>>;
1073
1151
  }
1074
1152
 
1075
1153
  /**
@@ -1202,14 +1280,14 @@ declare class PaymentsAPI {
1202
1280
  /**
1203
1281
  * Initialize payment: start the payment step before redirecting the user to
1204
1282
  * the gateway. Returns the next {@link PaymentAction} (typically REDIRECT or
1205
- * POST for hosted gateways, or showOrder for zero-amount/instant payments).
1283
+ * POST for hosted gateways, or show_order for zero-amount/instant payments).
1206
1284
  */
1207
1285
  initialize(options?: RequestOptions): Promise<SazitoResponse<PaymentAction>>;
1208
1286
  /**
1209
1287
  * Verify payment after the user returns from the gateway. Forwards the
1210
1288
  * gateway callback parameters (e.g. `tatoken`, `trackingData`, `isFailed`,
1211
1289
  * `code`) to the same payment-step endpoint and returns the settled
1212
- * {@link PaymentAction} (showOrder on success, FAIL/StockViolated otherwise,
1290
+ * {@link PaymentAction} (show_order on success, FAIL/StockViolated otherwise,
1213
1291
  * or pending if the gateway has not reported back yet).
1214
1292
  */
1215
1293
  verify(input?: PaymentStepInput, options?: RequestOptions): Promise<SazitoResponse<PaymentAction>>;
@@ -1238,6 +1316,7 @@ declare class PaymentsAPI {
1238
1316
  clearPayment(): void;
1239
1317
  private withExactJsonHeader;
1240
1318
  private buildProcessStepFormData;
1319
+ private buildProcessStepBody;
1241
1320
  private appendFormValue;
1242
1321
  /**
1243
1322
  * Post-process a `process_payment_step` response. The exact-JSON endpoint
@@ -1246,6 +1325,9 @@ declare class PaymentsAPI {
1246
1325
  */
1247
1326
  private finalizeStepResponse;
1248
1327
  private normalizeAction;
1328
+ private optionalNumber;
1329
+ private isPostPayload;
1330
+ private isCheckoutOrder;
1249
1331
  private callPinchAfterSuccessfulPayment;
1250
1332
  }
1251
1333
 
@@ -2314,4 +2396,4 @@ declare function transformAddToCartInput(variantId: number, quantity: number, fo
2314
2396
  declare function transformCreateCartInput(input: TransformValue): TransformObject;
2315
2397
 
2316
2398
  export { CredentialsManager, HttpClient, MemoryStorage, SazitoClient, TokenStorage, createBookingAPI as booking, createCartAPI as cart, createCategoriesAPI as categories, createCMSAPI as cms, createBookingAPI, createCMSAPI, createCartAPI, createCategoriesAPI, createDynamicFormsAPI, createEntityRoutesAPI, createFeedbacksAPI, createGeneralAPI, createImagesAPI, createInvoicesAPI, createMenuAPI, createOrdersAPI, createPaymentsAPI, createProductsAPI, createRegionsAPI, createSazitoClient, createSearchAPI, createShippingAPI, createUsersAPI, createVisitsAPI, createWalletAPI, createDynamicFormsAPI as dynamicForms, createEntityRoutesAPI as entityRoutes, createFeedbacksAPI as feedbacks, createGeneralAPI as general, createImagesAPI as images, createInvoicesAPI as invoices, createMenuAPI as menu, createOrdersAPI as orders, createPaymentsAPI as payments, createProductsAPI as products, createRegionsAPI as regions, createSearchAPI as search, createShippingAPI as shipping, toEnglishDigits, transformAddToCartInput, transformApiResponse, transformCartResponse, transformCreateCartInput, transformInvoiceResponse, transformProductListResponse, transformRequestKeys, transformResponseKeys, transformShippingAddressInput, createUsersAPI as users, createVisitsAPI as visits, createWalletAPI as wallet };
2317
- export type { AddToCartInput, ApplicableShippingMethods, BlogPage, BlogPageEntityRoute, CMSPageEntityRoute, CMSPageType, CacheConfig, Cart, CartCredentials, CartProduct, CheckoutProductSnapshot, City$1 as City, CmsPage, CookieOptions, CreateCartInput, CreateInvoiceInput, CreatePaymentInput, EntityRoute, EntityRouteResponse, EntityType, FormAttributeValue, Image, Invoice, InvoiceCredentials, InvoiceItem, InvoiceItemFormAttributes, InvoiceShippingAddress, InvoiceShippingAddressRegion, ItemShippingRate, JsonArray, JsonObject, JsonPrimitive, JsonValue, MenuItem, MenuNode, MenuTree, Order, OrderFilters, OrdersListResponse, PaginatedResponse, Payment, PaymentAction, PaymentCredentials, PaymentGateway, PaymentMethod, PaymentStatus, PaymentStepFormFields, PaymentStepFormValue, PaymentStepInput, Product, ProductAttribute, ProductAttributeValueObject, ProductCategory, ProductCategoryEntityRoute, ProductEntityRoute, ProductFilters, ProductSort, ProductVariant, RefreshInvoiceInput, Region$1 as Region, RequestOptions, RetryConfig, SazitoConfig, SazitoError, SazitoResponse, SchedulerBookingAttributes, SearchFilters, SearchResponse, ShippingAddress, ShippingAddressCity, ShippingAddressCredentials, ShippingAddressInput, ShippingAddressRegion, ShippingAssignment, ShippingItem, ShippingMethod, ShippingRate, StorageAdapter, Tag, UnknownEntityRoute, UploadedFormFileAttribute, User };
2399
+ export type { AddToCartInput, ApplicableShippingMethods, BlogPage, BlogPageEntityRoute, CMSPageEntityRoute, CMSPageType, CacheConfig, Cart, CartCredentials, CartProduct, CheckoutProductSnapshot, City$1 as City, CmsPage, CookieOptions, CreateCartInput, CreateInvoiceInput, CreatePaymentInput, EntityRoute, EntityRouteResponse, EntityType, FormAttributeValue, Image, Invoice, InvoiceCredentials, InvoiceItem, InvoiceItemFormAttributes, InvoiceShippingAddress, InvoiceShippingAddressRegion, ItemShippingRate, JsonArray, JsonObject, JsonPrimitive, JsonValue, MenuItem, MenuNode, MenuTree, Order, OrderFilters, OrderInvoice, OrderInvoiceItem, OrderPublicId, OrderShippingItem, OrdersListResponse, PaginatedResponse, Payment, PaymentAction, PaymentCredentials, PaymentGateway, PaymentMethod, PaymentStatus, PaymentStepFormFields, PaymentStepFormValue, PaymentStepInput, Product, ProductAttribute, ProductAttributeValueObject, ProductCategory, ProductCategoryEntityRoute, ProductEntityRoute, ProductFilters, ProductSort, ProductVariant, RefreshInvoiceInput, Region$1 as Region, RequestOptions, RetryConfig, SazitoConfig, SazitoError, SazitoResponse, SchedulerBookingAttributes, SearchFilters, SearchResponse, ShippingAddress, ShippingAddressCity, ShippingAddressCredentials, ShippingAddressInput, ShippingAddressRegion, ShippingAssignment, ShippingItem, ShippingMethod, ShippingRate, StorageAdapter, Tag, UnknownEntityRoute, UploadedFormFileAttribute, User };
package/dist/index.d.ts CHANGED
@@ -478,14 +478,69 @@ interface ShippingAssignment {
478
478
  * Order-related types
479
479
  */
480
480
 
481
+ type OrderPublicId = number | string;
482
+ interface OrderInvoiceItem {
483
+ productVariantId: OrderPublicId;
484
+ name: string;
485
+ image?: {
486
+ url?: string;
487
+ };
488
+ variantAttributes: Array<{
489
+ name: string;
490
+ value: string;
491
+ }>;
492
+ singleItemPrice: number;
493
+ noOfItems: number;
494
+ totalItemsPrice: number;
495
+ customerProfit?: number;
496
+ formAttributes?: unknown;
497
+ bookingAttributes?: unknown;
498
+ productVariant: {
499
+ commercialFiles?: Array<{
500
+ id: OrderPublicId;
501
+ }>;
502
+ product: {
503
+ productType: string;
504
+ };
505
+ };
506
+ }
507
+ interface OrderShippingItem {
508
+ id: OrderPublicId;
509
+ invoiceItemIds: OrderPublicId[];
510
+ rate: {
511
+ id?: OrderPublicId;
512
+ name: string;
513
+ price: number;
514
+ type?: string;
515
+ icon?: string;
516
+ color?: string;
517
+ };
518
+ }
519
+ interface OrderInvoice {
520
+ invoiceItems: OrderInvoiceItem[];
521
+ shippingItems: OrderShippingItem[];
522
+ netTotal: number;
523
+ finalTotal: number;
524
+ shippingTotal?: number;
525
+ discountTotal?: number;
526
+ creditTotal?: number;
527
+ vat?: number;
528
+ vatPercent?: number;
529
+ itemsTotalRawPrice?: number;
530
+ itemsDiscount?: number;
531
+ customerProfit?: number;
532
+ customerProfitPercentage?: number;
533
+ discountUsages?: Array<{
534
+ discountCode?: {
535
+ code?: string;
536
+ };
537
+ }>;
538
+ }
481
539
  interface Order {
482
- id: number;
483
- orderNumber: string;
540
+ id: OrderPublicId;
541
+ orderNumber: OrderPublicId;
484
542
  orderIdentifier: string;
485
- invoice: {
486
- shippingItems: JsonObject[];
487
- invoiceItems: InvoiceItem[];
488
- };
543
+ invoice: OrderInvoice;
489
544
  }
490
545
  interface OrdersListResponse {
491
546
  orders: Order[];
@@ -535,14 +590,33 @@ interface Payment {
535
590
  };
536
591
  amount: number;
537
592
  }
538
- interface PaymentAction {
539
- action: 'POST' | 'REDIRECT' | 'UPLOAD' | 'pending' | 'showOrder' | 'StockViolated' | 'FAIL';
540
- address?: string;
541
- payload?: JsonObject;
542
- order?: Order;
543
- time?: number;
593
+ interface PaymentActionBase {
544
594
  message?: string;
545
595
  }
596
+ type PaymentAction = PaymentActionBase & ({
597
+ action: 'POST';
598
+ address: string;
599
+ payload: Record<string, string | number>;
600
+ } | {
601
+ action: 'REDIRECT';
602
+ address: string;
603
+ } | {
604
+ action: 'UPLOAD';
605
+ time?: number;
606
+ } | {
607
+ action: 'show_otp_modal';
608
+ time?: number;
609
+ } | {
610
+ action: 'show_order';
611
+ order: Order;
612
+ } | {
613
+ action: 'pending';
614
+ order: Order;
615
+ } | {
616
+ action: 'payment_fail_error' | 'show_error' | 'FAIL';
617
+ } | {
618
+ action: 'StockViolated';
619
+ });
546
620
  interface PaymentCredentials {
547
621
  id: number;
548
622
  identifier: string;
@@ -553,7 +627,9 @@ interface CreatePaymentInput {
553
627
  paymentType: number;
554
628
  }
555
629
  interface PaymentStepInput {
630
+ /** Payment ID supplied by Sazito's gateway-return path. */
556
631
  id?: number;
632
+ /** Payment identifier supplied by Sazito's gateway-return path. */
557
633
  paymentIdentifier?: string;
558
634
  payload?: JsonObject;
559
635
  tatoken?: string;
@@ -861,7 +937,9 @@ declare class HttpClient {
861
937
  /**
862
938
  * POST request
863
939
  */
864
- post<T>(endpoint: string, body?: any, options?: RequestOptions): Promise<SazitoResponse<T>>;
940
+ post<T>(endpoint: string, body?: any, options?: RequestOptions & {
941
+ skipRequestTransform?: boolean;
942
+ }): Promise<SazitoResponse<T>>;
865
943
  /**
866
944
  * PUT request
867
945
  */
@@ -1069,7 +1147,7 @@ declare class OrdersAPI {
1069
1147
  /**
1070
1148
  * Get single order by ID (requires authentication)
1071
1149
  */
1072
- get(orderId: number, options?: RequestOptions): Promise<SazitoResponse<Order>>;
1150
+ get(orderId: OrderPublicId, options?: RequestOptions): Promise<SazitoResponse<Order>>;
1073
1151
  }
1074
1152
 
1075
1153
  /**
@@ -1202,14 +1280,14 @@ declare class PaymentsAPI {
1202
1280
  /**
1203
1281
  * Initialize payment: start the payment step before redirecting the user to
1204
1282
  * the gateway. Returns the next {@link PaymentAction} (typically REDIRECT or
1205
- * POST for hosted gateways, or showOrder for zero-amount/instant payments).
1283
+ * POST for hosted gateways, or show_order for zero-amount/instant payments).
1206
1284
  */
1207
1285
  initialize(options?: RequestOptions): Promise<SazitoResponse<PaymentAction>>;
1208
1286
  /**
1209
1287
  * Verify payment after the user returns from the gateway. Forwards the
1210
1288
  * gateway callback parameters (e.g. `tatoken`, `trackingData`, `isFailed`,
1211
1289
  * `code`) to the same payment-step endpoint and returns the settled
1212
- * {@link PaymentAction} (showOrder on success, FAIL/StockViolated otherwise,
1290
+ * {@link PaymentAction} (show_order on success, FAIL/StockViolated otherwise,
1213
1291
  * or pending if the gateway has not reported back yet).
1214
1292
  */
1215
1293
  verify(input?: PaymentStepInput, options?: RequestOptions): Promise<SazitoResponse<PaymentAction>>;
@@ -1238,6 +1316,7 @@ declare class PaymentsAPI {
1238
1316
  clearPayment(): void;
1239
1317
  private withExactJsonHeader;
1240
1318
  private buildProcessStepFormData;
1319
+ private buildProcessStepBody;
1241
1320
  private appendFormValue;
1242
1321
  /**
1243
1322
  * Post-process a `process_payment_step` response. The exact-JSON endpoint
@@ -1246,6 +1325,9 @@ declare class PaymentsAPI {
1246
1325
  */
1247
1326
  private finalizeStepResponse;
1248
1327
  private normalizeAction;
1328
+ private optionalNumber;
1329
+ private isPostPayload;
1330
+ private isCheckoutOrder;
1249
1331
  private callPinchAfterSuccessfulPayment;
1250
1332
  }
1251
1333
 
@@ -2314,4 +2396,4 @@ declare function transformAddToCartInput(variantId: number, quantity: number, fo
2314
2396
  declare function transformCreateCartInput(input: TransformValue): TransformObject;
2315
2397
 
2316
2398
  export { CredentialsManager, HttpClient, MemoryStorage, SazitoClient, TokenStorage, createBookingAPI as booking, createCartAPI as cart, createCategoriesAPI as categories, createCMSAPI as cms, createBookingAPI, createCMSAPI, createCartAPI, createCategoriesAPI, createDynamicFormsAPI, createEntityRoutesAPI, createFeedbacksAPI, createGeneralAPI, createImagesAPI, createInvoicesAPI, createMenuAPI, createOrdersAPI, createPaymentsAPI, createProductsAPI, createRegionsAPI, createSazitoClient, createSearchAPI, createShippingAPI, createUsersAPI, createVisitsAPI, createWalletAPI, createDynamicFormsAPI as dynamicForms, createEntityRoutesAPI as entityRoutes, createFeedbacksAPI as feedbacks, createGeneralAPI as general, createImagesAPI as images, createInvoicesAPI as invoices, createMenuAPI as menu, createOrdersAPI as orders, createPaymentsAPI as payments, createProductsAPI as products, createRegionsAPI as regions, createSearchAPI as search, createShippingAPI as shipping, toEnglishDigits, transformAddToCartInput, transformApiResponse, transformCartResponse, transformCreateCartInput, transformInvoiceResponse, transformProductListResponse, transformRequestKeys, transformResponseKeys, transformShippingAddressInput, createUsersAPI as users, createVisitsAPI as visits, createWalletAPI as wallet };
2317
- export type { AddToCartInput, ApplicableShippingMethods, BlogPage, BlogPageEntityRoute, CMSPageEntityRoute, CMSPageType, CacheConfig, Cart, CartCredentials, CartProduct, CheckoutProductSnapshot, City$1 as City, CmsPage, CookieOptions, CreateCartInput, CreateInvoiceInput, CreatePaymentInput, EntityRoute, EntityRouteResponse, EntityType, FormAttributeValue, Image, Invoice, InvoiceCredentials, InvoiceItem, InvoiceItemFormAttributes, InvoiceShippingAddress, InvoiceShippingAddressRegion, ItemShippingRate, JsonArray, JsonObject, JsonPrimitive, JsonValue, MenuItem, MenuNode, MenuTree, Order, OrderFilters, OrdersListResponse, PaginatedResponse, Payment, PaymentAction, PaymentCredentials, PaymentGateway, PaymentMethod, PaymentStatus, PaymentStepFormFields, PaymentStepFormValue, PaymentStepInput, Product, ProductAttribute, ProductAttributeValueObject, ProductCategory, ProductCategoryEntityRoute, ProductEntityRoute, ProductFilters, ProductSort, ProductVariant, RefreshInvoiceInput, Region$1 as Region, RequestOptions, RetryConfig, SazitoConfig, SazitoError, SazitoResponse, SchedulerBookingAttributes, SearchFilters, SearchResponse, ShippingAddress, ShippingAddressCity, ShippingAddressCredentials, ShippingAddressInput, ShippingAddressRegion, ShippingAssignment, ShippingItem, ShippingMethod, ShippingRate, StorageAdapter, Tag, UnknownEntityRoute, UploadedFormFileAttribute, User };
2399
+ export type { AddToCartInput, ApplicableShippingMethods, BlogPage, BlogPageEntityRoute, CMSPageEntityRoute, CMSPageType, CacheConfig, Cart, CartCredentials, CartProduct, CheckoutProductSnapshot, City$1 as City, CmsPage, CookieOptions, CreateCartInput, CreateInvoiceInput, CreatePaymentInput, EntityRoute, EntityRouteResponse, EntityType, FormAttributeValue, Image, Invoice, InvoiceCredentials, InvoiceItem, InvoiceItemFormAttributes, InvoiceShippingAddress, InvoiceShippingAddressRegion, ItemShippingRate, JsonArray, JsonObject, JsonPrimitive, JsonValue, MenuItem, MenuNode, MenuTree, Order, OrderFilters, OrderInvoice, OrderInvoiceItem, OrderPublicId, OrderShippingItem, OrdersListResponse, PaginatedResponse, Payment, PaymentAction, PaymentCredentials, PaymentGateway, PaymentMethod, PaymentStatus, PaymentStepFormFields, PaymentStepFormValue, PaymentStepInput, Product, ProductAttribute, ProductAttributeValueObject, ProductCategory, ProductCategoryEntityRoute, ProductEntityRoute, ProductFilters, ProductSort, ProductVariant, RefreshInvoiceInput, Region$1 as Region, RequestOptions, RetryConfig, SazitoConfig, SazitoError, SazitoResponse, SchedulerBookingAttributes, SearchFilters, SearchResponse, ShippingAddress, ShippingAddressCity, ShippingAddressCredentials, ShippingAddressInput, ShippingAddressRegion, ShippingAssignment, ShippingItem, ShippingMethod, ShippingRate, StorageAdapter, Tag, UnknownEntityRoute, UploadedFormFileAttribute, User };