@mitumba/sdk 1.27.1 → 1.29.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.ts CHANGED
@@ -404,6 +404,136 @@ interface OrderHistoryParams {
404
404
  page?: number;
405
405
  }
406
406
 
407
+ type BaleGrade = 'Cream' | 'A' | 'B' | 'C';
408
+ type BaleType = 'original' | 'sorted';
409
+ interface WholesaleStore {
410
+ id: string;
411
+ name: string;
412
+ slug: string;
413
+ tagline: string | null;
414
+ description: string | null;
415
+ logo_url: string | null;
416
+ origins: string[];
417
+ verified: boolean;
418
+ }
419
+ interface WholesaleDepot {
420
+ id: string;
421
+ name: string;
422
+ address: string | null;
423
+ city_id: string | null;
424
+ is_primary: boolean;
425
+ }
426
+ interface Bale {
427
+ id: string;
428
+ store_id: string;
429
+ seller_id: string;
430
+ title: string;
431
+ category: string;
432
+ grade: BaleGrade;
433
+ bale_type: BaleType;
434
+ weight_kg: number;
435
+ origin: string | null;
436
+ est_pieces: number | null;
437
+ price_kes: number;
438
+ moq: number;
439
+ mix: string | null;
440
+ description: string | null;
441
+ city_id: string | null;
442
+ status: 'draft' | 'active' | 'sold_out';
443
+ created_at: string;
444
+ }
445
+ interface BaleDetail extends Bale {
446
+ images: string[];
447
+ store: {
448
+ name: string;
449
+ slug: string;
450
+ verified: boolean;
451
+ sti: number | null;
452
+ };
453
+ }
454
+ interface CreateBaleInput {
455
+ title: string;
456
+ category: string;
457
+ grade: BaleGrade;
458
+ bale_type?: BaleType;
459
+ weight_kg: number;
460
+ origin?: string;
461
+ est_pieces?: number;
462
+ price_kes: number;
463
+ moq?: number;
464
+ mix?: string;
465
+ description?: string;
466
+ city_id?: string;
467
+ status?: 'draft' | 'active' | 'sold_out';
468
+ }
469
+ interface WholesaleFeedParams {
470
+ q?: string;
471
+ category?: string;
472
+ grade?: BaleGrade;
473
+ origin?: string;
474
+ city_id?: string;
475
+ limit?: number;
476
+ offset?: number;
477
+ }
478
+ interface BaleFeedItem extends Bale {
479
+ image_url: string | null;
480
+ store: {
481
+ name: string;
482
+ slug: string;
483
+ verified: boolean;
484
+ sti: number | null;
485
+ };
486
+ }
487
+ interface SaveWholesaleStoreInput {
488
+ name: string;
489
+ tagline?: string;
490
+ description?: string;
491
+ logo_url?: string;
492
+ origins?: string[];
493
+ }
494
+ interface AddDepotInput {
495
+ name: string;
496
+ address?: string;
497
+ city_id?: string;
498
+ is_primary?: boolean;
499
+ }
500
+ declare const BALE_ORDER_STATUSES: readonly ["pending_payment", "paid", "confirmed", "in_transit", "delivered", "completed", "cancelled"];
501
+ type BaleOrderStatus = typeof BALE_ORDER_STATUSES[number];
502
+ type BaleFulfillment = 'pickup' | 'courier';
503
+ interface BaleOrder {
504
+ id: string;
505
+ bale_id: string;
506
+ buyer_id: string;
507
+ seller_id: string;
508
+ store_id: string;
509
+ title: string;
510
+ grade: string;
511
+ origin: string | null;
512
+ image_url: string | null;
513
+ qty: number;
514
+ unit_kes: number;
515
+ total_kes: number;
516
+ fulfillment: BaleFulfillment;
517
+ freight_kes: number | null;
518
+ status: BaleOrderStatus;
519
+ city_id: string | null;
520
+ buyer_name: string | null;
521
+ store_name: string | null;
522
+ created_at: string;
523
+ }
524
+ interface BaleOrderEvent {
525
+ actor: string;
526
+ old_status: string | null;
527
+ new_status: string;
528
+ note: string | null;
529
+ created_at: string;
530
+ }
531
+ interface CreateBaleOrderInput {
532
+ bale_id: string;
533
+ qty?: number;
534
+ fulfillment: BaleFulfillment;
535
+ }
536
+
407
537
  interface StkPushInput {
408
538
  order_id: string;
409
539
  phone: string;
@@ -429,6 +559,73 @@ interface PaymentStatusResponse {
429
559
  status: PaymentStatus;
430
560
  total: number;
431
561
  }
562
+ type KnownPaymentProvider = 'daraja' | 'intasend' | 'paystack' | 'airtel';
563
+ type ProviderId = KnownPaymentProvider | (string & {});
564
+ type PaymentProvider = ProviderId;
565
+ type CheckoutPaymentMethod = {
566
+ type: 'mobile_money';
567
+ phone: string;
568
+ } | {
569
+ type: 'card';
570
+ };
571
+ interface InitiateCheckoutInput {
572
+ order_id: string;
573
+ idempotency_key: string;
574
+ method: CheckoutPaymentMethod;
575
+ }
576
+ type CheckoutNextAction = {
577
+ type: 'await_confirmation';
578
+ } | {
579
+ type: 'redirect';
580
+ url: string;
581
+ expires_at: string | null;
582
+ };
583
+ interface InitiateCheckoutResponse {
584
+ version: 1;
585
+ order_id: string;
586
+ attempt: {
587
+ id: string;
588
+ sequence: number;
589
+ provider: ProviderId;
590
+ status: 'initiated';
591
+ };
592
+ next_action: CheckoutNextAction;
593
+ }
594
+ type PaymentAttemptStatus = 'initiated' | 'funded' | 'failed' | 'refunded' | 'cancelled';
595
+ type CheckoutStatus = 'pending' | 'paid' | 'failed' | 'cancelled' | 'refunded';
596
+ type CheckoutOrder = {
597
+ type: 'retail';
598
+ status: OrderStatus;
599
+ } | {
600
+ type: 'bale';
601
+ status: BaleOrderStatus;
602
+ };
603
+ interface CheckoutStatusResponse {
604
+ version: 1;
605
+ order_id: string;
606
+ order: CheckoutOrder;
607
+ checkout_status: CheckoutStatus;
608
+ terminal: boolean;
609
+ retryable: boolean;
610
+ amount: {
611
+ currency: 'KES';
612
+ minor_units: number;
613
+ };
614
+ latest_attempt: {
615
+ id: string;
616
+ sequence: number;
617
+ provider: PaymentProvider;
618
+ status: PaymentAttemptStatus;
619
+ terminal: boolean;
620
+ created_at: string;
621
+ updated_at: string;
622
+ } | null;
623
+ attempt_count: number;
624
+ order_updated_at: string;
625
+ status_updated_at: string;
626
+ server_time: string;
627
+ poll_after_ms: number;
628
+ }
432
629
 
433
630
  interface VAZIOutfitItem {
434
631
  id: string;
@@ -1040,136 +1237,6 @@ interface DisputeListParams {
1040
1237
  page?: number;
1041
1238
  }
1042
1239
 
1043
- type BaleGrade = 'Cream' | 'A' | 'B' | 'C';
1044
- type BaleType = 'original' | 'sorted';
1045
- interface WholesaleStore {
1046
- id: string;
1047
- name: string;
1048
- slug: string;
1049
- tagline: string | null;
1050
- description: string | null;
1051
- logo_url: string | null;
1052
- origins: string[];
1053
- verified: boolean;
1054
- }
1055
- interface WholesaleDepot {
1056
- id: string;
1057
- name: string;
1058
- address: string | null;
1059
- city_id: string | null;
1060
- is_primary: boolean;
1061
- }
1062
- interface Bale {
1063
- id: string;
1064
- store_id: string;
1065
- seller_id: string;
1066
- title: string;
1067
- category: string;
1068
- grade: BaleGrade;
1069
- bale_type: BaleType;
1070
- weight_kg: number;
1071
- origin: string | null;
1072
- est_pieces: number | null;
1073
- price_kes: number;
1074
- moq: number;
1075
- mix: string | null;
1076
- description: string | null;
1077
- city_id: string | null;
1078
- status: 'draft' | 'active' | 'sold_out';
1079
- created_at: string;
1080
- }
1081
- interface BaleDetail extends Bale {
1082
- images: string[];
1083
- store: {
1084
- name: string;
1085
- slug: string;
1086
- verified: boolean;
1087
- sti: number | null;
1088
- };
1089
- }
1090
- interface CreateBaleInput {
1091
- title: string;
1092
- category: string;
1093
- grade: BaleGrade;
1094
- bale_type?: BaleType;
1095
- weight_kg: number;
1096
- origin?: string;
1097
- est_pieces?: number;
1098
- price_kes: number;
1099
- moq?: number;
1100
- mix?: string;
1101
- description?: string;
1102
- city_id?: string;
1103
- status?: 'draft' | 'active' | 'sold_out';
1104
- }
1105
- interface WholesaleFeedParams {
1106
- q?: string;
1107
- category?: string;
1108
- grade?: BaleGrade;
1109
- origin?: string;
1110
- city_id?: string;
1111
- limit?: number;
1112
- offset?: number;
1113
- }
1114
- interface BaleFeedItem extends Bale {
1115
- image_url: string | null;
1116
- store: {
1117
- name: string;
1118
- slug: string;
1119
- verified: boolean;
1120
- sti: number | null;
1121
- };
1122
- }
1123
- interface SaveWholesaleStoreInput {
1124
- name: string;
1125
- tagline?: string;
1126
- description?: string;
1127
- logo_url?: string;
1128
- origins?: string[];
1129
- }
1130
- interface AddDepotInput {
1131
- name: string;
1132
- address?: string;
1133
- city_id?: string;
1134
- is_primary?: boolean;
1135
- }
1136
- declare const BALE_ORDER_STATUSES: readonly ["pending_payment", "paid", "confirmed", "in_transit", "delivered", "completed", "cancelled"];
1137
- type BaleOrderStatus = typeof BALE_ORDER_STATUSES[number];
1138
- type BaleFulfillment = 'pickup' | 'courier';
1139
- interface BaleOrder {
1140
- id: string;
1141
- bale_id: string;
1142
- buyer_id: string;
1143
- seller_id: string;
1144
- store_id: string;
1145
- title: string;
1146
- grade: string;
1147
- origin: string | null;
1148
- image_url: string | null;
1149
- qty: number;
1150
- unit_kes: number;
1151
- total_kes: number;
1152
- fulfillment: BaleFulfillment;
1153
- freight_kes: number | null;
1154
- status: BaleOrderStatus;
1155
- city_id: string | null;
1156
- buyer_name: string | null;
1157
- store_name: string | null;
1158
- created_at: string;
1159
- }
1160
- interface BaleOrderEvent {
1161
- actor: string;
1162
- old_status: string | null;
1163
- new_status: string;
1164
- note: string | null;
1165
- created_at: string;
1166
- }
1167
- interface CreateBaleOrderInput {
1168
- bale_id: string;
1169
- qty?: number;
1170
- fulfillment: BaleFulfillment;
1171
- }
1172
-
1173
1240
  interface MitumbaClientConfig {
1174
1241
  baseUrl: string;
1175
1242
  debug?: boolean;
@@ -1602,10 +1669,30 @@ declare class PayModule {
1602
1669
  * Initiate a Paystack payment — returns access_code for inline popup.
1603
1670
  */
1604
1671
  initPaystack(input: PaystackInput, options?: RequestOptions): Promise<PaystackInitResponse>;
1672
+ /**
1673
+ * Initiate a provider-neutral checkout for an order.
1674
+ *
1675
+ * The payment provider is selected by the API. Continue checkout using the
1676
+ * returned next action, then poll {@link getCheckoutStatus} for payment state.
1677
+ * Retrying after cancellation requires the same input and idempotency key.
1678
+ *
1679
+ * @param input - Order, idempotency key, and buyer-selected payment method.
1680
+ * @param options - Request options, including an optional abort signal.
1681
+ * @returns The initiated attempt and its required continuation action.
1682
+ * @throws {APIError} When the API rejects or cannot initiate the checkout.
1683
+ */
1684
+ initiateCheckout(input: InitiateCheckoutInput, options?: RequestOptions): Promise<InitiateCheckoutResponse>;
1605
1685
  /**
1606
1686
  * Poll for the current status of a payment by its order ID.
1687
+ *
1688
+ * @deprecated Use {@link getCheckoutStatus} for the typed checkout lifecycle.
1689
+ * This method retains its legacy route and response for compatibility.
1607
1690
  */
1608
1691
  getStatus(orderId: string, options?: RequestOptions): Promise<PaymentStatusResponse>;
1692
+ /**
1693
+ * Get the buyer-visible checkout lifecycle for a retail or bale order.
1694
+ */
1695
+ getCheckoutStatus(orderId: string, options?: RequestOptions): Promise<CheckoutStatusResponse>;
1609
1696
  }
1610
1697
 
1611
1698
  declare class VaziModule {
@@ -2399,4 +2486,4 @@ declare class MitumbaClient {
2399
2486
  isAuthenticated(): Promise<boolean>;
2400
2487
  }
2401
2488
 
2402
- export { APIClient, APIError, type APIErrorResponse, type Add2FAMethodInput, type Add2FAMethodResult, type AddAddressInput, type AddDepotInput, type AddPaymentMethodInput, type Address, type AdminListingItem, AdminModule, type AdminOrderDetail, type AdminOrderListItem, type AdminPayoutItem, type AdminReport, type AdminStoreDetail, type AdminStoreListItem, type AdminUserDetail, type AdminUserListItem, type AdminVaziOutfit, type AdminVerificationItem, AuthModule, type AuthTokens, type AuthenticationResponseJSON, BALE_ORDER_STATUSES, type Bale, type BaleDetail, type BaleFeedItem, type BaleFulfillment, type BaleGrade, type BaleOrder, type BaleOrderEvent, type BaleOrderStatus, type BaleType, type BecomeBaleSellerInput, type BecomeSellerInput, type BlockedIp, type Business, type BusinessType, BusinessesModule, CONDITIONS, type CartItem, CartModule, type Category, type ChangePasswordInput, type City, type CompleteOnboardingInput, type Condition, type Conversation, type CreateBaleInput, type CreateBaleOrderInput, type CreateListingInput, type CreateOrderInput, type CreateReportInput, type CreateReviewInput, type CreateStoreInput, DESIRED_RESOLUTIONS, DISPUTE_REASONS, DISPUTE_STATUSES, type DeliveryAddress, type DesiredResolution, type Dispute, type DisputeEvent, type DisputeEvidence, type DisputeListParams, type DisputeReason, type DisputeStatus, DisputesModule, type EmailLoginInput, type EmailRegisterInput, type FollowedStore, type ForgotPasswordInput, IDBTokenStore, type InboxRealtimeEvent, LISTING_STATUSES, type LinkedAccount, type LinkedAccountProvider, type Listing, type ListingImage, type ListingStatus, type ListingsFeedParams, ListingsModule, type LoginInput, MailerModule, type MailerTemplate, MemoryTokenStore, type Message, type MessageResponse, MessagesModule, MitumbaClient, type MitumbaClientConfig, type MpesaInput, type Notification, type NotificationPref, type NotificationType, NotificationsModule, ORDER_STATUSES, type Order, type OrderEvent, type OrderHistoryParams, type OrderStatus, OrdersModule, PAYMENT_STATUSES, type PaginatedResponse, PayModule, type PaymentMethod, type PaymentMethodType, type PaymentStatus, type PaymentStatusResponse, type PaystackInitResponse, type PaystackInput, type PhoneLoginInput, type PhoneRegisterInput, type PresignImageResponse, type PublicKeyCredentialCreationOptionsJSON, type PublicKeyCredentialRequestOptionsJSON, type RaiseDisputeInput, type RegisterInput, type RegistrationResponseJSON, ReportsModule, type RequestOptions, type ResetPasswordInput, type ResolveDisputeInput, type RespondDisputeInput, type Review, type ReviewableOrder, ReviewsModule, type SaveSearchInput, type SaveWholesaleStoreInput, type SearchHistoryItem, SearchModule, type SearchParams, type SearchResult, type SellerProfile, type SellerStorefront, type SellerType, type SendEmailInput, type SendMessageInput, type SendOtpInput, type Session, SettingsModule, type SimilarListing, type StiEvent, type StkPushInput, type StkPushResponse, type Store, type StoreAnalytics, type StoreSettings, type StoreStats, StoresModule, type SubscriptionTier, type SystemStats, TWO_FACTOR_METHOD_TYPES, type TokenStore, type TransitionOrderInput, type TrendingTerm, type TwoFactorMethod, type TwoFactorMethodType, type TwoFactorRequired, type UpdateBusinessInput, type UpdateListingInput, type UpdateProfileInput, type UpdateStoreInput, UploadsModule, type UserProfile, type VAZIOutfit, type VAZIOutfitDetail, type VAZIOutfitDetailItem, type VAZIOutfitItem, type VaziFeedParams, type VaziFeedResponse, VaziModule, type Verify2FAInput, type VerifyOtpInput, type WholesaleDepot, type WholesaleFeedParams, WholesaleModule, type WholesaleStore, type WishlistListing, WishlistsModule, createTokenStore };
2489
+ export { APIClient, APIError, type APIErrorResponse, type Add2FAMethodInput, type Add2FAMethodResult, type AddAddressInput, type AddDepotInput, type AddPaymentMethodInput, type Address, type AdminListingItem, AdminModule, type AdminOrderDetail, type AdminOrderListItem, type AdminPayoutItem, type AdminReport, type AdminStoreDetail, type AdminStoreListItem, type AdminUserDetail, type AdminUserListItem, type AdminVaziOutfit, type AdminVerificationItem, AuthModule, type AuthTokens, type AuthenticationResponseJSON, BALE_ORDER_STATUSES, type Bale, type BaleDetail, type BaleFeedItem, type BaleFulfillment, type BaleGrade, type BaleOrder, type BaleOrderEvent, type BaleOrderStatus, type BaleType, type BecomeBaleSellerInput, type BecomeSellerInput, type BlockedIp, type Business, type BusinessType, BusinessesModule, CONDITIONS, type CartItem, CartModule, type Category, type ChangePasswordInput, type CheckoutNextAction, type CheckoutOrder, type CheckoutPaymentMethod, type CheckoutStatus, type CheckoutStatusResponse, type City, type CompleteOnboardingInput, type Condition, type Conversation, type CreateBaleInput, type CreateBaleOrderInput, type CreateListingInput, type CreateOrderInput, type CreateReportInput, type CreateReviewInput, type CreateStoreInput, DESIRED_RESOLUTIONS, DISPUTE_REASONS, DISPUTE_STATUSES, type DeliveryAddress, type DesiredResolution, type Dispute, type DisputeEvent, type DisputeEvidence, type DisputeListParams, type DisputeReason, type DisputeStatus, DisputesModule, type EmailLoginInput, type EmailRegisterInput, type FollowedStore, type ForgotPasswordInput, IDBTokenStore, type InboxRealtimeEvent, type InitiateCheckoutInput, type InitiateCheckoutResponse, type KnownPaymentProvider, LISTING_STATUSES, type LinkedAccount, type LinkedAccountProvider, type Listing, type ListingImage, type ListingStatus, type ListingsFeedParams, ListingsModule, type LoginInput, MailerModule, type MailerTemplate, MemoryTokenStore, type Message, type MessageResponse, MessagesModule, MitumbaClient, type MitumbaClientConfig, type MpesaInput, type Notification, type NotificationPref, type NotificationType, NotificationsModule, ORDER_STATUSES, type Order, type OrderEvent, type OrderHistoryParams, type OrderStatus, OrdersModule, PAYMENT_STATUSES, type PaginatedResponse, PayModule, type PaymentAttemptStatus, type PaymentMethod, type PaymentMethodType, type PaymentProvider, type PaymentStatus, type PaymentStatusResponse, type PaystackInitResponse, type PaystackInput, type PhoneLoginInput, type PhoneRegisterInput, type PresignImageResponse, type ProviderId, type PublicKeyCredentialCreationOptionsJSON, type PublicKeyCredentialRequestOptionsJSON, type RaiseDisputeInput, type RegisterInput, type RegistrationResponseJSON, ReportsModule, type RequestOptions, type ResetPasswordInput, type ResolveDisputeInput, type RespondDisputeInput, type Review, type ReviewableOrder, ReviewsModule, type SaveSearchInput, type SaveWholesaleStoreInput, type SearchHistoryItem, SearchModule, type SearchParams, type SearchResult, type SellerProfile, type SellerStorefront, type SellerType, type SendEmailInput, type SendMessageInput, type SendOtpInput, type Session, SettingsModule, type SimilarListing, type StiEvent, type StkPushInput, type StkPushResponse, type Store, type StoreAnalytics, type StoreSettings, type StoreStats, StoresModule, type SubscriptionTier, type SystemStats, TWO_FACTOR_METHOD_TYPES, type TokenStore, type TransitionOrderInput, type TrendingTerm, type TwoFactorMethod, type TwoFactorMethodType, type TwoFactorRequired, type UpdateBusinessInput, type UpdateListingInput, type UpdateProfileInput, type UpdateStoreInput, UploadsModule, type UserProfile, type VAZIOutfit, type VAZIOutfitDetail, type VAZIOutfitDetailItem, type VAZIOutfitItem, type VaziFeedParams, type VaziFeedResponse, VaziModule, type Verify2FAInput, type VerifyOtpInput, type WholesaleDepot, type WholesaleFeedParams, WholesaleModule, type WholesaleStore, type WishlistListing, WishlistsModule, createTokenStore };
package/dist/index.js CHANGED
@@ -725,12 +725,36 @@ var PayModule = class {
725
725
  async initPaystack(input, options) {
726
726
  return this.client.post("/pay/paystack/init", input, options);
727
727
  }
728
+ /**
729
+ * Initiate a provider-neutral checkout for an order.
730
+ *
731
+ * The payment provider is selected by the API. Continue checkout using the
732
+ * returned next action, then poll {@link getCheckoutStatus} for payment state.
733
+ * Retrying after cancellation requires the same input and idempotency key.
734
+ *
735
+ * @param input - Order, idempotency key, and buyer-selected payment method.
736
+ * @param options - Request options, including an optional abort signal.
737
+ * @returns The initiated attempt and its required continuation action.
738
+ * @throws {APIError} When the API rejects or cannot initiate the checkout.
739
+ */
740
+ async initiateCheckout(input, options) {
741
+ return this.client.post("/pay/checkout/initiate", input, options);
742
+ }
728
743
  /**
729
744
  * Poll for the current status of a payment by its order ID.
745
+ *
746
+ * @deprecated Use {@link getCheckoutStatus} for the typed checkout lifecycle.
747
+ * This method retains its legacy route and response for compatibility.
730
748
  */
731
749
  async getStatus(orderId, options) {
732
750
  return this.client.get(`/pay/status/${orderId}`, void 0, options);
733
751
  }
752
+ /**
753
+ * Get the buyer-visible checkout lifecycle for a retail or bale order.
754
+ */
755
+ async getCheckoutStatus(orderId, options) {
756
+ return this.client.get(`/pay/checkout-status/${orderId}`, void 0, options);
757
+ }
734
758
  };
735
759
 
736
760
  // src/modules/vazi.ts