@tagadapay/headless-sdk 1.17.0 → 1.18.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/README.md CHANGED
@@ -182,6 +182,26 @@ email, and promotion code are sourced from the loaded `CheckoutSession`.
182
182
  | `tagada.customer` | CRM data — profile, orders, subscriptions |
183
183
  | `tagada.catalog` | Product browsing — list products, variants, prices |
184
184
  | `tagada.funnel` | Funnel navigation — bootstrap session and redirect into a funnel step |
185
+ | `tagada.track` | Coded funnels — report steps and events, fire the pixels bound on the canvas |
186
+ | `tagada.portal` | Customer portal — email-code login, subscriptions, cancel flow, addresses, cards, credits |
187
+ | `tagada.rx` | Tagada Rx — telehealth intake, cases, activation status |
188
+
189
+ ## Coded Funnels
190
+
191
+ Declare the steps of a funnel you code in `tagada.funnel.ts` (with `@tagadapay/node-sdk`), push it with
192
+ `npx tagada funnel push`, and report each step from the browser. The steps appear as cards on the CRM
193
+ canvas, where you bind your pixels; the SDK loads and fires them.
194
+
195
+ ```typescript
196
+ const tagada = createHeadlessClient({ storeId: 'store_abc123', funnel: 'main' });
197
+
198
+ tagada.track.step('quiz'); // or useStep('quiz') in React
199
+ tagada.track.event('quiz_completed', { goal: 'sleep' });
200
+ ```
201
+
202
+ Nothing is sent and no pixel loads until the first `track.step()`. `InitiateCheckout` and `Purchase`
203
+ fire on their own from the checkout and payment modules. Guide:
204
+ [docs.tagada.io/developer-tools/headless-sdk/coded-funnels](https://docs.tagada.io/developer-tools/headless-sdk/coded-funnels).
185
205
 
186
206
  ## React Hooks
187
207
 
@@ -195,6 +215,7 @@ One hook per page of a typical storefront:
195
215
  | `useOrder(orderId)` | Thank-you page — the order + `relatedOrders` from accepted upsells (watched automatically) |
196
216
  | `useCustomer(customerId?)` | Account dashboard — profile, orders, subscriptions |
197
217
  | `useCatalog()` | Product pages — products, variants, prices |
218
+ | `useStep(stepId, data?)` | Any step of a coded funnel — reports it and fires its pixels |
198
219
 
199
220
  ## CDN Usage
200
221
 
@@ -227,6 +248,7 @@ A complete React checkout app is available as a live demo and open-source refere
227
248
  |------------|--------------|
228
249
  | `@tagadapay/headless-sdk` | Core client + all modules |
229
250
  | `@tagadapay/headless-sdk/react` | React hooks + provider |
251
+ | `@tagadapay/headless-sdk/stripe` | Stripe Express Checkout (`StripeExpressButton`, `useStripeExpress`, `StripeExpressCheckout`); needs `@tagadapay/core-js` |
230
252
 
231
253
  ## License
232
254
 
@@ -11,14 +11,27 @@ export declare class CustomerModule {
11
11
  constructor(http: HttpClient, storeId: string);
12
12
  /** Get customer profile by ID. */
13
13
  getProfile(customerId: string): Promise<Customer>;
14
- /** Get customer profile by email. */
14
+ /**
15
+ * Not available: no route finds a customer by email for a storefront session. The only email
16
+ * search (`POST /api/v1/customers/search`) needs a secret API key of the whole account, which a
17
+ * storefront must never ship. Always rejects with a `TagadaError` of code `not_supported`, without
18
+ * sending a request. For the logged-in customer use `portal.getMe()` (Subscriptions V3 stores) or
19
+ * `getProfile(customerId)`.
20
+ *
21
+ * @deprecated There is no API route behind it.
22
+ */
15
23
  getByEmail(email: string): Promise<Customer | null>;
16
24
  /**
17
25
  * Update the customer's email (`POST /api/v1/customers/:id`, the checkout's email step): the
18
26
  * route stores the email only. A portal customer's name and phone go through `portal.updateProfile`.
19
27
  */
20
28
  updateProfile(customerId: string, data: Partial<Pick<Customer, 'email' | 'firstName' | 'lastName' | 'phone' | 'metadata'>>): Promise<Customer>;
21
- /** List orders for a customer. */
29
+ /**
30
+ * The customer's orders on this store, newest first (`GET /api/v1/orders/customer/:customerId`).
31
+ * Needs a session of that customer: the checkout session, or a portal login
32
+ * (`portal.verifyCode`). Another customer's id rejects with `TagadaNotFoundError`. The route sends
33
+ * every order at once: `limit` and `offset` slice them here, `total` counts them all.
34
+ */
22
35
  getOrders(customerId: string, opts?: {
23
36
  limit?: number;
24
37
  offset?: number;
@@ -54,9 +67,18 @@ export declare class CustomerModule {
54
67
  /** Delay between polls in ms. Default: 2000. */
55
68
  intervalMs?: number;
56
69
  }): Promise<Order>;
57
- /** List subscriptions for a customer. */
70
+ /**
71
+ * The customer's subscriptions on this store, newest first (`GET /api/v1/subscriptions`). The
72
+ * route answers for the customer of the session: the checkout session, or a portal login
73
+ * (`portal.verifyCode`), which a Subscriptions V3 store requires. Another customer's id gets `[]`.
74
+ * Only the 20 most recent come back: the route's page size cannot travel in a query string.
75
+ */
58
76
  getSubscriptions(customerId: string): Promise<Subscription[]>;
59
- /** Get a single subscription by ID. */
77
+ /**
78
+ * One subscription of the session's customer. No route reads a subscription by id: this picks it
79
+ * from `getSubscriptions`' route, so it needs the same session and finds only the 20 most recent.
80
+ * Rejects with `TagadaNotFoundError` when it is not among them.
81
+ */
60
82
  getSubscription(subscriptionId: string): Promise<Subscription>;
61
83
  /** Pause billing. `resumeAt` (ISO date) resumes it on that day. */
62
84
  pauseSubscription(subscriptionId: string, opts?: {
@@ -1 +1 @@
1
- {"version":3,"file":"customer.d.ts","sourceRoot":"","sources":["../../../src/core/modules/customer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEjE;;;;GAIG;AACH,qBAAa,cAAc;IAEvB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBADP,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,MAAM;IAGlC,kCAAkC;IAC5B,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAQvD,qCAAqC;IAC/B,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAYzD;;;OAGG;IACG,aAAa,CACjB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,OAA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
4
+ ...row,
5
+ storeId,
6
+ amount: row.priceCurrencyOptions?.[row.currency]?.amount ?? 0,
7
+ interval: row.priceInterval ?? '',
8
+ intervalCount: row.priceIntervalCount ?? 1,
9
+ };
10
+ }
1
11
  /**
2
12
  * Customer data -- profile, orders, subscriptions.
3
13
  *
@@ -13,15 +23,17 @@ export class CustomerModule {
13
23
  const res = await this.http.get(`/api/v1/customers/${customerId}`, { params: { storeId: this.storeId } });
14
24
  return res.customer;
15
25
  }
16
- /** Get customer profile by email. */
26
+ /**
27
+ * Not available: no route finds a customer by email for a storefront session. The only email
28
+ * search (`POST /api/v1/customers/search`) needs a secret API key of the whole account, which a
29
+ * storefront must never ship. Always rejects with a `TagadaError` of code `not_supported`, without
30
+ * sending a request. For the logged-in customer use `portal.getMe()` (Subscriptions V3 stores) or
31
+ * `getProfile(customerId)`.
32
+ *
33
+ * @deprecated There is no API route behind it.
34
+ */
17
35
  async getByEmail(email) {
18
- try {
19
- const res = await this.http.get('/api/v1/customers/by-email', { params: { email, storeId: this.storeId } });
20
- return res.customer;
21
- }
22
- catch {
23
- return null;
24
- }
36
+ throw new TagadaError('customer.getByEmail is not available: no API route finds a customer by email for a storefront session.', 'not_supported');
25
37
  }
26
38
  /**
27
39
  * Update the customer's email (`POST /api/v1/customers/:id`, the checkout's email step): the
@@ -31,9 +43,19 @@ export class CustomerModule {
31
43
  await this.http.post(`/api/v1/customers/${customerId}`, { customerId, data: { email: data.email } });
32
44
  return this.getProfile(customerId);
33
45
  }
34
- /** List orders for a customer. */
46
+ /**
47
+ * The customer's orders on this store, newest first (`GET /api/v1/orders/customer/:customerId`).
48
+ * Needs a session of that customer: the checkout session, or a portal login
49
+ * (`portal.verifyCode`). Another customer's id rejects with `TagadaNotFoundError`. The route sends
50
+ * every order at once: `limit` and `offset` slice them here, `total` counts them all.
51
+ */
35
52
  async getOrders(customerId, opts) {
36
- return this.http.get(`/api/v1/customers/${customerId}/orders`, { params: { storeId: this.storeId, limit: opts?.limit, offset: opts?.offset } });
53
+ const { orders } = await this.http.get(`/api/v1/orders/customer/${customerId}`, {
54
+ params: { storeId: this.storeId },
55
+ });
56
+ const start = opts?.offset ?? 0;
57
+ const end = opts?.limit === undefined ? undefined : start + opts.limit;
58
+ return { orders: orders.slice(start, end), total: orders.length };
37
59
  }
38
60
  /**
39
61
  * Get a single order by ID.
@@ -76,15 +98,27 @@ export class CustomerModule {
76
98
  }
77
99
  return order;
78
100
  }
79
- /** List subscriptions for a customer. */
101
+ /**
102
+ * The customer's subscriptions on this store, newest first (`GET /api/v1/subscriptions`). The
103
+ * route answers for the customer of the session: the checkout session, or a portal login
104
+ * (`portal.verifyCode`), which a Subscriptions V3 store requires. Another customer's id gets `[]`.
105
+ * Only the 20 most recent come back: the route's page size cannot travel in a query string.
106
+ */
80
107
  async getSubscriptions(customerId) {
81
- const res = await this.http.get(`/api/v1/customers/${customerId}/subscriptions`, { params: { storeId: this.storeId } });
82
- return res.subscriptions;
108
+ const { items } = await this.http.get('/api/v1/subscriptions');
109
+ return items.filter((row) => row.customerId === customerId).map((row) => toSubscription(row, this.storeId));
83
110
  }
84
- /** Get a single subscription by ID. */
111
+ /**
112
+ * One subscription of the session's customer. No route reads a subscription by id: this picks it
113
+ * from `getSubscriptions`' route, so it needs the same session and finds only the 20 most recent.
114
+ * Rejects with `TagadaNotFoundError` when it is not among them.
115
+ */
85
116
  async getSubscription(subscriptionId) {
86
- const res = await this.http.get(`/api/v1/subscriptions/${subscriptionId}`, { params: { storeId: this.storeId } });
87
- return res.subscription;
117
+ const { items } = await this.http.get('/api/v1/subscriptions');
118
+ const row = items.find((item) => item.id === subscriptionId);
119
+ if (!row)
120
+ throw new TagadaNotFoundError('Subscription', subscriptionId);
121
+ return toSubscription(row, this.storeId);
88
122
  }
89
123
  // ---------------------------------------------------------------------------
90
124
  // Subscription actions of the logged-in customer (customer portal session).
@@ -1 +1 @@
1
- {"version":3,"file":"customer.js","sourceRoot":"","sources":["../../../src/core/modules/customer.ts"],"names":[],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O,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;QACvE,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,iCAAiC,EAAE,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;IACvF,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,uBAAuB,CAC3B,cAAsB,EACtB,MAA4G;QAE5G,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,oCAAoC,EAAE,EAAE,cAAc,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IAC5F,CAAC;IAED,uDAAuD;IACvD,KAAK,CAAC,+BAA+B,CAAC,cAAsB,EAAE,WAAmB;QAC/E,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,sCAAsC,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC,CAAC;IAChG,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,kBAAkB,CAAC,cAAsB,EAAE,IAAsC;QACrF,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,8BAA8B,EAAE;YACnD,cAAc;YACd,iBAAiB,EAAE,IAAI,EAAE,iBAAiB,IAAI,IAAI;SACnD,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1,4 +1,4 @@
1
1
  /** Identity this package reports to the SDK routes. A test pins it to `package.json`. */
2
2
  export declare const SDK_NAME: "headless";
3
- export declare const SDK_VERSION: "1.17.0";
3
+ export declare const SDK_VERSION: "1.18.0";
4
4
  //# sourceMappingURL=version.d.ts.map
@@ -1,4 +1,4 @@
1
1
  /** Identity this package reports to the SDK routes. A test pins it to `package.json`. */
2
2
  export const SDK_NAME = 'headless';
3
- export const SDK_VERSION = '1.17.0';
3
+ export const SDK_VERSION = '1.18.0';
4
4
  //# sourceMappingURL=version.js.map
@@ -1,5 +1,5 @@
1
1
  export { TagadaHeadlessProvider, useHeadlessClient } from './provider.js';
2
- export type { TagadaHeadlessProviderProps } from './provider.js';
2
+ export type { TagadaHeadlessProviderProps, TagadaHeadlessProviderConfigProps } from './provider.js';
3
3
  export { useCheckout } from './hooks/useCheckout.js';
4
4
  export type { UseCheckoutReturn } from './hooks/useCheckout.js';
5
5
  export { usePayment } from './hooks/usePayment.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC1E,YAAY,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAEjF,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,YAAY,EAAE,4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AC;AAEjE,YAAY,EACV,cAAc,EACd,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,WAAW,EACX,SAAS,EACT,UAAU,EACV,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,EACL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACR,KAAK,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EACd,YAAY,EACZ,cAAc,EACd,oBAAoB,GACrB,MAAM,kBAAkB,CAAC"}
@@ -14,18 +14,29 @@ export interface TagadaHeadlessProviderProps {
14
14
  config?: HeadlessConfig;
15
15
  children: React.ReactNode;
16
16
  }
17
+ /** Props when the whole config is passed: it replaces `storeId`, `environment`, `apiKey` and `baseUrl`. */
18
+ export interface TagadaHeadlessProviderConfigProps {
19
+ /** Full config object. The only way to pass `funnel`, `accountId`, `timeout` or `bootstrap`. */
20
+ config: HeadlessConfig;
21
+ children: React.ReactNode;
22
+ }
17
23
  /**
18
24
  * Root provider for the TagadaPay Headless SDK React integration.
19
- * Creates a single HeadlessClient and shares it via context.
25
+ * Creates a single HeadlessClient and shares it via context. The client is rebuilt only
26
+ * when a config value changes, so an inline `config` object keeps the same client.
20
27
  *
21
28
  * @example
22
29
  * ```tsx
23
30
  * <TagadaHeadlessProvider storeId="store_abc123" environment="production">
24
31
  * <App />
25
32
  * </TagadaHeadlessProvider>
33
+ *
34
+ * <TagadaHeadlessProvider config={{ storeId: 'store_abc123', funnel: 'main' }}>
35
+ * <App />
36
+ * </TagadaHeadlessProvider>
26
37
  * ```
27
38
  */
28
- export declare function TagadaHeadlessProvider({ storeId, environment, apiKey, baseUrl, config, children, }: TagadaHeadlessProviderProps): import("react/jsx-runtime.js").JSX.Element;
39
+ export declare function TagadaHeadlessProvider(props: TagadaHeadlessProviderProps | TagadaHeadlessProviderConfigProps): import("react/jsx-runtime.js").JSX.Element;
29
40
  /** Access the HeadlessClient from context. Throws if used outside the provider. */
30
41
  export declare function useHeadlessClient(): HeadlessClient;
31
42
  //# sourceMappingURL=provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/react/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,cAAc,EAAwB,MAAM,mBAAmB,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAQpE,MAAM,WAAW,2BAA2B;IAC1C,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,OAAO,EACP,WAAW,EACX,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,GACT,EAAE,2BAA2B,8CAa7B;AAED,mFAAmF;AACnF,wBAAgB,iBAAiB,IAAI,cAAc,CAMlD"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/react/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,cAAc,EAAwB,MAAM,mBAAmB,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAQpE,MAAM,WAAW,2BAA2B;IAC1C,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,2GAA2G;AAC3G,MAAM,WAAW,iCAAiC;IAChD,gGAAgG;IAChG,MAAM,EAAE,cAAc,CAAC;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AA2BD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,2BAA2B,GAAG,iCAAiC,8CAY5G;AAED,mFAAmF;AACnF,wBAAgB,iBAAiB,IAAI,cAAc,CAMlD"}
@@ -2,24 +2,52 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { createContext, useContext, useMemo } from 'react';
3
3
  import { createHeadlessClient } from '../core/client.js';
4
4
  const TagadaHeadlessContext = createContext(null);
5
+ /**
6
+ * A string that changes only when a config value does. `bootstrap` is plain JSON from the server,
7
+ * so it is compared by content. The `Record` stops compiling when `HeadlessConfig` gains a field,
8
+ * so a new field cannot be left out of the comparison.
9
+ */
10
+ function configKey(config) {
11
+ const values = {
12
+ storeId: config.storeId,
13
+ environment: config.environment,
14
+ apiKey: config.apiKey,
15
+ baseUrl: config.baseUrl,
16
+ accountId: config.accountId,
17
+ funnel: config.funnel,
18
+ timeout: config.timeout,
19
+ bootstrap: config.bootstrap,
20
+ };
21
+ return JSON.stringify(values);
22
+ }
23
+ function resolveConfig(props) {
24
+ if (props.config)
25
+ return props.config;
26
+ const { storeId, environment, apiKey, baseUrl } = props;
27
+ return { storeId, environment, apiKey, baseUrl };
28
+ }
5
29
  /**
6
30
  * Root provider for the TagadaPay Headless SDK React integration.
7
- * Creates a single HeadlessClient and shares it via context.
31
+ * Creates a single HeadlessClient and shares it via context. The client is rebuilt only
32
+ * when a config value changes, so an inline `config` object keeps the same client.
8
33
  *
9
34
  * @example
10
35
  * ```tsx
11
36
  * <TagadaHeadlessProvider storeId="store_abc123" environment="production">
12
37
  * <App />
13
38
  * </TagadaHeadlessProvider>
39
+ *
40
+ * <TagadaHeadlessProvider config={{ storeId: 'store_abc123', funnel: 'main' }}>
41
+ * <App />
42
+ * </TagadaHeadlessProvider>
14
43
  * ```
15
44
  */
16
- export function TagadaHeadlessProvider({ storeId, environment, apiKey, baseUrl, config, children, }) {
17
- const client = useMemo(() => {
18
- const cfg = config ?? { storeId, environment, apiKey, baseUrl };
19
- return createHeadlessClient(cfg);
20
- }, [storeId, environment, apiKey, baseUrl, config]);
45
+ export function TagadaHeadlessProvider(props) {
46
+ const cfg = resolveConfig(props);
47
+ const key = configKey(cfg);
48
+ const client = useMemo(() => createHeadlessClient(cfg), [key]);
21
49
  const value = useMemo(() => ({ client }), [client]);
22
- return (_jsx(TagadaHeadlessContext.Provider, { value: value, children: children }));
50
+ return (_jsx(TagadaHeadlessContext.Provider, { value: value, children: props.children }));
23
51
  }
24
52
  /** Access the HeadlessClient from context. Throws if used outside the provider. */
25
53
  export function useHeadlessClient() {
@@ -1 +1 @@
1
- {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/react/provider.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,EAAkB,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAOzE,MAAM,qBAAqB,GAAG,aAAa,CAAoC,IAAI,CAAC,CAAC;AAgBrF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CAAC,EACrC,OAAO,EACP,WAAW,EACX,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,GACoB;IAC5B,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE;QAC1B,MAAM,GAAG,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 @@
1
1
  /**
2
- * @tagadapay/headless-sdk v1.17.0
2
+ * @tagadapay/headless-sdk v1.18.0
3
3
  * Headless checkout, payments, offers, and CRM
4
4
  * @license MIT
5
5
  */
6
- "use strict";var TagadaHeadlessCommerceBundle=(()=>{var f=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var I=(i,t)=>{for(var e in t)f(i,e,{get:t[e],enumerable:!0})},v=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of P(t))!g.call(i,s)&&s!==e&&f(i,s,{get:()=>t[s],enumerable:!(r=y(t,s))||r.enumerable});return i};var w=i=>v(f({},"__esModule",{value:!0}),i);var b={};I(b,{CustomerModule:()=>m,CustomerPortalModule:()=>c,OffersModule:()=>l});var c=class{constructor(t,e,r){this.http=t;this.storeId=e;this.setToken=r}async requestCode(t){await this.http.post("/api/v1/cms/session/request-code",{email:t,storeId:this.storeId})}async verifyCode(t,e){let r=await this.http.post("/api/v1/cms/session/login",{email:t,code:e,storeId:this.storeId});return this.setToken(r.token),r}async getConfig(){return this.http.get("/api/v1/portal/config",{params:{storeId:this.storeId}})}async getMe(){return this.http.get("/api/v1/portal/me")}async cancelFlow(t){return this.http.post("/api/v1/portal/cancel-flow",t)}async acceptCancelOffer(t){return this.http.post("/api/v1/portal/cancel-flow/accept",t)}async switchOption(t){return this.http.post("/api/v1/portal/switch",t)}async getOffer(t){return this.http.get(`/api/v1/portal/offers/${encodeURIComponent(t)}`)}async acceptOffer(t){return this.http.post("/api/v1/portal/offers/accept",t)}async addToNextOrder(t){return this.http.post("/api/v1/portal/next-order",t)}async getCredits(){return this.http.get("/api/v1/portal/credits")}async redeemCredits(t){return this.http.post("/api/v1/portal/credits/redeem",t)}async buyCreditPack(t){return this.http.post("/api/v1/portal/credits/packs/buy",t)}async requestEmailChangeCode(t){await this.http.post("/api/v1/portal/profile/email-code",{email:t})}async updateProfile(t){await this.http.post("/api/v1/portal/profile",t)}async saveAddress(t){return this.http.post("/api/v1/portal/addresses",t)}async removeAddress(t){await this.http.post("/api/v1/portal/addresses/remove",{addressId:t})}async setDefaultAddress(t){await this.http.post("/api/v1/portal/addresses/default",{addressId:t})}async addCard(t){return this.http.post("/api/v1/portal/payment-methods",t)}async removeCard(t){await this.http.post("/api/v1/portal/payment-methods/remove",{paymentMethodId:t})}async setDefaultPaymentMethod(t){await this.http.post("/api/v1/portal/payment-methods/default",{paymentMethodId:t})}async retryPayment(t){return this.http.post("/api/v1/portal/retry-payment",{subscriptionId:t})}async buyAgain(t){return this.http.post("/api/v1/portal/buy-again",{lines:t.map(({variantId:e,quantity:r})=>({variantId:e,quantity:r}))})}async joinMembership(t){return this.http.post("/api/v1/portal/membership/join",{billing:t})}async buyNow(t,e=1){return this.buyAgain([{variantId:t,quantity:e}])}async sendNow(t){return this.http.post("/api/v1/subscriptions/send-now",{subscriptionId:t})}async reactivateSubscription(t){return this.http.post("/api/v1/subscriptions/reactivate",{subscriptionId:t})}async setSubscriptionCard(t,e){return this.http.post("/api/v1/subscriptions/saved-card",{subscriptionId:t,paymentMethodId:e})}async setSubscriptionAddress(t,e){return this.http.post("/api/v1/subscriptions/shipping-address",{subscriptionId:t,addressId:e})}async skipDate(t,e){return this.http.post("/api/v1/subscriptions/skip-date",{subscriptionId:t,date:e})}async unskipDate(t,e){return this.http.post("/api/v1/subscriptions/unskip",{subscriptionId:t,date:e})}};var l=class{constructor(t,e,r){this.http=t;this.storeId=e;this.payment=r}async getOffer(t){return this.http.get(`/api/v1/offers/${t}`)}async listOffers(t){var n;let e=`/api/v1/stores/${this.storeId}/offers`,r=[];if(t!=null&&t.type&&r.push(`type=${encodeURIComponent(t.type)}`),(n=t==null?void 0:t.ids)!=null&&n.length)for(let d of t.ids)r.push(`ids=${encodeURIComponent(d)}`);return r.length&&(e+=`?${r.join("&")}`),(await this.http.get(e)).offers??[]}async previewOffer(t){return this.http.post(`/api/v1/offers/${t.offerId}/preview`,{offerId:t.offerId,currency:t.currency??"",lineItems:t.lineItems,funnelSessionId:t.funnelSessionId})}async enterFunnelStep(t){let e=typeof window<"u"?window.location.origin:"http://localhost";return{funnelSessionId:(await this.http.post("/api/v1/funnel/initialize",{cmsSession:{customerId:"anon_placeholder",sessionId:"anon_placeholder",storeId:this.storeId,accountId:t.accountId},funnelId:t.funnelId,funnelStepId:t.stepId,existingSessionId:t.funnelSessionId,currentUrl:t.checkoutToken?`${e}/?checkoutToken=${encodeURIComponent(t.checkoutToken)}`:void 0,draft:!1})).context.sessionId}}async payPreviewedOffer(t){return this.http.post(`/api/v1/offers/${t.offerId}/pay-preview`,{offerId:t.offerId,currency:t.currency??"",lineItems:t.lineItems,returnUrl:t.returnUrl??(typeof window<"u"?window.location.href:""),mainOrderId:t.mainOrderId,paymentInstrumentId:t.paymentInstrumentId,funnelSessionId:t.funnelSessionId})}async processOfferPayment(t){if(!this.payment)throw new Error("OffersModule: no PaymentModule injected. Use createHeadlessClient() instead of constructing OffersModule directly.");let e=t.returnUrl??(typeof window<"u"?window.location.href:void 0),r=await this.payPreviewedOffer({...t,returnUrl:e});return this.payment.finalize({payment:r.payment,order:r.order},{returnUrl:e})}async toggleOrderBump(t){return this.http.post(`/api/v1/checkout-sessions/${t.checkoutSessionId}/toggle-order-bump`,{orderBumpOfferId:t.orderBumpOfferId,selected:t.selected})}async listPostPurchaseOffers(t){let e=await this.http.get(`/api/v1/post-purchase/${t}/offers`);return Array.isArray(e)?e:[]}async acceptPostPurchaseOffer(t){var s,n;let e;if((s=t.items)!=null&&s.length){let d=await this.http.post(`/api/v1/offers/${t.offerId}/preview`,{offerId:t.offerId,currency:""});e=[];for(let p of t.items){let o=d.lineItems.filter(a=>{var u;return a.variantId===p.variantId||((u=d.preview.options[a.productId])==null?void 0:u.some(h=>h.id===p.variantId))});if(o.length!==1||e.some(a=>a.lineItemId===o[0].lineItemId))return{success:!1,error:"Invalid selection"};e.push({...p,lineItemId:o[0].lineItemId,productId:o[0].productId})}}let r=await this.payPreviewedOffer({offerId:t.offerId,mainOrderId:t.orderId,lineItems:e});return r.payment.status==="succeeded"?{success:!0}:{success:!1,error:r.payment.status==="pending"?"Payment pending":r.payment.status==="requires_action"||r.payment.requireAction&&r.payment.requireAction!=="none"?"Payment requires authentication":((n=r.payment.requireActionData)==null?void 0:n.message)||"Payment declined"}}async declinePostPurchaseOffer(t){return{success:!0}}};var m=class{constructor(t,e){this.http=t;this.storeId=e}async getProfile(t){return(await this.http.get(`/api/v1/customers/${t}`,{params:{storeId:this.storeId}})).customer}async getByEmail(t){try{return(await this.http.get("/api/v1/customers/by-email",{params:{email:t,storeId:this.storeId}})).customer}catch{return null}}async updateProfile(t,e){return await this.http.post(`/api/v1/customers/${t}`,{customerId:t,data:{email:e.email}}),this.getProfile(t)}async getOrders(t,e){return this.http.get(`/api/v1/customers/${t}/orders`,{params:{storeId:this.storeId,limit:e==null?void 0:e.limit,offset:e==null?void 0:e.offset}})}async getOrder(t,e){var o,a;let r=async()=>(await this.http.get(`/api/v1/orders/${t}`,{params:{storeId:this.storeId}})).order,s=await r();if(!(e!=null&&e.waitForRelatedOrders)||(o=s.relatedOrders)!=null&&o.length)return s;let n=e.timeoutMs??8e3,d=e.intervalMs??2e3,p=Date.now()+n;for(;Date.now()<p;)if(await new Promise(u=>setTimeout(u,Math.min(d,Math.max(0,p-Date.now())))),s=await r(),(a=s.relatedOrders)!=null&&a.length)return s;return s}async getSubscriptions(t){return(await this.http.get(`/api/v1/customers/${t}/subscriptions`,{params:{storeId:this.storeId}})).subscriptions}async getSubscription(t){return(await this.http.get(`/api/v1/subscriptions/${t}`,{params:{storeId:this.storeId}})).subscription}async pauseSubscription(t,e){await this.http.post("/api/v1/subscriptions/pause",{subscriptionId:t,resumeAt:e==null?void 0:e.resumeAt})}async resumeSubscription(t){await this.http.post("/api/v1/subscriptions/resume",{subscriptionId:t})}async skipSubscription(t){await this.http.post("/api/v1/subscriptions/skip",{subscriptionId:t})}async rescheduleSubscription(t,e){await this.http.post("/api/v1/subscriptions/reschedule",{subscriptionId:t,nextBillingDate:e})}async updateSubscriptionQuantity(t,e){await this.http.post("/api/v1/subscriptions/quantity",{subscriptionId:t,quantity:e})}async changeSubscriptionFrequency(t,e){let r=typeof e=="string"?{priceId:e}:e;await this.http.post("/api/v1/subscriptions/frequency",{subscriptionId:t,...r})}async swapSubscriptionProduct(t,e){await this.http.post("/api/v1/subscriptions/swap-product",{subscriptionId:t,...e})}async updateSubscriptionPaymentMethod(t,e){await this.http.post("/api/v1/subscriptions/payment-method",{subscriptionId:t,tagadaToken:e})}async cancelSubscription(t,e){await this.http.post("/api/v1/subscriptions/cancel",{subscriptionId:t,cancelAtPeriodEnd:(e==null?void 0:e.cancelAtPeriodEnd)??!0})}};return w(b);})();
6
+ "use strict";var TagadaHeadlessCommerceBundle=(()=>{var g=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var w=(i,t)=>{for(var e in t)g(i,e,{get:t[e],enumerable:!0})},C=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of v(t))!b.call(i,s)&&s!==e&&g(i,s,{get:()=>t[s],enumerable:!(r=I(t,s))||r.enumerable});return i};var O=i=>C(g({},"__esModule",{value:!0}),i);var R={};w(R,{CustomerModule:()=>h,CustomerPortalModule:()=>l,OffersModule:()=>m});var l=class{constructor(t,e,r){this.http=t;this.storeId=e;this.setToken=r}async requestCode(t){await this.http.post("/api/v1/cms/session/request-code",{email:t,storeId:this.storeId})}async verifyCode(t,e){let r=await this.http.post("/api/v1/cms/session/login",{email:t,code:e,storeId:this.storeId});return this.setToken(r.token),r}async getConfig(){return this.http.get("/api/v1/portal/config",{params:{storeId:this.storeId}})}async getMe(){return this.http.get("/api/v1/portal/me")}async cancelFlow(t){return this.http.post("/api/v1/portal/cancel-flow",t)}async acceptCancelOffer(t){return this.http.post("/api/v1/portal/cancel-flow/accept",t)}async switchOption(t){return this.http.post("/api/v1/portal/switch",t)}async getOffer(t){return this.http.get(`/api/v1/portal/offers/${encodeURIComponent(t)}`)}async acceptOffer(t){return this.http.post("/api/v1/portal/offers/accept",t)}async addToNextOrder(t){return this.http.post("/api/v1/portal/next-order",t)}async getCredits(){return this.http.get("/api/v1/portal/credits")}async redeemCredits(t){return this.http.post("/api/v1/portal/credits/redeem",t)}async buyCreditPack(t){return this.http.post("/api/v1/portal/credits/packs/buy",t)}async requestEmailChangeCode(t){await this.http.post("/api/v1/portal/profile/email-code",{email:t})}async updateProfile(t){await this.http.post("/api/v1/portal/profile",t)}async saveAddress(t){return this.http.post("/api/v1/portal/addresses",t)}async removeAddress(t){await this.http.post("/api/v1/portal/addresses/remove",{addressId:t})}async setDefaultAddress(t){await this.http.post("/api/v1/portal/addresses/default",{addressId:t})}async addCard(t){return this.http.post("/api/v1/portal/payment-methods",t)}async removeCard(t){await this.http.post("/api/v1/portal/payment-methods/remove",{paymentMethodId:t})}async setDefaultPaymentMethod(t){await this.http.post("/api/v1/portal/payment-methods/default",{paymentMethodId:t})}async retryPayment(t){return this.http.post("/api/v1/portal/retry-payment",{subscriptionId:t})}async buyAgain(t){return this.http.post("/api/v1/portal/buy-again",{lines:t.map(({variantId:e,quantity:r})=>({variantId:e,quantity:r}))})}async joinMembership(t){return this.http.post("/api/v1/portal/membership/join",{billing:t})}async buyNow(t,e=1){return this.buyAgain([{variantId:t,quantity:e}])}async sendNow(t){return this.http.post("/api/v1/subscriptions/send-now",{subscriptionId:t})}async reactivateSubscription(t){return this.http.post("/api/v1/subscriptions/reactivate",{subscriptionId:t})}async setSubscriptionCard(t,e){return this.http.post("/api/v1/subscriptions/saved-card",{subscriptionId:t,paymentMethodId:e})}async setSubscriptionAddress(t,e){return this.http.post("/api/v1/subscriptions/shipping-address",{subscriptionId:t,addressId:e})}async skipDate(t,e){return this.http.post("/api/v1/subscriptions/skip-date",{subscriptionId:t,date:e})}async unskipDate(t,e){return this.http.post("/api/v1/subscriptions/unskip",{subscriptionId:t,date:e})}};var m=class{constructor(t,e,r){this.http=t;this.storeId=e;this.payment=r}async getOffer(t){return this.http.get(`/api/v1/offers/${t}`)}async listOffers(t){var n;let e=`/api/v1/stores/${this.storeId}/offers`,r=[];if(t!=null&&t.type&&r.push(`type=${encodeURIComponent(t.type)}`),(n=t==null?void 0:t.ids)!=null&&n.length)for(let d of t.ids)r.push(`ids=${encodeURIComponent(d)}`);return r.length&&(e+=`?${r.join("&")}`),(await this.http.get(e)).offers??[]}async previewOffer(t){return this.http.post(`/api/v1/offers/${t.offerId}/preview`,{offerId:t.offerId,currency:t.currency??"",lineItems:t.lineItems,funnelSessionId:t.funnelSessionId})}async enterFunnelStep(t){let e=typeof window<"u"?window.location.origin:"http://localhost";return{funnelSessionId:(await this.http.post("/api/v1/funnel/initialize",{cmsSession:{customerId:"anon_placeholder",sessionId:"anon_placeholder",storeId:this.storeId,accountId:t.accountId},funnelId:t.funnelId,funnelStepId:t.stepId,existingSessionId:t.funnelSessionId,currentUrl:t.checkoutToken?`${e}/?checkoutToken=${encodeURIComponent(t.checkoutToken)}`:void 0,draft:!1})).context.sessionId}}async payPreviewedOffer(t){return this.http.post(`/api/v1/offers/${t.offerId}/pay-preview`,{offerId:t.offerId,currency:t.currency??"",lineItems:t.lineItems,returnUrl:t.returnUrl??(typeof window<"u"?window.location.href:""),mainOrderId:t.mainOrderId,paymentInstrumentId:t.paymentInstrumentId,funnelSessionId:t.funnelSessionId})}async processOfferPayment(t){if(!this.payment)throw new Error("OffersModule: no PaymentModule injected. Use createHeadlessClient() instead of constructing OffersModule directly.");let e=t.returnUrl??(typeof window<"u"?window.location.href:void 0),r=await this.payPreviewedOffer({...t,returnUrl:e});return this.payment.finalize({payment:r.payment,order:r.order},{returnUrl:e})}async toggleOrderBump(t){return this.http.post(`/api/v1/checkout-sessions/${t.checkoutSessionId}/toggle-order-bump`,{orderBumpOfferId:t.orderBumpOfferId,selected:t.selected})}async listPostPurchaseOffers(t){let e=await this.http.get(`/api/v1/post-purchase/${t}/offers`);return Array.isArray(e)?e:[]}async acceptPostPurchaseOffer(t){var s,n;let e;if((s=t.items)!=null&&s.length){let d=await this.http.post(`/api/v1/offers/${t.offerId}/preview`,{offerId:t.offerId,currency:""});e=[];for(let u of t.items){let o=d.lineItems.filter(a=>{var c;return a.variantId===u.variantId||((c=d.preview.options[a.productId])==null?void 0:c.some(P=>P.id===u.variantId))});if(o.length!==1||e.some(a=>a.lineItemId===o[0].lineItemId))return{success:!1,error:"Invalid selection"};e.push({...u,lineItemId:o[0].lineItemId,productId:o[0].productId})}}let r=await this.payPreviewedOffer({offerId:t.offerId,mainOrderId:t.orderId,lineItems:e});return r.payment.status==="succeeded"?{success:!0}:{success:!1,error:r.payment.status==="pending"?"Payment pending":r.payment.status==="requires_action"||r.payment.requireAction&&r.payment.requireAction!=="none"?"Payment requires authentication":((n=r.payment.requireActionData)==null?void 0:n.message)||"Payment declined"}}async declinePostPurchaseOffer(t){return{success:!0}}};var p=class extends Error{constructor(t,e,r,s){super(t),this.name="TagadaError",this.code=e,this.statusCode=r,this.details=s}};var f=class extends p{constructor(t,e){super(`${t} "${e}" not found.`,"not_found",404),this.name="TagadaNotFoundError"}};function y(i,t){var e,r;return{...i,storeId:t,amount:((r=(e=i.priceCurrencyOptions)==null?void 0:e[i.currency])==null?void 0:r.amount)??0,interval:i.priceInterval??"",intervalCount:i.priceIntervalCount??1}}var h=class{constructor(t,e){this.http=t;this.storeId=e}async getProfile(t){return(await this.http.get(`/api/v1/customers/${t}`,{params:{storeId:this.storeId}})).customer}async getByEmail(t){throw new p("customer.getByEmail is not available: no API route finds a customer by email for a storefront session.","not_supported")}async updateProfile(t,e){return await this.http.post(`/api/v1/customers/${t}`,{customerId:t,data:{email:e.email}}),this.getProfile(t)}async getOrders(t,e){let{orders:r}=await this.http.get(`/api/v1/orders/customer/${t}`,{params:{storeId:this.storeId}}),s=(e==null?void 0:e.offset)??0,n=(e==null?void 0:e.limit)===void 0?void 0:s+e.limit;return{orders:r.slice(s,n),total:r.length}}async getOrder(t,e){var o,a;let r=async()=>(await this.http.get(`/api/v1/orders/${t}`,{params:{storeId:this.storeId}})).order,s=await r();if(!(e!=null&&e.waitForRelatedOrders)||(o=s.relatedOrders)!=null&&o.length)return s;let n=e.timeoutMs??8e3,d=e.intervalMs??2e3,u=Date.now()+n;for(;Date.now()<u;)if(await new Promise(c=>setTimeout(c,Math.min(d,Math.max(0,u-Date.now())))),s=await r(),(a=s.relatedOrders)!=null&&a.length)return s;return s}async getSubscriptions(t){let{items:e}=await this.http.get("/api/v1/subscriptions");return e.filter(r=>r.customerId===t).map(r=>y(r,this.storeId))}async getSubscription(t){let{items:e}=await this.http.get("/api/v1/subscriptions"),r=e.find(s=>s.id===t);if(!r)throw new f("Subscription",t);return y(r,this.storeId)}async pauseSubscription(t,e){await this.http.post("/api/v1/subscriptions/pause",{subscriptionId:t,resumeAt:e==null?void 0:e.resumeAt})}async resumeSubscription(t){await this.http.post("/api/v1/subscriptions/resume",{subscriptionId:t})}async skipSubscription(t){await this.http.post("/api/v1/subscriptions/skip",{subscriptionId:t})}async rescheduleSubscription(t,e){await this.http.post("/api/v1/subscriptions/reschedule",{subscriptionId:t,nextBillingDate:e})}async updateSubscriptionQuantity(t,e){await this.http.post("/api/v1/subscriptions/quantity",{subscriptionId:t,quantity:e})}async changeSubscriptionFrequency(t,e){let r=typeof e=="string"?{priceId:e}:e;await this.http.post("/api/v1/subscriptions/frequency",{subscriptionId:t,...r})}async swapSubscriptionProduct(t,e){await this.http.post("/api/v1/subscriptions/swap-product",{subscriptionId:t,...e})}async updateSubscriptionPaymentMethod(t,e){await this.http.post("/api/v1/subscriptions/payment-method",{subscriptionId:t,tagadaToken:e})}async cancelSubscription(t,e){await this.http.post("/api/v1/subscriptions/cancel",{subscriptionId:t,cancelAtPeriodEnd:(e==null?void 0:e.cancelAtPeriodEnd)??!0})}};return O(R);})();
7
7
  window.TagadaHeadlessCommerce=TagadaHeadlessCommerceBundle;
8
8
  //# sourceMappingURL=tagada-headless-commerce.min.js.map