@tagadapay/plugin-sdk 2.4.14 → 2.4.15

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.
@@ -89,5 +89,9 @@ export interface UseClubOffersResult {
89
89
  * Clear error state
90
90
  */
91
91
  clearError: () => void;
92
+ /**
93
+ * Pay for a club offer
94
+ */
95
+ payOffer: (offerId: string, returnUrl?: string) => Promise<Response>;
92
96
  }
93
97
  export declare function useClubOffers(options?: UseClubOffersOptions): UseClubOffersResult;
@@ -55,6 +55,15 @@ export function useClubOffers(options = {}) {
55
55
  return total + (firstSummary?.totalAmount - firstSummary?.totalAdjustedAmount || 0);
56
56
  }, 0);
57
57
  }, [offers]);
58
+ const payOffer = useCallback(async (offerId, returnUrl) => {
59
+ const url = returnUrl || (typeof window !== 'undefined' ? window.location.href : '');
60
+ return await apiService.fetch(`/api/v1/offers/${offerId}/pay`, {
61
+ method: 'POST',
62
+ body: JSON.stringify({
63
+ returnUrl: url,
64
+ }),
65
+ });
66
+ }, [apiService]);
58
67
  useEffect(() => {
59
68
  void fetchClubOffers();
60
69
  }, [fetchClubOffers]);
@@ -67,5 +76,6 @@ export function useClubOffers(options = {}) {
67
76
  getTotalValue,
68
77
  getTotalSavings,
69
78
  clearError,
79
+ payOffer,
70
80
  };
71
81
  }
@@ -4,7 +4,6 @@
4
4
  export { TagadaProvider } from './providers/TagadaProvider';
5
5
  export { useAuth } from './hooks/useAuth';
6
6
  export { useCheckout } from './hooks/useCheckout';
7
- export { useClubOffers } from './hooks/useClubOffers';
8
7
  export { useCurrency } from './hooks/useCurrency';
9
8
  export { useCustomer } from './hooks/useCustomer';
10
9
  export { useDiscounts } from './hooks/useDiscounts';
@@ -42,7 +41,6 @@ export type { CheckoutData, CheckoutInitParams, CheckoutLineItem, CheckoutSessio
42
41
  export type { Discount, DiscountCodeValidation, UseDiscountsOptions, UseDiscountsResult } from './hooks/useDiscounts';
43
42
  export type { OrderBumpPreview, UseOrderBumpOptions, UseOrderBumpResult } from './hooks/useOrderBump';
44
43
  export type { UseVipOffersOptions, UseVipOffersResult, VipOffer, VipPreviewResponse } from './hooks/useVipOffers';
45
- export type { ClubOffer, ClubOfferItem, ClubOfferLineItem, ClubOfferSummary, UseClubOffersOptions, UseClubOffersResult } from './hooks/useClubOffers';
46
44
  export type { PostPurchaseOffer, PostPurchaseOfferItem, PostPurchaseOfferLineItem, PostPurchaseOfferSummary, UsePostPurchasesOptions, UsePostPurchasesResult } from './hooks/usePostPurchases';
47
45
  export type { Payment, PaymentPollingHook, PollingOptions } from './hooks/usePaymentPolling';
48
46
  export type { PaymentInstrument, ThreedsChallenge, ThreedsHook, ThreedsOptions, ThreedsProvider, ThreedsSession } from './hooks/useThreeds';
@@ -7,7 +7,6 @@ export { TagadaProvider } from './providers/TagadaProvider';
7
7
  // Hook exports
8
8
  export { useAuth } from './hooks/useAuth';
9
9
  export { useCheckout } from './hooks/useCheckout';
10
- export { useClubOffers } from './hooks/useClubOffers';
11
10
  export { useCurrency } from './hooks/useCurrency';
12
11
  export { useCustomer } from './hooks/useCustomer';
13
12
  export { useDiscounts } from './hooks/useDiscounts';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tagadapay/plugin-sdk",
3
- "version": "2.4.14",
3
+ "version": "2.4.15",
4
4
  "description": "Modern React SDK for building Tagada Pay plugins",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",