@tagadapay/plugin-sdk 3.1.5 → 3.1.9

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.
Files changed (71) hide show
  1. package/README.md +1129 -1129
  2. package/build-cdn.js +220 -113
  3. package/dist/external-tracker.js +1225 -558
  4. package/dist/external-tracker.min.js +2 -2
  5. package/dist/external-tracker.min.js.map +4 -4
  6. package/dist/react/hooks/useApplePay.js +25 -36
  7. package/dist/react/hooks/usePaymentPolling.d.ts +9 -3
  8. package/dist/react/providers/TagadaProvider.js +5 -5
  9. package/dist/react/utils/money.d.ts +4 -3
  10. package/dist/react/utils/money.js +39 -6
  11. package/dist/react/utils/trackingUtils.js +1 -0
  12. package/dist/tagada-sdk.js +10142 -0
  13. package/dist/tagada-sdk.min.js +43 -0
  14. package/dist/tagada-sdk.min.js.map +7 -0
  15. package/dist/v2/core/client.js +34 -2
  16. package/dist/v2/core/config/environment.js +9 -2
  17. package/dist/v2/core/funnelClient.d.ts +180 -2
  18. package/dist/v2/core/funnelClient.js +289 -6
  19. package/dist/v2/core/resources/apiClient.js +1 -1
  20. package/dist/v2/core/resources/checkout.d.ts +68 -0
  21. package/dist/v2/core/resources/funnel.d.ts +25 -0
  22. package/dist/v2/core/resources/payments.d.ts +70 -3
  23. package/dist/v2/core/resources/payments.js +72 -7
  24. package/dist/v2/core/utils/index.d.ts +1 -0
  25. package/dist/v2/core/utils/index.js +2 -0
  26. package/dist/v2/core/utils/pluginConfig.d.ts +8 -0
  27. package/dist/v2/core/utils/pluginConfig.js +68 -5
  28. package/dist/v2/core/utils/previewMode.d.ts +7 -0
  29. package/dist/v2/core/utils/previewMode.js +72 -14
  30. package/dist/v2/core/utils/previewModeIndicator.d.ts +19 -0
  31. package/dist/v2/core/utils/previewModeIndicator.js +414 -0
  32. package/dist/v2/core/utils/tokenStorage.d.ts +4 -0
  33. package/dist/v2/core/utils/tokenStorage.js +15 -1
  34. package/dist/v2/index.d.ts +9 -3
  35. package/dist/v2/index.js +8 -3
  36. package/dist/v2/react/components/ApplePayButton.d.ts +22 -123
  37. package/dist/v2/react/components/ApplePayButton.js +247 -317
  38. package/dist/v2/react/components/FunnelScriptInjector.d.ts +3 -1
  39. package/dist/v2/react/components/FunnelScriptInjector.js +255 -162
  40. package/dist/v2/react/components/GooglePayButton.d.ts +2 -0
  41. package/dist/v2/react/components/GooglePayButton.js +80 -64
  42. package/dist/v2/react/components/PreviewModeIndicator.d.ts +46 -0
  43. package/dist/v2/react/components/PreviewModeIndicator.js +113 -0
  44. package/dist/v2/react/hooks/useApplePayCheckout.d.ts +16 -0
  45. package/dist/v2/react/hooks/useApplePayCheckout.js +193 -0
  46. package/dist/v2/react/hooks/useFunnel.d.ts +48 -6
  47. package/dist/v2/react/hooks/useFunnel.js +25 -5
  48. package/dist/v2/react/hooks/useGoogleAutocomplete.d.ts +10 -0
  49. package/dist/v2/react/hooks/useGoogleAutocomplete.js +48 -0
  50. package/dist/v2/react/hooks/useGooglePayCheckout.d.ts +21 -0
  51. package/dist/v2/react/hooks/useGooglePayCheckout.js +198 -0
  52. package/dist/v2/react/hooks/usePaymentPolling.d.ts +15 -3
  53. package/dist/v2/react/hooks/usePaymentPolling.js +31 -9
  54. package/dist/v2/react/hooks/usePaymentQuery.d.ts +34 -2
  55. package/dist/v2/react/hooks/usePaymentQuery.js +731 -7
  56. package/dist/v2/react/hooks/usePaymentRetrieve.d.ts +26 -0
  57. package/dist/v2/react/hooks/usePaymentRetrieve.js +175 -0
  58. package/dist/v2/react/hooks/usePixelTracking.d.ts +56 -0
  59. package/dist/v2/react/hooks/usePixelTracking.js +508 -0
  60. package/dist/v2/react/hooks/useStepConfig.d.ts +64 -0
  61. package/dist/v2/react/hooks/useStepConfig.js +53 -0
  62. package/dist/v2/react/index.d.ts +15 -5
  63. package/dist/v2/react/index.js +8 -2
  64. package/dist/v2/react/providers/ExpressPaymentMethodsProvider.d.ts +1 -0
  65. package/dist/v2/react/providers/ExpressPaymentMethodsProvider.js +41 -13
  66. package/dist/v2/react/providers/TagadaProvider.js +24 -23
  67. package/dist/v2/standalone/external-tracker.d.ts +2 -0
  68. package/dist/v2/standalone/external-tracker.js +6 -3
  69. package/package.json +112 -112
  70. package/dist/v2/react/hooks/useApplePay.d.ts +0 -16
  71. package/dist/v2/react/hooks/useApplePay.js +0 -247
@@ -7,11 +7,14 @@
7
7
  */
8
8
  export * from './core/googleAutocomplete';
9
9
  export * from './core/isoData';
10
+ export * from './core/utils/configHotReload';
10
11
  export * from './core/utils/currency';
11
12
  export * from './core/utils/pluginConfig';
12
- export * from './core/utils/products';
13
13
  export * from './core/utils/previewMode';
14
- export * from './core/utils/configHotReload';
14
+ export { injectPreviewModeIndicator, isIndicatorInjected, removePreviewModeIndicator } from './core/utils/previewModeIndicator';
15
+ export * from './core/utils/products';
16
+ export { getAssignedPaymentFlowId, getAssignedScripts, getAssignedStaticResources, getAssignedStepConfig, getLocalFunnelConfig, loadLocalFunnelConfig } from './core/funnelClient';
17
+ export type { LocalFunnelConfig, RuntimeStepConfig } from './core/funnelClient';
15
18
  export * from './core/pathRemapping';
16
19
  export type { CheckoutData, CheckoutInitParams, CheckoutLineItem, CheckoutSession, CheckoutSessionPreview, Promotion } from './core/resources/checkout';
17
20
  export type { Order, OrderLineItem } from './core/utils/order';
@@ -25,17 +28,20 @@ export type { ToggleOrderBumpResponse, VipOffer, VipPreviewResponse } from './co
25
28
  export type { StoreConfig } from './core/resources/storeConfig';
26
29
  export { FunnelActionType } from './core/resources/funnel';
27
30
  export type { BackNavigationActionData, CartUpdatedActionData, DirectNavigationActionData, FormSubmitActionData, FunnelContextUpdateRequest, FunnelContextUpdateResponse, FunnelAction as FunnelEvent, FunnelInitializeRequest, FunnelInitializeResponse, FunnelNavigateRequest, FunnelNavigateResponse, FunnelNavigationAction, FunnelNavigationResult, NextAction, OfferAcceptedActionData, OfferDeclinedActionData, PaymentFailedActionData, PaymentSuccessActionData, SimpleFunnelContext } from './core/resources/funnel';
28
- export { ApplePayButton, ExpressPaymentMethodsProvider, formatMoney, getAvailableLanguages, GooglePayButton, queryKeys, TagadaProvider, useApiMutation, useApiQuery, useAuth, useCheckout, useCheckoutToken, useClubOffers, useCountryOptions, useCredits, useCurrency, useCustomer, useCustomerInfos, useCustomerOrders, useCustomerSubscriptions, useDiscounts, useExpressPaymentMethods, useFunnel, useFunnelLegacy, useGeoLocation, useGoogleAutocomplete, useInvalidateQuery, useISOData, useLanguageImport, useLogin, useOffer, useOrder, useOrderBump, usePayment, usePluginConfig, usePostPurchases, usePreloadQuery, usePreviewOffer, useProducts, usePromotions, useRegionOptions, useRemappableParams, useShippingRates, useSimpleFunnel, useStoreConfig, useTagadaContext, useThreeds, useThreedsModal, useTranslation, useVipOffers } from './react';
31
+ export { ApplePayButton, ExpressPaymentMethodsProvider, formatMoney, getAvailableLanguages, GooglePayButton, PreviewModeIndicator, queryKeys, TagadaProvider, useApiMutation, useApiQuery, useApplePayCheckout, useAuth, useCheckout, useCheckoutToken, useClubOffers, useCountryOptions, useCredits, useCurrency, useCustomer, useCustomerInfos, useCustomerOrders, useCustomerSubscriptions, useDiscounts, useExpressPaymentMethods, useFunnel, useFunnelLegacy, useGeoLocation, useGoogleAutocomplete, useGooglePayCheckout, useInvalidateQuery, useISOData, useLanguageImport, useLogin, useOffer, useOrder, useOrderBump, usePayment, usePaymentRetrieve, usePixelTracking, usePluginConfig, usePostPurchases, usePreloadQuery, usePreviewOffer, useProducts, usePromotions, useRegionOptions, useRemappableParams, useShippingRates, useSimpleFunnel, useStepConfig, useStoreConfig, useTagadaContext, useThreeds, useThreedsModal, useTranslation, useVipOffers } from './react';
29
32
  export type { DebugScript } from './react';
30
33
  export type { TranslateFunction, TranslationText, UseTranslationOptions, UseTranslationResult } from './react/hooks/useTranslation';
31
34
  export type { FunnelContextValue } from './react/hooks/useFunnel';
35
+ export type { UseApplePayCheckoutOptions } from './react/hooks/useApplePayCheckout';
32
36
  export type { ClubOffer, ClubOfferItem, ClubOfferLineItem, ClubOfferSummary, UseClubOffersOptions, UseClubOffersResult } from './react/hooks/useClubOffers';
33
37
  export type { UseCreditsOptions, UseCreditsResult } from './react/hooks/useCredits';
38
+ export type { UseGooglePayCheckoutOptions } from './react/hooks/useGooglePayCheckout';
34
39
  export type { UseLoginOptions, UseLoginResult } from './react/hooks/useLogin';
35
40
  export type { CustomerAddress, CustomerInfos, CustomerOrderSummary, OrderWithRelations, Subscription, SubscriptionsResponse } from './core/resources/customer';
36
41
  export type { UseCustomerResult } from './react/hooks/useCustomer';
37
42
  export type { UseCustomerInfosOptions, UseCustomerInfosResult } from './react/hooks/useCustomerInfos';
38
43
  export type { UseCustomerOrdersOptions, UseCustomerOrdersResult } from './react/hooks/useCustomerOrders';
39
44
  export type { UseCustomerSubscriptionsOptions, UseCustomerSubscriptionsResult } from './react/hooks/useCustomerSubscriptions';
45
+ export type { PaymentRetrieveHook as UsePaymentRetrieveResult } from './react/hooks/usePaymentRetrieve';
40
46
  export type { UseShippingRatesQueryOptions, UseShippingRatesQueryResult } from './react/hooks/useShippingRatesQuery';
41
47
  export type { PreviewOfferSummary, UsePreviewOfferOptions, UsePreviewOfferResult } from './react/hooks/usePreviewOffer';
package/dist/v2/index.js CHANGED
@@ -8,13 +8,18 @@
8
8
  // Core exports (selective to avoid conflicts)
9
9
  export * from './core/googleAutocomplete';
10
10
  export * from './core/isoData';
11
+ export * from './core/utils/configHotReload';
11
12
  export * from './core/utils/currency';
12
13
  export * from './core/utils/pluginConfig';
13
- export * from './core/utils/products';
14
14
  export * from './core/utils/previewMode';
15
- export * from './core/utils/configHotReload';
15
+ export { injectPreviewModeIndicator, isIndicatorInjected, removePreviewModeIndicator } from './core/utils/previewModeIndicator';
16
+ export * from './core/utils/products';
17
+ // Step config utilities (for reading runtime configuration from HTML)
18
+ export { getAssignedPaymentFlowId, getAssignedScripts, getAssignedStaticResources, getAssignedStepConfig, getLocalFunnelConfig,
19
+ // Local development helpers
20
+ loadLocalFunnelConfig } from './core/funnelClient';
16
21
  // Path remapping helpers (framework-agnostic)
17
22
  export * from './core/pathRemapping';
18
23
  export { FunnelActionType } from './core/resources/funnel';
19
24
  // React exports (hooks and components only, types are exported above)
20
- export { ApplePayButton, ExpressPaymentMethodsProvider, formatMoney, getAvailableLanguages, GooglePayButton, queryKeys, TagadaProvider, useApiMutation, useApiQuery, useAuth, useCheckout, useCheckoutToken, useClubOffers, useCountryOptions, useCredits, useCurrency, useCustomer, useCustomerInfos, useCustomerOrders, useCustomerSubscriptions, useDiscounts, useExpressPaymentMethods, useFunnel, useFunnelLegacy, useGeoLocation, useGoogleAutocomplete, useInvalidateQuery, useISOData, useLanguageImport, useLogin, useOffer, useOrder, useOrderBump, usePayment, usePluginConfig, usePostPurchases, usePreloadQuery, usePreviewOffer, useProducts, usePromotions, useRegionOptions, useRemappableParams, useShippingRates, useSimpleFunnel, useStoreConfig, useTagadaContext, useThreeds, useThreedsModal, useTranslation, useVipOffers } from './react';
25
+ export { ApplePayButton, ExpressPaymentMethodsProvider, formatMoney, getAvailableLanguages, GooglePayButton, PreviewModeIndicator, queryKeys, TagadaProvider, useApiMutation, useApiQuery, useApplePayCheckout, useAuth, useCheckout, useCheckoutToken, useClubOffers, useCountryOptions, useCredits, useCurrency, useCustomer, useCustomerInfos, useCustomerOrders, useCustomerSubscriptions, useDiscounts, useExpressPaymentMethods, useFunnel, useFunnelLegacy, useGeoLocation, useGoogleAutocomplete, useGooglePayCheckout, useInvalidateQuery, useISOData, useLanguageImport, useLogin, useOffer, useOrder, useOrderBump, usePayment, usePaymentRetrieve, usePixelTracking, usePluginConfig, usePostPurchases, usePreloadQuery, usePreviewOffer, useProducts, usePromotions, useRegionOptions, useRemappableParams, useShippingRates, useSimpleFunnel, useStepConfig, useStoreConfig, useTagadaContext, useThreeds, useThreedsModal, useTranslation, useVipOffers } from './react';
@@ -1,141 +1,40 @@
1
1
  /**
2
2
  * Apple Pay Button Component for v2 Architecture
3
- * Uses v2 useExpressPaymentMethods hook and follows clean architecture principles
3
+ * Clean rewrite based on working CMS implementation
4
4
  */
5
5
  import React from 'react';
6
6
  import { CheckoutData } from '../../core/resources/checkout';
7
+ declare global {
8
+ interface Window {
9
+ ApplePaySession: typeof ApplePaySession;
10
+ }
11
+ }
7
12
  declare class ApplePaySession {
8
- static canMakePayments(): boolean;
9
- static canMakePaymentsWithActiveCard(merchantId: string): Promise<boolean>;
10
13
  static STATUS_SUCCESS: number;
11
14
  static STATUS_FAILURE: number;
12
- static STATUS_INVALID_BILLING_POSTAL_ADDRESS: number;
13
- static STATUS_INVALID_SHIPPING_POSTAL_ADDRESS: number;
14
- static STATUS_INVALID_SHIPPING_CONTACT: number;
15
- static STATUS_PIN_REQUIRED: number;
16
- static STATUS_PIN_INCORRECT: number;
17
- static STATUS_PIN_LOCKOUT: number;
18
- constructor(version: number, paymentRequest: ApplePayPaymentRequest);
15
+ static canMakePayments(): boolean;
16
+ constructor(version: number, request: any);
19
17
  begin(): void;
20
18
  abort(): void;
21
19
  completeMerchantValidation(merchantSession: any): void;
22
- completePayment(result: ApplePayPaymentAuthorizationResult): void;
23
- completeShippingContactSelection(update: ApplePayShippingContactUpdate): void;
24
- completeShippingMethodSelection(update: ApplePayShippingMethodUpdate): void;
25
- completePaymentMethodSelection(update: ApplePayPaymentMethodUpdate): void;
26
- onvalidatemerchant: ((event: ApplePayValidateMerchantEvent) => void) | null;
27
- onpaymentauthorized: ((event: ApplePayPaymentAuthorizedEvent) => void) | null;
28
- onshippingcontactselected: ((event: ApplePayShippingContactSelectionEvent) => void) | null;
29
- onshippingmethodselected: ((event: ApplePayShippingMethodSelectionEvent) => void) | null;
30
- onpaymentmethodselected: ((event: ApplePayPaymentMethodSelectionEvent) => void) | null;
31
- oncancel: ((event: Event) => void) | null;
32
- }
33
- interface ApplePayPaymentRequest {
34
- countryCode: string;
35
- currencyCode: string;
36
- supportedNetworks: string[];
37
- merchantCapabilities: string[];
38
- total: ApplePayLineItem;
39
- lineItems?: ApplePayLineItem[];
40
- shippingType?: 'shipping' | 'delivery' | 'storePickup' | 'servicePickup';
41
- shippingMethods?: ApplePayShippingMethod[];
42
- requiredBillingContactFields?: string[];
43
- requiredShippingContactFields?: string[];
44
- applicationData?: string;
45
- }
46
- interface ApplePayLineItem {
47
- label: string;
48
- amount: string;
49
- type?: 'final' | 'pending';
50
- }
51
- interface ApplePayShippingMethod {
52
- label: string;
53
- amount: string;
54
- detail?: string;
55
- identifier: string;
56
- }
57
- interface ApplePayPaymentToken {
58
- paymentData: any;
59
- paymentMethod: {
60
- displayName: string;
61
- network: string;
62
- type: string;
63
- paymentPass: any;
64
- billingContact?: ApplePayPaymentContact;
65
- };
66
- transactionIdentifier: string;
67
- }
68
- interface ApplePayPaymentContact {
69
- phoneNumber?: string;
70
- emailAddress?: string;
71
- givenName?: string;
72
- familyName?: string;
73
- phoneticGivenName?: string;
74
- phoneticFamilyName?: string;
75
- addressLines?: string[];
76
- locality?: string;
77
- administrativeArea?: string;
78
- postalCode?: string;
79
- countryCode?: string;
80
- }
81
- interface ApplePayValidateMerchantEvent {
82
- validationURL: string;
83
- }
84
- interface ApplePayPaymentAuthorizedEvent {
85
- payment: {
86
- token: ApplePayPaymentToken;
87
- billingContact?: ApplePayPaymentContact;
88
- shippingContact?: ApplePayPaymentContact;
89
- };
90
- }
91
- interface ApplePayShippingContactSelectionEvent {
92
- shippingContact: ApplePayPaymentContact;
93
- }
94
- interface ApplePayShippingMethodSelectionEvent {
95
- shippingMethod: ApplePayShippingMethod;
96
- }
97
- interface ApplePayPaymentMethodSelectionEvent {
98
- paymentMethod: any;
99
- }
100
- interface ApplePayPaymentAuthorizationResult {
101
- status: number;
102
- errors?: ApplePayError[];
103
- }
104
- interface ApplePayShippingContactUpdate {
105
- errors?: ApplePayError[];
106
- newShippingMethods?: ApplePayShippingMethod[];
107
- newTotal?: ApplePayLineItem;
108
- newLineItems?: ApplePayLineItem[];
109
- }
110
- interface ApplePayShippingMethodUpdate {
111
- newTotal?: ApplePayLineItem;
112
- newLineItems?: ApplePayLineItem[];
113
- }
114
- interface ApplePayPaymentMethodUpdate {
115
- newTotal?: ApplePayLineItem;
116
- newLineItems?: ApplePayLineItem[];
117
- }
118
- interface ApplePayError {
119
- code: string;
120
- message: string;
121
- contactField?: string;
122
- }
123
- declare global {
124
- interface Window {
125
- ApplePaySession: typeof ApplePaySession;
126
- }
20
+ completePayment(status: number): void;
21
+ completeShippingContactSelection(status: number, shippingMethods: any[], total: any, lineItems: any[]): void;
22
+ completeShippingMethodSelection(status: number, total: any, lineItems: any[]): void;
23
+ onvalidatemerchant: ((event: any) => void) | null;
24
+ onpaymentauthorized: ((event: any) => void) | null;
25
+ onshippingcontactselected: ((event: any) => void) | null;
26
+ onshippingmethodselected: ((event: any) => void) | null;
27
+ oncancel: (() => void) | null;
28
+ onerror: ((event: any) => void) | null;
127
29
  }
128
30
  export interface ApplePayButtonProps {
129
- className?: string;
130
- disabled?: boolean;
131
- onSuccess?: (payment: any) => void;
31
+ checkout: CheckoutData;
32
+ onSuccess?: (result: {
33
+ payment: any;
34
+ order: any;
35
+ }) => void;
132
36
  onError?: (error: string) => void;
133
37
  onCancel?: () => void;
134
- storeName?: string;
135
- currencyCode?: string;
136
- variant?: 'default' | 'outline' | 'ghost';
137
- size?: 'sm' | 'md' | 'lg';
138
- checkout: CheckoutData;
139
38
  }
140
39
  export declare const ApplePayButton: React.FC<ApplePayButtonProps>;
141
40
  export default ApplePayButton;