@economist/web-apple-pay 2.0.0-beta.3 → 2.0.0-beta.4

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.
@@ -1015,12 +1015,10 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
1015
1015
  // src/templates/apple-pay-button.template.html
1016
1016
  var apple_pay_button_template_default = `<style>
1017
1017
  /*
1018
- * Entry CTA: caption + Apple Pay wordmark, built from text (no SVG), as in Figma (Play Global Spec 3268:39728):
1019
- * black #0d0d0d, 4px radius, 40px high, 8px 16px padding, 4px gap.
1020
- * Marber tokens (as bound in Figma): caption size label-2-size (15px), line height label-3-leading (24px);
1021
- * glyph + "Pay" 17px (label-3-size) with auto line height; padding spacing-xs / spacing-md; gap + radius spacing-2xs;
1022
- * background london-5. Expected content widths in Figma: caption 98px, wordmark 42px, button content 176px.
1023
- * Caption: SF Pro Regular. Wordmark: the Apple glyph (U+F8FF, Regular) + "Pay" (Medium 510).
1018
+ * Entry CTA: caption + Apple Pay wordmark, built from text (no SVG). Figma: Play pilot 7781:7325 (text style) and
1019
+ * Play Global Spec 3268:39728 (layout): black #0d0d0d, 4px radius, 40px high, 8px 16px padding, 4px gap.
1020
+ * Text: SF Pro Medium 510, line height normal; caption size label-2-size (15px), glyph + "Pay" 17px (label-3-size).
1021
+ * Padding spacing-xs / spacing-md; gap + radius spacing-2xs; background london-5.
1024
1022
  * SF Pro is the system font on Apple devices, which are the only devices Apple Pay is shown on.
1025
1023
  */
1026
1024
  teg-apple-pay-button {
@@ -1054,15 +1052,14 @@ var apple_pay_button_template_default = `<style>
1054
1052
  border: none;
1055
1053
  border-radius: var(--apple-pay-border-radius, var(--mb-spacing-2xs, 0.25rem));
1056
1054
  cursor: pointer;
1057
- /* Figma: SF Pro (system font on Apple devices), Regular 15 / 24 */
1055
+ /* Figma Play pilot 7781:7325: SF Pro (system font on Apple devices), Medium 510, 15px, line height normal */
1058
1056
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro', system-ui, sans-serif;
1059
1057
  font-size: var(--mb-typestyle-label-2-size, 0.9375rem);
1060
- font-weight: 400;
1058
+ font-weight: 510;
1061
1059
  font-variation-settings: 'wdth' 100;
1062
1060
  /* Figma letter spacing 0 */
1063
1061
  letter-spacing: 0;
1064
- /* Figma caption: line height is the label-3-leading token (24px) */
1065
- line-height: var(--mb-typestyle-label-3-leading, 1.5rem);
1062
+ line-height: normal;
1066
1063
  }
1067
1064
 
1068
1065
  teg-apple-pay-button .apple-pay-btn__label {
@@ -1076,8 +1073,7 @@ var apple_pay_button_template_default = `<style>
1076
1073
  teg-apple-pay-button .apple-pay-btn__logo {
1077
1074
  display: inline-flex;
1078
1075
  align-items: baseline;
1079
- /* Figma "Pay" layer: 17px (label-3 size) with AUTO line height (a 20px box centred in the 24px caption row),
1080
- not the 24px leading token the caption uses. */
1076
+ /* Figma "Pay" layer: 17px (label-3 size), line height normal. */
1081
1077
  font-size: var(--mb-typestyle-label-3-size, 1.0625rem);
1082
1078
  line-height: normal;
1083
1079
  }
@@ -1124,15 +1120,15 @@ var apple_pay_button_template_default = `<style>
1124
1120
 
1125
1121
  </style>
1126
1122
 
1127
- <div class="apple-pay-container" aria-label="Subscribe with Apple Pay">
1123
+ <div class="apple-pay-container" aria-label="Continue with Apple Pay">
1128
1124
  <button
1129
1125
  class="apple-pay-btn"
1130
1126
  type="button"
1131
- aria-label="Subscribe with Apple Pay"
1127
+ aria-label="Continue with Apple Pay"
1132
1128
  data-analytics="paywall:apple-pay-checkout"
1133
1129
  >
1134
1130
  <span class="apple-pay-btn__label"
1135
- ><span class="apple-pay-btn__caption">Subscribe with</span
1131
+ ><span class="apple-pay-btn__caption">Continue with</span
1136
1132
  ><span class="apple-pay-btn__logo" aria-hidden="true"
1137
1133
  ><span class="apple-pay-btn__logo-glyph">&#63743;</span
1138
1134
  ><span class="apple-pay-btn__logo-word">Pay</span
@@ -1376,32 +1372,44 @@ var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
1376
1372
  device: getDevice()
1377
1373
  });
1378
1374
  };
1375
+ var withEntryPoint = ({ entryPoint } = {}) => entryPoint ? { entry_point: entryPoint } : {};
1379
1376
  var trackExpressWalletClick = (skuId, { entryPoint } = {}) => {
1380
1377
  track(EXPRESS_CHECKOUT_EVENTS.BUTTON_CLICK, {
1381
1378
  sku_id: skuId,
1382
1379
  ...entryPoint ? { entry_point: entryPoint } : {}
1383
1380
  });
1384
1381
  };
1385
- var trackWalletPaymentSheetOpen = (skuId) => {
1386
- track(EXPRESS_CHECKOUT_EVENTS.SHEET_OPEN, { sku_id: skuId });
1382
+ var trackWalletPaymentSheetOpen = (skuId, metadata) => {
1383
+ track(EXPRESS_CHECKOUT_EVENTS.SHEET_OPEN, {
1384
+ sku_id: skuId,
1385
+ ...withEntryPoint(metadata)
1386
+ });
1387
1387
  };
1388
- var trackWalletPaymentAuthorised = (skuId) => {
1389
- track(EXPRESS_CHECKOUT_EVENTS.AUTHORISED, { sku_id: skuId });
1388
+ var trackWalletPaymentAuthorised = (skuId, metadata) => {
1389
+ track(EXPRESS_CHECKOUT_EVENTS.AUTHORISED, {
1390
+ sku_id: skuId,
1391
+ ...withEntryPoint(metadata)
1392
+ });
1390
1393
  };
1391
- var trackWalletPaymentSuccess = (skuId, basketId) => {
1394
+ var trackWalletPaymentSuccess = (skuId, basketId, metadata) => {
1392
1395
  track(EXPRESS_CHECKOUT_EVENTS.SUCCESS, {
1393
1396
  sku_id: skuId,
1394
- basket_id: basketId
1397
+ basket_id: basketId,
1398
+ ...withEntryPoint(metadata)
1395
1399
  });
1396
1400
  };
1397
- var trackWalletPaymentFailure = (skuId, reason) => {
1401
+ var trackWalletPaymentFailure = (skuId, reason, metadata) => {
1398
1402
  track(EXPRESS_CHECKOUT_EVENTS.FAILURE, {
1399
1403
  sku_id: skuId,
1400
- failure_reason: reason
1404
+ failure_reason: reason,
1405
+ ...withEntryPoint(metadata)
1401
1406
  });
1402
1407
  };
1403
- var trackFallbackCheckout = (skuId) => {
1404
- track(EXPRESS_CHECKOUT_EVENTS.FALLBACK_CHECKOUT, { sku_id: skuId });
1408
+ var trackFallbackCheckout = (skuId, metadata) => {
1409
+ track(EXPRESS_CHECKOUT_EVENTS.FALLBACK_CHECKOUT, {
1410
+ sku_id: skuId,
1411
+ ...withEntryPoint(metadata)
1412
+ });
1405
1413
  };
1406
1414
  var trackValidationFieldError = (field, errorType) => {
1407
1415
  track(`validation_${field}_${errorType}`, {});
@@ -1470,6 +1478,10 @@ function startApplePaySession(config) {
1470
1478
  requiredBillingContactFields: ["postalAddress", "name"],
1471
1479
  ...shippingFields.length > 0 && {
1472
1480
  requiredShippingContactFields: shippingFields
1481
+ },
1482
+ // Restrict the shipping country picker for print; onshippingcontactselected still validates as a backstop.
1483
+ ...config.delivery && config.delivery.supportedCountries.length > 0 && {
1484
+ supportedCountries: config.delivery.supportedCountries
1473
1485
  }
1474
1486
  };
1475
1487
  try {
@@ -1875,8 +1887,11 @@ var price_zones_default = {
1875
1887
  "UK-UK": ["GB"]
1876
1888
  };
1877
1889
 
1878
- // src/utils/address-rules.ts
1890
+ // src/utils/price-zones.ts
1879
1891
  var priceZones = price_zones_default;
1892
+ var getZoneByCountry = (country) => Object.keys(priceZones).find((key) => priceZones[key].includes(country)) ?? null;
1893
+
1894
+ // src/utils/address-rules.ts
1880
1895
  var ADDRESS_LIMITS = {
1881
1896
  address1: 35,
1882
1897
  address2: 35,
@@ -1885,10 +1900,9 @@ var ADDRESS_LIMITS = {
1885
1900
  postalCode: 20,
1886
1901
  phone: 35
1887
1902
  };
1888
- var zoneOf = (country) => Object.keys(priceZones).find((zone) => priceZones[zone].includes(country));
1889
1903
  var COUNTRIES_REQUIRING_PHONE = ["IN", "CN"];
1890
1904
  var requiredDeliveryFields = (offerCountry, country) => {
1891
- const zone = zoneOf(offerCountry);
1905
+ const zone = getZoneByCountry(offerCountry);
1892
1906
  const fields = ["address1", "city"];
1893
1907
  if (zone === "AS-AU" || zone === "AS-JP" || zone === "NA-CA" || country === "US") {
1894
1908
  fields.push("state");
@@ -1901,7 +1915,7 @@ var requiredDeliveryFields = (offerCountry, country) => {
1901
1915
  };
1902
1916
  var postalCodeFormatError = (offerCountry, postalCode) => {
1903
1917
  if (!postalCode) return null;
1904
- const zone = zoneOf(offerCountry);
1918
+ const zone = getZoneByCountry(offerCountry);
1905
1919
  if (zone === "NA-US" && !/(^\d{5}$)|(^\d{5}-\d{4}$)/.test(postalCode)) {
1906
1920
  return "Zip code must be a valid US zip code";
1907
1921
  }
@@ -2084,8 +2098,11 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
2084
2098
  const result = await performPurchase({
2085
2099
  applePayToken: event.payment.token,
2086
2100
  skuId: config.skuId,
2101
+ // Offer/geo country — must not fall back to billing country on the BFF (print billing is unrestricted).
2102
+ countryCode: config.country,
2087
2103
  currency: config.currency,
2088
2104
  billingContact: event.payment.billingContact,
2105
+ supportedBillingCountries: config.supportedBillingCountries,
2089
2106
  ...event.payment.shippingContact && {
2090
2107
  shippingContact: event.payment.shippingContact
2091
2108
  },
@@ -2159,20 +2176,25 @@ var eea_countries_default = [
2159
2176
  "SE"
2160
2177
  ];
2161
2178
 
2179
+ // src/utils/print-variants.ts
2180
+ var PRINT_VARIANTS = [
2181
+ "bundle",
2182
+ "insider_print"
2183
+ ];
2184
+ var isPrintVariant = (variant) => PRINT_VARIANTS.includes(variant ?? "");
2185
+
2162
2186
  // src/utils/billing-countries.ts
2163
- var priceZones2 = price_zones_default;
2164
2187
  var eeaCountries = eea_countries_default;
2165
- var ALL_COUNTRY_CODES = Object.values(priceZones2).flat();
2166
- var getZoneByCountry = (country) => Object.keys(priceZones2).find((key) => priceZones2[key].includes(country)) ?? null;
2188
+ var ALL_COUNTRY_CODES = Object.values(priceZones).flat();
2167
2189
  var getSupportedBillingCountries = (offerCountry, offerVariant) => {
2168
- if (offerVariant === "bundle" || offerVariant === "insider_print") {
2190
+ if (isPrintVariant(offerVariant)) {
2169
2191
  return [...ALL_COUNTRY_CODES];
2170
2192
  }
2171
2193
  const zone = getZoneByCountry(offerCountry);
2172
2194
  if (!zone) {
2173
2195
  return [...ALL_COUNTRY_CODES];
2174
2196
  }
2175
- const zoneCountries = priceZones2[zone];
2197
+ const zoneCountries = priceZones[zone];
2176
2198
  if (eeaCountries.includes(offerCountry)) {
2177
2199
  return Array.from(/* @__PURE__ */ new Set([...zoneCountries, ...eeaCountries]));
2178
2200
  }
@@ -2215,14 +2237,14 @@ var no_delivery_countries_default = [
2215
2237
  ];
2216
2238
 
2217
2239
  // src/utils/delivery-countries.ts
2218
- var priceZones3 = price_zones_default;
2240
+ var priceZones2 = price_zones_default;
2219
2241
  var noDeliveryCountries = no_delivery_countries_default;
2220
2242
  var getSupportedDeliveryCountries = (offerCountry) => {
2221
- const zone = Object.keys(priceZones3).find(
2222
- (key) => priceZones3[key].includes(offerCountry)
2243
+ const zone = Object.keys(priceZones2).find(
2244
+ (key) => priceZones2[key].includes(offerCountry)
2223
2245
  );
2224
2246
  if (!zone) return [];
2225
- return priceZones3[zone].filter(
2247
+ return priceZones2[zone].filter(
2226
2248
  (country) => !noDeliveryCountries.includes(country)
2227
2249
  );
2228
2250
  };
@@ -2242,7 +2264,7 @@ var getButtonCopy = (enabled = CONTINUE_WITH_COPY_ENABLED) => enabled ? BUTTON_C
2242
2264
  var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
2243
2265
 
2244
2266
  // src/apple-pay-button.ts
2245
- var PRINT_VARIANTS = ["bundle", "insider_print"];
2267
+ var PRINT_VARIANTS2 = ["bundle", "insider_print"];
2246
2268
  var NO_EXCLUSIONS = [];
2247
2269
  var ENTRY_POINT_CONFIG = {
2248
2270
  ["dual_offer_banner" /* DUAL_OFFER_BANNER */]: {
@@ -2294,7 +2316,7 @@ var SEL_CONTAINER = ".apple-pay-container";
2294
2316
  var SEL_BUTTON = ".apple-pay-btn";
2295
2317
  var getExcludedVariants = (entryPoint) => {
2296
2318
  const config = ENTRY_POINT_CONFIG[entryPoint || DEFAULT_ENTRY_POINT] ?? ENTRY_POINT_CONFIG[DEFAULT_ENTRY_POINT];
2297
- return PRINT_OFFERS_ENABLED && config.allowsPrintOffers ? NO_EXCLUSIONS : PRINT_VARIANTS;
2319
+ return PRINT_OFFERS_ENABLED && config.allowsPrintOffers ? NO_EXCLUSIONS : PRINT_VARIANTS2;
2298
2320
  };
2299
2321
  var ApplePayButton = class _ApplePayButton extends HTMLElement {
2300
2322
  static tag = "teg-apple-pay-button";
@@ -2541,7 +2563,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2541
2563
  */
2542
2564
  #computeDeliveryCountries() {
2543
2565
  const variant = this.#offer.product?.variant;
2544
- if (!PRINT_VARIANTS.includes(variant)) {
2566
+ if (!PRINT_VARIANTS2.includes(variant)) {
2545
2567
  this.#supportedDeliveryCountries = null;
2546
2568
  return false;
2547
2569
  }
@@ -1007,12 +1007,10 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
1007
1007
  // src/templates/apple-pay-button.template.html
1008
1008
  var apple_pay_button_template_default = `<style>
1009
1009
  /*
1010
- * Entry CTA: caption + Apple Pay wordmark, built from text (no SVG), as in Figma (Play Global Spec 3268:39728):
1011
- * black #0d0d0d, 4px radius, 40px high, 8px 16px padding, 4px gap.
1012
- * Marber tokens (as bound in Figma): caption size label-2-size (15px), line height label-3-leading (24px);
1013
- * glyph + "Pay" 17px (label-3-size) with auto line height; padding spacing-xs / spacing-md; gap + radius spacing-2xs;
1014
- * background london-5. Expected content widths in Figma: caption 98px, wordmark 42px, button content 176px.
1015
- * Caption: SF Pro Regular. Wordmark: the Apple glyph (U+F8FF, Regular) + "Pay" (Medium 510).
1010
+ * Entry CTA: caption + Apple Pay wordmark, built from text (no SVG). Figma: Play pilot 7781:7325 (text style) and
1011
+ * Play Global Spec 3268:39728 (layout): black #0d0d0d, 4px radius, 40px high, 8px 16px padding, 4px gap.
1012
+ * Text: SF Pro Medium 510, line height normal; caption size label-2-size (15px), glyph + "Pay" 17px (label-3-size).
1013
+ * Padding spacing-xs / spacing-md; gap + radius spacing-2xs; background london-5.
1016
1014
  * SF Pro is the system font on Apple devices, which are the only devices Apple Pay is shown on.
1017
1015
  */
1018
1016
  teg-apple-pay-button {
@@ -1046,15 +1044,14 @@ var apple_pay_button_template_default = `<style>
1046
1044
  border: none;
1047
1045
  border-radius: var(--apple-pay-border-radius, var(--mb-spacing-2xs, 0.25rem));
1048
1046
  cursor: pointer;
1049
- /* Figma: SF Pro (system font on Apple devices), Regular 15 / 24 */
1047
+ /* Figma Play pilot 7781:7325: SF Pro (system font on Apple devices), Medium 510, 15px, line height normal */
1050
1048
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro', system-ui, sans-serif;
1051
1049
  font-size: var(--mb-typestyle-label-2-size, 0.9375rem);
1052
- font-weight: 400;
1050
+ font-weight: 510;
1053
1051
  font-variation-settings: 'wdth' 100;
1054
1052
  /* Figma letter spacing 0 */
1055
1053
  letter-spacing: 0;
1056
- /* Figma caption: line height is the label-3-leading token (24px) */
1057
- line-height: var(--mb-typestyle-label-3-leading, 1.5rem);
1054
+ line-height: normal;
1058
1055
  }
1059
1056
 
1060
1057
  teg-apple-pay-button .apple-pay-btn__label {
@@ -1068,8 +1065,7 @@ var apple_pay_button_template_default = `<style>
1068
1065
  teg-apple-pay-button .apple-pay-btn__logo {
1069
1066
  display: inline-flex;
1070
1067
  align-items: baseline;
1071
- /* Figma "Pay" layer: 17px (label-3 size) with AUTO line height (a 20px box centred in the 24px caption row),
1072
- not the 24px leading token the caption uses. */
1068
+ /* Figma "Pay" layer: 17px (label-3 size), line height normal. */
1073
1069
  font-size: var(--mb-typestyle-label-3-size, 1.0625rem);
1074
1070
  line-height: normal;
1075
1071
  }
@@ -1116,15 +1112,15 @@ var apple_pay_button_template_default = `<style>
1116
1112
 
1117
1113
  </style>
1118
1114
 
1119
- <div class="apple-pay-container" aria-label="Subscribe with Apple Pay">
1115
+ <div class="apple-pay-container" aria-label="Continue with Apple Pay">
1120
1116
  <button
1121
1117
  class="apple-pay-btn"
1122
1118
  type="button"
1123
- aria-label="Subscribe with Apple Pay"
1119
+ aria-label="Continue with Apple Pay"
1124
1120
  data-analytics="paywall:apple-pay-checkout"
1125
1121
  >
1126
1122
  <span class="apple-pay-btn__label"
1127
- ><span class="apple-pay-btn__caption">Subscribe with</span
1123
+ ><span class="apple-pay-btn__caption">Continue with</span
1128
1124
  ><span class="apple-pay-btn__logo" aria-hidden="true"
1129
1125
  ><span class="apple-pay-btn__logo-glyph">&#63743;</span
1130
1126
  ><span class="apple-pay-btn__logo-word">Pay</span
@@ -1368,32 +1364,44 @@ var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
1368
1364
  device: getDevice()
1369
1365
  });
1370
1366
  };
1367
+ var withEntryPoint = ({ entryPoint } = {}) => entryPoint ? { entry_point: entryPoint } : {};
1371
1368
  var trackExpressWalletClick = (skuId, { entryPoint } = {}) => {
1372
1369
  track(EXPRESS_CHECKOUT_EVENTS.BUTTON_CLICK, {
1373
1370
  sku_id: skuId,
1374
1371
  ...entryPoint ? { entry_point: entryPoint } : {}
1375
1372
  });
1376
1373
  };
1377
- var trackWalletPaymentSheetOpen = (skuId) => {
1378
- track(EXPRESS_CHECKOUT_EVENTS.SHEET_OPEN, { sku_id: skuId });
1374
+ var trackWalletPaymentSheetOpen = (skuId, metadata) => {
1375
+ track(EXPRESS_CHECKOUT_EVENTS.SHEET_OPEN, {
1376
+ sku_id: skuId,
1377
+ ...withEntryPoint(metadata)
1378
+ });
1379
1379
  };
1380
- var trackWalletPaymentAuthorised = (skuId) => {
1381
- track(EXPRESS_CHECKOUT_EVENTS.AUTHORISED, { sku_id: skuId });
1380
+ var trackWalletPaymentAuthorised = (skuId, metadata) => {
1381
+ track(EXPRESS_CHECKOUT_EVENTS.AUTHORISED, {
1382
+ sku_id: skuId,
1383
+ ...withEntryPoint(metadata)
1384
+ });
1382
1385
  };
1383
- var trackWalletPaymentSuccess = (skuId, basketId) => {
1386
+ var trackWalletPaymentSuccess = (skuId, basketId, metadata) => {
1384
1387
  track(EXPRESS_CHECKOUT_EVENTS.SUCCESS, {
1385
1388
  sku_id: skuId,
1386
- basket_id: basketId
1389
+ basket_id: basketId,
1390
+ ...withEntryPoint(metadata)
1387
1391
  });
1388
1392
  };
1389
- var trackWalletPaymentFailure = (skuId, reason) => {
1393
+ var trackWalletPaymentFailure = (skuId, reason, metadata) => {
1390
1394
  track(EXPRESS_CHECKOUT_EVENTS.FAILURE, {
1391
1395
  sku_id: skuId,
1392
- failure_reason: reason
1396
+ failure_reason: reason,
1397
+ ...withEntryPoint(metadata)
1393
1398
  });
1394
1399
  };
1395
- var trackFallbackCheckout = (skuId) => {
1396
- track(EXPRESS_CHECKOUT_EVENTS.FALLBACK_CHECKOUT, { sku_id: skuId });
1400
+ var trackFallbackCheckout = (skuId, metadata) => {
1401
+ track(EXPRESS_CHECKOUT_EVENTS.FALLBACK_CHECKOUT, {
1402
+ sku_id: skuId,
1403
+ ...withEntryPoint(metadata)
1404
+ });
1397
1405
  };
1398
1406
  var trackValidationFieldError = (field, errorType) => {
1399
1407
  track(`validation_${field}_${errorType}`, {});
@@ -1462,6 +1470,10 @@ function startApplePaySession(config) {
1462
1470
  requiredBillingContactFields: ["postalAddress", "name"],
1463
1471
  ...shippingFields.length > 0 && {
1464
1472
  requiredShippingContactFields: shippingFields
1473
+ },
1474
+ // Restrict the shipping country picker for print; onshippingcontactselected still validates as a backstop.
1475
+ ...config.delivery && config.delivery.supportedCountries.length > 0 && {
1476
+ supportedCountries: config.delivery.supportedCountries
1465
1477
  }
1466
1478
  };
1467
1479
  try {
@@ -1867,8 +1879,11 @@ var price_zones_default = {
1867
1879
  "UK-UK": ["GB"]
1868
1880
  };
1869
1881
 
1870
- // src/utils/address-rules.ts
1882
+ // src/utils/price-zones.ts
1871
1883
  var priceZones = price_zones_default;
1884
+ var getZoneByCountry = (country) => Object.keys(priceZones).find((key) => priceZones[key].includes(country)) ?? null;
1885
+
1886
+ // src/utils/address-rules.ts
1872
1887
  var ADDRESS_LIMITS = {
1873
1888
  address1: 35,
1874
1889
  address2: 35,
@@ -1877,10 +1892,9 @@ var ADDRESS_LIMITS = {
1877
1892
  postalCode: 20,
1878
1893
  phone: 35
1879
1894
  };
1880
- var zoneOf = (country) => Object.keys(priceZones).find((zone) => priceZones[zone].includes(country));
1881
1895
  var COUNTRIES_REQUIRING_PHONE = ["IN", "CN"];
1882
1896
  var requiredDeliveryFields = (offerCountry, country) => {
1883
- const zone = zoneOf(offerCountry);
1897
+ const zone = getZoneByCountry(offerCountry);
1884
1898
  const fields = ["address1", "city"];
1885
1899
  if (zone === "AS-AU" || zone === "AS-JP" || zone === "NA-CA" || country === "US") {
1886
1900
  fields.push("state");
@@ -1893,7 +1907,7 @@ var requiredDeliveryFields = (offerCountry, country) => {
1893
1907
  };
1894
1908
  var postalCodeFormatError = (offerCountry, postalCode) => {
1895
1909
  if (!postalCode) return null;
1896
- const zone = zoneOf(offerCountry);
1910
+ const zone = getZoneByCountry(offerCountry);
1897
1911
  if (zone === "NA-US" && !/(^\d{5}$)|(^\d{5}-\d{4}$)/.test(postalCode)) {
1898
1912
  return "Zip code must be a valid US zip code";
1899
1913
  }
@@ -2076,8 +2090,11 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
2076
2090
  const result = await performPurchase({
2077
2091
  applePayToken: event.payment.token,
2078
2092
  skuId: config.skuId,
2093
+ // Offer/geo country — must not fall back to billing country on the BFF (print billing is unrestricted).
2094
+ countryCode: config.country,
2079
2095
  currency: config.currency,
2080
2096
  billingContact: event.payment.billingContact,
2097
+ supportedBillingCountries: config.supportedBillingCountries,
2081
2098
  ...event.payment.shippingContact && {
2082
2099
  shippingContact: event.payment.shippingContact
2083
2100
  },
@@ -2151,20 +2168,25 @@ var eea_countries_default = [
2151
2168
  "SE"
2152
2169
  ];
2153
2170
 
2171
+ // src/utils/print-variants.ts
2172
+ var PRINT_VARIANTS = [
2173
+ "bundle",
2174
+ "insider_print"
2175
+ ];
2176
+ var isPrintVariant = (variant) => PRINT_VARIANTS.includes(variant ?? "");
2177
+
2154
2178
  // src/utils/billing-countries.ts
2155
- var priceZones2 = price_zones_default;
2156
2179
  var eeaCountries = eea_countries_default;
2157
- var ALL_COUNTRY_CODES = Object.values(priceZones2).flat();
2158
- var getZoneByCountry = (country) => Object.keys(priceZones2).find((key) => priceZones2[key].includes(country)) ?? null;
2180
+ var ALL_COUNTRY_CODES = Object.values(priceZones).flat();
2159
2181
  var getSupportedBillingCountries = (offerCountry, offerVariant) => {
2160
- if (offerVariant === "bundle" || offerVariant === "insider_print") {
2182
+ if (isPrintVariant(offerVariant)) {
2161
2183
  return [...ALL_COUNTRY_CODES];
2162
2184
  }
2163
2185
  const zone = getZoneByCountry(offerCountry);
2164
2186
  if (!zone) {
2165
2187
  return [...ALL_COUNTRY_CODES];
2166
2188
  }
2167
- const zoneCountries = priceZones2[zone];
2189
+ const zoneCountries = priceZones[zone];
2168
2190
  if (eeaCountries.includes(offerCountry)) {
2169
2191
  return Array.from(/* @__PURE__ */ new Set([...zoneCountries, ...eeaCountries]));
2170
2192
  }
@@ -2207,14 +2229,14 @@ var no_delivery_countries_default = [
2207
2229
  ];
2208
2230
 
2209
2231
  // src/utils/delivery-countries.ts
2210
- var priceZones3 = price_zones_default;
2232
+ var priceZones2 = price_zones_default;
2211
2233
  var noDeliveryCountries = no_delivery_countries_default;
2212
2234
  var getSupportedDeliveryCountries = (offerCountry) => {
2213
- const zone = Object.keys(priceZones3).find(
2214
- (key) => priceZones3[key].includes(offerCountry)
2235
+ const zone = Object.keys(priceZones2).find(
2236
+ (key) => priceZones2[key].includes(offerCountry)
2215
2237
  );
2216
2238
  if (!zone) return [];
2217
- return priceZones3[zone].filter(
2239
+ return priceZones2[zone].filter(
2218
2240
  (country) => !noDeliveryCountries.includes(country)
2219
2241
  );
2220
2242
  };
@@ -2234,7 +2256,7 @@ var getButtonCopy = (enabled = CONTINUE_WITH_COPY_ENABLED) => enabled ? BUTTON_C
2234
2256
  var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
2235
2257
 
2236
2258
  // src/apple-pay-button.ts
2237
- var PRINT_VARIANTS = ["bundle", "insider_print"];
2259
+ var PRINT_VARIANTS2 = ["bundle", "insider_print"];
2238
2260
  var NO_EXCLUSIONS = [];
2239
2261
  var ENTRY_POINT_CONFIG = {
2240
2262
  ["dual_offer_banner" /* DUAL_OFFER_BANNER */]: {
@@ -2286,7 +2308,7 @@ var SEL_CONTAINER = ".apple-pay-container";
2286
2308
  var SEL_BUTTON = ".apple-pay-btn";
2287
2309
  var getExcludedVariants = (entryPoint) => {
2288
2310
  const config = ENTRY_POINT_CONFIG[entryPoint || DEFAULT_ENTRY_POINT] ?? ENTRY_POINT_CONFIG[DEFAULT_ENTRY_POINT];
2289
- return PRINT_OFFERS_ENABLED && config.allowsPrintOffers ? NO_EXCLUSIONS : PRINT_VARIANTS;
2311
+ return PRINT_OFFERS_ENABLED && config.allowsPrintOffers ? NO_EXCLUSIONS : PRINT_VARIANTS2;
2290
2312
  };
2291
2313
  var ApplePayButton = class _ApplePayButton extends HTMLElement {
2292
2314
  static tag = "teg-apple-pay-button";
@@ -2533,7 +2555,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2533
2555
  */
2534
2556
  #computeDeliveryCountries() {
2535
2557
  const variant = this.#offer.product?.variant;
2536
- if (!PRINT_VARIANTS.includes(variant)) {
2558
+ if (!PRINT_VARIANTS2.includes(variant)) {
2537
2559
  this.#supportedDeliveryCountries = null;
2538
2560
  return false;
2539
2561
  }
@@ -179,14 +179,24 @@ var track = (action, extra) => {
179
179
  ...extra
180
180
  });
181
181
  };
182
- var trackWalletPaymentSheetOpen = (skuId) => {
183
- track(EXPRESS_CHECKOUT_EVENTS.SHEET_OPEN, { sku_id: skuId });
182
+ var withEntryPoint = ({ entryPoint } = {}) => entryPoint ? { entry_point: entryPoint } : {};
183
+ var trackWalletPaymentSheetOpen = (skuId, metadata) => {
184
+ track(EXPRESS_CHECKOUT_EVENTS.SHEET_OPEN, {
185
+ sku_id: skuId,
186
+ ...withEntryPoint(metadata)
187
+ });
184
188
  };
185
- var trackWalletPaymentAuthorised = (skuId) => {
186
- track(EXPRESS_CHECKOUT_EVENTS.AUTHORISED, { sku_id: skuId });
189
+ var trackWalletPaymentAuthorised = (skuId, metadata) => {
190
+ track(EXPRESS_CHECKOUT_EVENTS.AUTHORISED, {
191
+ sku_id: skuId,
192
+ ...withEntryPoint(metadata)
193
+ });
187
194
  };
188
- var trackFallbackCheckout = (skuId) => {
189
- track(EXPRESS_CHECKOUT_EVENTS.FALLBACK_CHECKOUT, { sku_id: skuId });
195
+ var trackFallbackCheckout = (skuId, metadata) => {
196
+ track(EXPRESS_CHECKOUT_EVENTS.FALLBACK_CHECKOUT, {
197
+ sku_id: skuId,
198
+ ...withEntryPoint(metadata)
199
+ });
190
200
  };
191
201
 
192
202
  // src/clients/payment-checkout/messages.ts
@@ -245,6 +255,10 @@ function startApplePaySession(config) {
245
255
  requiredBillingContactFields: ["postalAddress", "name"],
246
256
  ...shippingFields.length > 0 && {
247
257
  requiredShippingContactFields: shippingFields
258
+ },
259
+ // Restrict the shipping country picker for print; onshippingcontactselected still validates as a backstop.
260
+ ...config.delivery && config.delivery.supportedCountries.length > 0 && {
261
+ supportedCountries: config.delivery.supportedCountries
248
262
  }
249
263
  };
250
264
  try {
@@ -252,8 +252,11 @@ var price_zones_default = {
252
252
  "UK-UK": ["GB"]
253
253
  };
254
254
 
255
- // src/utils/address-rules.ts
255
+ // src/utils/price-zones.ts
256
256
  var priceZones = price_zones_default;
257
+ var getZoneByCountry = (country) => Object.keys(priceZones).find((key) => priceZones[key].includes(country)) ?? null;
258
+
259
+ // src/utils/address-rules.ts
257
260
  var ADDRESS_LIMITS = {
258
261
  address1: 35,
259
262
  address2: 35,
@@ -262,10 +265,9 @@ var ADDRESS_LIMITS = {
262
265
  postalCode: 20,
263
266
  phone: 35
264
267
  };
265
- var zoneOf = (country) => Object.keys(priceZones).find((zone) => priceZones[zone].includes(country));
266
268
  var COUNTRIES_REQUIRING_PHONE = ["IN", "CN"];
267
269
  var requiredDeliveryFields = (offerCountry, country) => {
268
- const zone = zoneOf(offerCountry);
270
+ const zone = getZoneByCountry(offerCountry);
269
271
  const fields = ["address1", "city"];
270
272
  if (zone === "AS-AU" || zone === "AS-JP" || zone === "NA-CA" || country === "US") {
271
273
  fields.push("state");
@@ -278,7 +280,7 @@ var requiredDeliveryFields = (offerCountry, country) => {
278
280
  };
279
281
  var postalCodeFormatError = (offerCountry, postalCode) => {
280
282
  if (!postalCode) return null;
281
- const zone = zoneOf(offerCountry);
283
+ const zone = getZoneByCountry(offerCountry);
282
284
  if (zone === "NA-US" && !/(^\d{5}$)|(^\d{5}-\d{4}$)/.test(postalCode)) {
283
285
  return "Zip code must be a valid US zip code";
284
286
  }
@@ -93,20 +93,26 @@ var track = (action, extra) => {
93
93
  ...extra
94
94
  });
95
95
  };
96
- var trackWalletPaymentSuccess = (skuId, basketId) => {
96
+ var withEntryPoint = ({ entryPoint } = {}) => entryPoint ? { entry_point: entryPoint } : {};
97
+ var trackWalletPaymentSuccess = (skuId, basketId, metadata) => {
97
98
  track(EXPRESS_CHECKOUT_EVENTS.SUCCESS, {
98
99
  sku_id: skuId,
99
- basket_id: basketId
100
+ basket_id: basketId,
101
+ ...withEntryPoint(metadata)
100
102
  });
101
103
  };
102
- var trackWalletPaymentFailure = (skuId, reason) => {
104
+ var trackWalletPaymentFailure = (skuId, reason, metadata) => {
103
105
  track(EXPRESS_CHECKOUT_EVENTS.FAILURE, {
104
106
  sku_id: skuId,
105
- failure_reason: reason
107
+ failure_reason: reason,
108
+ ...withEntryPoint(metadata)
106
109
  });
107
110
  };
108
- var trackFallbackCheckout = (skuId) => {
109
- track(EXPRESS_CHECKOUT_EVENTS.FALLBACK_CHECKOUT, { sku_id: skuId });
111
+ var trackFallbackCheckout = (skuId, metadata) => {
112
+ track(EXPRESS_CHECKOUT_EVENTS.FALLBACK_CHECKOUT, {
113
+ sku_id: skuId,
114
+ ...withEntryPoint(metadata)
115
+ });
110
116
  };
111
117
  var trackValidationFieldError = (field, errorType) => {
112
118
  track(`validation_${field}_${errorType}`, {});
@@ -486,8 +492,11 @@ var price_zones_default = {
486
492
  "UK-UK": ["GB"]
487
493
  };
488
494
 
489
- // src/utils/address-rules.ts
495
+ // src/utils/price-zones.ts
490
496
  var priceZones = price_zones_default;
497
+ var getZoneByCountry = (country) => Object.keys(priceZones).find((key) => priceZones[key].includes(country)) ?? null;
498
+
499
+ // src/utils/address-rules.ts
491
500
  var ADDRESS_LIMITS = {
492
501
  address1: 35,
493
502
  address2: 35,
@@ -496,10 +505,9 @@ var ADDRESS_LIMITS = {
496
505
  postalCode: 20,
497
506
  phone: 35
498
507
  };
499
- var zoneOf = (country) => Object.keys(priceZones).find((zone) => priceZones[zone].includes(country));
500
508
  var COUNTRIES_REQUIRING_PHONE = ["IN", "CN"];
501
509
  var requiredDeliveryFields = (offerCountry, country) => {
502
- const zone = zoneOf(offerCountry);
510
+ const zone = getZoneByCountry(offerCountry);
503
511
  const fields = ["address1", "city"];
504
512
  if (zone === "AS-AU" || zone === "AS-JP" || zone === "NA-CA" || country === "US") {
505
513
  fields.push("state");
@@ -512,7 +520,7 @@ var requiredDeliveryFields = (offerCountry, country) => {
512
520
  };
513
521
  var postalCodeFormatError = (offerCountry, postalCode) => {
514
522
  if (!postalCode) return null;
515
- const zone = zoneOf(offerCountry);
523
+ const zone = getZoneByCountry(offerCountry);
516
524
  if (zone === "NA-US" && !/(^\d{5}$)|(^\d{5}-\d{4}$)/.test(postalCode)) {
517
525
  return "Zip code must be a valid US zip code";
518
526
  }
@@ -743,8 +751,11 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
743
751
  const result = await performPurchase({
744
752
  applePayToken: event.payment.token,
745
753
  skuId: config.skuId,
754
+ // Offer/geo country — must not fall back to billing country on the BFF (print billing is unrestricted).
755
+ countryCode: config.country,
746
756
  currency: config.currency,
747
757
  billingContact: event.payment.billingContact,
758
+ supportedBillingCountries: config.supportedBillingCountries,
748
759
  ...event.payment.shippingContact && {
749
760
  shippingContact: event.payment.shippingContact
750
761
  },