@tagadapay/plugin-sdk 3.1.24 → 3.1.25

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 (39) hide show
  1. package/dist/external-tracker.js +243 -2871
  2. package/dist/external-tracker.min.js +2 -2
  3. package/dist/external-tracker.min.js.map +4 -4
  4. package/dist/react/hooks/useCheckout.js +7 -2
  5. package/dist/tagada-react-sdk-minimal.min.js +2 -2
  6. package/dist/tagada-react-sdk-minimal.min.js.map +3 -3
  7. package/dist/tagada-react-sdk.js +340 -173
  8. package/dist/tagada-react-sdk.min.js +2 -2
  9. package/dist/tagada-react-sdk.min.js.map +3 -3
  10. package/dist/tagada-sdk.js +776 -3327
  11. package/dist/tagada-sdk.min.js +2 -2
  12. package/dist/tagada-sdk.min.js.map +4 -4
  13. package/dist/v2/core/client.js +1 -0
  14. package/dist/v2/core/funnelClient.d.ts +8 -0
  15. package/dist/v2/core/funnelClient.js +1 -1
  16. package/dist/v2/core/resources/apiClient.d.ts +18 -14
  17. package/dist/v2/core/resources/apiClient.js +151 -109
  18. package/dist/v2/core/resources/checkout.d.ts +1 -1
  19. package/dist/v2/core/resources/index.d.ts +1 -1
  20. package/dist/v2/core/resources/index.js +1 -1
  21. package/dist/v2/core/resources/offers.js +4 -4
  22. package/dist/v2/core/resources/payments.d.ts +1 -0
  23. package/dist/v2/core/utils/currency.d.ts +3 -0
  24. package/dist/v2/core/utils/currency.js +40 -2
  25. package/dist/v2/core/utils/deviceInfo.d.ts +1 -0
  26. package/dist/v2/core/utils/deviceInfo.js +1 -0
  27. package/dist/v2/core/utils/previewMode.js +12 -0
  28. package/dist/v2/react/components/ApplePayButton.js +39 -16
  29. package/dist/v2/react/components/StripeExpressButton.js +1 -2
  30. package/dist/v2/react/hooks/payment-actions/useAirwallexRadarAction.js +1 -0
  31. package/dist/v2/react/hooks/useApiQuery.d.ts +1 -1
  32. package/dist/v2/react/hooks/useApiQuery.js +1 -1
  33. package/dist/v2/react/hooks/useCheckoutQuery.js +6 -2
  34. package/dist/v2/react/hooks/usePreviewOffer.js +1 -1
  35. package/dist/v2/react/providers/ExpressPaymentMethodsProvider.d.ts +7 -0
  36. package/dist/v2/react/providers/ExpressPaymentMethodsProvider.js +97 -9
  37. package/dist/v2/react/providers/TagadaProvider.js +1 -1
  38. package/dist/v2/standalone/payment-service.js +1 -0
  39. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * TagadaPay React SDK v3.1.24
2
+ * TagadaPay React SDK v3.1.25
3
3
  * CDN Bundle - React hooks and TagadaProvider (Debug Build)
4
4
  * @license MIT
5
5
  */
@@ -9638,6 +9638,16 @@ var TagadaReactSDKBundle = (() => {
9638
9638
  if (urlBaseUrl) {
9639
9639
  setClientBaseUrl(urlBaseUrl);
9640
9640
  }
9641
+ const urlCurrency = urlParams.get("currency");
9642
+ if (urlCurrency) {
9643
+ setInStorage(STORAGE_KEYS.CURRENCY, urlCurrency.toUpperCase());
9644
+ setInCookie(STORAGE_KEYS.CURRENCY, urlCurrency.toUpperCase(), 86400);
9645
+ }
9646
+ const urlLocale = urlParams.get("locale");
9647
+ if (urlLocale) {
9648
+ setInStorage(STORAGE_KEYS.LOCALE, urlLocale);
9649
+ setInCookie(STORAGE_KEYS.LOCALE, urlLocale, 86400);
9650
+ }
9641
9651
  }
9642
9652
  function setFunnelTracking(enabled) {
9643
9653
  if (typeof window === "undefined") return;
@@ -10538,7 +10548,7 @@ var TagadaReactSDKBundle = (() => {
10538
10548
  if (this.config.debugMode) {
10539
10549
  console.log("\u{1F680} [FunnelClient] Auto-redirecting to:", result.url, "(skipped session refresh - next page will initialize)");
10540
10550
  }
10541
- window.location.href = result.url;
10551
+ window.location.replace(result.url);
10542
10552
  }
10543
10553
  return result;
10544
10554
  } catch (error) {
@@ -10648,11 +10658,24 @@ var TagadaReactSDKBundle = (() => {
10648
10658
  });
10649
10659
 
10650
10660
  // src/v2/core/resources/apiClient.ts
10661
+ function anySignal(signals) {
10662
+ const controller = new AbortController();
10663
+ for (const signal of signals) {
10664
+ if (signal.aborted) {
10665
+ controller.abort(signal.reason);
10666
+ return controller.signal;
10667
+ }
10668
+ signal.addEventListener("abort", () => controller.abort(signal.reason), {
10669
+ once: true,
10670
+ signal: controller.signal
10671
+ });
10672
+ }
10673
+ return controller.signal;
10674
+ }
10651
10675
  var ApiClient;
10652
10676
  var init_apiClient = __esm({
10653
10677
  "src/v2/core/resources/apiClient.ts"() {
10654
10678
  "use strict";
10655
- init_axios2();
10656
10679
  init_errors();
10657
10680
  ApiClient = class {
10658
10681
  // Max 30 requests per endpoint in window
@@ -10664,66 +10687,14 @@ var TagadaReactSDKBundle = (() => {
10664
10687
  this.WINDOW_MS = 5e3;
10665
10688
  // 5 seconds window
10666
10689
  this.MAX_REQUESTS = 30;
10667
- this.axios = axios_default.create({
10668
- baseURL: config.baseURL,
10669
- timeout: config.timeout || 6e4,
10670
- // 60 seconds for payment operations
10671
- headers: __spreadValues({
10672
- "Content-Type": "application/json"
10673
- }, config.headers)
10674
- });
10690
+ this.baseURL = config.baseURL;
10691
+ this.timeout = config.timeout || 6e4;
10692
+ this.defaultHeaders = __spreadValues({
10693
+ "Content-Type": "application/json"
10694
+ }, config.headers);
10675
10695
  if (typeof setInterval !== "undefined") {
10676
10696
  setInterval(() => this.cleanupHistory(), 1e4);
10677
10697
  }
10678
- this.axios.interceptors.request.use(
10679
- async (config2) => {
10680
- var _a11, _b2;
10681
- if (config2.url) {
10682
- try {
10683
- this.checkRequestLimit("".concat((_a11 = config2.method) == null ? void 0 : _a11.toUpperCase(), ":").concat(config2.url));
10684
- } catch (error) {
10685
- console.error("[SDK] \u{1F6D1} Request blocked by Circuit Breaker:", error);
10686
- return Promise.reject(error);
10687
- }
10688
- }
10689
- if (!config2.skipAuth && !this.currentToken && this.tokenProvider) {
10690
- try {
10691
- console.log("[SDK] Waiting for token...");
10692
- const token = await this.tokenProvider();
10693
- if (token) {
10694
- this.updateToken(token);
10695
- config2.headers["x-cms-token"] = token;
10696
- }
10697
- } catch (error) {
10698
- console.error("[SDK] Failed to get token from provider:", error);
10699
- }
10700
- }
10701
- if (!config2.skipAuth && this.currentToken) {
10702
- config2.headers["x-cms-token"] = this.currentToken;
10703
- }
10704
- console.log("[SDK] Making ".concat((_b2 = config2.method) == null ? void 0 : _b2.toUpperCase(), " request to: ").concat(config2.baseURL || "").concat(config2.url));
10705
- return config2;
10706
- },
10707
- (error) => {
10708
- console.error("[SDK] Request error:", error);
10709
- return Promise.reject(error instanceof Error ? error : new Error(String(error)));
10710
- }
10711
- );
10712
- this.axios.interceptors.response.use(
10713
- (response) => response,
10714
- (error) => {
10715
- console.error("[SDK] Response error:", error.message);
10716
- if (error instanceof TagadaError) {
10717
- return Promise.reject(error);
10718
- }
10719
- if (axios_default.isAxiosError(error)) {
10720
- return Promise.reject(this.toTagadaError(error));
10721
- }
10722
- return Promise.reject(
10723
- error instanceof Error ? error : new Error(String(error))
10724
- );
10725
- }
10726
- );
10727
10698
  }
10728
10699
  // Set a provider that returns a promise resolving to the token
10729
10700
  // This allows requests to wait until the token is ready
@@ -10732,31 +10703,26 @@ var TagadaReactSDKBundle = (() => {
10732
10703
  }
10733
10704
  // Convenience methods
10734
10705
  async get(url, config) {
10735
- const response = await this.axios.get(url, config);
10736
- return response.data;
10706
+ return this.request("GET", url, void 0, config);
10737
10707
  }
10738
10708
  async post(url, data, config) {
10739
- const response = await this.axios.post(url, data, config);
10740
- return response.data;
10709
+ return this.request("POST", url, data, config);
10741
10710
  }
10742
10711
  async put(url, data, config) {
10743
- const response = await this.axios.put(url, data, config);
10744
- return response.data;
10712
+ return this.request("PUT", url, data, config);
10745
10713
  }
10746
10714
  async patch(url, data, config) {
10747
- const response = await this.axios.patch(url, data, config);
10748
- return response.data;
10715
+ return this.request("PATCH", url, data, config);
10749
10716
  }
10750
10717
  async delete(url, config) {
10751
- const response = await this.axios.delete(url, config);
10752
- return response.data;
10718
+ return this.request("DELETE", url, void 0, config);
10753
10719
  }
10754
10720
  // Update headers (useful for auth tokens)
10755
10721
  setHeader(key, value) {
10756
- this.axios.defaults.headers.common[key] = value;
10722
+ this.defaultHeaders[key] = value;
10757
10723
  }
10758
10724
  removeHeader(key) {
10759
- delete this.axios.defaults.headers.common[key];
10725
+ delete this.defaultHeaders[key];
10760
10726
  }
10761
10727
  // Token management methods (matching old ApiService pattern)
10762
10728
  updateToken(token) {
@@ -10774,58 +10740,91 @@ var TagadaReactSDKBundle = (() => {
10774
10740
  // Update configuration (useful for environment changes)
10775
10741
  updateConfig(config) {
10776
10742
  if (config.baseURL) {
10777
- this.axios.defaults.baseURL = config.baseURL;
10743
+ this.baseURL = config.baseURL;
10778
10744
  }
10779
10745
  if (config.timeout) {
10780
- this.axios.defaults.timeout = config.timeout;
10746
+ this.timeout = config.timeout;
10781
10747
  }
10782
10748
  if (config.headers) {
10783
- Object.assign(this.axios.defaults.headers.common, config.headers);
10749
+ Object.assign(this.defaultHeaders, config.headers);
10784
10750
  }
10785
10751
  console.log("[SDK] ApiClient configuration updated");
10786
10752
  }
10787
- // Circuit Breaker Implementation
10788
- checkRequestLimit(key) {
10789
- const now = Date.now();
10790
- const history2 = this.requestHistory.get(key);
10791
- if (!history2) {
10792
- this.requestHistory.set(key, { count: 1, firstRequestTime: now });
10793
- return;
10753
+ // ---- Core request method ----
10754
+ async request(method, url, data, config) {
10755
+ const requestKey = "".concat(method, ":").concat(url);
10756
+ try {
10757
+ this.checkRequestLimit(requestKey);
10758
+ } catch (error) {
10759
+ console.error("[SDK] \u{1F6D1} Request blocked by Circuit Breaker:", error);
10760
+ throw error;
10794
10761
  }
10795
- if (now - history2.firstRequestTime > this.WINDOW_MS) {
10796
- this.requestHistory.set(key, { count: 1, firstRequestTime: now });
10797
- return;
10762
+ if (!(config == null ? void 0 : config.skipAuth) && !this.currentToken && this.tokenProvider) {
10763
+ try {
10764
+ console.log("[SDK] Waiting for token...");
10765
+ const token = await this.tokenProvider();
10766
+ if (token) {
10767
+ this.updateToken(token);
10768
+ }
10769
+ } catch (error) {
10770
+ console.error("[SDK] Failed to get token from provider:", error);
10771
+ }
10798
10772
  }
10799
- history2.count++;
10800
- if (history2.count > this.MAX_REQUESTS) {
10801
- throw new TagadaCircuitBreakerError(
10802
- "Circuit Breaker: Too many requests to ".concat(key, " (").concat(history2.count, " in ").concat(this.WINDOW_MS, "ms)")
10803
- );
10773
+ const headers = __spreadValues({}, this.defaultHeaders);
10774
+ if (config == null ? void 0 : config.headers) {
10775
+ Object.assign(headers, config.headers);
10804
10776
  }
10805
- }
10806
- cleanupHistory() {
10807
- const now = Date.now();
10808
- for (const [key, history2] of this.requestHistory.entries()) {
10809
- if (now - history2.firstRequestTime > this.WINDOW_MS) {
10810
- this.requestHistory.delete(key);
10811
- }
10777
+ if (!(config == null ? void 0 : config.skipAuth) && this.currentToken) {
10778
+ headers["x-cms-token"] = this.currentToken;
10812
10779
  }
10813
- }
10814
- /** Convert an AxiosError into the appropriate TagadaError subclass. */
10815
- toTagadaError(error) {
10816
- var _a11, _b2, _c, _d, _e;
10817
- const status = (_a11 = error.response) == null ? void 0 : _a11.status;
10818
- const data = (_b2 = error.response) == null ? void 0 : _b2.data;
10819
- const serverMessage = (_d = (_c = data == null ? void 0 : data.message) != null ? _c : data == null ? void 0 : data.error) != null ? _d : error.message;
10820
- if (!error.response) {
10821
- if (error.code === "ECONNABORTED") {
10822
- return new TagadaApiError("Request timed out", 0, {
10780
+ let fullUrl = "".concat(this.baseURL).concat(url);
10781
+ if (config == null ? void 0 : config.params) {
10782
+ const searchParams = new URLSearchParams(config.params);
10783
+ fullUrl += "?".concat(searchParams.toString());
10784
+ }
10785
+ console.log("[SDK] Making ".concat(method, " request to: ").concat(fullUrl));
10786
+ const controller = new AbortController();
10787
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
10788
+ const signal = (config == null ? void 0 : config.signal) ? anySignal([config.signal, controller.signal]) : controller.signal;
10789
+ try {
10790
+ const fetchOptions = {
10791
+ method,
10792
+ headers,
10793
+ signal
10794
+ };
10795
+ if (data !== void 0) {
10796
+ fetchOptions.body = JSON.stringify(data);
10797
+ }
10798
+ const response = await fetch(fullUrl, fetchOptions);
10799
+ if (!response.ok) {
10800
+ const errorData = await this.safeParseJson(response);
10801
+ throw this.toTagadaError(response.status, errorData, response.statusText);
10802
+ }
10803
+ const responseData = await response.json();
10804
+ return responseData;
10805
+ } catch (error) {
10806
+ if (error instanceof TagadaError) {
10807
+ throw error;
10808
+ }
10809
+ if (error instanceof DOMException && error.name === "AbortError") {
10810
+ throw new TagadaApiError("Request timed out", 0, {
10823
10811
  code: TagadaErrorCode.TIMEOUT,
10824
10812
  retryable: true
10825
10813
  });
10826
10814
  }
10827
- return new TagadaNetworkError(serverMessage);
10815
+ if (error instanceof TypeError) {
10816
+ throw new TagadaNetworkError(error.message);
10817
+ }
10818
+ throw error instanceof Error ? error : new Error(String(error));
10819
+ } finally {
10820
+ clearTimeout(timeoutId);
10828
10821
  }
10822
+ }
10823
+ // ---- Error mapping ----
10824
+ /** Convert a non-ok fetch response into the appropriate TagadaError subclass. */
10825
+ toTagadaError(status, data, statusText) {
10826
+ var _a11, _b2, _c;
10827
+ const serverMessage = (_b2 = (_a11 = data == null ? void 0 : data.message) != null ? _a11 : data == null ? void 0 : data.error) != null ? _b2 : statusText;
10829
10828
  if (status === 401 || status === 403) {
10830
10829
  return new TagadaAuthError(serverMessage, status);
10831
10830
  }
@@ -10841,12 +10840,47 @@ var TagadaReactSDKBundle = (() => {
10841
10840
  retryable: false
10842
10841
  });
10843
10842
  }
10844
- return new TagadaApiError(serverMessage, status != null ? status : 0, {
10845
- code: (_e = data == null ? void 0 : data.code) != null ? _e : TagadaErrorCode.API_ERROR,
10843
+ return new TagadaApiError(serverMessage, status, {
10844
+ code: (_c = data == null ? void 0 : data.code) != null ? _c : TagadaErrorCode.API_ERROR,
10846
10845
  details: data,
10847
- retryable: (status != null ? status : 0) >= 500
10846
+ retryable: status >= 500
10848
10847
  });
10849
10848
  }
10849
+ // ---- Helpers ----
10850
+ async safeParseJson(response) {
10851
+ try {
10852
+ return await response.json();
10853
+ } catch (e3) {
10854
+ return void 0;
10855
+ }
10856
+ }
10857
+ // Circuit Breaker Implementation
10858
+ checkRequestLimit(key) {
10859
+ const now = Date.now();
10860
+ const history2 = this.requestHistory.get(key);
10861
+ if (!history2) {
10862
+ this.requestHistory.set(key, { count: 1, firstRequestTime: now });
10863
+ return;
10864
+ }
10865
+ if (now - history2.firstRequestTime > this.WINDOW_MS) {
10866
+ this.requestHistory.set(key, { count: 1, firstRequestTime: now });
10867
+ return;
10868
+ }
10869
+ history2.count++;
10870
+ if (history2.count > this.MAX_REQUESTS) {
10871
+ throw new TagadaCircuitBreakerError(
10872
+ "Circuit Breaker: Too many requests to ".concat(key, " (").concat(history2.count, " in ").concat(this.WINDOW_MS, "ms)")
10873
+ );
10874
+ }
10875
+ }
10876
+ cleanupHistory() {
10877
+ const now = Date.now();
10878
+ for (const [key, history2] of this.requestHistory.entries()) {
10879
+ if (now - history2.firstRequestTime > this.WINDOW_MS) {
10880
+ this.requestHistory.delete(key);
10881
+ }
10882
+ }
10883
+ }
10850
10884
  };
10851
10885
  }
10852
10886
  });
@@ -11016,7 +11050,8 @@ var TagadaReactSDKBundle = (() => {
11016
11050
  currency: params.get("currency") || void 0,
11017
11051
  utmSource: params.get("utm_source") || void 0,
11018
11052
  utmMedium: params.get("utm_medium") || void 0,
11019
- utmCampaign: params.get("utm_campaign") || void 0
11053
+ utmCampaign: params.get("utm_campaign") || void 0,
11054
+ gclid: params.get("gclid") || void 0
11020
11055
  };
11021
11056
  }
11022
11057
  var UA;
@@ -12016,6 +12051,7 @@ var TagadaReactSDKBundle = (() => {
12016
12051
  utmSource: urlParams.utmSource,
12017
12052
  utmMedium: urlParams.utmMedium,
12018
12053
  utmCampaign: urlParams.utmCampaign,
12054
+ gclid: urlParams.gclid,
12019
12055
  browser: deviceInfo.userAgent.browser.name,
12020
12056
  browserVersion: deviceInfo.userAgent.browser.version,
12021
12057
  os: deviceInfo.userAgent.os.name,
@@ -13145,14 +13181,23 @@ var TagadaReactSDKBundle = (() => {
13145
13181
  var init_currency = __esm({
13146
13182
  "src/v2/core/utils/currency.ts"() {
13147
13183
  "use strict";
13148
- CurrencyUtils = class {
13184
+ CurrencyUtils = class _CurrencyUtils {
13149
13185
  /**
13150
13186
  * Get currency from context or fallback to default
13151
13187
  */
13152
13188
  static getCurrency(context, defaultCurrency = "USD") {
13153
- var _a11, _b2, _c;
13189
+ var _a11, _b2, _c, _d;
13154
13190
  let currencyCode;
13155
- if (typeof (context == null ? void 0 : context.currency) === "string") {
13191
+ let isExplicit = false;
13192
+ const urlCurrency = typeof window !== "undefined" ? new URLSearchParams(window.location.search).get("currency") : null;
13193
+ const storedCurrency = typeof window !== "undefined" ? localStorage.getItem("tgd_currency") || _CurrencyUtils.getCookieValue("tgd_currency") : null;
13194
+ if (urlCurrency) {
13195
+ currencyCode = urlCurrency.toUpperCase();
13196
+ isExplicit = true;
13197
+ } else if (storedCurrency) {
13198
+ currencyCode = storedCurrency.toUpperCase();
13199
+ isExplicit = true;
13200
+ } else if (typeof (context == null ? void 0 : context.currency) === "string") {
13156
13201
  currencyCode = context.currency;
13157
13202
  } else if ((_a11 = context == null ? void 0 : context.currency) == null ? void 0 : _a11.code) {
13158
13203
  currencyCode = context.currency.code;
@@ -13161,13 +13206,32 @@ var TagadaReactSDKBundle = (() => {
13161
13206
  } else {
13162
13207
  currencyCode = defaultCurrency;
13163
13208
  }
13209
+ const presentment = (_d = context == null ? void 0 : context.store) == null ? void 0 : _d.presentmentCurrencies;
13210
+ if ((presentment == null ? void 0 : presentment.length) && !presentment.includes(currencyCode)) {
13211
+ console.warn(
13212
+ '[CurrencyUtils] Currency "'.concat(currencyCode, '" is not in store presentmentCurrencies [').concat(presentment.join(", "), "]. Falling back to ").concat(presentment[0], ".")
13213
+ );
13214
+ currencyCode = presentment[0];
13215
+ if (isExplicit && typeof window !== "undefined") {
13216
+ try {
13217
+ localStorage.setItem("tgd_currency", currencyCode);
13218
+ } catch (e3) {
13219
+ }
13220
+ }
13221
+ }
13164
13222
  return {
13165
13223
  code: currencyCode,
13166
13224
  symbol: this.getCurrencySymbol(currencyCode),
13167
13225
  name: this.getCurrencyName(currencyCode),
13168
- decimalPlaces: this.getDecimalPlaces(currencyCode)
13226
+ decimalPlaces: this.getDecimalPlaces(currencyCode),
13227
+ isExplicit
13169
13228
  };
13170
13229
  }
13230
+ static getCookieValue(name) {
13231
+ if (typeof document === "undefined") return null;
13232
+ const match4 = document.cookie.match(new RegExp("(?:^|; )".concat(name, "=([^;]*)")));
13233
+ return match4 ? decodeURIComponent(match4[1]) : null;
13234
+ }
13171
13235
  /**
13172
13236
  * Get currency symbol
13173
13237
  */
@@ -13851,7 +13915,7 @@ var TagadaReactSDKBundle = (() => {
13851
13915
  * - Use lineItemId for precise updates (same product, different variants)
13852
13916
  * - Use productId for simple updates (all items with this product)
13853
13917
  */
13854
- async previewOffer(offerId, currency = "USD", lineItems) {
13918
+ async previewOffer(offerId, currency = "", lineItems) {
13855
13919
  console.log("\u{1F4E1} [OffersResource] Calling preview API:", {
13856
13920
  offerId,
13857
13921
  currency,
@@ -13875,7 +13939,7 @@ var TagadaReactSDKBundle = (() => {
13875
13939
  * @param returnUrl - Optional return URL for checkout
13876
13940
  * @param mainOrderId - Optional main order ID (for upsells)
13877
13941
  */
13878
- async payPreviewedOffer(offerId, currency = "USD", lineItems, returnUrl, mainOrderId) {
13942
+ async payPreviewedOffer(offerId, currency = "", lineItems, returnUrl, mainOrderId) {
13879
13943
  console.log("\u{1F4B3} [OffersResource] Calling pay-preview API:", {
13880
13944
  offerId,
13881
13945
  currency,
@@ -13903,7 +13967,7 @@ var TagadaReactSDKBundle = (() => {
13903
13967
  * @param returnUrl - Optional return URL for checkout
13904
13968
  * @param mainOrderId - Optional main order ID
13905
13969
  */
13906
- async toCheckout(offerId, currency = "USD", lineItems, returnUrl, mainOrderId) {
13970
+ async toCheckout(offerId, currency = "", lineItems, returnUrl, mainOrderId) {
13907
13971
  console.log("\u{1F6D2} [OffersResource] Calling to-checkout API:", {
13908
13972
  offerId,
13909
13973
  currency,
@@ -14024,7 +14088,7 @@ var TagadaReactSDKBundle = (() => {
14024
14088
  *
14025
14089
  * // By the time page loads, background processing is usually complete
14026
14090
  */
14027
- async toCheckoutAsync(offerId, currency = "USD", lineItems, returnUrl, mainOrderId) {
14091
+ async toCheckoutAsync(offerId, currency = "", lineItems, returnUrl, mainOrderId) {
14028
14092
  console.log("\u{1F6D2} [OffersResource] Calling to-checkout-async API:", {
14029
14093
  offerId,
14030
14094
  currency,
@@ -18105,7 +18169,7 @@ var TagadaReactSDKBundle = (() => {
18105
18169
  if (shouldAutoRedirect && (result == null ? void 0 : result.url) && typeof window !== "undefined") {
18106
18170
  console.log("\u{1F680} [TagadaProvider] Auto-redirecting to:", result.url);
18107
18171
  setPendingRedirect(true);
18108
- window.location.href = result.url;
18172
+ window.location.replace(result.url);
18109
18173
  }
18110
18174
  };
18111
18175
  const next = async (event, options) => {
@@ -18830,7 +18894,7 @@ var TagadaReactSDKBundle = (() => {
18830
18894
  asap: asap2,
18831
18895
  isIterable: isIterable2
18832
18896
  };
18833
- function AxiosError5(message, code, config, request, response) {
18897
+ function AxiosError4(message, code, config, request, response) {
18834
18898
  Error.call(this);
18835
18899
  if (Error.captureStackTrace) {
18836
18900
  Error.captureStackTrace(this, this.constructor);
@@ -18847,7 +18911,7 @@ var TagadaReactSDKBundle = (() => {
18847
18911
  this.status = response.status ? response.status : null;
18848
18912
  }
18849
18913
  }
18850
- utils$1.inherits(AxiosError5, Error, {
18914
+ utils$1.inherits(AxiosError4, Error, {
18851
18915
  toJSON: function toJSON2() {
18852
18916
  return {
18853
18917
  // Standard
@@ -18868,7 +18932,7 @@ var TagadaReactSDKBundle = (() => {
18868
18932
  };
18869
18933
  }
18870
18934
  });
18871
- var prototype$1 = AxiosError5.prototype;
18935
+ var prototype$1 = AxiosError4.prototype;
18872
18936
  var descriptors2 = {};
18873
18937
  [
18874
18938
  "ERR_BAD_OPTION_VALUE",
@@ -18887,9 +18951,9 @@ var TagadaReactSDKBundle = (() => {
18887
18951
  ].forEach((code) => {
18888
18952
  descriptors2[code] = { value: code };
18889
18953
  });
18890
- Object.defineProperties(AxiosError5, descriptors2);
18954
+ Object.defineProperties(AxiosError4, descriptors2);
18891
18955
  Object.defineProperty(prototype$1, "isAxiosError", { value: true });
18892
- AxiosError5.from = (error, code, config, request, response, customProps) => {
18956
+ AxiosError4.from = (error, code, config, request, response, customProps) => {
18893
18957
  const axiosError = Object.create(prototype$1);
18894
18958
  utils$1.toFlatObject(error, axiosError, function filter2(obj) {
18895
18959
  return obj !== Error.prototype;
@@ -18898,7 +18962,7 @@ var TagadaReactSDKBundle = (() => {
18898
18962
  });
18899
18963
  const msg = error && error.message ? error.message : "Error";
18900
18964
  const errCode = code == null && error ? error.code : code;
18901
- AxiosError5.call(axiosError, msg, errCode, config, request, response);
18965
+ AxiosError4.call(axiosError, msg, errCode, config, request, response);
18902
18966
  if (error && axiosError.cause == null) {
18903
18967
  Object.defineProperty(axiosError, "cause", { value: error, configurable: true });
18904
18968
  }
@@ -18956,7 +19020,7 @@ var TagadaReactSDKBundle = (() => {
18956
19020
  return value.toString();
18957
19021
  }
18958
19022
  if (!useBlob && utils$1.isBlob(value)) {
18959
- throw new AxiosError5("Blob is not supported. Use a Buffer instead.");
19023
+ throw new AxiosError4("Blob is not supported. Use a Buffer instead.");
18960
19024
  }
18961
19025
  if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
18962
19026
  return useBlob && typeof Blob === "function" ? new Blob([value]) : Buffer.from(value);
@@ -19307,7 +19371,7 @@ var TagadaReactSDKBundle = (() => {
19307
19371
  } catch (e3) {
19308
19372
  if (strictJSONParsing) {
19309
19373
  if (e3.name === "SyntaxError") {
19310
- throw AxiosError5.from(e3, AxiosError5.ERR_BAD_RESPONSE, this, null, this.response);
19374
+ throw AxiosError4.from(e3, AxiosError4.ERR_BAD_RESPONSE, this, null, this.response);
19311
19375
  }
19312
19376
  throw e3;
19313
19377
  }
@@ -19627,10 +19691,10 @@ var TagadaReactSDKBundle = (() => {
19627
19691
  return !!(value && value.__CANCEL__);
19628
19692
  }
19629
19693
  function CanceledError3(message, config, request) {
19630
- AxiosError5.call(this, message == null ? "canceled" : message, AxiosError5.ERR_CANCELED, config, request);
19694
+ AxiosError4.call(this, message == null ? "canceled" : message, AxiosError4.ERR_CANCELED, config, request);
19631
19695
  this.name = "CanceledError";
19632
19696
  }
19633
- utils$1.inherits(CanceledError3, AxiosError5, {
19697
+ utils$1.inherits(CanceledError3, AxiosError4, {
19634
19698
  __CANCEL__: true
19635
19699
  });
19636
19700
  function settle2(resolve, reject, response) {
@@ -19638,9 +19702,9 @@ var TagadaReactSDKBundle = (() => {
19638
19702
  if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
19639
19703
  resolve(response);
19640
19704
  } else {
19641
- reject(new AxiosError5(
19705
+ reject(new AxiosError4(
19642
19706
  "Request failed with status code " + response.status,
19643
- [AxiosError5.ERR_BAD_REQUEST, AxiosError5.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
19707
+ [AxiosError4.ERR_BAD_REQUEST, AxiosError4.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
19644
19708
  response.config,
19645
19709
  response.request,
19646
19710
  response
@@ -19987,12 +20051,12 @@ var TagadaReactSDKBundle = (() => {
19987
20051
  if (!request) {
19988
20052
  return;
19989
20053
  }
19990
- reject(new AxiosError5("Request aborted", AxiosError5.ECONNABORTED, config, request));
20054
+ reject(new AxiosError4("Request aborted", AxiosError4.ECONNABORTED, config, request));
19991
20055
  request = null;
19992
20056
  };
19993
20057
  request.onerror = function handleError(event) {
19994
20058
  const msg = event && event.message ? event.message : "Network Error";
19995
- const err = new AxiosError5(msg, AxiosError5.ERR_NETWORK, config, request);
20059
+ const err = new AxiosError4(msg, AxiosError4.ERR_NETWORK, config, request);
19996
20060
  err.event = event || null;
19997
20061
  reject(err);
19998
20062
  request = null;
@@ -20003,9 +20067,9 @@ var TagadaReactSDKBundle = (() => {
20003
20067
  if (_config.timeoutErrorMessage) {
20004
20068
  timeoutErrorMessage = _config.timeoutErrorMessage;
20005
20069
  }
20006
- reject(new AxiosError5(
20070
+ reject(new AxiosError4(
20007
20071
  timeoutErrorMessage,
20008
- transitional2.clarifyTimeoutError ? AxiosError5.ETIMEDOUT : AxiosError5.ECONNABORTED,
20072
+ transitional2.clarifyTimeoutError ? AxiosError4.ETIMEDOUT : AxiosError4.ECONNABORTED,
20009
20073
  config,
20010
20074
  request
20011
20075
  ));
@@ -20048,7 +20112,7 @@ var TagadaReactSDKBundle = (() => {
20048
20112
  }
20049
20113
  const protocol = parseProtocol2(_config.url);
20050
20114
  if (protocol && platform.protocols.indexOf(protocol) === -1) {
20051
- reject(new AxiosError5("Unsupported protocol " + protocol + ":", AxiosError5.ERR_BAD_REQUEST, config));
20115
+ reject(new AxiosError4("Unsupported protocol " + protocol + ":", AxiosError4.ERR_BAD_REQUEST, config));
20052
20116
  return;
20053
20117
  }
20054
20118
  request.send(requestData || null);
@@ -20064,12 +20128,12 @@ var TagadaReactSDKBundle = (() => {
20064
20128
  aborted = true;
20065
20129
  unsubscribe();
20066
20130
  const err = reason instanceof Error ? reason : this.reason;
20067
- controller.abort(err instanceof AxiosError5 ? err : new CanceledError3(err instanceof Error ? err.message : err));
20131
+ controller.abort(err instanceof AxiosError4 ? err : new CanceledError3(err instanceof Error ? err.message : err));
20068
20132
  }
20069
20133
  };
20070
20134
  let timer = timeout && setTimeout(() => {
20071
20135
  timer = null;
20072
- onabort(new AxiosError5("timeout ".concat(timeout, " of ms exceeded"), AxiosError5.ETIMEDOUT));
20136
+ onabort(new AxiosError4("timeout ".concat(timeout, " of ms exceeded"), AxiosError4.ETIMEDOUT));
20073
20137
  }, timeout);
20074
20138
  const unsubscribe = () => {
20075
20139
  if (signals) {
@@ -20232,7 +20296,7 @@ var TagadaReactSDKBundle = (() => {
20232
20296
  if (method) {
20233
20297
  return method.call(res);
20234
20298
  }
20235
- throw new AxiosError5("Response type '".concat(type, "' is not supported"), AxiosError5.ERR_NOT_SUPPORT, config);
20299
+ throw new AxiosError4("Response type '".concat(type, "' is not supported"), AxiosError4.ERR_NOT_SUPPORT, config);
20236
20300
  });
20237
20301
  });
20238
20302
  })();
@@ -20356,13 +20420,13 @@ var TagadaReactSDKBundle = (() => {
20356
20420
  unsubscribe && unsubscribe();
20357
20421
  if (err && err.name === "TypeError" && /Load failed|fetch/i.test(err.message)) {
20358
20422
  throw Object.assign(
20359
- new AxiosError5("Network Error", AxiosError5.ERR_NETWORK, config, request),
20423
+ new AxiosError4("Network Error", AxiosError4.ERR_NETWORK, config, request),
20360
20424
  {
20361
20425
  cause: err.cause || err
20362
20426
  }
20363
20427
  );
20364
20428
  }
20365
- throw AxiosError5.from(err, err && err.code, config, request);
20429
+ throw AxiosError4.from(err, err && err.code, config, request);
20366
20430
  }
20367
20431
  };
20368
20432
  };
@@ -20416,7 +20480,7 @@ var TagadaReactSDKBundle = (() => {
20416
20480
  if (!isResolvedHandle2(nameOrAdapter)) {
20417
20481
  adapter2 = knownAdapters2[(id = String(nameOrAdapter)).toLowerCase()];
20418
20482
  if (adapter2 === void 0) {
20419
- throw new AxiosError5("Unknown adapter '".concat(id, "'"));
20483
+ throw new AxiosError4("Unknown adapter '".concat(id, "'"));
20420
20484
  }
20421
20485
  }
20422
20486
  if (adapter2 && (utils$1.isFunction(adapter2) || (adapter2 = adapter2.get(config)))) {
@@ -20429,7 +20493,7 @@ var TagadaReactSDKBundle = (() => {
20429
20493
  ([id, state]) => "adapter ".concat(id, " ") + (state === false ? "is not supported by the environment" : "is not available in the build")
20430
20494
  );
20431
20495
  let s3 = length ? reasons.length > 1 ? "since :\n" + reasons.map(renderReason2).join("\n") : " " + renderReason2(reasons[0]) : "as no adapter specified";
20432
- throw new AxiosError5(
20496
+ throw new AxiosError4(
20433
20497
  "There is no suitable adapter to dispatch the request " + s3,
20434
20498
  "ERR_NOT_SUPPORT"
20435
20499
  );
@@ -20505,9 +20569,9 @@ var TagadaReactSDKBundle = (() => {
20505
20569
  }
20506
20570
  return (value, opt, opts) => {
20507
20571
  if (validator2 === false) {
20508
- throw new AxiosError5(
20572
+ throw new AxiosError4(
20509
20573
  formatMessage(opt, " has been removed" + (version ? " in " + version : "")),
20510
- AxiosError5.ERR_DEPRECATED
20574
+ AxiosError4.ERR_DEPRECATED
20511
20575
  );
20512
20576
  }
20513
20577
  if (version && !deprecatedWarnings2[opt]) {
@@ -20530,7 +20594,7 @@ var TagadaReactSDKBundle = (() => {
20530
20594
  };
20531
20595
  function assertOptions2(options, schema, allowUnknown) {
20532
20596
  if (typeof options !== "object") {
20533
- throw new AxiosError5("options must be an object", AxiosError5.ERR_BAD_OPTION_VALUE);
20597
+ throw new AxiosError4("options must be an object", AxiosError4.ERR_BAD_OPTION_VALUE);
20534
20598
  }
20535
20599
  const keys = Object.keys(options);
20536
20600
  let i3 = keys.length;
@@ -20541,12 +20605,12 @@ var TagadaReactSDKBundle = (() => {
20541
20605
  const value = options[opt];
20542
20606
  const result = value === void 0 || validator2(value, opt, options);
20543
20607
  if (result !== true) {
20544
- throw new AxiosError5("option " + opt + " must be " + result, AxiosError5.ERR_BAD_OPTION_VALUE);
20608
+ throw new AxiosError4("option " + opt + " must be " + result, AxiosError4.ERR_BAD_OPTION_VALUE);
20545
20609
  }
20546
20610
  continue;
20547
20611
  }
20548
20612
  if (allowUnknown !== true) {
20549
- throw new AxiosError5("Unknown option " + opt, AxiosError5.ERR_BAD_OPTION);
20613
+ throw new AxiosError4("Unknown option " + opt, AxiosError4.ERR_BAD_OPTION);
20550
20614
  }
20551
20615
  }
20552
20616
  }
@@ -20920,7 +20984,7 @@ var TagadaReactSDKBundle = (() => {
20920
20984
  axios2.isCancel = isCancel3;
20921
20985
  axios2.VERSION = VERSION3;
20922
20986
  axios2.toFormData = toFormData3;
20923
- axios2.AxiosError = AxiosError5;
20987
+ axios2.AxiosError = AxiosError4;
20924
20988
  axios2.Cancel = axios2.CanceledError;
20925
20989
  axios2.all = function all3(promises) {
20926
20990
  return Promise.all(promises);
@@ -27354,16 +27418,55 @@ var TagadaReactSDKBundle = (() => {
27354
27418
  var ExpressPaymentMethodsContext = (0, import_react2.createContext)(
27355
27419
  void 0
27356
27420
  );
27421
+ function paymentMethodsFromSetupConfig(config) {
27422
+ const methods = [];
27423
+ for (const [key, entry] of Object.entries(config)) {
27424
+ if (!entry.enabled) continue;
27425
+ if (key.startsWith("express_checkout:") && entry.methods) {
27426
+ methods.push({
27427
+ id: key,
27428
+ type: "stripe_apm",
27429
+ title: entry.label || "Express Checkout",
27430
+ iconUrl: entry.logoUrl || "",
27431
+ default: false,
27432
+ settings: {
27433
+ publishableKey: entry.publishableKey,
27434
+ processors: [{
27435
+ processorId: entry.processorId,
27436
+ methods: entry.methods
27437
+ }]
27438
+ }
27439
+ });
27440
+ continue;
27441
+ }
27442
+ if (entry.express || entry.type === "apple_pay" || entry.type === "google_pay") {
27443
+ methods.push({
27444
+ id: key,
27445
+ type: entry.type || entry.method || key,
27446
+ title: entry.label || key,
27447
+ iconUrl: entry.logoUrl || "",
27448
+ default: false,
27449
+ settings: { processorId: entry.processorId, publishableKey: entry.publishableKey }
27450
+ });
27451
+ }
27452
+ }
27453
+ return methods;
27454
+ }
27357
27455
  var ExpressPaymentMethodsProvider = ({
27358
27456
  children,
27359
27457
  customerId,
27360
- checkout
27458
+ checkout,
27459
+ paymentSetupConfig
27361
27460
  }) => {
27362
27461
  var _a11;
27363
27462
  const queryClient = useQueryClient();
27364
27463
  const [availableExpressPaymentMethodIds, setAvailableExpressPaymentMethodIds] = (0, import_react2.useState)([]);
27365
27464
  const [error, setError] = (0, import_react2.useState)(null);
27366
27465
  const checkoutSessionId = (_a11 = checkout == null ? void 0 : checkout.checkoutSession) == null ? void 0 : _a11.id;
27466
+ const configDerivedMethods = (0, import_react2.useMemo)(
27467
+ () => paymentSetupConfig ? paymentMethodsFromSetupConfig(paymentSetupConfig) : void 0,
27468
+ [paymentSetupConfig]
27469
+ );
27367
27470
  const expressPaymentResource = (0, import_react2.useMemo)(() => {
27368
27471
  try {
27369
27472
  return new ExpressPaymentMethodsResource(getGlobalApiClient());
@@ -27373,14 +27476,14 @@ var TagadaReactSDKBundle = (() => {
27373
27476
  );
27374
27477
  }
27375
27478
  }, []);
27376
- const { data: paymentMethods, isLoading: isLoadingPaymentMethods } = useQuery({
27479
+ const { data: apiPaymentMethods, isLoading: isLoadingPaymentMethods } = useQuery({
27377
27480
  queryKey: ["payment-methods", checkoutSessionId],
27378
27481
  queryFn: () => expressPaymentResource.getPaymentMethods(checkoutSessionId),
27379
- enabled: !!checkoutSessionId,
27482
+ enabled: !!checkoutSessionId && !configDerivedMethods,
27380
27483
  staleTime: 6e4,
27381
- // 1 minute
27382
27484
  refetchOnWindowFocus: false
27383
27485
  });
27486
+ const paymentMethods = configDerivedMethods != null ? configDerivedMethods : apiPaymentMethods;
27384
27487
  const { shippingRates, refetch: refetchRates } = useShippingRatesQuery({ checkout });
27385
27488
  const orderSummary = checkout == null ? void 0 : checkout.summary;
27386
27489
  const handleAddExpressId = (0, import_react2.useCallback)((id) => {
@@ -27508,7 +27611,44 @@ var TagadaReactSDKBundle = (() => {
27508
27611
  },
27509
27612
  [customerId, updateEmailMutation]
27510
27613
  );
27511
- const isApplePayAvailable = typeof window !== "undefined" && typeof window.ApplePaySession !== "undefined";
27614
+ const [isApplePayAvailable, setIsApplePayAvailable] = (0, import_react2.useState)(
27615
+ () => typeof window !== "undefined" && typeof window.ApplePaySession !== "undefined"
27616
+ );
27617
+ const [isApplePaySdkLoading, setIsApplePaySdkLoading] = (0, import_react2.useState)(false);
27618
+ const hasApplePayConfig = paymentMethods == null ? void 0 : paymentMethods.some((p3) => p3.type === "apple_pay");
27619
+ (0, import_react2.useEffect)(() => {
27620
+ if (isApplePayAvailable || !hasApplePayConfig) return;
27621
+ const APPLE_PAY_SDK_URL2 = "https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js";
27622
+ const onSdkReady = () => {
27623
+ if (typeof window.ApplePaySession !== "undefined") {
27624
+ setIsApplePayAvailable(true);
27625
+ }
27626
+ setIsApplePaySdkLoading(false);
27627
+ };
27628
+ const existing = document.querySelector('script[src="'.concat(APPLE_PAY_SDK_URL2, '"]'));
27629
+ if (existing) {
27630
+ setIsApplePaySdkLoading(true);
27631
+ if (typeof window.ApplePaySession !== "undefined") {
27632
+ onSdkReady();
27633
+ } else {
27634
+ existing.addEventListener("load", onSdkReady);
27635
+ const timer = setTimeout(onSdkReady, 2e3);
27636
+ return () => {
27637
+ existing.removeEventListener("load", onSdkReady);
27638
+ clearTimeout(timer);
27639
+ };
27640
+ }
27641
+ return;
27642
+ }
27643
+ setIsApplePaySdkLoading(true);
27644
+ const script = document.createElement("script");
27645
+ script.src = APPLE_PAY_SDK_URL2;
27646
+ script.crossOrigin = "anonymous";
27647
+ script.async = true;
27648
+ script.onload = onSdkReady;
27649
+ script.onerror = () => setIsApplePaySdkLoading(false);
27650
+ document.head.appendChild(script);
27651
+ }, [isApplePayAvailable, hasApplePayConfig]);
27512
27652
  const applePayPaymentMethod = (0, import_react2.useMemo)(
27513
27653
  () => {
27514
27654
  return isApplePayAvailable ? paymentMethods == null ? void 0 : paymentMethods.find((p3) => p3.type === "apple_pay") : void 0;
@@ -27544,7 +27684,7 @@ var TagadaReactSDKBundle = (() => {
27544
27684
  },
27545
27685
  [paymentMethods]
27546
27686
  );
27547
- const loading = !paymentMethods || isLoadingPaymentMethods;
27687
+ const loading = !paymentMethods || !configDerivedMethods && isLoadingPaymentMethods || isApplePaySdkLoading;
27548
27688
  const tagadaError = (0, import_react2.useMemo)(
27549
27689
  () => error ? new TagadaError(error, { code: TagadaErrorCode.PAYMENT_FAILED }) : null,
27550
27690
  [error]
@@ -28691,6 +28831,7 @@ var TagadaReactSDKBundle = (() => {
28691
28831
  }
28692
28832
  console.log("Airwallex device fingerprint session created:", sessionId);
28693
28833
  await paymentsResource.saveRadarSession({
28834
+ paymentId: payment.id,
28694
28835
  checkoutSessionId,
28695
28836
  orderId,
28696
28837
  airwallexRadarSessionId: sessionId
@@ -30187,6 +30328,28 @@ var TagadaReactSDKBundle = (() => {
30187
30328
  email: (contact == null ? void 0 : contact.emailAddress) || ""
30188
30329
  };
30189
30330
  };
30331
+ var APPLE_PAY_SDK_URL = "https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js";
30332
+ var applePaySdkPromise = null;
30333
+ function loadApplePaySdk() {
30334
+ if (applePaySdkPromise) return applePaySdkPromise;
30335
+ if (document.querySelector('script[src="'.concat(APPLE_PAY_SDK_URL, '"]'))) {
30336
+ applePaySdkPromise = Promise.resolve();
30337
+ return applePaySdkPromise;
30338
+ }
30339
+ applePaySdkPromise = new Promise((resolve, reject) => {
30340
+ const script = document.createElement("script");
30341
+ script.src = APPLE_PAY_SDK_URL;
30342
+ script.crossOrigin = "anonymous";
30343
+ script.async = true;
30344
+ script.onload = () => resolve();
30345
+ script.onerror = () => {
30346
+ applePaySdkPromise = null;
30347
+ reject(new Error("[ApplePay] Failed to load Apple Pay SDK"));
30348
+ };
30349
+ document.head.appendChild(script);
30350
+ });
30351
+ return applePaySdkPromise;
30352
+ }
30190
30353
  var ApplePayButton = ({ checkout, onSuccess, onError: onError3, onCancel }) => {
30191
30354
  var _a11;
30192
30355
  const {
@@ -30208,18 +30371,22 @@ var TagadaReactSDKBundle = (() => {
30208
30371
  return null;
30209
30372
  }
30210
30373
  (0, import_react30.useEffect)(() => {
30211
- const addExpress = () => handleAddExpressId("apple_pay");
30212
- try {
30213
- if ((window == null ? void 0 : window.ApplePaySession) && ApplePaySession.canMakePayments()) {
30214
- setIsApplePayAvailable(true);
30215
- addExpress();
30216
- } else {
30217
- setIsApplePayAvailable(false);
30374
+ let cancelled = false;
30375
+ const checkAvailability = () => {
30376
+ try {
30377
+ if (!cancelled && (window == null ? void 0 : window.ApplePaySession) && ApplePaySession.canMakePayments()) {
30378
+ setIsApplePayAvailable(true);
30379
+ handleAddExpressId("apple_pay");
30380
+ }
30381
+ } catch (error) {
30382
+ console.warn("[ApplePay] Apple Pay not available:", error);
30218
30383
  }
30219
- } catch (error) {
30220
- console.warn("[ApplePay] Apple Pay not available:", error);
30221
- setIsApplePayAvailable(false);
30222
- }
30384
+ };
30385
+ loadApplePaySdk().then(checkAvailability).catch(() => {
30386
+ });
30387
+ return () => {
30388
+ cancelled = true;
30389
+ };
30223
30390
  }, [handleAddExpressId]);
30224
30391
  const minorUnitsToCurrencyString = (0, import_react30.useCallback)(
30225
30392
  (amountMinor, currency) => {
@@ -31226,7 +31393,7 @@ var TagadaReactSDKBundle = (() => {
31226
31393
  init_payments();
31227
31394
  init_useApiQuery();
31228
31395
  var import_jsx_runtime8 = __require("react/jsx-runtime");
31229
- var EXPRESS_METHOD_KEYS = ["apple_pay", "google_pay", "paypal", "link", "klarna_express"];
31396
+ var EXPRESS_METHOD_KEYS = ["apple_pay", "google_pay", "link", "klarna_express"];
31230
31397
  function StripeExpressButtonInner({
31231
31398
  checkout,
31232
31399
  processorId,
@@ -31361,7 +31528,6 @@ var TagadaReactSDKBundle = (() => {
31361
31528
  applePay: enabledExpressMethods.includes("apple_pay") ? "always" : "never",
31362
31529
  googlePay: enabledExpressMethods.includes("google_pay") ? "always" : "never",
31363
31530
  link: enabledExpressMethods.includes("link") ? "auto" : "never",
31364
- paypal: enabledExpressMethods.includes("paypal") ? "auto" : "never",
31365
31531
  klarna: enabledExpressMethods.includes("klarna_express") ? "auto" : "never"
31366
31532
  },
31367
31533
  emailRequired: true,
@@ -34886,6 +35052,7 @@ var TagadaReactSDKBundle = (() => {
34886
35052
  }
34887
35053
  }, [providedToken, internalToken]);
34888
35054
  const checkoutToken = providedToken || internalToken;
35055
+ const explicitCurrency = currency.isExplicit ? currency.code : void 0;
34889
35056
  const {
34890
35057
  data: checkout,
34891
35058
  isLoading,
@@ -34893,8 +35060,8 @@ var TagadaReactSDKBundle = (() => {
34893
35060
  isSuccess,
34894
35061
  refetch
34895
35062
  } = useQuery({
34896
- queryKey: ["checkout", checkoutToken, currency.code],
34897
- queryFn: () => checkoutResource.getCheckout(checkoutToken, currency.code),
35063
+ queryKey: ["checkout", checkoutToken, explicitCurrency],
35064
+ queryFn: () => checkoutResource.getCheckout(checkoutToken, explicitCurrency),
34898
35065
  enabled: enabled && !!checkoutToken && isSessionInitialized,
34899
35066
  staleTime: 3e4,
34900
35067
  // 30 seconds
@@ -36447,7 +36614,7 @@ var TagadaReactSDKBundle = (() => {
36447
36614
  init_offers();
36448
36615
  init_useApiQuery();
36449
36616
  function usePreviewOffer(options) {
36450
- const { offerId, currency: requestedCurrency = "USD", initialSelections = {} } = options;
36617
+ const { offerId, currency: requestedCurrency = "", initialSelections = {} } = options;
36451
36618
  const queryParamsCurrency = typeof window !== "undefined" ? new URLSearchParams(window.location.search).get("currency") || void 0 : void 0;
36452
36619
  const effectiveCurrency = queryParamsCurrency || requestedCurrency;
36453
36620
  const offersResource = (0, import_react64.useMemo)(() => new OffersResource(getGlobalApiClient()), []);