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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -78,7 +78,7 @@ If `merchantId` is not configured, Apple Pay availability checks return `false`
78
78
 
79
79
  - Requires `offer` and `country` before click flow is meaningful.
80
80
  - Checks Apple Pay availability on connect; if unavailable, it hides.
81
- - Skips rendering for excluded variants (`bundle`, `insider_print`). Every other `ProductVariant` (including `play`) is eligible; billing countries are restricted to the offer's price zone.
81
+ - Skips rendering for variants excluded on its entry point (`getExcludedVariants(entryPoint)`: `bundle`, `insider_print` everywhere except `SUBSCRIBE` while `PRINT_OFFERS_ENABLED` is `true`). Every other `ProductVariant` (including `play`) is eligible; billing countries are restricted to the offer's price zone (unrestricted for print).
82
82
  - Forwards `data-logged-in` from button to modal (`modal.dataset.loggedIn`).
83
83
 
84
84
  #### Awaiting render completion — `whenReady()`
@@ -132,26 +132,17 @@ Consumers should listen for this event and continue payment orchestration.
132
132
  - `SALES_PAGE`: same always-on-after-exclusions gate for sma-checkout sales pages (Black Friday and other promotions); no Amplitude. Host-managed return URL like `SUBSCRIBE`; print offers excluded. Wallet impression `entry_point` is `sales_page`.
133
133
  - `PAYWALL`: always-on after offer exclusions + Safari/Apple placement eligibility. No Amplitude experiment / `$exposure`.
134
134
  - `REGWALL`: inert — always returns `null`.
135
- - **Address parity — behind a flag.** `ADDRESS_PARITY_ENABLED` (`src/utils/addressParityFlag.ts`) ships `false`. When `true`, billing names/addresses must be Latin characters plus the approved diacritics (SMA-3066; the sheet shows "Please use Latin characters only.") and the purchase carries `strictAddressRules`, so the wallet-payments-api also truncates billing lines to the Commerce limits and maps Puerto Rico to US. Print delivery details are always held to these rules. Deploy the wallet-payments-api change first.
136
- - **Button wording — behind a flag.** `CONTINUE_WITH_COPY_ENABLED` (`src/utils/buttonCopyFlag.ts`) ships `false`: the button reads "Subscribe with Apple Pay" on every surface, as before. Flip it to `true` in a release for "Continue with Apple Pay" (caption and accessible name).
137
- - **Print offers (`bundle`, `insider_print`) — behind a flag.** `PRINT_OFFERS_ENABLED` (`src/utils/printOffersFlag.ts`) ships `false`: every entry point excludes print exactly as before, so releasing and bumping the package changes nothing. Flip it to `true` in a release to enable the feature. Even then, only entry points with `allowsPrintOffers: true` in `ENTRY_POINT_CONFIG` (`src/apple-pay-button.ts`) take print — currently only `SUBSCRIBE`; banners, popup, paywall and regwall never do. Hosts that update `button.offer` in place should use `getExcludedVariants(entryPoint)` (it honours the flag) instead of the deprecated `APPLE_PAY_EXCLUDED_VARIANTS`. For an allowed print offer the sheet additionally collects the delivery address, name and phone and:
138
- - limits delivery to the offer's price zone minus the countries print cannot be delivered to (`src/data/no-delivery-countries.json`); an offer with no deliverable country hides the button;
135
+ - **Analytics.** The entry point is sent as `entry_point` on every TEDL funnel event: `express_wallet_impression`, `express_wallet_click`, `wallet_payment_sheet_open`, `wallet_payment_authorised`, `wallet_payment_success`, `wallet_payment_failure` and `fallback_checkout`. It is left out when the host does not set one. The per-field `validation_*` events do not carry it.
136
+ - **Print offers (`bundle`, `insider_print`) — enabled.** `PRINT_OFFERS_ENABLED` is `true`. Entry points with `allowsPrintOffers: true` in `ENTRY_POINT_CONFIG` (`src/apple-pay-button.ts`) take print — currently only `SUBSCRIBE`; banners, popup, paywall, regwall and `SALES_PAGE` never do. Hosts that update `button.offer` in place should use `getExcludedVariants(entryPoint)` (it honours the flag) instead of the deprecated `APPLE_PAY_EXCLUDED_VARIANTS`. For an allowed print offer the sheet additionally collects the delivery address, name and phone and:
137
+ - limits delivery to the offer's price zone minus the countries print cannot be delivered to (`src/data/no-delivery-countries.json`, also set as Apple Pay `supportedCountries`); an offer with no deliverable country hides the button;
139
138
  - validates the address with the sma-checkout delivery-form rules (required fields by zone, Commerce Services length limits, US zip / Canadian postcode formats, phone required for IN and CN) and keeps the sheet open with field-level errors (`delivery-contact-details.ts`, rules in `utils/address-rules.ts`);
140
- - sends `supportedDeliveryCountries` and the shipping contact to `/v1/wallet/purchase`, which re-validates and forwards the delivery address to Commerce Services. **Release order:** deploy the wallet-payments-api change before flipping the flag.
139
+ - sends offer `countryCode`, `supportedBillingCountries`, `supportedDeliveryCountries` and the shipping contact to `/v1/wallet/purchase` (phone normalised by the validator, e.g. IN `098765 43210` → `+919876543210`), which re-validates and forwards the delivery address to Commerce Services. **Requires** wallet-payments-api with print delivery enabled;
140
+ - reports billing and delivery field errors together, so the sheet shows every bad field at once.
141
141
  - Names and addresses must be Latin characters plus the approved diacritics for every purchase (SMA-3066), the same as sma-checkout; non-Latin input shows "Please use Latin characters only." in the sheet.
142
- The address rules, zones and no-delivery list are copies of sma-checkout's; keep them in sync.
143
- - **Where the user returns after purchase.** Each entry point sets a `ReturnUrlPolicy` in `ENTRY_POINT_CONFIG` (`src/apple-pay-button.ts`), which decides what is written to `localStorage['checkout-redirect']` (read by the onboarding app):
144
- - `CURRENT_PAGE`: the page the button is on (banners, popup, paywall, regwall), e.g. back to the article.
145
- - `HOST_MANAGED`: nothing is written, so the host's own value is kept (`SUBSCRIBE`: sma-checkout stores the article the user arrived from; with none stored, onboarding returns them to the home page).
146
- - A new entry point must declare its policy, or it will not compile.
142
+ - **Return after purchase.** Banners, popup, paywall and regwall return the user to the page the button is on. `SUBSCRIBE` and `SALES_PAGE` leave the return target to the host (sma-checkout keeps the article the user arrived from).
147
143
  - `ApplePayModal`: modal component class.
148
144
  - `Offer`: offer contract type used by component props.
149
145
 
150
- ### Breaking changes
151
-
152
- - `APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY`, `APPLE_PAY_EXPRESS_VARIANTS`, and `ApplePayExperimentFlagKey` are no longer exported. Paywalls are always-on after Safari/offer checks; drop those imports.
153
- - `APPLE_PAY_EXPRESS_EXPERIMENT_KEY` (retired banners experiment flag) remains unpublished.
154
-
155
146
  ## Troubleshooting
156
147
 
157
148
  ### Button does not appear
@@ -162,7 +153,7 @@ Check:
162
153
  - device/browser supports Apple Pay (Safari on Apple device required — enforced by `isApplePayAvailable` on mount)
163
154
  - for paywalls: Safari/Apple placement eligibility (or `?BYPASS_APPLE_PAY_CHECKS=1` for QA)
164
155
  - for banners / `FREE_TRIAL_POPUP`: consumer kill switch off (no homepage/Safari gate at `createIfEnabled`)
165
- - offer variant is not excluded (`bundle`, `insider_print`)
156
+ - offer variant is not excluded (`bundle`, `insider_print` are only allowed on `SUBSCRIBE` while `PRINT_OFFERS_ENABLED` is `true`)
166
157
 
167
158
  ### Logged-in checkbox copy looks wrong
168
159
 
@@ -213,6 +204,5 @@ Story coverage matrix:
213
204
  - `ApplePayModal` docs page shows the stable default example.
214
205
  - `ApplePayModal` behavior and state variants are available as individual canvas stories in Storybook.
215
206
 
216
-
217
-
207
+ Print offers are enabled (`PRINT_OFFERS_ENABLED` is `true`) on `SUBSCRIBE` only; see the Public API section above.
218
208
 
package/dist/index.js CHANGED
@@ -1012,12 +1012,10 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
1012
1012
  // src/templates/apple-pay-button.template.html
1013
1013
  var apple_pay_button_template_default = `<style>
1014
1014
  /*
1015
- * Entry CTA: caption + Apple Pay wordmark, built from text (no SVG), as in Figma (Play Global Spec 3268:39728):
1016
- * black #0d0d0d, 4px radius, 40px high, 8px 16px padding, 4px gap.
1017
- * Marber tokens (as bound in Figma): caption size label-2-size (15px), line height label-3-leading (24px);
1018
- * glyph + "Pay" 17px (label-3-size) with auto line height; padding spacing-xs / spacing-md; gap + radius spacing-2xs;
1019
- * background london-5. Expected content widths in Figma: caption 98px, wordmark 42px, button content 176px.
1020
- * Caption: SF Pro Regular. Wordmark: the Apple glyph (U+F8FF, Regular) + "Pay" (Medium 510).
1015
+ * Entry CTA: caption + Apple Pay wordmark, built from text (no SVG). Figma: Play pilot 7781:7325 (text style) and
1016
+ * Play Global Spec 3268:39728 (layout): black #0d0d0d, 4px radius, 40px high, 8px 16px padding, 4px gap.
1017
+ * Text: SF Pro Medium 510, line height normal; caption size label-2-size (15px), glyph + "Pay" 17px (label-3-size).
1018
+ * Padding spacing-xs / spacing-md; gap + radius spacing-2xs; background london-5.
1021
1019
  * SF Pro is the system font on Apple devices, which are the only devices Apple Pay is shown on.
1022
1020
  */
1023
1021
  teg-apple-pay-button {
@@ -1051,15 +1049,14 @@ var apple_pay_button_template_default = `<style>
1051
1049
  border: none;
1052
1050
  border-radius: var(--apple-pay-border-radius, var(--mb-spacing-2xs, 0.25rem));
1053
1051
  cursor: pointer;
1054
- /* Figma: SF Pro (system font on Apple devices), Regular 15 / 24 */
1052
+ /* Figma Play pilot 7781:7325: SF Pro (system font on Apple devices), Medium 510, 15px, line height normal */
1055
1053
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro', system-ui, sans-serif;
1056
1054
  font-size: var(--mb-typestyle-label-2-size, 0.9375rem);
1057
- font-weight: 400;
1055
+ font-weight: 510;
1058
1056
  font-variation-settings: 'wdth' 100;
1059
1057
  /* Figma letter spacing 0 */
1060
1058
  letter-spacing: 0;
1061
- /* Figma caption: line height is the label-3-leading token (24px) */
1062
- line-height: var(--mb-typestyle-label-3-leading, 1.5rem);
1059
+ line-height: normal;
1063
1060
  }
1064
1061
 
1065
1062
  teg-apple-pay-button .apple-pay-btn__label {
@@ -1073,8 +1070,7 @@ var apple_pay_button_template_default = `<style>
1073
1070
  teg-apple-pay-button .apple-pay-btn__logo {
1074
1071
  display: inline-flex;
1075
1072
  align-items: baseline;
1076
- /* Figma "Pay" layer: 17px (label-3 size) with AUTO line height (a 20px box centred in the 24px caption row),
1077
- not the 24px leading token the caption uses. */
1073
+ /* Figma "Pay" layer: 17px (label-3 size), line height normal. */
1078
1074
  font-size: var(--mb-typestyle-label-3-size, 1.0625rem);
1079
1075
  line-height: normal;
1080
1076
  }
@@ -1121,15 +1117,15 @@ var apple_pay_button_template_default = `<style>
1121
1117
 
1122
1118
  </style>
1123
1119
 
1124
- <div class="apple-pay-container" aria-label="Subscribe with Apple Pay">
1120
+ <div class="apple-pay-container" aria-label="Continue with Apple Pay">
1125
1121
  <button
1126
1122
  class="apple-pay-btn"
1127
1123
  type="button"
1128
- aria-label="Subscribe with Apple Pay"
1124
+ aria-label="Continue with Apple Pay"
1129
1125
  data-analytics="paywall:apple-pay-checkout"
1130
1126
  >
1131
1127
  <span class="apple-pay-btn__label"
1132
- ><span class="apple-pay-btn__caption">Subscribe with</span
1128
+ ><span class="apple-pay-btn__caption">Continue with</span
1133
1129
  ><span class="apple-pay-btn__logo" aria-hidden="true"
1134
1130
  ><span class="apple-pay-btn__logo-glyph">&#63743;</span
1135
1131
  ><span class="apple-pay-btn__logo-word">Pay</span
@@ -1373,32 +1369,44 @@ var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
1373
1369
  device: getDevice()
1374
1370
  });
1375
1371
  };
1372
+ var withEntryPoint = ({ entryPoint } = {}) => entryPoint ? { entry_point: entryPoint } : {};
1376
1373
  var trackExpressWalletClick = (skuId, { entryPoint } = {}) => {
1377
1374
  track(EXPRESS_CHECKOUT_EVENTS.BUTTON_CLICK, {
1378
1375
  sku_id: skuId,
1379
1376
  ...entryPoint ? { entry_point: entryPoint } : {}
1380
1377
  });
1381
1378
  };
1382
- var trackWalletPaymentSheetOpen = (skuId) => {
1383
- track(EXPRESS_CHECKOUT_EVENTS.SHEET_OPEN, { sku_id: skuId });
1379
+ var trackWalletPaymentSheetOpen = (skuId, metadata) => {
1380
+ track(EXPRESS_CHECKOUT_EVENTS.SHEET_OPEN, {
1381
+ sku_id: skuId,
1382
+ ...withEntryPoint(metadata)
1383
+ });
1384
1384
  };
1385
- var trackWalletPaymentAuthorised = (skuId) => {
1386
- track(EXPRESS_CHECKOUT_EVENTS.AUTHORISED, { sku_id: skuId });
1385
+ var trackWalletPaymentAuthorised = (skuId, metadata) => {
1386
+ track(EXPRESS_CHECKOUT_EVENTS.AUTHORISED, {
1387
+ sku_id: skuId,
1388
+ ...withEntryPoint(metadata)
1389
+ });
1387
1390
  };
1388
- var trackWalletPaymentSuccess = (skuId, basketId) => {
1391
+ var trackWalletPaymentSuccess = (skuId, basketId, metadata) => {
1389
1392
  track(EXPRESS_CHECKOUT_EVENTS.SUCCESS, {
1390
1393
  sku_id: skuId,
1391
- basket_id: basketId
1394
+ basket_id: basketId,
1395
+ ...withEntryPoint(metadata)
1392
1396
  });
1393
1397
  };
1394
- var trackWalletPaymentFailure = (skuId, reason) => {
1398
+ var trackWalletPaymentFailure = (skuId, reason, metadata) => {
1395
1399
  track(EXPRESS_CHECKOUT_EVENTS.FAILURE, {
1396
1400
  sku_id: skuId,
1397
- failure_reason: reason
1401
+ failure_reason: reason,
1402
+ ...withEntryPoint(metadata)
1398
1403
  });
1399
1404
  };
1400
- var trackFallbackCheckout = (skuId) => {
1401
- track(EXPRESS_CHECKOUT_EVENTS.FALLBACK_CHECKOUT, { sku_id: skuId });
1405
+ var trackFallbackCheckout = (skuId, metadata) => {
1406
+ track(EXPRESS_CHECKOUT_EVENTS.FALLBACK_CHECKOUT, {
1407
+ sku_id: skuId,
1408
+ ...withEntryPoint(metadata)
1409
+ });
1402
1410
  };
1403
1411
  var trackValidationFieldError = (field, errorType) => {
1404
1412
  track(`validation_${field}_${errorType}`, {});
@@ -1467,6 +1475,10 @@ function startApplePaySession(config) {
1467
1475
  requiredBillingContactFields: ["postalAddress", "name"],
1468
1476
  ...shippingFields.length > 0 && {
1469
1477
  requiredShippingContactFields: shippingFields
1478
+ },
1479
+ // Restrict the shipping country picker for print; onshippingcontactselected still validates as a backstop.
1480
+ ...config.delivery && config.delivery.supportedCountries.length > 0 && {
1481
+ supportedCountries: config.delivery.supportedCountries
1470
1482
  }
1471
1483
  };
1472
1484
  try {
@@ -1872,8 +1884,11 @@ var price_zones_default = {
1872
1884
  "UK-UK": ["GB"]
1873
1885
  };
1874
1886
 
1875
- // src/utils/address-rules.ts
1887
+ // src/utils/price-zones.ts
1876
1888
  var priceZones = price_zones_default;
1889
+ var getZoneByCountry = (country) => Object.keys(priceZones).find((key) => priceZones[key].includes(country)) ?? null;
1890
+
1891
+ // src/utils/address-rules.ts
1877
1892
  var ADDRESS_LIMITS = {
1878
1893
  address1: 35,
1879
1894
  address2: 35,
@@ -1882,10 +1897,9 @@ var ADDRESS_LIMITS = {
1882
1897
  postalCode: 20,
1883
1898
  phone: 35
1884
1899
  };
1885
- var zoneOf = (country) => Object.keys(priceZones).find((zone) => priceZones[zone].includes(country));
1886
1900
  var COUNTRIES_REQUIRING_PHONE = ["IN", "CN"];
1887
1901
  var requiredDeliveryFields = (offerCountry, country) => {
1888
- const zone = zoneOf(offerCountry);
1902
+ const zone = getZoneByCountry(offerCountry);
1889
1903
  const fields = ["address1", "city"];
1890
1904
  if (zone === "AS-AU" || zone === "AS-JP" || zone === "NA-CA" || country === "US") {
1891
1905
  fields.push("state");
@@ -1898,7 +1912,7 @@ var requiredDeliveryFields = (offerCountry, country) => {
1898
1912
  };
1899
1913
  var postalCodeFormatError = (offerCountry, postalCode) => {
1900
1914
  if (!postalCode) return null;
1901
- const zone = zoneOf(offerCountry);
1915
+ const zone = getZoneByCountry(offerCountry);
1902
1916
  if (zone === "NA-US" && !/(^\d{5}$)|(^\d{5}-\d{4}$)/.test(postalCode)) {
1903
1917
  return "Zip code must be a valid US zip code";
1904
1918
  }
@@ -2086,7 +2100,10 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
2086
2100
  ...event.payment.shippingContact && {
2087
2101
  shippingContact: event.payment.shippingContact
2088
2102
  },
2103
+ // Print only: billing is unrestricted, so the BFF must not fall back to the billing country for the offer.
2089
2104
  ...config.delivery && {
2105
+ countryCode: config.country,
2106
+ supportedBillingCountries: config.supportedBillingCountries,
2090
2107
  supportedDeliveryCountries: config.delivery.supportedCountries
2091
2108
  },
2092
2109
  ...ADDRESS_PARITY_ENABLED ? { strictAddressRules: true } : {},
@@ -2156,20 +2173,25 @@ var eea_countries_default = [
2156
2173
  "SE"
2157
2174
  ];
2158
2175
 
2176
+ // src/utils/print-variants.ts
2177
+ var PRINT_VARIANTS = [
2178
+ "bundle",
2179
+ "insider_print"
2180
+ ];
2181
+ var isPrintVariant = (variant) => PRINT_VARIANTS.includes(variant ?? "");
2182
+
2159
2183
  // src/utils/billing-countries.ts
2160
- var priceZones2 = price_zones_default;
2161
2184
  var eeaCountries = eea_countries_default;
2162
- var ALL_COUNTRY_CODES = Object.values(priceZones2).flat();
2163
- var getZoneByCountry = (country) => Object.keys(priceZones2).find((key) => priceZones2[key].includes(country)) ?? null;
2185
+ var ALL_COUNTRY_CODES = Object.values(priceZones).flat();
2164
2186
  var getSupportedBillingCountries = (offerCountry, offerVariant) => {
2165
- if (offerVariant === "bundle" || offerVariant === "insider_print") {
2187
+ if (isPrintVariant(offerVariant)) {
2166
2188
  return [...ALL_COUNTRY_CODES];
2167
2189
  }
2168
2190
  const zone = getZoneByCountry(offerCountry);
2169
2191
  if (!zone) {
2170
2192
  return [...ALL_COUNTRY_CODES];
2171
2193
  }
2172
- const zoneCountries = priceZones2[zone];
2194
+ const zoneCountries = priceZones[zone];
2173
2195
  if (eeaCountries.includes(offerCountry)) {
2174
2196
  return Array.from(/* @__PURE__ */ new Set([...zoneCountries, ...eeaCountries]));
2175
2197
  }
@@ -2212,14 +2234,14 @@ var no_delivery_countries_default = [
2212
2234
  ];
2213
2235
 
2214
2236
  // src/utils/delivery-countries.ts
2215
- var priceZones3 = price_zones_default;
2237
+ var priceZones2 = price_zones_default;
2216
2238
  var noDeliveryCountries = no_delivery_countries_default;
2217
2239
  var getSupportedDeliveryCountries = (offerCountry) => {
2218
- const zone = Object.keys(priceZones3).find(
2219
- (key) => priceZones3[key].includes(offerCountry)
2240
+ const zone = Object.keys(priceZones2).find(
2241
+ (key) => priceZones2[key].includes(offerCountry)
2220
2242
  );
2221
2243
  if (!zone) return [];
2222
- return priceZones3[zone].filter(
2244
+ return priceZones2[zone].filter(
2223
2245
  (country) => !noDeliveryCountries.includes(country)
2224
2246
  );
2225
2247
  };
@@ -2251,7 +2273,7 @@ var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
2251
2273
  })(ApplePayEntryPoint || {});
2252
2274
 
2253
2275
  // src/apple-pay-button.ts
2254
- var PRINT_VARIANTS = ["bundle", "insider_print"];
2276
+ var PRINT_VARIANTS2 = ["bundle", "insider_print"];
2255
2277
  var NO_EXCLUSIONS = [];
2256
2278
  var ENTRY_POINT_CONFIG = {
2257
2279
  ["dual_offer_banner" /* DUAL_OFFER_BANNER */]: {
@@ -2301,10 +2323,10 @@ var DEFAULT_CURRENCY = "USD";
2301
2323
  var DEFAULT_TOTAL = "0.00";
2302
2324
  var SEL_CONTAINER = ".apple-pay-container";
2303
2325
  var SEL_BUTTON = ".apple-pay-btn";
2304
- var APPLE_PAY_EXCLUDED_VARIANTS = PRINT_VARIANTS;
2326
+ var APPLE_PAY_EXCLUDED_VARIANTS = PRINT_VARIANTS2;
2305
2327
  var getExcludedVariants = (entryPoint) => {
2306
2328
  const config = ENTRY_POINT_CONFIG[entryPoint || DEFAULT_ENTRY_POINT] ?? ENTRY_POINT_CONFIG[DEFAULT_ENTRY_POINT];
2307
- return PRINT_OFFERS_ENABLED && config.allowsPrintOffers ? NO_EXCLUSIONS : PRINT_VARIANTS;
2329
+ return PRINT_OFFERS_ENABLED && config.allowsPrintOffers ? NO_EXCLUSIONS : PRINT_VARIANTS2;
2308
2330
  };
2309
2331
  var ApplePayButton = class _ApplePayButton extends HTMLElement {
2310
2332
  static tag = "teg-apple-pay-button";
@@ -2551,7 +2573,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2551
2573
  */
2552
2574
  #computeDeliveryCountries() {
2553
2575
  const variant = this.#offer.product?.variant;
2554
- if (!PRINT_VARIANTS.includes(variant)) {
2576
+ if (!PRINT_VARIANTS2.includes(variant)) {
2555
2577
  this.#supportedDeliveryCountries = null;
2556
2578
  return false;
2557
2579
  }
@@ -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
  }
@@ -2081,7 +2095,10 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
2081
2095
  ...event.payment.shippingContact && {
2082
2096
  shippingContact: event.payment.shippingContact
2083
2097
  },
2098
+ // Print only: billing is unrestricted, so the BFF must not fall back to the billing country for the offer.
2084
2099
  ...config.delivery && {
2100
+ countryCode: config.country,
2101
+ supportedBillingCountries: config.supportedBillingCountries,
2085
2102
  supportedDeliveryCountries: config.delivery.supportedCountries
2086
2103
  },
2087
2104
  ...ADDRESS_PARITY_ENABLED ? { strictAddressRules: true } : {},
@@ -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 */]: {
@@ -2284,10 +2306,10 @@ var DEFAULT_CURRENCY = "USD";
2284
2306
  var DEFAULT_TOTAL = "0.00";
2285
2307
  var SEL_CONTAINER = ".apple-pay-container";
2286
2308
  var SEL_BUTTON = ".apple-pay-btn";
2287
- var APPLE_PAY_EXCLUDED_VARIANTS = PRINT_VARIANTS;
2309
+ var APPLE_PAY_EXCLUDED_VARIANTS = PRINT_VARIANTS2;
2288
2310
  var getExcludedVariants = (entryPoint) => {
2289
2311
  const config = ENTRY_POINT_CONFIG[entryPoint || DEFAULT_ENTRY_POINT] ?? ENTRY_POINT_CONFIG[DEFAULT_ENTRY_POINT];
2290
- return PRINT_OFFERS_ENABLED && config.allowsPrintOffers ? NO_EXCLUSIONS : PRINT_VARIANTS;
2312
+ return PRINT_OFFERS_ENABLED && config.allowsPrintOffers ? NO_EXCLUSIONS : PRINT_VARIANTS2;
2291
2313
  };
2292
2314
  var ApplePayButton = class _ApplePayButton extends HTMLElement {
2293
2315
  static tag = "teg-apple-pay-button";
@@ -2534,7 +2556,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2534
2556
  */
2535
2557
  #computeDeliveryCountries() {
2536
2558
  const variant = this.#offer.product?.variant;
2537
- if (!PRINT_VARIANTS.includes(variant)) {
2559
+ if (!PRINT_VARIANTS2.includes(variant)) {
2538
2560
  this.#supportedDeliveryCountries = null;
2539
2561
  return false;
2540
2562
  }