@economist/web-apple-pay 1.7.7 → 1.7.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.
package/dist/index.js CHANGED
@@ -956,7 +956,6 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
956
956
  cta.removeAttribute("aria-busy");
957
957
  }
958
958
  }).catch(() => {
959
- console.error("[web-apple-pay] apple-pay-modal: failed to pre-fetch reCAPTCHA tokens; CTA remains disabled");
960
959
  if (cta) {
961
960
  cta.removeAttribute("aria-busy");
962
961
  }
@@ -1121,7 +1120,7 @@ var isAppleDeviceOrSafari = () => {
1121
1120
  const isSafariBrowser = navigator.userAgent.indexOf("Safari") > -1 && navigator.userAgent.indexOf("Chrome") === -1;
1122
1121
  return isIOSOrMacTouchDevice || isSafariBrowser;
1123
1122
  };
1124
- var bypassApplePayChecks = () => new URLSearchParams(window.location.search).get("BYPASS_APPLE_PAY_CHECKS") !== null && getApplePayConfig()?.debugBypassEnabled === true;
1123
+ var bypassApplePayChecks = () => new URLSearchParams(window.location.search).get("BYPASS_APPLE_PAY_CHECKS") !== null;
1125
1124
  var isApplePayAvailable = async () => {
1126
1125
  if (bypassApplePayChecks()) {
1127
1126
  return true;
@@ -1142,15 +1141,11 @@ var isApplePayAvailable = async () => {
1142
1141
  }
1143
1142
  const merchantId = getApplePayConfig()?.merchantId;
1144
1143
  if (!merchantId) {
1145
- console.warn(
1146
- "[web-apple-pay] Missing merchantId. Call configureApplePay({ merchantId, ... }) before rendering Apple Pay components."
1147
- );
1148
1144
  return false;
1149
1145
  }
1150
1146
  const hasActiveCard = await applePaySession.canMakePaymentsWithActiveCard(merchantId);
1151
1147
  return hasActiveCard;
1152
- } catch (error) {
1153
- console.error("Error checking Apple Pay active card status:", error);
1148
+ } catch {
1154
1149
  return false;
1155
1150
  }
1156
1151
  };
@@ -1397,8 +1392,7 @@ async function handleMerchantValidation(event, session, config) {
1397
1392
  return;
1398
1393
  }
1399
1394
  session.completeMerchantValidation(response.merchantSession);
1400
- } catch (err) {
1401
- console.error("[web-apple-pay] onvalidatemerchant: error during validation", err);
1395
+ } catch {
1402
1396
  session.abort();
1403
1397
  redirectToFallbackCheckout(config);
1404
1398
  }
@@ -1431,8 +1425,7 @@ function startApplePaySession(config) {
1431
1425
  };
1432
1426
  trackWalletPaymentSheetOpen(config.skuId);
1433
1427
  session.begin();
1434
- } catch (err) {
1435
- console.error("[web-apple-pay] startApplePaySession: failed to create session", err);
1428
+ } catch {
1436
1429
  redirectToFallbackCheckout(config);
1437
1430
  }
1438
1431
  }
@@ -1647,7 +1640,6 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
1647
1640
  failApplePaySession(session, err.errors);
1648
1641
  return;
1649
1642
  }
1650
- console.error("[web-apple-pay] onpaymentauthorized error", { skuId, err });
1651
1643
  const walletError = parseWalletApiError(err);
1652
1644
  trackWalletPaymentFailure(skuId, walletError?.errorType ?? "UNKNOWN");
1653
1645
  failApplePaySession(session);
@@ -1925,7 +1917,6 @@ var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
1925
1917
  var TOTAL_LABEL = "The Economist";
1926
1918
  var DEFAULT_CURRENCY = "USD";
1927
1919
  var DEFAULT_TOTAL = "0.00";
1928
- var ERROR_INITIATE = "Failed to initiate Apple Pay session:";
1929
1920
  var SEL_CONTAINER = ".apple-pay-container";
1930
1921
  var SEL_BUTTON = ".apple-pay-btn";
1931
1922
  var APPLE_PAY_EXCLUDED_VARIANTS = [
@@ -2049,16 +2040,15 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2049
2040
  // ─── Render pipeline ────────────────────────────────────────────────────────
2050
2041
  async #run() {
2051
2042
  try {
2043
+ this.#renderTemplate();
2052
2044
  if (await this.#checkAvailability()) return;
2053
2045
  if (this.#checkOffer()) return;
2054
- this.#renderTemplate();
2055
2046
  if (await this.#checkSession()) return;
2056
2047
  this.#captureReturnUrl();
2057
2048
  this.#computeBillingCountries();
2058
2049
  if (await this.#fetchAndCacheOptions()) return;
2059
2050
  this.#finishLoading();
2060
- } catch (err) {
2061
- console.error("[web-apple-pay] #run: unexpected error, hiding button", err);
2051
+ } catch {
2062
2052
  this.style.display = "none";
2063
2053
  this.querySelector(SEL_CONTAINER)?.remove();
2064
2054
  } finally {
@@ -2070,6 +2060,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2070
2060
  const available = await isApplePayAvailable();
2071
2061
  if (!available) {
2072
2062
  this.style.display = "none";
2063
+ this.querySelector(SEL_CONTAINER)?.remove();
2073
2064
  return true;
2074
2065
  }
2075
2066
  return false;
@@ -2091,6 +2082,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2091
2082
  #checkOffer() {
2092
2083
  if (!this.#offer) {
2093
2084
  this.style.display = "none";
2085
+ this.querySelector(SEL_CONTAINER)?.remove();
2094
2086
  return true;
2095
2087
  }
2096
2088
  return false;
@@ -2197,8 +2189,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2197
2189
  */
2198
2190
  #scheduleRecaptchaTokens() {
2199
2191
  const attempt = getPurchaseRecaptchaTokens();
2200
- attempt.catch((err) => {
2201
- console.error("[web-apple-pay] reCAPTCHA token pre-fetch failed; will retry on modal open", err);
2192
+ attempt.catch(() => {
2202
2193
  if (this.#recaptchaTokensPromise === attempt) {
2203
2194
  this.#recaptchaTokensPromise = null;
2204
2195
  }
@@ -2259,8 +2250,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2259
2250
  recaptchaTokens
2260
2251
  )
2261
2252
  );
2262
- } catch (error) {
2263
- console.error(ERROR_INITIATE, error);
2253
+ } catch {
2264
2254
  }
2265
2255
  }
2266
2256
  };
@@ -2269,6 +2259,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2269
2259
  var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
2270
2260
  ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
2271
2261
  ApplePayEntryPoint2["REGWALL"] = "article_regwall";
2262
+ ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
2272
2263
  return ApplePayEntryPoint2;
2273
2264
  })(ApplePayEntryPoint || {});
2274
2265
 
@@ -951,7 +951,6 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
951
951
  cta.removeAttribute("aria-busy");
952
952
  }
953
953
  }).catch(() => {
954
- console.error("[web-apple-pay] apple-pay-modal: failed to pre-fetch reCAPTCHA tokens; CTA remains disabled");
955
954
  if (cta) {
956
955
  cta.removeAttribute("aria-busy");
957
956
  }
@@ -1116,7 +1115,7 @@ var isAppleDeviceOrSafari = () => {
1116
1115
  const isSafariBrowser = navigator.userAgent.indexOf("Safari") > -1 && navigator.userAgent.indexOf("Chrome") === -1;
1117
1116
  return isIOSOrMacTouchDevice || isSafariBrowser;
1118
1117
  };
1119
- var bypassApplePayChecks = () => new URLSearchParams(window.location.search).get("BYPASS_APPLE_PAY_CHECKS") !== null && getApplePayConfig()?.debugBypassEnabled === true;
1118
+ var bypassApplePayChecks = () => new URLSearchParams(window.location.search).get("BYPASS_APPLE_PAY_CHECKS") !== null;
1120
1119
  var isApplePayAvailable = async () => {
1121
1120
  if (bypassApplePayChecks()) {
1122
1121
  return true;
@@ -1137,15 +1136,11 @@ var isApplePayAvailable = async () => {
1137
1136
  }
1138
1137
  const merchantId = getApplePayConfig()?.merchantId;
1139
1138
  if (!merchantId) {
1140
- console.warn(
1141
- "[web-apple-pay] Missing merchantId. Call configureApplePay({ merchantId, ... }) before rendering Apple Pay components."
1142
- );
1143
1139
  return false;
1144
1140
  }
1145
1141
  const hasActiveCard = await applePaySession.canMakePaymentsWithActiveCard(merchantId);
1146
1142
  return hasActiveCard;
1147
- } catch (error) {
1148
- console.error("Error checking Apple Pay active card status:", error);
1143
+ } catch {
1149
1144
  return false;
1150
1145
  }
1151
1146
  };
@@ -1392,8 +1387,7 @@ async function handleMerchantValidation(event, session, config) {
1392
1387
  return;
1393
1388
  }
1394
1389
  session.completeMerchantValidation(response.merchantSession);
1395
- } catch (err) {
1396
- console.error("[web-apple-pay] onvalidatemerchant: error during validation", err);
1390
+ } catch {
1397
1391
  session.abort();
1398
1392
  redirectToFallbackCheckout(config);
1399
1393
  }
@@ -1426,8 +1420,7 @@ function startApplePaySession(config) {
1426
1420
  };
1427
1421
  trackWalletPaymentSheetOpen(config.skuId);
1428
1422
  session.begin();
1429
- } catch (err) {
1430
- console.error("[web-apple-pay] startApplePaySession: failed to create session", err);
1423
+ } catch {
1431
1424
  redirectToFallbackCheckout(config);
1432
1425
  }
1433
1426
  }
@@ -1642,7 +1635,6 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
1642
1635
  failApplePaySession(session, err.errors);
1643
1636
  return;
1644
1637
  }
1645
- console.error("[web-apple-pay] onpaymentauthorized error", { skuId, err });
1646
1638
  const walletError = parseWalletApiError(err);
1647
1639
  trackWalletPaymentFailure(skuId, walletError?.errorType ?? "UNKNOWN");
1648
1640
  failApplePaySession(session);
@@ -1920,7 +1912,6 @@ var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
1920
1912
  var TOTAL_LABEL = "The Economist";
1921
1913
  var DEFAULT_CURRENCY = "USD";
1922
1914
  var DEFAULT_TOTAL = "0.00";
1923
- var ERROR_INITIATE = "Failed to initiate Apple Pay session:";
1924
1915
  var SEL_CONTAINER = ".apple-pay-container";
1925
1916
  var SEL_BUTTON = ".apple-pay-btn";
1926
1917
  var APPLE_PAY_EXCLUDED_VARIANTS = [
@@ -2044,16 +2035,15 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2044
2035
  // ─── Render pipeline ────────────────────────────────────────────────────────
2045
2036
  async #run() {
2046
2037
  try {
2038
+ this.#renderTemplate();
2047
2039
  if (await this.#checkAvailability()) return;
2048
2040
  if (this.#checkOffer()) return;
2049
- this.#renderTemplate();
2050
2041
  if (await this.#checkSession()) return;
2051
2042
  this.#captureReturnUrl();
2052
2043
  this.#computeBillingCountries();
2053
2044
  if (await this.#fetchAndCacheOptions()) return;
2054
2045
  this.#finishLoading();
2055
- } catch (err) {
2056
- console.error("[web-apple-pay] #run: unexpected error, hiding button", err);
2046
+ } catch {
2057
2047
  this.style.display = "none";
2058
2048
  this.querySelector(SEL_CONTAINER)?.remove();
2059
2049
  } finally {
@@ -2065,6 +2055,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2065
2055
  const available = await isApplePayAvailable();
2066
2056
  if (!available) {
2067
2057
  this.style.display = "none";
2058
+ this.querySelector(SEL_CONTAINER)?.remove();
2068
2059
  return true;
2069
2060
  }
2070
2061
  return false;
@@ -2086,6 +2077,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2086
2077
  #checkOffer() {
2087
2078
  if (!this.#offer) {
2088
2079
  this.style.display = "none";
2080
+ this.querySelector(SEL_CONTAINER)?.remove();
2089
2081
  return true;
2090
2082
  }
2091
2083
  return false;
@@ -2192,8 +2184,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2192
2184
  */
2193
2185
  #scheduleRecaptchaTokens() {
2194
2186
  const attempt = getPurchaseRecaptchaTokens();
2195
- attempt.catch((err) => {
2196
- console.error("[web-apple-pay] reCAPTCHA token pre-fetch failed; will retry on modal open", err);
2187
+ attempt.catch(() => {
2197
2188
  if (this.#recaptchaTokensPromise === attempt) {
2198
2189
  this.#recaptchaTokensPromise = null;
2199
2190
  }
@@ -2254,8 +2245,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2254
2245
  recaptchaTokens
2255
2246
  )
2256
2247
  );
2257
- } catch (error) {
2258
- console.error(ERROR_INITIATE, error);
2248
+ } catch {
2259
2249
  }
2260
2250
  }
2261
2251
  };
@@ -959,7 +959,6 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
959
959
  cta.removeAttribute("aria-busy");
960
960
  }
961
961
  }).catch(() => {
962
- console.error("[web-apple-pay] apple-pay-modal: failed to pre-fetch reCAPTCHA tokens; CTA remains disabled");
963
962
  if (cta) {
964
963
  cta.removeAttribute("aria-busy");
965
964
  }
@@ -1124,7 +1123,7 @@ var isAppleDeviceOrSafari = () => {
1124
1123
  const isSafariBrowser = navigator.userAgent.indexOf("Safari") > -1 && navigator.userAgent.indexOf("Chrome") === -1;
1125
1124
  return isIOSOrMacTouchDevice || isSafariBrowser;
1126
1125
  };
1127
- var bypassApplePayChecks = () => new URLSearchParams(window.location.search).get("BYPASS_APPLE_PAY_CHECKS") !== null && getApplePayConfig()?.debugBypassEnabled === true;
1126
+ var bypassApplePayChecks = () => new URLSearchParams(window.location.search).get("BYPASS_APPLE_PAY_CHECKS") !== null;
1128
1127
  var isApplePayAvailable = async () => {
1129
1128
  if (bypassApplePayChecks()) {
1130
1129
  return true;
@@ -1145,15 +1144,11 @@ var isApplePayAvailable = async () => {
1145
1144
  }
1146
1145
  const merchantId = getApplePayConfig()?.merchantId;
1147
1146
  if (!merchantId) {
1148
- console.warn(
1149
- "[web-apple-pay] Missing merchantId. Call configureApplePay({ merchantId, ... }) before rendering Apple Pay components."
1150
- );
1151
1147
  return false;
1152
1148
  }
1153
1149
  const hasActiveCard = await applePaySession.canMakePaymentsWithActiveCard(merchantId);
1154
1150
  return hasActiveCard;
1155
- } catch (error) {
1156
- console.error("Error checking Apple Pay active card status:", error);
1151
+ } catch {
1157
1152
  return false;
1158
1153
  }
1159
1154
  };
@@ -1400,8 +1395,7 @@ async function handleMerchantValidation(event, session, config) {
1400
1395
  return;
1401
1396
  }
1402
1397
  session.completeMerchantValidation(response.merchantSession);
1403
- } catch (err) {
1404
- console.error("[web-apple-pay] onvalidatemerchant: error during validation", err);
1398
+ } catch {
1405
1399
  session.abort();
1406
1400
  redirectToFallbackCheckout(config);
1407
1401
  }
@@ -1434,8 +1428,7 @@ function startApplePaySession(config) {
1434
1428
  };
1435
1429
  trackWalletPaymentSheetOpen(config.skuId);
1436
1430
  session.begin();
1437
- } catch (err) {
1438
- console.error("[web-apple-pay] startApplePaySession: failed to create session", err);
1431
+ } catch {
1439
1432
  redirectToFallbackCheckout(config);
1440
1433
  }
1441
1434
  }
@@ -1650,7 +1643,6 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
1650
1643
  failApplePaySession(session, err.errors);
1651
1644
  return;
1652
1645
  }
1653
- console.error("[web-apple-pay] onpaymentauthorized error", { skuId, err });
1654
1646
  const walletError = parseWalletApiError(err);
1655
1647
  trackWalletPaymentFailure(skuId, walletError?.errorType ?? "UNKNOWN");
1656
1648
  failApplePaySession(session);
@@ -1928,7 +1920,6 @@ var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
1928
1920
  var TOTAL_LABEL = "The Economist";
1929
1921
  var DEFAULT_CURRENCY = "USD";
1930
1922
  var DEFAULT_TOTAL = "0.00";
1931
- var ERROR_INITIATE = "Failed to initiate Apple Pay session:";
1932
1923
  var SEL_CONTAINER = ".apple-pay-container";
1933
1924
  var SEL_BUTTON = ".apple-pay-btn";
1934
1925
  var APPLE_PAY_EXCLUDED_VARIANTS = [
@@ -2052,16 +2043,15 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2052
2043
  // ─── Render pipeline ────────────────────────────────────────────────────────
2053
2044
  async #run() {
2054
2045
  try {
2046
+ this.#renderTemplate();
2055
2047
  if (await this.#checkAvailability()) return;
2056
2048
  if (this.#checkOffer()) return;
2057
- this.#renderTemplate();
2058
2049
  if (await this.#checkSession()) return;
2059
2050
  this.#captureReturnUrl();
2060
2051
  this.#computeBillingCountries();
2061
2052
  if (await this.#fetchAndCacheOptions()) return;
2062
2053
  this.#finishLoading();
2063
- } catch (err) {
2064
- console.error("[web-apple-pay] #run: unexpected error, hiding button", err);
2054
+ } catch {
2065
2055
  this.style.display = "none";
2066
2056
  this.querySelector(SEL_CONTAINER)?.remove();
2067
2057
  } finally {
@@ -2073,6 +2063,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2073
2063
  const available = await isApplePayAvailable();
2074
2064
  if (!available) {
2075
2065
  this.style.display = "none";
2066
+ this.querySelector(SEL_CONTAINER)?.remove();
2076
2067
  return true;
2077
2068
  }
2078
2069
  return false;
@@ -2094,6 +2085,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2094
2085
  #checkOffer() {
2095
2086
  if (!this.#offer) {
2096
2087
  this.style.display = "none";
2088
+ this.querySelector(SEL_CONTAINER)?.remove();
2097
2089
  return true;
2098
2090
  }
2099
2091
  return false;
@@ -2200,8 +2192,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2200
2192
  */
2201
2193
  #scheduleRecaptchaTokens() {
2202
2194
  const attempt = getPurchaseRecaptchaTokens();
2203
- attempt.catch((err) => {
2204
- console.error("[web-apple-pay] reCAPTCHA token pre-fetch failed; will retry on modal open", err);
2195
+ attempt.catch(() => {
2205
2196
  if (this.#recaptchaTokensPromise === attempt) {
2206
2197
  this.#recaptchaTokensPromise = null;
2207
2198
  }
@@ -2262,8 +2253,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2262
2253
  recaptchaTokens
2263
2254
  )
2264
2255
  );
2265
- } catch (error) {
2266
- console.error(ERROR_INITIATE, error);
2256
+ } catch {
2267
2257
  }
2268
2258
  }
2269
2259
  };
@@ -951,7 +951,6 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
951
951
  cta.removeAttribute("aria-busy");
952
952
  }
953
953
  }).catch(() => {
954
- console.error("[web-apple-pay] apple-pay-modal: failed to pre-fetch reCAPTCHA tokens; CTA remains disabled");
955
954
  if (cta) {
956
955
  cta.removeAttribute("aria-busy");
957
956
  }
@@ -951,7 +951,6 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
951
951
  cta.removeAttribute("aria-busy");
952
952
  }
953
953
  }).catch(() => {
954
- console.error("[web-apple-pay] apple-pay-modal: failed to pre-fetch reCAPTCHA tokens; CTA remains disabled");
955
954
  if (cta) {
956
955
  cta.removeAttribute("aria-busy");
957
956
  }
@@ -1116,7 +1115,7 @@ var isAppleDeviceOrSafari = () => {
1116
1115
  const isSafariBrowser = navigator.userAgent.indexOf("Safari") > -1 && navigator.userAgent.indexOf("Chrome") === -1;
1117
1116
  return isIOSOrMacTouchDevice || isSafariBrowser;
1118
1117
  };
1119
- var bypassApplePayChecks = () => new URLSearchParams(window.location.search).get("BYPASS_APPLE_PAY_CHECKS") !== null && getApplePayConfig()?.debugBypassEnabled === true;
1118
+ var bypassApplePayChecks = () => new URLSearchParams(window.location.search).get("BYPASS_APPLE_PAY_CHECKS") !== null;
1120
1119
  var isApplePayAvailable = async () => {
1121
1120
  if (bypassApplePayChecks()) {
1122
1121
  return true;
@@ -1137,15 +1136,11 @@ var isApplePayAvailable = async () => {
1137
1136
  }
1138
1137
  const merchantId = getApplePayConfig()?.merchantId;
1139
1138
  if (!merchantId) {
1140
- console.warn(
1141
- "[web-apple-pay] Missing merchantId. Call configureApplePay({ merchantId, ... }) before rendering Apple Pay components."
1142
- );
1143
1139
  return false;
1144
1140
  }
1145
1141
  const hasActiveCard = await applePaySession.canMakePaymentsWithActiveCard(merchantId);
1146
1142
  return hasActiveCard;
1147
- } catch (error) {
1148
- console.error("Error checking Apple Pay active card status:", error);
1143
+ } catch {
1149
1144
  return false;
1150
1145
  }
1151
1146
  };
@@ -1392,8 +1387,7 @@ async function handleMerchantValidation(event, session, config) {
1392
1387
  return;
1393
1388
  }
1394
1389
  session.completeMerchantValidation(response.merchantSession);
1395
- } catch (err) {
1396
- console.error("[web-apple-pay] onvalidatemerchant: error during validation", err);
1390
+ } catch {
1397
1391
  session.abort();
1398
1392
  redirectToFallbackCheckout(config);
1399
1393
  }
@@ -1426,8 +1420,7 @@ function startApplePaySession(config) {
1426
1420
  };
1427
1421
  trackWalletPaymentSheetOpen(config.skuId);
1428
1422
  session.begin();
1429
- } catch (err) {
1430
- console.error("[web-apple-pay] startApplePaySession: failed to create session", err);
1423
+ } catch {
1431
1424
  redirectToFallbackCheckout(config);
1432
1425
  }
1433
1426
  }
@@ -1642,7 +1635,6 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
1642
1635
  failApplePaySession(session, err.errors);
1643
1636
  return;
1644
1637
  }
1645
- console.error("[web-apple-pay] onpaymentauthorized error", { skuId, err });
1646
1638
  const walletError = parseWalletApiError(err);
1647
1639
  trackWalletPaymentFailure(skuId, walletError?.errorType ?? "UNKNOWN");
1648
1640
  failApplePaySession(session);
@@ -1920,7 +1912,6 @@ var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
1920
1912
  var TOTAL_LABEL = "The Economist";
1921
1913
  var DEFAULT_CURRENCY = "USD";
1922
1914
  var DEFAULT_TOTAL = "0.00";
1923
- var ERROR_INITIATE = "Failed to initiate Apple Pay session:";
1924
1915
  var SEL_CONTAINER = ".apple-pay-container";
1925
1916
  var SEL_BUTTON = ".apple-pay-btn";
1926
1917
  var APPLE_PAY_EXCLUDED_VARIANTS = [
@@ -2044,16 +2035,15 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2044
2035
  // ─── Render pipeline ────────────────────────────────────────────────────────
2045
2036
  async #run() {
2046
2037
  try {
2038
+ this.#renderTemplate();
2047
2039
  if (await this.#checkAvailability()) return;
2048
2040
  if (this.#checkOffer()) return;
2049
- this.#renderTemplate();
2050
2041
  if (await this.#checkSession()) return;
2051
2042
  this.#captureReturnUrl();
2052
2043
  this.#computeBillingCountries();
2053
2044
  if (await this.#fetchAndCacheOptions()) return;
2054
2045
  this.#finishLoading();
2055
- } catch (err) {
2056
- console.error("[web-apple-pay] #run: unexpected error, hiding button", err);
2046
+ } catch {
2057
2047
  this.style.display = "none";
2058
2048
  this.querySelector(SEL_CONTAINER)?.remove();
2059
2049
  } finally {
@@ -2065,6 +2055,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2065
2055
  const available = await isApplePayAvailable();
2066
2056
  if (!available) {
2067
2057
  this.style.display = "none";
2058
+ this.querySelector(SEL_CONTAINER)?.remove();
2068
2059
  return true;
2069
2060
  }
2070
2061
  return false;
@@ -2086,6 +2077,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2086
2077
  #checkOffer() {
2087
2078
  if (!this.#offer) {
2088
2079
  this.style.display = "none";
2080
+ this.querySelector(SEL_CONTAINER)?.remove();
2089
2081
  return true;
2090
2082
  }
2091
2083
  return false;
@@ -2192,8 +2184,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2192
2184
  */
2193
2185
  #scheduleRecaptchaTokens() {
2194
2186
  const attempt = getPurchaseRecaptchaTokens();
2195
- attempt.catch((err) => {
2196
- console.error("[web-apple-pay] reCAPTCHA token pre-fetch failed; will retry on modal open", err);
2187
+ attempt.catch(() => {
2197
2188
  if (this.#recaptchaTokensPromise === attempt) {
2198
2189
  this.#recaptchaTokensPromise = null;
2199
2190
  }
@@ -2254,8 +2245,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2254
2245
  recaptchaTokens
2255
2246
  )
2256
2247
  );
2257
- } catch (error) {
2258
- console.error(ERROR_INITIATE, error);
2248
+ } catch {
2259
2249
  }
2260
2250
  }
2261
2251
  };
@@ -211,8 +211,7 @@ async function handleMerchantValidation(event, session, config) {
211
211
  return;
212
212
  }
213
213
  session.completeMerchantValidation(response.merchantSession);
214
- } catch (err) {
215
- console.error("[web-apple-pay] onvalidatemerchant: error during validation", err);
214
+ } catch {
216
215
  session.abort();
217
216
  redirectToFallbackCheckout(config);
218
217
  }
@@ -245,8 +244,7 @@ function startApplePaySession(config) {
245
244
  };
246
245
  trackWalletPaymentSheetOpen(config.skuId);
247
246
  session.begin();
248
- } catch (err) {
249
- console.error("[web-apple-pay] startApplePaySession: failed to create session", err);
247
+ } catch {
250
248
  redirectToFallbackCheckout(config);
251
249
  }
252
250
  }
@@ -8,7 +8,7 @@ var isAppleDeviceOrSafari = () => {
8
8
  const isSafariBrowser = navigator.userAgent.indexOf("Safari") > -1 && navigator.userAgent.indexOf("Chrome") === -1;
9
9
  return isIOSOrMacTouchDevice || isSafariBrowser;
10
10
  };
11
- var bypassApplePayChecks = () => new URLSearchParams(window.location.search).get("BYPASS_APPLE_PAY_CHECKS") !== null && getApplePayConfig()?.debugBypassEnabled === true;
11
+ var bypassApplePayChecks = () => new URLSearchParams(window.location.search).get("BYPASS_APPLE_PAY_CHECKS") !== null;
12
12
  var isApplePayAvailable = async () => {
13
13
  if (bypassApplePayChecks()) {
14
14
  return true;
@@ -29,15 +29,11 @@ var isApplePayAvailable = async () => {
29
29
  }
30
30
  const merchantId = getApplePayConfig()?.merchantId;
31
31
  if (!merchantId) {
32
- console.warn(
33
- "[web-apple-pay] Missing merchantId. Call configureApplePay({ merchantId, ... }) before rendering Apple Pay components."
34
- );
35
32
  return false;
36
33
  }
37
34
  const hasActiveCard = await applePaySession.canMakePaymentsWithActiveCard(merchantId);
38
35
  return hasActiveCard;
39
- } catch (error) {
40
- console.error("Error checking Apple Pay active card status:", error);
36
+ } catch {
41
37
  return false;
42
38
  }
43
39
  };
@@ -378,7 +378,6 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
378
378
  failApplePaySession(session, err.errors);
379
379
  return;
380
380
  }
381
- console.error("[web-apple-pay] onpaymentauthorized error", { skuId, err });
382
381
  const walletError = parseWalletApiError(err);
383
382
  trackWalletPaymentFailure(skuId, walletError?.errorType ?? "UNKNOWN");
384
383
  failApplePaySession(session);
@@ -1,4 +1,5 @@
1
1
  export declare enum ApplePayEntryPoint {
2
2
  PAYWALL = "article_paywall",
3
- REGWALL = "article_regwall"
3
+ REGWALL = "article_regwall",
4
+ DUAL_OFFER_BANNER = "dual_offer_banner"
4
5
  }
@@ -2,6 +2,7 @@
2
2
  var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
3
3
  ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
4
4
  ApplePayEntryPoint2["REGWALL"] = "article_regwall";
5
+ ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
5
6
  return ApplePayEntryPoint2;
6
7
  })(ApplePayEntryPoint || {});
7
8
  export {
package/dist/src/index.js CHANGED
@@ -956,7 +956,6 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
956
956
  cta.removeAttribute("aria-busy");
957
957
  }
958
958
  }).catch(() => {
959
- console.error("[web-apple-pay] apple-pay-modal: failed to pre-fetch reCAPTCHA tokens; CTA remains disabled");
960
959
  if (cta) {
961
960
  cta.removeAttribute("aria-busy");
962
961
  }
@@ -1121,7 +1120,7 @@ var isAppleDeviceOrSafari = () => {
1121
1120
  const isSafariBrowser = navigator.userAgent.indexOf("Safari") > -1 && navigator.userAgent.indexOf("Chrome") === -1;
1122
1121
  return isIOSOrMacTouchDevice || isSafariBrowser;
1123
1122
  };
1124
- var bypassApplePayChecks = () => new URLSearchParams(window.location.search).get("BYPASS_APPLE_PAY_CHECKS") !== null && getApplePayConfig()?.debugBypassEnabled === true;
1123
+ var bypassApplePayChecks = () => new URLSearchParams(window.location.search).get("BYPASS_APPLE_PAY_CHECKS") !== null;
1125
1124
  var isApplePayAvailable = async () => {
1126
1125
  if (bypassApplePayChecks()) {
1127
1126
  return true;
@@ -1142,15 +1141,11 @@ var isApplePayAvailable = async () => {
1142
1141
  }
1143
1142
  const merchantId = getApplePayConfig()?.merchantId;
1144
1143
  if (!merchantId) {
1145
- console.warn(
1146
- "[web-apple-pay] Missing merchantId. Call configureApplePay({ merchantId, ... }) before rendering Apple Pay components."
1147
- );
1148
1144
  return false;
1149
1145
  }
1150
1146
  const hasActiveCard = await applePaySession.canMakePaymentsWithActiveCard(merchantId);
1151
1147
  return hasActiveCard;
1152
- } catch (error) {
1153
- console.error("Error checking Apple Pay active card status:", error);
1148
+ } catch {
1154
1149
  return false;
1155
1150
  }
1156
1151
  };
@@ -1397,8 +1392,7 @@ async function handleMerchantValidation(event, session, config) {
1397
1392
  return;
1398
1393
  }
1399
1394
  session.completeMerchantValidation(response.merchantSession);
1400
- } catch (err) {
1401
- console.error("[web-apple-pay] onvalidatemerchant: error during validation", err);
1395
+ } catch {
1402
1396
  session.abort();
1403
1397
  redirectToFallbackCheckout(config);
1404
1398
  }
@@ -1431,8 +1425,7 @@ function startApplePaySession(config) {
1431
1425
  };
1432
1426
  trackWalletPaymentSheetOpen(config.skuId);
1433
1427
  session.begin();
1434
- } catch (err) {
1435
- console.error("[web-apple-pay] startApplePaySession: failed to create session", err);
1428
+ } catch {
1436
1429
  redirectToFallbackCheckout(config);
1437
1430
  }
1438
1431
  }
@@ -1647,7 +1640,6 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
1647
1640
  failApplePaySession(session, err.errors);
1648
1641
  return;
1649
1642
  }
1650
- console.error("[web-apple-pay] onpaymentauthorized error", { skuId, err });
1651
1643
  const walletError = parseWalletApiError(err);
1652
1644
  trackWalletPaymentFailure(skuId, walletError?.errorType ?? "UNKNOWN");
1653
1645
  failApplePaySession(session);
@@ -1925,7 +1917,6 @@ var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
1925
1917
  var TOTAL_LABEL = "The Economist";
1926
1918
  var DEFAULT_CURRENCY = "USD";
1927
1919
  var DEFAULT_TOTAL = "0.00";
1928
- var ERROR_INITIATE = "Failed to initiate Apple Pay session:";
1929
1920
  var SEL_CONTAINER = ".apple-pay-container";
1930
1921
  var SEL_BUTTON = ".apple-pay-btn";
1931
1922
  var APPLE_PAY_EXCLUDED_VARIANTS = [
@@ -2049,16 +2040,15 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2049
2040
  // ─── Render pipeline ────────────────────────────────────────────────────────
2050
2041
  async #run() {
2051
2042
  try {
2043
+ this.#renderTemplate();
2052
2044
  if (await this.#checkAvailability()) return;
2053
2045
  if (this.#checkOffer()) return;
2054
- this.#renderTemplate();
2055
2046
  if (await this.#checkSession()) return;
2056
2047
  this.#captureReturnUrl();
2057
2048
  this.#computeBillingCountries();
2058
2049
  if (await this.#fetchAndCacheOptions()) return;
2059
2050
  this.#finishLoading();
2060
- } catch (err) {
2061
- console.error("[web-apple-pay] #run: unexpected error, hiding button", err);
2051
+ } catch {
2062
2052
  this.style.display = "none";
2063
2053
  this.querySelector(SEL_CONTAINER)?.remove();
2064
2054
  } finally {
@@ -2070,6 +2060,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2070
2060
  const available = await isApplePayAvailable();
2071
2061
  if (!available) {
2072
2062
  this.style.display = "none";
2063
+ this.querySelector(SEL_CONTAINER)?.remove();
2073
2064
  return true;
2074
2065
  }
2075
2066
  return false;
@@ -2091,6 +2082,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2091
2082
  #checkOffer() {
2092
2083
  if (!this.#offer) {
2093
2084
  this.style.display = "none";
2085
+ this.querySelector(SEL_CONTAINER)?.remove();
2094
2086
  return true;
2095
2087
  }
2096
2088
  return false;
@@ -2197,8 +2189,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2197
2189
  */
2198
2190
  #scheduleRecaptchaTokens() {
2199
2191
  const attempt = getPurchaseRecaptchaTokens();
2200
- attempt.catch((err) => {
2201
- console.error("[web-apple-pay] reCAPTCHA token pre-fetch failed; will retry on modal open", err);
2192
+ attempt.catch(() => {
2202
2193
  if (this.#recaptchaTokensPromise === attempt) {
2203
2194
  this.#recaptchaTokensPromise = null;
2204
2195
  }
@@ -2259,8 +2250,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2259
2250
  recaptchaTokens
2260
2251
  )
2261
2252
  );
2262
- } catch (error) {
2263
- console.error(ERROR_INITIATE, error);
2253
+ } catch {
2264
2254
  }
2265
2255
  }
2266
2256
  };
@@ -2269,6 +2259,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2269
2259
  var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
2270
2260
  ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
2271
2261
  ApplePayEntryPoint2["REGWALL"] = "article_regwall";
2262
+ ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
2272
2263
  return ApplePayEntryPoint2;
2273
2264
  })(ApplePayEntryPoint || {});
2274
2265
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@economist/web-apple-pay",
3
3
  "description": "Web component package for Apple Pay checkout UI",
4
- "version": "1.7.7",
4
+ "version": "1.7.9",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",