@tagadapay/plugin-sdk 2.7.8 → 2.7.13

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.
@@ -308,4 +308,13 @@ export declare class CheckoutResource {
308
308
  shippingCountryChanged?: boolean;
309
309
  billingCountryChanged?: boolean;
310
310
  }>;
311
+ previewCheckoutSession(params: {
312
+ lineItems: CheckoutLineItem[];
313
+ storeId?: string;
314
+ currency: string;
315
+ promotionIds?: string[];
316
+ }): Promise<{
317
+ success: boolean;
318
+ preview: CheckoutSessionPreview;
319
+ }>;
311
320
  }
@@ -117,4 +117,7 @@ export class CheckoutResource {
117
117
  async updateCustomerAndSessionInfo(checkoutSessionId, data) {
118
118
  return this.apiClient.post(`/api/v1/checkout-sessions/${checkoutSessionId}/customer-and-session-info`, data);
119
119
  }
120
+ async previewCheckoutSession(params) {
121
+ return this.apiClient.post('/api/v1/checkout-sessions/preview', params);
122
+ }
120
123
  }
@@ -23,7 +23,7 @@ export type { ToggleOrderBumpResponse, VipOffer, VipPreviewResponse } from './co
23
23
  export type { StoreConfig } from './core/resources/storeConfig';
24
24
  export type { FunnelContextUpdateRequest, FunnelContextUpdateResponse, FunnelEvent, FunnelInitializeRequest, FunnelInitializeResponse, FunnelNavigateRequest, FunnelNavigateResponse, FunnelNavigationAction, FunnelNavigationResult, SimpleFunnelContext } from './core/resources/funnel';
25
25
  export { ApplePayButton, ExpressPaymentMethodsProvider, formatMoney, getAvailableLanguages, GooglePayButton, queryKeys, TagadaProvider, useApiMutation, useApiQuery, useAuth, useCheckout, useCheckoutToken, useClubOffers, useCountryOptions, useCurrency, useCustomer, useCustomerInfos, useCustomerOrders, useCustomerSubscriptions, useDiscounts, useExpressPaymentMethods, useFunnel, useGeoLocation, useGoogleAutocomplete, useInvalidateQuery, useISOData, useLanguageImport, useLogin, useOffers, useOrder, useOrderBump, usePayment, usePluginConfig, usePostPurchases, usePreloadQuery, useProducts, usePromotions, useRegionOptions, useShippingRates, useSimpleFunnel, useStoreConfig, useTagadaContext, useThreeds, useThreedsModal, useTranslation, useVipOffers } from './react';
26
- export type { TranslateFunction, UseTranslationOptions, UseTranslationResult } from './react/hooks/useTranslation';
26
+ export type { TranslateFunction, TranslationText, UseTranslationOptions, UseTranslationResult } from './react/hooks/useTranslation';
27
27
  export type { ClubOffer, ClubOfferItem, ClubOfferLineItem, ClubOfferSummary, UseClubOffersOptions, UseClubOffersResult } from './react/hooks/useClubOffers';
28
28
  export type { UseLoginOptions, UseLoginResult } from './react/hooks/useLogin';
29
29
  export type { CustomerAddress, CustomerInfos, CustomerOrderSummary, OrderWithRelations, Subscription, SubscriptionsResponse } from './core/resources/customer';
@@ -2,7 +2,7 @@
2
2
  * Checkout Hook using TanStack Query
3
3
  * Replaces the coordinator pattern with automatic cache invalidation
4
4
  */
5
- import { CheckoutData, CheckoutInitParams, CheckoutLineItem } from '../../core/resources/checkout';
5
+ import { CheckoutData, CheckoutInitParams, CheckoutLineItem, CheckoutSessionPreview } from '../../core/resources/checkout';
6
6
  export interface UseCheckoutQueryOptions {
7
7
  checkoutToken?: string;
8
8
  enabled?: boolean;
@@ -36,5 +36,9 @@ export interface UseCheckoutQueryResult {
36
36
  }) => Promise<any>;
37
37
  applyPromotionCode: (code: string) => Promise<any>;
38
38
  removePromotion: (promotionId: string) => Promise<any>;
39
+ previewCheckoutSession: (lineItems: CheckoutLineItem[], promotionIds?: string[]) => Promise<{
40
+ success: boolean;
41
+ preview: CheckoutSessionPreview;
42
+ }>;
39
43
  }
40
44
  export declare function useCheckoutQuery(options?: UseCheckoutQueryOptions): UseCheckoutQueryResult;
@@ -2,13 +2,13 @@
2
2
  * Checkout Hook using TanStack Query
3
3
  * Replaces the coordinator pattern with automatic cache invalidation
4
4
  */
5
- import { useCallback, useState, useEffect, useMemo, useRef } from 'react';
6
- import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
5
+ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
6
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
7
7
  import { CheckoutResource } from '../../core/resources/checkout';
8
8
  import { useTagadaContext } from '../providers/TagadaProvider';
9
- import { usePluginConfig } from './usePluginConfig';
10
- import { useCurrency } from './useCurrency';
11
9
  import { getGlobalApiClient } from './useApiQuery';
10
+ import { useCurrency } from './useCurrency';
11
+ import { usePluginConfig } from './usePluginConfig';
12
12
  export function useCheckoutQuery(options = {}) {
13
13
  const { checkoutToken: providedToken, enabled = true } = options;
14
14
  const { storeId } = usePluginConfig();
@@ -237,6 +237,14 @@ export function useCheckoutQuery(options = {}) {
237
237
  }
238
238
  },
239
239
  });
240
+ const previewCheckoutSessionMutation = useMutation({
241
+ mutationFn: ({ lineItems, promotionIds }) => checkoutResource.previewCheckoutSession({
242
+ lineItems,
243
+ storeId,
244
+ currency: currency.code,
245
+ promotionIds,
246
+ }),
247
+ });
240
248
  return {
241
249
  // Query data
242
250
  checkout,
@@ -265,5 +273,6 @@ export function useCheckoutQuery(options = {}) {
265
273
  updateCustomerAndSessionInfo: (data) => customerAndSessionMutation.mutateAsync(data),
266
274
  applyPromotionCode: (code) => promotionMutation.mutateAsync({ code }),
267
275
  removePromotion: (promotionId) => removePromotionMutation.mutateAsync({ promotionId }),
276
+ previewCheckoutSession: (lineItems, promotionIds) => previewCheckoutSessionMutation.mutateAsync({ lineItems, promotionIds }),
268
277
  };
269
278
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tagadapay/plugin-sdk",
3
- "version": "2.7.8",
3
+ "version": "2.7.13",
4
4
  "description": "Modern React SDK for building Tagada Pay plugins",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",