@mitumba/sdk 5.19.0 → 5.20.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 CHANGED
@@ -2818,6 +2818,91 @@ interface CartItem {
2818
2818
  delivery_fee: number;
2819
2819
  }
2820
2820
 
2821
+ /** An amount in a currency's minor units (cents for KES). */
2822
+ interface CheckoutMoney {
2823
+ currency: string;
2824
+ minor_units: number;
2825
+ }
2826
+ interface CreateCheckoutInput {
2827
+ /** One of the buyer's saved addresses. */
2828
+ address_id: string;
2829
+ /** One per buyer intent, 8 to 128 characters. A retry with the same key returns the same checkout. */
2830
+ idempotency_key: string;
2831
+ /** Exactly one per shop in the cart: the delivery quote picked for that shop. */
2832
+ deliveries: Array<{
2833
+ store_id: string;
2834
+ quote_id: string;
2835
+ }>;
2836
+ }
2837
+ type CheckoutState = 'awaiting_payment' | 'paid' | 'expired' | 'cancelled';
2838
+ /** One shop's order within a checkout. */
2839
+ interface CheckoutShopOrder {
2840
+ order_id: string;
2841
+ store_id: string;
2842
+ items_total: CheckoutMoney;
2843
+ delivery_fee: CheckoutMoney;
2844
+ /** The buyer protection fee (BPF) on this shop's order; zero when none. */
2845
+ bpf: CheckoutMoney;
2846
+ /** What the buyer pays for this shop's order: items + delivery + BPF. */
2847
+ total: CheckoutMoney;
2848
+ }
2849
+ /** One cart submission, holding one order per shop. */
2850
+ interface Checkout {
2851
+ id: string;
2852
+ invoice_number: string;
2853
+ status: CheckoutState;
2854
+ market_code: string;
2855
+ items_total: CheckoutMoney;
2856
+ delivery_total: CheckoutMoney;
2857
+ /** The BPF across every shop's order; zero when none. */
2858
+ bpf_total: CheckoutMoney;
2859
+ /** What the buyer pays: items + delivery + BPF. */
2860
+ total: CheckoutMoney;
2861
+ /** Payment due-by (ISO 8601). */
2862
+ due_at: string;
2863
+ created_at: string;
2864
+ orders: CheckoutShopOrder[];
2865
+ }
2866
+ interface CreateCheckoutResponse {
2867
+ checkout: Checkout;
2868
+ order_ids: string[];
2869
+ count: number;
2870
+ }
2871
+ interface GetCheckoutResponse {
2872
+ checkout: Checkout;
2873
+ }
2874
+ /** Why a checkout was refused: the error body, keyed by `error`. */
2875
+ type CheckoutRefusal = {
2876
+ error: 'invalid_input' | 'empty_cart' | 'cannot_buy_own' | 'invalid_deliveries';
2877
+ } | {
2878
+ error: 'address_not_found';
2879
+ } | {
2880
+ error: 'idempotency_conflict';
2881
+ } | {
2882
+ error: 'listing_unavailable';
2883
+ listings: Array<{
2884
+ listing_id: string;
2885
+ available: number;
2886
+ }>;
2887
+ } | {
2888
+ error: 'mixed_market_cart' | 'market_not_active';
2889
+ } | {
2890
+ error: 'checkout_payment_in_progress';
2891
+ checkout_id: string;
2892
+ } | {
2893
+ error: 'delivery_quote_rejected';
2894
+ store_id: string | null;
2895
+ reason: string;
2896
+ } | {
2897
+ error: 'address_region_invalid';
2898
+ } | {
2899
+ error: 'delivery_required';
2900
+ store_ids: string[];
2901
+ } | {
2902
+ error: 'delivery_quotes_unavailable';
2903
+ };
2904
+ type CheckoutRefusalCode = CheckoutRefusal['error'];
2905
+
2821
2906
  /**
2822
2907
  * Fields a user may change on their own profile via `PUT /auth/me`. Every field is optional;
2823
2908
  * only the ones provided are updated. The server enforces the profile contract:
@@ -3283,7 +3368,9 @@ declare class APIError extends Error {
3283
3368
  readonly code: string;
3284
3369
  readonly status: number;
3285
3370
  readonly details?: unknown;
3286
- constructor(status: number, data: APIErrorResponse);
3371
+ /** The decoded error body as the server sent it, for errors whose details are top-level fields. */
3372
+ readonly body?: unknown;
3373
+ constructor(status: number, data: APIErrorResponse, body?: unknown);
3287
3374
  }
3288
3375
  declare class APIClient {
3289
3376
  private config;
@@ -4209,6 +4296,8 @@ declare class CartModule {
4209
4296
  }>;
4210
4297
  /**
4211
4298
  * Checkout the cart — creates orders grouped by store and clears the cart.
4299
+ * @deprecated Use `sdk.checkouts.create`: checkout needs an address, an idempotency key and a
4300
+ * delivery quote per shop, and returns the checkout with its totals.
4212
4301
  */
4213
4302
  checkout(options?: RequestOptions): Promise<{
4214
4303
  order_ids: string[];
@@ -4216,6 +4305,25 @@ declare class CartModule {
4216
4305
  }>;
4217
4306
  }
4218
4307
 
4308
+ /**
4309
+ * The checkout refusal carried by an error thrown from `checkouts.create`, or null when the error is
4310
+ * not one. The body is the server's own, so the refusal's details (such as `listings` for
4311
+ * `listing_unavailable`) are present.
4312
+ */
4313
+ declare function checkoutRefusal(error: unknown): CheckoutRefusal | null;
4314
+ declare class CheckoutsModule {
4315
+ private readonly client;
4316
+ constructor(client: APIClient);
4317
+ /**
4318
+ * Create a checkout from the buyer's cart: one order per shop, each at the delivery quote picked
4319
+ * for it, held until the checkout's due-by. A retry with the same `idempotency_key` returns the
4320
+ * same checkout. A refusal throws an `APIError`; read it with `checkoutRefusal(error)`.
4321
+ */
4322
+ create(input: CreateCheckoutInput, options?: RequestOptions): Promise<CreateCheckoutResponse>;
4323
+ /** Read one of the buyer's checkouts. Anyone else gets a 404. */
4324
+ get(checkoutId: string, options?: RequestOptions): Promise<GetCheckoutResponse>;
4325
+ }
4326
+
4219
4327
  declare class SettingsModule {
4220
4328
  private readonly client;
4221
4329
  constructor(client: APIClient);
@@ -5162,6 +5270,7 @@ declare class MitumbaClient {
5162
5270
  readonly reviews: ReviewsModule;
5163
5271
  readonly wishlists: WishlistsModule;
5164
5272
  readonly cart: CartModule;
5273
+ readonly checkouts: CheckoutsModule;
5165
5274
  readonly settings: SettingsModule;
5166
5275
  readonly mailer: MailerModule;
5167
5276
  readonly businesses: BusinessesModule;
@@ -5203,4 +5312,4 @@ declare class MitumbaClient {
5203
5312
  isAuthenticated(): Promise<boolean>;
5204
5313
  }
5205
5314
 
5206
- export { APIClient, APIError, type APIErrorResponse, type ActivateIamUserInput, type ActivateIamUserResult, type Add2FAMethodInput, type Add2FAMethodResult, type AddAddressInput, type AddDepotInput, type AddIamPasskeyResult, type AddIamTotpResult, type AddIamTwoFactorMethodInput, type AddPaymentMethodInput, type Address, type AdminAuditActor, type AdminAuditEntry, type AdminAuditQuery, type AdminAuthStrength, type AdminListingItem, type AdminMessageReport, type AdminMessageReportDetail, type AdminMessageReportList, type AdminMessageReportThreadMessage, AdminModule, type AdminOperator, type AdminOrderDetail, type AdminOrderListItem, type AdminPayoutItem, type AdminPermission, type AdminPermissionDescription, type AdminRecoveryEvent, type AdminRecoveryRequest, type AdminReport, type AdminRolePreset, type AdminStoreDetail, type AdminStoreListItem, type AdminUserDetail, type AdminUserListItem, type AdminVaziOutfit, type AdminVerificationItem, type AdminWholesalePendingStore, type ApiResponse, type AttachmentDownloadAuthorization, type AttachmentUploadAuthorization, type AttachmentUploadBody, type AttachmentUploadState, type AttachmentUploadStatus, type AuthCapabilities, AuthModule, type AuthTokens, type AuthenticationResponseJSON, BALE_ORDER_STATUSES, type Bale, type BaleDetail, type BaleFeedItem, type BaleFulfillment, type BaleGrade, type BaleImageUploadResult, type BaleOrder, type BaleOrderEvent, type BaleOrderStatus, type BaleType, type BecomeBaleSellerInput, type BecomeSellerInput, type BlockedIp, type Business, type BusinessType, BusinessesModule, type BuyerResolveThreadInput, type BuyerSummary, CONDITIONS, type CartItem, CartModule, type Category, type ChangePasswordInput, type ChangePlatformSettingInput, type ChangePlatformSettingResult, type CheckoutNextAction, type CheckoutOrder, type CheckoutPaymentMethod, type CheckoutStatus, type CheckoutStatusResponse, type City, type CompleteOnboardingInput, type CompleteRecoveryResult, type Condition, type Conversation, type ConversationId, type ConversationSummary, type CreateAttachmentUploadInput, type CreateBaleInput, type CreateBaleOrderInput, type CreateIamUserInput, type CreateIamUserResult, type CreateListingInput, type CreateMessageBlockInput, type CreateMessageBlockResult, type CreateMessageReportInput, type CreateMessageReportResult, type CreateOrderInput, type CreateOrganizationInput, type CreateReportInput, type CreateReviewInput, type CreateStoreInput, type CursorPage, DEFAULT_SHARE_ORIGIN, 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 FileResponse, type FinishIamPasskeyEnrollmentInput, type FinishIamPasskeyLoginInput, type FollowedStore, type ForgotPasswordInput, IDBTokenStore, type IamActivation, type IamLoginInput, type IamLoginMethod, type IamMethodsResult, IamModule, type IamPasskeyLoginOptions, type IamProfile, type IamSession, type IamSessionsResult, type IamSignIn, type IamSignInFailureReason, type IamSignInsResult, type IamTokens, type IamTwoFactorRequired, type IamUser, type IamUserStatus, type InboxRealtimeEvent, type InitiateCheckoutInput, type InitiateCheckoutResponse, type Jwk, type Jwks, type KnownPaymentProvider, LISTING_STATUSES, type LegacyLinkResolution, type LegacyMessageArchiveSummary, type LegacyMessagePage, type LegacyMessageRecord, type LibraryCadence, type LibraryCompleter, type LibraryDocument, type LibraryDocumentSummary, type LibraryKind, type LibraryListing, type LibraryOccurrence, type LibraryOccurrenceRecorded, type LibraryOccurrenceStatus, type LibraryRoutineState, type LibrarySchedule, type LibraryScheduleRule, type LibrarySeason, type LibraryWeekday, type LinkedAccount, type LinkedAccountProvider, type ListConversationsParams, type ListIamUsersResult, type ListThreadMessagesParams, type ListThreadsParams, type Listing, type ListingImage, type ListingStatus, type ListingsFeedParams, ListingsModule, type LoginInput, MailerModule, type MailerTemplate, type Market, type MarketCurrency, type MarketPhone, type MarketRegion, type MarketRegionsResponse, type MarketStatus, MarketsModule, type MarketsResponse, MemoryTokenStore, type Message, type MessageAttachment, type MessageAuthor, type MessageId, type MessagePage, type MessageReportOutcome, type MessageReportReason, type MessageReportStatus, type MessageResponse, MessagesModule, type MessagesRealtimeConnection, type MessagesRealtimeEnvelope, type MessagesRealtimeEvent, type MessagesRealtimeOptions, type MessagesRealtimeState, type MessagesRealtimeTicket, type MessagingBlockInput, type MessagingBlockRemovedResult, type MessagingBlockResult, type MessagingCapabilities, type MessagingCursor, type MessagingErrorCode, type MessagingIdempotentRequestOptions, type MessagingInboxes, type MessagingPerspective, type MessagingSide, MitumbaClient, type MitumbaClientConfig, type MpesaInput, type Notification, type NotificationPref, type NotificationType, NotificationsModule, type OAuthAuthorizeInput, type OAuthAuthorizeResult, type OAuthClient, type OAuthClientSummary, type OAuthClientTrustLevel, type OAuthClientType, type OAuthConsent, type OAuthConsentInput, type OAuthConsentRequired, type OAuthConsentRevokeResult, OAuthModule, type OAuthTokenExchangeInput, type OAuthTokenResult, ORDER_STATUSES, type OidcSigningKey, type OpenIdConfiguration, type OperatorPermissionGrant, type Order, type OrderDocument, type OrderDocumentKind, type OrderEvent, type OrderHistoryParams, type OrderStatus, OrdersModule, type Organization, type OrganizationKind, type OrganizationStatus, type OrganizationSummary, PAYMENT_STATUSES, type PaginatedResponse, PayModule, type PaymentAttemptStatus, type PaymentMethod, type PaymentMethodType, type PaymentProvider, type PaymentStatus, type PaymentStatusResponse, type PaystackInitResponse, type PaystackInput, type PendingPayoutApproval, type PhoneLoginInput, type PhoneRegisterInput, type PlatformSetting, type PlatformSettingChange, type PlatformSettingDetail, type PlatformSettingGroup, type PlatformSettingKind, type PresignImageResponse, type ProviderId, type PublicKeyCredentialCreationOptionsJSON, type PublicKeyCredentialRequestOptionsJSON, type RaiseDisputeInput, type ReadCursorResult, RealtimeProtocolError, RealtimeUnavailableError, type RecoveryStatus, type RecoveryStatusResult, type RegenerateBackupCodesResult, type RegenerateIamBackupCodesResult, type RegisterInput, type RegisterOAuthClientInput, type RegisteredOAuthClient, type RegistrationResponseJSON, ReportsModule, type RequestOptions, type RequestRecoveryInput, type RequestRecoveryResult, type ResetPasswordInput, type ResolveDisputeInput, type ResolveMessageReportInput, type ResolveMessageReportResult, type ResolveThreadResult, type RespondDisputeInput, type Review, type ReviewableOrder, ReviewsModule, type RootSetupInput, type RootSetupResult, type SaveSearchInput, type SaveWholesaleStoreInput, type SearchHistoryItem, SearchModule, type SearchParams, type SearchResult, type SellerProfile, type SellerStorefront, type SellerType, type SendEmailInput, type SendMessageInput, type SendOtpInput, type SendThreadMessageInput, type SendThreadMessageResult, type Session, SettingsModule, type ShareUrlOptions, type SilentAuthorizeResult, type SimilarListing, type StiEvent, type StkPushInput, type StkPushResponse, type Store, type StoreAnalytics, type StoreResolveThreadInput, type StoreReviewsPage, type StoreSettings, type StoreStats, type StoreSummary, StoresModule, type SubscriptionTier, type SystemStats, TWO_FACTOR_METHOD_TYPES, type ThreadCard, type ThreadId, type ThreadMessage, type ThreadSubject, type ThreadSystemEvent, type ThreadTimelineItem, type ThreadTimelineItemId, type TokenStore, type TransitionOrderInput, type TrendingTerm, type TwoFactorMethod, type TwoFactorMethodType, type TwoFactorRequired, type UpdateBusinessInput, type UpdateConversationPreferencesInput, type UpdateListingInput, type UpdateOrganizationInput, type UpdateProfileInput, type UpdateStoreInput, type UpdateThreadPreferencesInput, UploadsModule, type UserInfo, type UserProfile, type VAZIOutfit, type VAZIOutfitDetail, type VAZIOutfitDetailItem, type VAZIOutfitItem, type VaziFeedParams, type VaziFeedResponse, VaziModule, type Verify2FAInput, type VerifyIamMethodResult, type VerifyIamTwoFactorInput, type VerifyOtpInput, type WebSocketCloseEventLike, type WebSocketFactory, type WebSocketLike, type WebSocketMessageEventLike, type WholesaleAnalytics, type WholesaleDepot, type WholesaleFeedParams, WholesaleModule, type WholesaleReviewStatus, type WholesaleStore, type WishlistListing, WishlistsModule, activeMarkets, baleShareUrl, createTokenStore, findMarket, findRegion, formatAmount, formatMoney, formatMoneyCompact, formatPhone, isConsentRequired, isMessagingAPIError, isValidPhone, listingShareUrl, maskPhone, normalizePhone, regionById, storeShareUrl };
5315
+ export { APIClient, APIError, type APIErrorResponse, type ActivateIamUserInput, type ActivateIamUserResult, type Add2FAMethodInput, type Add2FAMethodResult, type AddAddressInput, type AddDepotInput, type AddIamPasskeyResult, type AddIamTotpResult, type AddIamTwoFactorMethodInput, type AddPaymentMethodInput, type Address, type AdminAuditActor, type AdminAuditEntry, type AdminAuditQuery, type AdminAuthStrength, type AdminListingItem, type AdminMessageReport, type AdminMessageReportDetail, type AdminMessageReportList, type AdminMessageReportThreadMessage, AdminModule, type AdminOperator, type AdminOrderDetail, type AdminOrderListItem, type AdminPayoutItem, type AdminPermission, type AdminPermissionDescription, type AdminRecoveryEvent, type AdminRecoveryRequest, type AdminReport, type AdminRolePreset, type AdminStoreDetail, type AdminStoreListItem, type AdminUserDetail, type AdminUserListItem, type AdminVaziOutfit, type AdminVerificationItem, type AdminWholesalePendingStore, type ApiResponse, type AttachmentDownloadAuthorization, type AttachmentUploadAuthorization, type AttachmentUploadBody, type AttachmentUploadState, type AttachmentUploadStatus, type AuthCapabilities, AuthModule, type AuthTokens, type AuthenticationResponseJSON, BALE_ORDER_STATUSES, type Bale, type BaleDetail, type BaleFeedItem, type BaleFulfillment, type BaleGrade, type BaleImageUploadResult, type BaleOrder, type BaleOrderEvent, type BaleOrderStatus, type BaleType, type BecomeBaleSellerInput, type BecomeSellerInput, type BlockedIp, type Business, type BusinessType, BusinessesModule, type BuyerResolveThreadInput, type BuyerSummary, CONDITIONS, type CartItem, CartModule, type Category, type ChangePasswordInput, type ChangePlatformSettingInput, type ChangePlatformSettingResult, type Checkout, type CheckoutMoney, type CheckoutNextAction, type CheckoutOrder, type CheckoutPaymentMethod, type CheckoutRefusal, type CheckoutRefusalCode, type CheckoutShopOrder, type CheckoutState, type CheckoutStatus, type CheckoutStatusResponse, CheckoutsModule, type City, type CompleteOnboardingInput, type CompleteRecoveryResult, type Condition, type Conversation, type ConversationId, type ConversationSummary, type CreateAttachmentUploadInput, type CreateBaleInput, type CreateBaleOrderInput, type CreateCheckoutInput, type CreateCheckoutResponse, type CreateIamUserInput, type CreateIamUserResult, type CreateListingInput, type CreateMessageBlockInput, type CreateMessageBlockResult, type CreateMessageReportInput, type CreateMessageReportResult, type CreateOrderInput, type CreateOrganizationInput, type CreateReportInput, type CreateReviewInput, type CreateStoreInput, type CursorPage, DEFAULT_SHARE_ORIGIN, 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 FileResponse, type FinishIamPasskeyEnrollmentInput, type FinishIamPasskeyLoginInput, type FollowedStore, type ForgotPasswordInput, type GetCheckoutResponse, IDBTokenStore, type IamActivation, type IamLoginInput, type IamLoginMethod, type IamMethodsResult, IamModule, type IamPasskeyLoginOptions, type IamProfile, type IamSession, type IamSessionsResult, type IamSignIn, type IamSignInFailureReason, type IamSignInsResult, type IamTokens, type IamTwoFactorRequired, type IamUser, type IamUserStatus, type InboxRealtimeEvent, type InitiateCheckoutInput, type InitiateCheckoutResponse, type Jwk, type Jwks, type KnownPaymentProvider, LISTING_STATUSES, type LegacyLinkResolution, type LegacyMessageArchiveSummary, type LegacyMessagePage, type LegacyMessageRecord, type LibraryCadence, type LibraryCompleter, type LibraryDocument, type LibraryDocumentSummary, type LibraryKind, type LibraryListing, type LibraryOccurrence, type LibraryOccurrenceRecorded, type LibraryOccurrenceStatus, type LibraryRoutineState, type LibrarySchedule, type LibraryScheduleRule, type LibrarySeason, type LibraryWeekday, type LinkedAccount, type LinkedAccountProvider, type ListConversationsParams, type ListIamUsersResult, type ListThreadMessagesParams, type ListThreadsParams, type Listing, type ListingImage, type ListingStatus, type ListingsFeedParams, ListingsModule, type LoginInput, MailerModule, type MailerTemplate, type Market, type MarketCurrency, type MarketPhone, type MarketRegion, type MarketRegionsResponse, type MarketStatus, MarketsModule, type MarketsResponse, MemoryTokenStore, type Message, type MessageAttachment, type MessageAuthor, type MessageId, type MessagePage, type MessageReportOutcome, type MessageReportReason, type MessageReportStatus, type MessageResponse, MessagesModule, type MessagesRealtimeConnection, type MessagesRealtimeEnvelope, type MessagesRealtimeEvent, type MessagesRealtimeOptions, type MessagesRealtimeState, type MessagesRealtimeTicket, type MessagingBlockInput, type MessagingBlockRemovedResult, type MessagingBlockResult, type MessagingCapabilities, type MessagingCursor, type MessagingErrorCode, type MessagingIdempotentRequestOptions, type MessagingInboxes, type MessagingPerspective, type MessagingSide, MitumbaClient, type MitumbaClientConfig, type MpesaInput, type Notification, type NotificationPref, type NotificationType, NotificationsModule, type OAuthAuthorizeInput, type OAuthAuthorizeResult, type OAuthClient, type OAuthClientSummary, type OAuthClientTrustLevel, type OAuthClientType, type OAuthConsent, type OAuthConsentInput, type OAuthConsentRequired, type OAuthConsentRevokeResult, OAuthModule, type OAuthTokenExchangeInput, type OAuthTokenResult, ORDER_STATUSES, type OidcSigningKey, type OpenIdConfiguration, type OperatorPermissionGrant, type Order, type OrderDocument, type OrderDocumentKind, type OrderEvent, type OrderHistoryParams, type OrderStatus, OrdersModule, type Organization, type OrganizationKind, type OrganizationStatus, type OrganizationSummary, PAYMENT_STATUSES, type PaginatedResponse, PayModule, type PaymentAttemptStatus, type PaymentMethod, type PaymentMethodType, type PaymentProvider, type PaymentStatus, type PaymentStatusResponse, type PaystackInitResponse, type PaystackInput, type PendingPayoutApproval, type PhoneLoginInput, type PhoneRegisterInput, type PlatformSetting, type PlatformSettingChange, type PlatformSettingDetail, type PlatformSettingGroup, type PlatformSettingKind, type PresignImageResponse, type ProviderId, type PublicKeyCredentialCreationOptionsJSON, type PublicKeyCredentialRequestOptionsJSON, type RaiseDisputeInput, type ReadCursorResult, RealtimeProtocolError, RealtimeUnavailableError, type RecoveryStatus, type RecoveryStatusResult, type RegenerateBackupCodesResult, type RegenerateIamBackupCodesResult, type RegisterInput, type RegisterOAuthClientInput, type RegisteredOAuthClient, type RegistrationResponseJSON, ReportsModule, type RequestOptions, type RequestRecoveryInput, type RequestRecoveryResult, type ResetPasswordInput, type ResolveDisputeInput, type ResolveMessageReportInput, type ResolveMessageReportResult, type ResolveThreadResult, type RespondDisputeInput, type Review, type ReviewableOrder, ReviewsModule, type RootSetupInput, type RootSetupResult, type SaveSearchInput, type SaveWholesaleStoreInput, type SearchHistoryItem, SearchModule, type SearchParams, type SearchResult, type SellerProfile, type SellerStorefront, type SellerType, type SendEmailInput, type SendMessageInput, type SendOtpInput, type SendThreadMessageInput, type SendThreadMessageResult, type Session, SettingsModule, type ShareUrlOptions, type SilentAuthorizeResult, type SimilarListing, type StiEvent, type StkPushInput, type StkPushResponse, type Store, type StoreAnalytics, type StoreResolveThreadInput, type StoreReviewsPage, type StoreSettings, type StoreStats, type StoreSummary, StoresModule, type SubscriptionTier, type SystemStats, TWO_FACTOR_METHOD_TYPES, type ThreadCard, type ThreadId, type ThreadMessage, type ThreadSubject, type ThreadSystemEvent, type ThreadTimelineItem, type ThreadTimelineItemId, type TokenStore, type TransitionOrderInput, type TrendingTerm, type TwoFactorMethod, type TwoFactorMethodType, type TwoFactorRequired, type UpdateBusinessInput, type UpdateConversationPreferencesInput, type UpdateListingInput, type UpdateOrganizationInput, type UpdateProfileInput, type UpdateStoreInput, type UpdateThreadPreferencesInput, UploadsModule, type UserInfo, type UserProfile, type VAZIOutfit, type VAZIOutfitDetail, type VAZIOutfitDetailItem, type VAZIOutfitItem, type VaziFeedParams, type VaziFeedResponse, VaziModule, type Verify2FAInput, type VerifyIamMethodResult, type VerifyIamTwoFactorInput, type VerifyOtpInput, type WebSocketCloseEventLike, type WebSocketFactory, type WebSocketLike, type WebSocketMessageEventLike, type WholesaleAnalytics, type WholesaleDepot, type WholesaleFeedParams, WholesaleModule, type WholesaleReviewStatus, type WholesaleStore, type WishlistListing, WishlistsModule, activeMarkets, baleShareUrl, checkoutRefusal, createTokenStore, findMarket, findRegion, formatAmount, formatMoney, formatMoneyCompact, formatPhone, isConsentRequired, isMessagingAPIError, isValidPhone, listingShareUrl, maskPhone, normalizePhone, regionById, storeShareUrl };
package/dist/index.d.ts CHANGED
@@ -2818,6 +2818,91 @@ interface CartItem {
2818
2818
  delivery_fee: number;
2819
2819
  }
2820
2820
 
2821
+ /** An amount in a currency's minor units (cents for KES). */
2822
+ interface CheckoutMoney {
2823
+ currency: string;
2824
+ minor_units: number;
2825
+ }
2826
+ interface CreateCheckoutInput {
2827
+ /** One of the buyer's saved addresses. */
2828
+ address_id: string;
2829
+ /** One per buyer intent, 8 to 128 characters. A retry with the same key returns the same checkout. */
2830
+ idempotency_key: string;
2831
+ /** Exactly one per shop in the cart: the delivery quote picked for that shop. */
2832
+ deliveries: Array<{
2833
+ store_id: string;
2834
+ quote_id: string;
2835
+ }>;
2836
+ }
2837
+ type CheckoutState = 'awaiting_payment' | 'paid' | 'expired' | 'cancelled';
2838
+ /** One shop's order within a checkout. */
2839
+ interface CheckoutShopOrder {
2840
+ order_id: string;
2841
+ store_id: string;
2842
+ items_total: CheckoutMoney;
2843
+ delivery_fee: CheckoutMoney;
2844
+ /** The buyer protection fee (BPF) on this shop's order; zero when none. */
2845
+ bpf: CheckoutMoney;
2846
+ /** What the buyer pays for this shop's order: items + delivery + BPF. */
2847
+ total: CheckoutMoney;
2848
+ }
2849
+ /** One cart submission, holding one order per shop. */
2850
+ interface Checkout {
2851
+ id: string;
2852
+ invoice_number: string;
2853
+ status: CheckoutState;
2854
+ market_code: string;
2855
+ items_total: CheckoutMoney;
2856
+ delivery_total: CheckoutMoney;
2857
+ /** The BPF across every shop's order; zero when none. */
2858
+ bpf_total: CheckoutMoney;
2859
+ /** What the buyer pays: items + delivery + BPF. */
2860
+ total: CheckoutMoney;
2861
+ /** Payment due-by (ISO 8601). */
2862
+ due_at: string;
2863
+ created_at: string;
2864
+ orders: CheckoutShopOrder[];
2865
+ }
2866
+ interface CreateCheckoutResponse {
2867
+ checkout: Checkout;
2868
+ order_ids: string[];
2869
+ count: number;
2870
+ }
2871
+ interface GetCheckoutResponse {
2872
+ checkout: Checkout;
2873
+ }
2874
+ /** Why a checkout was refused: the error body, keyed by `error`. */
2875
+ type CheckoutRefusal = {
2876
+ error: 'invalid_input' | 'empty_cart' | 'cannot_buy_own' | 'invalid_deliveries';
2877
+ } | {
2878
+ error: 'address_not_found';
2879
+ } | {
2880
+ error: 'idempotency_conflict';
2881
+ } | {
2882
+ error: 'listing_unavailable';
2883
+ listings: Array<{
2884
+ listing_id: string;
2885
+ available: number;
2886
+ }>;
2887
+ } | {
2888
+ error: 'mixed_market_cart' | 'market_not_active';
2889
+ } | {
2890
+ error: 'checkout_payment_in_progress';
2891
+ checkout_id: string;
2892
+ } | {
2893
+ error: 'delivery_quote_rejected';
2894
+ store_id: string | null;
2895
+ reason: string;
2896
+ } | {
2897
+ error: 'address_region_invalid';
2898
+ } | {
2899
+ error: 'delivery_required';
2900
+ store_ids: string[];
2901
+ } | {
2902
+ error: 'delivery_quotes_unavailable';
2903
+ };
2904
+ type CheckoutRefusalCode = CheckoutRefusal['error'];
2905
+
2821
2906
  /**
2822
2907
  * Fields a user may change on their own profile via `PUT /auth/me`. Every field is optional;
2823
2908
  * only the ones provided are updated. The server enforces the profile contract:
@@ -3283,7 +3368,9 @@ declare class APIError extends Error {
3283
3368
  readonly code: string;
3284
3369
  readonly status: number;
3285
3370
  readonly details?: unknown;
3286
- constructor(status: number, data: APIErrorResponse);
3371
+ /** The decoded error body as the server sent it, for errors whose details are top-level fields. */
3372
+ readonly body?: unknown;
3373
+ constructor(status: number, data: APIErrorResponse, body?: unknown);
3287
3374
  }
3288
3375
  declare class APIClient {
3289
3376
  private config;
@@ -4209,6 +4296,8 @@ declare class CartModule {
4209
4296
  }>;
4210
4297
  /**
4211
4298
  * Checkout the cart — creates orders grouped by store and clears the cart.
4299
+ * @deprecated Use `sdk.checkouts.create`: checkout needs an address, an idempotency key and a
4300
+ * delivery quote per shop, and returns the checkout with its totals.
4212
4301
  */
4213
4302
  checkout(options?: RequestOptions): Promise<{
4214
4303
  order_ids: string[];
@@ -4216,6 +4305,25 @@ declare class CartModule {
4216
4305
  }>;
4217
4306
  }
4218
4307
 
4308
+ /**
4309
+ * The checkout refusal carried by an error thrown from `checkouts.create`, or null when the error is
4310
+ * not one. The body is the server's own, so the refusal's details (such as `listings` for
4311
+ * `listing_unavailable`) are present.
4312
+ */
4313
+ declare function checkoutRefusal(error: unknown): CheckoutRefusal | null;
4314
+ declare class CheckoutsModule {
4315
+ private readonly client;
4316
+ constructor(client: APIClient);
4317
+ /**
4318
+ * Create a checkout from the buyer's cart: one order per shop, each at the delivery quote picked
4319
+ * for it, held until the checkout's due-by. A retry with the same `idempotency_key` returns the
4320
+ * same checkout. A refusal throws an `APIError`; read it with `checkoutRefusal(error)`.
4321
+ */
4322
+ create(input: CreateCheckoutInput, options?: RequestOptions): Promise<CreateCheckoutResponse>;
4323
+ /** Read one of the buyer's checkouts. Anyone else gets a 404. */
4324
+ get(checkoutId: string, options?: RequestOptions): Promise<GetCheckoutResponse>;
4325
+ }
4326
+
4219
4327
  declare class SettingsModule {
4220
4328
  private readonly client;
4221
4329
  constructor(client: APIClient);
@@ -5162,6 +5270,7 @@ declare class MitumbaClient {
5162
5270
  readonly reviews: ReviewsModule;
5163
5271
  readonly wishlists: WishlistsModule;
5164
5272
  readonly cart: CartModule;
5273
+ readonly checkouts: CheckoutsModule;
5165
5274
  readonly settings: SettingsModule;
5166
5275
  readonly mailer: MailerModule;
5167
5276
  readonly businesses: BusinessesModule;
@@ -5203,4 +5312,4 @@ declare class MitumbaClient {
5203
5312
  isAuthenticated(): Promise<boolean>;
5204
5313
  }
5205
5314
 
5206
- export { APIClient, APIError, type APIErrorResponse, type ActivateIamUserInput, type ActivateIamUserResult, type Add2FAMethodInput, type Add2FAMethodResult, type AddAddressInput, type AddDepotInput, type AddIamPasskeyResult, type AddIamTotpResult, type AddIamTwoFactorMethodInput, type AddPaymentMethodInput, type Address, type AdminAuditActor, type AdminAuditEntry, type AdminAuditQuery, type AdminAuthStrength, type AdminListingItem, type AdminMessageReport, type AdminMessageReportDetail, type AdminMessageReportList, type AdminMessageReportThreadMessage, AdminModule, type AdminOperator, type AdminOrderDetail, type AdminOrderListItem, type AdminPayoutItem, type AdminPermission, type AdminPermissionDescription, type AdminRecoveryEvent, type AdminRecoveryRequest, type AdminReport, type AdminRolePreset, type AdminStoreDetail, type AdminStoreListItem, type AdminUserDetail, type AdminUserListItem, type AdminVaziOutfit, type AdminVerificationItem, type AdminWholesalePendingStore, type ApiResponse, type AttachmentDownloadAuthorization, type AttachmentUploadAuthorization, type AttachmentUploadBody, type AttachmentUploadState, type AttachmentUploadStatus, type AuthCapabilities, AuthModule, type AuthTokens, type AuthenticationResponseJSON, BALE_ORDER_STATUSES, type Bale, type BaleDetail, type BaleFeedItem, type BaleFulfillment, type BaleGrade, type BaleImageUploadResult, type BaleOrder, type BaleOrderEvent, type BaleOrderStatus, type BaleType, type BecomeBaleSellerInput, type BecomeSellerInput, type BlockedIp, type Business, type BusinessType, BusinessesModule, type BuyerResolveThreadInput, type BuyerSummary, CONDITIONS, type CartItem, CartModule, type Category, type ChangePasswordInput, type ChangePlatformSettingInput, type ChangePlatformSettingResult, type CheckoutNextAction, type CheckoutOrder, type CheckoutPaymentMethod, type CheckoutStatus, type CheckoutStatusResponse, type City, type CompleteOnboardingInput, type CompleteRecoveryResult, type Condition, type Conversation, type ConversationId, type ConversationSummary, type CreateAttachmentUploadInput, type CreateBaleInput, type CreateBaleOrderInput, type CreateIamUserInput, type CreateIamUserResult, type CreateListingInput, type CreateMessageBlockInput, type CreateMessageBlockResult, type CreateMessageReportInput, type CreateMessageReportResult, type CreateOrderInput, type CreateOrganizationInput, type CreateReportInput, type CreateReviewInput, type CreateStoreInput, type CursorPage, DEFAULT_SHARE_ORIGIN, 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 FileResponse, type FinishIamPasskeyEnrollmentInput, type FinishIamPasskeyLoginInput, type FollowedStore, type ForgotPasswordInput, IDBTokenStore, type IamActivation, type IamLoginInput, type IamLoginMethod, type IamMethodsResult, IamModule, type IamPasskeyLoginOptions, type IamProfile, type IamSession, type IamSessionsResult, type IamSignIn, type IamSignInFailureReason, type IamSignInsResult, type IamTokens, type IamTwoFactorRequired, type IamUser, type IamUserStatus, type InboxRealtimeEvent, type InitiateCheckoutInput, type InitiateCheckoutResponse, type Jwk, type Jwks, type KnownPaymentProvider, LISTING_STATUSES, type LegacyLinkResolution, type LegacyMessageArchiveSummary, type LegacyMessagePage, type LegacyMessageRecord, type LibraryCadence, type LibraryCompleter, type LibraryDocument, type LibraryDocumentSummary, type LibraryKind, type LibraryListing, type LibraryOccurrence, type LibraryOccurrenceRecorded, type LibraryOccurrenceStatus, type LibraryRoutineState, type LibrarySchedule, type LibraryScheduleRule, type LibrarySeason, type LibraryWeekday, type LinkedAccount, type LinkedAccountProvider, type ListConversationsParams, type ListIamUsersResult, type ListThreadMessagesParams, type ListThreadsParams, type Listing, type ListingImage, type ListingStatus, type ListingsFeedParams, ListingsModule, type LoginInput, MailerModule, type MailerTemplate, type Market, type MarketCurrency, type MarketPhone, type MarketRegion, type MarketRegionsResponse, type MarketStatus, MarketsModule, type MarketsResponse, MemoryTokenStore, type Message, type MessageAttachment, type MessageAuthor, type MessageId, type MessagePage, type MessageReportOutcome, type MessageReportReason, type MessageReportStatus, type MessageResponse, MessagesModule, type MessagesRealtimeConnection, type MessagesRealtimeEnvelope, type MessagesRealtimeEvent, type MessagesRealtimeOptions, type MessagesRealtimeState, type MessagesRealtimeTicket, type MessagingBlockInput, type MessagingBlockRemovedResult, type MessagingBlockResult, type MessagingCapabilities, type MessagingCursor, type MessagingErrorCode, type MessagingIdempotentRequestOptions, type MessagingInboxes, type MessagingPerspective, type MessagingSide, MitumbaClient, type MitumbaClientConfig, type MpesaInput, type Notification, type NotificationPref, type NotificationType, NotificationsModule, type OAuthAuthorizeInput, type OAuthAuthorizeResult, type OAuthClient, type OAuthClientSummary, type OAuthClientTrustLevel, type OAuthClientType, type OAuthConsent, type OAuthConsentInput, type OAuthConsentRequired, type OAuthConsentRevokeResult, OAuthModule, type OAuthTokenExchangeInput, type OAuthTokenResult, ORDER_STATUSES, type OidcSigningKey, type OpenIdConfiguration, type OperatorPermissionGrant, type Order, type OrderDocument, type OrderDocumentKind, type OrderEvent, type OrderHistoryParams, type OrderStatus, OrdersModule, type Organization, type OrganizationKind, type OrganizationStatus, type OrganizationSummary, PAYMENT_STATUSES, type PaginatedResponse, PayModule, type PaymentAttemptStatus, type PaymentMethod, type PaymentMethodType, type PaymentProvider, type PaymentStatus, type PaymentStatusResponse, type PaystackInitResponse, type PaystackInput, type PendingPayoutApproval, type PhoneLoginInput, type PhoneRegisterInput, type PlatformSetting, type PlatformSettingChange, type PlatformSettingDetail, type PlatformSettingGroup, type PlatformSettingKind, type PresignImageResponse, type ProviderId, type PublicKeyCredentialCreationOptionsJSON, type PublicKeyCredentialRequestOptionsJSON, type RaiseDisputeInput, type ReadCursorResult, RealtimeProtocolError, RealtimeUnavailableError, type RecoveryStatus, type RecoveryStatusResult, type RegenerateBackupCodesResult, type RegenerateIamBackupCodesResult, type RegisterInput, type RegisterOAuthClientInput, type RegisteredOAuthClient, type RegistrationResponseJSON, ReportsModule, type RequestOptions, type RequestRecoveryInput, type RequestRecoveryResult, type ResetPasswordInput, type ResolveDisputeInput, type ResolveMessageReportInput, type ResolveMessageReportResult, type ResolveThreadResult, type RespondDisputeInput, type Review, type ReviewableOrder, ReviewsModule, type RootSetupInput, type RootSetupResult, type SaveSearchInput, type SaveWholesaleStoreInput, type SearchHistoryItem, SearchModule, type SearchParams, type SearchResult, type SellerProfile, type SellerStorefront, type SellerType, type SendEmailInput, type SendMessageInput, type SendOtpInput, type SendThreadMessageInput, type SendThreadMessageResult, type Session, SettingsModule, type ShareUrlOptions, type SilentAuthorizeResult, type SimilarListing, type StiEvent, type StkPushInput, type StkPushResponse, type Store, type StoreAnalytics, type StoreResolveThreadInput, type StoreReviewsPage, type StoreSettings, type StoreStats, type StoreSummary, StoresModule, type SubscriptionTier, type SystemStats, TWO_FACTOR_METHOD_TYPES, type ThreadCard, type ThreadId, type ThreadMessage, type ThreadSubject, type ThreadSystemEvent, type ThreadTimelineItem, type ThreadTimelineItemId, type TokenStore, type TransitionOrderInput, type TrendingTerm, type TwoFactorMethod, type TwoFactorMethodType, type TwoFactorRequired, type UpdateBusinessInput, type UpdateConversationPreferencesInput, type UpdateListingInput, type UpdateOrganizationInput, type UpdateProfileInput, type UpdateStoreInput, type UpdateThreadPreferencesInput, UploadsModule, type UserInfo, type UserProfile, type VAZIOutfit, type VAZIOutfitDetail, type VAZIOutfitDetailItem, type VAZIOutfitItem, type VaziFeedParams, type VaziFeedResponse, VaziModule, type Verify2FAInput, type VerifyIamMethodResult, type VerifyIamTwoFactorInput, type VerifyOtpInput, type WebSocketCloseEventLike, type WebSocketFactory, type WebSocketLike, type WebSocketMessageEventLike, type WholesaleAnalytics, type WholesaleDepot, type WholesaleFeedParams, WholesaleModule, type WholesaleReviewStatus, type WholesaleStore, type WishlistListing, WishlistsModule, activeMarkets, baleShareUrl, createTokenStore, findMarket, findRegion, formatAmount, formatMoney, formatMoneyCompact, formatPhone, isConsentRequired, isMessagingAPIError, isValidPhone, listingShareUrl, maskPhone, normalizePhone, regionById, storeShareUrl };
5315
+ export { APIClient, APIError, type APIErrorResponse, type ActivateIamUserInput, type ActivateIamUserResult, type Add2FAMethodInput, type Add2FAMethodResult, type AddAddressInput, type AddDepotInput, type AddIamPasskeyResult, type AddIamTotpResult, type AddIamTwoFactorMethodInput, type AddPaymentMethodInput, type Address, type AdminAuditActor, type AdminAuditEntry, type AdminAuditQuery, type AdminAuthStrength, type AdminListingItem, type AdminMessageReport, type AdminMessageReportDetail, type AdminMessageReportList, type AdminMessageReportThreadMessage, AdminModule, type AdminOperator, type AdminOrderDetail, type AdminOrderListItem, type AdminPayoutItem, type AdminPermission, type AdminPermissionDescription, type AdminRecoveryEvent, type AdminRecoveryRequest, type AdminReport, type AdminRolePreset, type AdminStoreDetail, type AdminStoreListItem, type AdminUserDetail, type AdminUserListItem, type AdminVaziOutfit, type AdminVerificationItem, type AdminWholesalePendingStore, type ApiResponse, type AttachmentDownloadAuthorization, type AttachmentUploadAuthorization, type AttachmentUploadBody, type AttachmentUploadState, type AttachmentUploadStatus, type AuthCapabilities, AuthModule, type AuthTokens, type AuthenticationResponseJSON, BALE_ORDER_STATUSES, type Bale, type BaleDetail, type BaleFeedItem, type BaleFulfillment, type BaleGrade, type BaleImageUploadResult, type BaleOrder, type BaleOrderEvent, type BaleOrderStatus, type BaleType, type BecomeBaleSellerInput, type BecomeSellerInput, type BlockedIp, type Business, type BusinessType, BusinessesModule, type BuyerResolveThreadInput, type BuyerSummary, CONDITIONS, type CartItem, CartModule, type Category, type ChangePasswordInput, type ChangePlatformSettingInput, type ChangePlatformSettingResult, type Checkout, type CheckoutMoney, type CheckoutNextAction, type CheckoutOrder, type CheckoutPaymentMethod, type CheckoutRefusal, type CheckoutRefusalCode, type CheckoutShopOrder, type CheckoutState, type CheckoutStatus, type CheckoutStatusResponse, CheckoutsModule, type City, type CompleteOnboardingInput, type CompleteRecoveryResult, type Condition, type Conversation, type ConversationId, type ConversationSummary, type CreateAttachmentUploadInput, type CreateBaleInput, type CreateBaleOrderInput, type CreateCheckoutInput, type CreateCheckoutResponse, type CreateIamUserInput, type CreateIamUserResult, type CreateListingInput, type CreateMessageBlockInput, type CreateMessageBlockResult, type CreateMessageReportInput, type CreateMessageReportResult, type CreateOrderInput, type CreateOrganizationInput, type CreateReportInput, type CreateReviewInput, type CreateStoreInput, type CursorPage, DEFAULT_SHARE_ORIGIN, 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 FileResponse, type FinishIamPasskeyEnrollmentInput, type FinishIamPasskeyLoginInput, type FollowedStore, type ForgotPasswordInput, type GetCheckoutResponse, IDBTokenStore, type IamActivation, type IamLoginInput, type IamLoginMethod, type IamMethodsResult, IamModule, type IamPasskeyLoginOptions, type IamProfile, type IamSession, type IamSessionsResult, type IamSignIn, type IamSignInFailureReason, type IamSignInsResult, type IamTokens, type IamTwoFactorRequired, type IamUser, type IamUserStatus, type InboxRealtimeEvent, type InitiateCheckoutInput, type InitiateCheckoutResponse, type Jwk, type Jwks, type KnownPaymentProvider, LISTING_STATUSES, type LegacyLinkResolution, type LegacyMessageArchiveSummary, type LegacyMessagePage, type LegacyMessageRecord, type LibraryCadence, type LibraryCompleter, type LibraryDocument, type LibraryDocumentSummary, type LibraryKind, type LibraryListing, type LibraryOccurrence, type LibraryOccurrenceRecorded, type LibraryOccurrenceStatus, type LibraryRoutineState, type LibrarySchedule, type LibraryScheduleRule, type LibrarySeason, type LibraryWeekday, type LinkedAccount, type LinkedAccountProvider, type ListConversationsParams, type ListIamUsersResult, type ListThreadMessagesParams, type ListThreadsParams, type Listing, type ListingImage, type ListingStatus, type ListingsFeedParams, ListingsModule, type LoginInput, MailerModule, type MailerTemplate, type Market, type MarketCurrency, type MarketPhone, type MarketRegion, type MarketRegionsResponse, type MarketStatus, MarketsModule, type MarketsResponse, MemoryTokenStore, type Message, type MessageAttachment, type MessageAuthor, type MessageId, type MessagePage, type MessageReportOutcome, type MessageReportReason, type MessageReportStatus, type MessageResponse, MessagesModule, type MessagesRealtimeConnection, type MessagesRealtimeEnvelope, type MessagesRealtimeEvent, type MessagesRealtimeOptions, type MessagesRealtimeState, type MessagesRealtimeTicket, type MessagingBlockInput, type MessagingBlockRemovedResult, type MessagingBlockResult, type MessagingCapabilities, type MessagingCursor, type MessagingErrorCode, type MessagingIdempotentRequestOptions, type MessagingInboxes, type MessagingPerspective, type MessagingSide, MitumbaClient, type MitumbaClientConfig, type MpesaInput, type Notification, type NotificationPref, type NotificationType, NotificationsModule, type OAuthAuthorizeInput, type OAuthAuthorizeResult, type OAuthClient, type OAuthClientSummary, type OAuthClientTrustLevel, type OAuthClientType, type OAuthConsent, type OAuthConsentInput, type OAuthConsentRequired, type OAuthConsentRevokeResult, OAuthModule, type OAuthTokenExchangeInput, type OAuthTokenResult, ORDER_STATUSES, type OidcSigningKey, type OpenIdConfiguration, type OperatorPermissionGrant, type Order, type OrderDocument, type OrderDocumentKind, type OrderEvent, type OrderHistoryParams, type OrderStatus, OrdersModule, type Organization, type OrganizationKind, type OrganizationStatus, type OrganizationSummary, PAYMENT_STATUSES, type PaginatedResponse, PayModule, type PaymentAttemptStatus, type PaymentMethod, type PaymentMethodType, type PaymentProvider, type PaymentStatus, type PaymentStatusResponse, type PaystackInitResponse, type PaystackInput, type PendingPayoutApproval, type PhoneLoginInput, type PhoneRegisterInput, type PlatformSetting, type PlatformSettingChange, type PlatformSettingDetail, type PlatformSettingGroup, type PlatformSettingKind, type PresignImageResponse, type ProviderId, type PublicKeyCredentialCreationOptionsJSON, type PublicKeyCredentialRequestOptionsJSON, type RaiseDisputeInput, type ReadCursorResult, RealtimeProtocolError, RealtimeUnavailableError, type RecoveryStatus, type RecoveryStatusResult, type RegenerateBackupCodesResult, type RegenerateIamBackupCodesResult, type RegisterInput, type RegisterOAuthClientInput, type RegisteredOAuthClient, type RegistrationResponseJSON, ReportsModule, type RequestOptions, type RequestRecoveryInput, type RequestRecoveryResult, type ResetPasswordInput, type ResolveDisputeInput, type ResolveMessageReportInput, type ResolveMessageReportResult, type ResolveThreadResult, type RespondDisputeInput, type Review, type ReviewableOrder, ReviewsModule, type RootSetupInput, type RootSetupResult, type SaveSearchInput, type SaveWholesaleStoreInput, type SearchHistoryItem, SearchModule, type SearchParams, type SearchResult, type SellerProfile, type SellerStorefront, type SellerType, type SendEmailInput, type SendMessageInput, type SendOtpInput, type SendThreadMessageInput, type SendThreadMessageResult, type Session, SettingsModule, type ShareUrlOptions, type SilentAuthorizeResult, type SimilarListing, type StiEvent, type StkPushInput, type StkPushResponse, type Store, type StoreAnalytics, type StoreResolveThreadInput, type StoreReviewsPage, type StoreSettings, type StoreStats, type StoreSummary, StoresModule, type SubscriptionTier, type SystemStats, TWO_FACTOR_METHOD_TYPES, type ThreadCard, type ThreadId, type ThreadMessage, type ThreadSubject, type ThreadSystemEvent, type ThreadTimelineItem, type ThreadTimelineItemId, type TokenStore, type TransitionOrderInput, type TrendingTerm, type TwoFactorMethod, type TwoFactorMethodType, type TwoFactorRequired, type UpdateBusinessInput, type UpdateConversationPreferencesInput, type UpdateListingInput, type UpdateOrganizationInput, type UpdateProfileInput, type UpdateStoreInput, type UpdateThreadPreferencesInput, UploadsModule, type UserInfo, type UserProfile, type VAZIOutfit, type VAZIOutfitDetail, type VAZIOutfitDetailItem, type VAZIOutfitItem, type VaziFeedParams, type VaziFeedResponse, VaziModule, type Verify2FAInput, type VerifyIamMethodResult, type VerifyIamTwoFactorInput, type VerifyOtpInput, type WebSocketCloseEventLike, type WebSocketFactory, type WebSocketLike, type WebSocketMessageEventLike, type WholesaleAnalytics, type WholesaleDepot, type WholesaleFeedParams, WholesaleModule, type WholesaleReviewStatus, type WholesaleStore, type WishlistListing, WishlistsModule, activeMarkets, baleShareUrl, checkoutRefusal, createTokenStore, findMarket, findRegion, formatAmount, formatMoney, formatMoneyCompact, formatPhone, isConsentRequired, isMessagingAPIError, isValidPhone, listingShareUrl, maskPhone, normalizePhone, regionById, storeShareUrl };
package/dist/index.js CHANGED
@@ -134,12 +134,15 @@ var APIError = class extends Error {
134
134
  code;
135
135
  status;
136
136
  details;
137
- constructor(status, data) {
137
+ /** The decoded error body as the server sent it, for errors whose details are top-level fields. */
138
+ body;
139
+ constructor(status, data, body) {
138
140
  super(data.message || data.error);
139
141
  this.name = "APIError";
140
142
  this.code = data.error;
141
143
  this.status = status;
142
144
  this.details = data.details;
145
+ this.body = body;
143
146
  }
144
147
  };
145
148
  function isExpiringSoon(token, thresholdSeconds) {
@@ -385,7 +388,7 @@ var APIClient = class {
385
388
  } catch {
386
389
  decoded = null;
387
390
  }
388
- throw new APIError(response.status, normalizeAPIErrorResponse(decoded, response.statusText));
391
+ throw new APIError(response.status, normalizeAPIErrorResponse(decoded, response.statusText), decoded ?? void 0);
389
392
  }
390
393
  return response;
391
394
  }
@@ -2104,12 +2107,57 @@ var CartModule = class {
2104
2107
  }
2105
2108
  /**
2106
2109
  * Checkout the cart — creates orders grouped by store and clears the cart.
2110
+ * @deprecated Use `sdk.checkouts.create`: checkout needs an address, an idempotency key and a
2111
+ * delivery quote per shop, and returns the checkout with its totals.
2107
2112
  */
2108
2113
  async checkout(options) {
2109
2114
  return this.client.post("/orders/checkout", void 0, options);
2110
2115
  }
2111
2116
  };
2112
2117
 
2118
+ // src/modules/checkouts.ts
2119
+ var REFUSAL_CODES = /* @__PURE__ */ new Set([
2120
+ "invalid_input",
2121
+ "empty_cart",
2122
+ "cannot_buy_own",
2123
+ "invalid_deliveries",
2124
+ "address_not_found",
2125
+ "idempotency_conflict",
2126
+ "listing_unavailable",
2127
+ "mixed_market_cart",
2128
+ "market_not_active",
2129
+ "checkout_payment_in_progress",
2130
+ "delivery_quote_rejected",
2131
+ "address_region_invalid",
2132
+ "delivery_required",
2133
+ "delivery_quotes_unavailable"
2134
+ ]);
2135
+ function checkoutRefusal(error) {
2136
+ if (!(error instanceof APIError)) return null;
2137
+ const body = error.body;
2138
+ if (typeof body !== "object" || body === null) return null;
2139
+ const code = body.error;
2140
+ if (typeof code !== "string" || !REFUSAL_CODES.has(code)) return null;
2141
+ return body;
2142
+ }
2143
+ var CheckoutsModule = class {
2144
+ constructor(client) {
2145
+ this.client = client;
2146
+ }
2147
+ /**
2148
+ * Create a checkout from the buyer's cart: one order per shop, each at the delivery quote picked
2149
+ * for it, held until the checkout's due-by. A retry with the same `idempotency_key` returns the
2150
+ * same checkout. A refusal throws an `APIError`; read it with `checkoutRefusal(error)`.
2151
+ */
2152
+ async create(input, options) {
2153
+ return this.client.post("/orders/checkout", input, options);
2154
+ }
2155
+ /** Read one of the buyer's checkouts. Anyone else gets a 404. */
2156
+ async get(checkoutId, options) {
2157
+ return this.client.get(`/orders/checkouts/${encodeURIComponent(checkoutId)}`, void 0, options);
2158
+ }
2159
+ };
2160
+
2113
2161
  // src/modules/settings.ts
2114
2162
  var SettingsModule = class {
2115
2163
  constructor(client) {
@@ -3198,6 +3246,7 @@ var MitumbaClient = class {
3198
3246
  reviews;
3199
3247
  wishlists;
3200
3248
  cart;
3249
+ checkouts;
3201
3250
  settings;
3202
3251
  mailer;
3203
3252
  businesses;
@@ -3223,6 +3272,7 @@ var MitumbaClient = class {
3223
3272
  this.reviews = new ReviewsModule(this.api);
3224
3273
  this.wishlists = new WishlistsModule(this.api);
3225
3274
  this.cart = new CartModule(this.api);
3275
+ this.checkouts = new CheckoutsModule(this.api);
3226
3276
  this.settings = new SettingsModule(this.api);
3227
3277
  this.mailer = new MailerModule(this.api);
3228
3278
  this.businesses = new BusinessesModule(this.api);
@@ -3281,6 +3331,7 @@ exports.BALE_ORDER_STATUSES = BALE_ORDER_STATUSES;
3281
3331
  exports.BusinessesModule = BusinessesModule;
3282
3332
  exports.CONDITIONS = CONDITIONS;
3283
3333
  exports.CartModule = CartModule;
3334
+ exports.CheckoutsModule = CheckoutsModule;
3284
3335
  exports.DEFAULT_SHARE_ORIGIN = DEFAULT_SHARE_ORIGIN;
3285
3336
  exports.DESIRED_RESOLUTIONS = DESIRED_RESOLUTIONS;
3286
3337
  exports.DISPUTE_REASONS = DISPUTE_REASONS;
@@ -3315,6 +3366,7 @@ exports.WholesaleModule = WholesaleModule;
3315
3366
  exports.WishlistsModule = WishlistsModule;
3316
3367
  exports.activeMarkets = activeMarkets;
3317
3368
  exports.baleShareUrl = baleShareUrl;
3369
+ exports.checkoutRefusal = checkoutRefusal;
3318
3370
  exports.createTokenStore = createTokenStore;
3319
3371
  exports.findMarket = findMarket;
3320
3372
  exports.findRegion = findRegion;