@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.
@@ -87,16 +87,20 @@ export type PurchaseRequest = {
87
87
  * only provide a `skuId`. Frontend uses `skuId` directly — BFF must be aligned.
88
88
  */
89
89
  skuId: string;
90
+ /** Offer/geo country for basket pricing and delivery zone rules (not the wallet billing country). */
91
+ countryCode: string;
90
92
  currency: string;
91
93
  billingContact: ApplePayPaymentContact;
92
94
  /** Required if loggedIn: false — contains emailAddress from Apple Pay sheet. */
93
95
  shippingContact?: ApplePayPaymentContact;
96
+ /** Countries the offer may be billed to (print is unrestricted; digital is price-zone limited). */
97
+ supportedBillingCountries: string[];
94
98
  /**
95
99
  * Print (bundle) offers only: the countries the offer can be delivered to. The BFF requires the delivery
96
100
  * country to be in this list, same pattern as `supportedBillingCountries`.
97
101
  */
98
102
  supportedDeliveryCountries?: string[];
99
- /** Sent when `ADDRESS_PARITY_ENABLED`: the BFF then applies the sma-checkout billing rules (Latin, truncation, PR). */
103
+ /** Always sent: the BFF then applies the sma-checkout billing rules (Latin, truncation, PR). */
100
104
  strictAddressRules?: boolean;
101
105
  recaptchaToken: string;
102
106
  };
package/dist/src/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
  }
@@ -2081,8 +2095,11 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
2081
2095
  const result = await performPurchase({
2082
2096
  applePayToken: event.payment.token,
2083
2097
  skuId: config.skuId,
2098
+ // Offer/geo country — must not fall back to billing country on the BFF (print billing is unrestricted).
2099
+ countryCode: config.country,
2084
2100
  currency: config.currency,
2085
2101
  billingContact: event.payment.billingContact,
2102
+ supportedBillingCountries: config.supportedBillingCountries,
2086
2103
  ...event.payment.shippingContact && {
2087
2104
  shippingContact: event.payment.shippingContact
2088
2105
  },
@@ -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
  }
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Delivery address rules for print (bundle) offers. Ported from sma-checkout
3
+ * `src/hooks/use-address-form-config/address-rules` (required.ts, validations.ts) so an Apple Pay delivery
4
+ * address is held to the same rules as the checkout form. The wallet-payments-api re-validates the same rules
5
+ * server-side. Keep all three in sync.
6
+ */
1
7
  export type DeliveryField = 'address1' | 'city' | 'state' | 'postalCode' | 'phone';
2
8
  /** Commerce Services length limits (sma-checkout `validations.ts`). */
3
9
  export declare const ADDRESS_LIMITS: {
@@ -203,8 +203,11 @@ var price_zones_default = {
203
203
  "UK-UK": ["GB"]
204
204
  };
205
205
 
206
- // src/utils/address-rules.ts
206
+ // src/utils/price-zones.ts
207
207
  var priceZones = price_zones_default;
208
+ var getZoneByCountry = (country) => Object.keys(priceZones).find((key) => priceZones[key].includes(country)) ?? null;
209
+
210
+ // src/utils/address-rules.ts
208
211
  var ADDRESS_LIMITS = {
209
212
  address1: 35,
210
213
  address2: 35,
@@ -213,10 +216,9 @@ var ADDRESS_LIMITS = {
213
216
  postalCode: 20,
214
217
  phone: 35
215
218
  };
216
- var zoneOf = (country) => Object.keys(priceZones).find((zone) => priceZones[zone].includes(country));
217
219
  var COUNTRIES_REQUIRING_PHONE = ["IN", "CN"];
218
220
  var requiredDeliveryFields = (offerCountry, country) => {
219
- const zone = zoneOf(offerCountry);
221
+ const zone = getZoneByCountry(offerCountry);
220
222
  const fields = ["address1", "city"];
221
223
  if (zone === "AS-AU" || zone === "AS-JP" || zone === "NA-CA" || country === "US") {
222
224
  fields.push("state");
@@ -229,7 +231,7 @@ var requiredDeliveryFields = (offerCountry, country) => {
229
231
  };
230
232
  var postalCodeFormatError = (offerCountry, postalCode) => {
231
233
  if (!postalCode) return null;
232
- const zone = zoneOf(offerCountry);
234
+ const zone = getZoneByCountry(offerCountry);
233
235
  if (zone === "NA-US" && !/(^\d{5}$)|(^\d{5}-\d{4}$)/.test(postalCode)) {
234
236
  return "Zip code must be a valid US zip code";
235
237
  }
@@ -1,3 +1,39 @@
1
+ // src/data/eea-countries.json
2
+ var eea_countries_default = [
3
+ "AT",
4
+ "BE",
5
+ "BG",
6
+ "HR",
7
+ "CY",
8
+ "CZ",
9
+ "DK",
10
+ "EE",
11
+ "FO",
12
+ "FI",
13
+ "FR",
14
+ "DE",
15
+ "GR",
16
+ "GL",
17
+ "HU",
18
+ "IS",
19
+ "IE",
20
+ "IT",
21
+ "LV",
22
+ "LI",
23
+ "LT",
24
+ "LU",
25
+ "MT",
26
+ "NL",
27
+ "NO",
28
+ "PL",
29
+ "PT",
30
+ "RO",
31
+ "SK",
32
+ "SI",
33
+ "ES",
34
+ "SE"
35
+ ];
36
+
1
37
  // src/data/price-zones.json
2
38
  var price_zones_default = {
3
39
  "AS-AS": [
@@ -203,49 +239,22 @@ var price_zones_default = {
203
239
  "UK-UK": ["GB"]
204
240
  };
205
241
 
206
- // src/data/eea-countries.json
207
- var eea_countries_default = [
208
- "AT",
209
- "BE",
210
- "BG",
211
- "HR",
212
- "CY",
213
- "CZ",
214
- "DK",
215
- "EE",
216
- "FO",
217
- "FI",
218
- "FR",
219
- "DE",
220
- "GR",
221
- "GL",
222
- "HU",
223
- "IS",
224
- "IE",
225
- "IT",
226
- "LV",
227
- "LI",
228
- "LT",
229
- "LU",
230
- "MT",
231
- "NL",
232
- "NO",
233
- "PL",
234
- "PT",
235
- "RO",
236
- "SK",
237
- "SI",
238
- "ES",
239
- "SE"
242
+ // src/utils/price-zones.ts
243
+ var priceZones = price_zones_default;
244
+ var getZoneByCountry = (country) => Object.keys(priceZones).find((key) => priceZones[key].includes(country)) ?? null;
245
+
246
+ // src/utils/print-variants.ts
247
+ var PRINT_VARIANTS = [
248
+ "bundle",
249
+ "insider_print"
240
250
  ];
251
+ var isPrintVariant = (variant) => PRINT_VARIANTS.includes(variant ?? "");
241
252
 
242
253
  // src/utils/billing-countries.ts
243
- var priceZones = price_zones_default;
244
254
  var eeaCountries = eea_countries_default;
245
255
  var ALL_COUNTRY_CODES = Object.values(priceZones).flat();
246
- var getZoneByCountry = (country) => Object.keys(priceZones).find((key) => priceZones[key].includes(country)) ?? null;
247
256
  var getSupportedBillingCountries = (offerCountry, offerVariant) => {
248
- if (offerVariant === "bundle" || offerVariant === "insider_print") {
257
+ if (isPrintVariant(offerVariant)) {
249
258
  return [...ALL_COUNTRY_CODES];
250
259
  }
251
260
  const zone = getZoneByCountry(offerCountry);
@@ -57,17 +57,25 @@ export type ClickMetadata = {
57
57
  /** Entry point where the Apple Pay button was clicked — e.g. 'free_trial_banner'. */
58
58
  entryPoint?: string;
59
59
  };
60
+ /**
61
+ * Entry point the Apple Pay button was rendered for. Added to every funnel event so the full
62
+ * funnel can be split per surface, not just the impression and click. Omitted when unset so
63
+ * payloads from hosts that do not pass an entry point are unchanged.
64
+ */
65
+ export type EntryPointMetadata = {
66
+ entryPoint?: string;
67
+ };
60
68
  /** Wallet button clicked */
61
69
  export declare const trackExpressWalletClick: (skuId: string, { entryPoint }?: ClickMetadata) => void;
62
70
  /** Apple Pay sheet opened (session.begin() called) */
63
- export declare const trackWalletPaymentSheetOpen: (skuId: string) => void;
71
+ export declare const trackWalletPaymentSheetOpen: (skuId: string, metadata?: EntryPointMetadata) => void;
64
72
  /** Payment authorised by the user in the Apple Pay sheet */
65
- export declare const trackWalletPaymentAuthorised: (skuId: string) => void;
73
+ export declare const trackWalletPaymentAuthorised: (skuId: string, metadata?: EntryPointMetadata) => void;
66
74
  /** Purchase completed — BFF returned success */
67
- export declare const trackWalletPaymentSuccess: (skuId: string, basketId: string) => void;
75
+ export declare const trackWalletPaymentSuccess: (skuId: string, basketId: string, metadata?: EntryPointMetadata) => void;
68
76
  /** Payment failed — BFF returned an error */
69
- export declare const trackWalletPaymentFailure: (skuId: string, reason: string) => void;
77
+ export declare const trackWalletPaymentFailure: (skuId: string, reason: string, metadata?: EntryPointMetadata) => void;
70
78
  /** Redirect to standard checkout triggered */
71
- export declare const trackFallbackCheckout: (skuId: string) => void;
79
+ export declare const trackFallbackCheckout: (skuId: string, metadata?: EntryPointMetadata) => void;
72
80
  /** Billing/shipping field failed validation (emitted per-field when Apple Pay sheet stays open) */
73
81
  export declare const trackValidationFieldError: (field: string, errorType: string) => void;
@@ -44,32 +44,44 @@ var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
44
44
  device: getDevice()
45
45
  });
46
46
  };
47
+ var withEntryPoint = ({ entryPoint } = {}) => entryPoint ? { entry_point: entryPoint } : {};
47
48
  var trackExpressWalletClick = (skuId, { entryPoint } = {}) => {
48
49
  track(EXPRESS_CHECKOUT_EVENTS.BUTTON_CLICK, {
49
50
  sku_id: skuId,
50
51
  ...entryPoint ? { entry_point: entryPoint } : {}
51
52
  });
52
53
  };
53
- var trackWalletPaymentSheetOpen = (skuId) => {
54
- track(EXPRESS_CHECKOUT_EVENTS.SHEET_OPEN, { sku_id: skuId });
54
+ var trackWalletPaymentSheetOpen = (skuId, metadata) => {
55
+ track(EXPRESS_CHECKOUT_EVENTS.SHEET_OPEN, {
56
+ sku_id: skuId,
57
+ ...withEntryPoint(metadata)
58
+ });
55
59
  };
56
- var trackWalletPaymentAuthorised = (skuId) => {
57
- track(EXPRESS_CHECKOUT_EVENTS.AUTHORISED, { sku_id: skuId });
60
+ var trackWalletPaymentAuthorised = (skuId, metadata) => {
61
+ track(EXPRESS_CHECKOUT_EVENTS.AUTHORISED, {
62
+ sku_id: skuId,
63
+ ...withEntryPoint(metadata)
64
+ });
58
65
  };
59
- var trackWalletPaymentSuccess = (skuId, basketId) => {
66
+ var trackWalletPaymentSuccess = (skuId, basketId, metadata) => {
60
67
  track(EXPRESS_CHECKOUT_EVENTS.SUCCESS, {
61
68
  sku_id: skuId,
62
- basket_id: basketId
69
+ basket_id: basketId,
70
+ ...withEntryPoint(metadata)
63
71
  });
64
72
  };
65
- var trackWalletPaymentFailure = (skuId, reason) => {
73
+ var trackWalletPaymentFailure = (skuId, reason, metadata) => {
66
74
  track(EXPRESS_CHECKOUT_EVENTS.FAILURE, {
67
75
  sku_id: skuId,
68
- failure_reason: reason
76
+ failure_reason: reason,
77
+ ...withEntryPoint(metadata)
69
78
  });
70
79
  };
71
- var trackFallbackCheckout = (skuId) => {
72
- track(EXPRESS_CHECKOUT_EVENTS.FALLBACK_CHECKOUT, { sku_id: skuId });
80
+ var trackFallbackCheckout = (skuId, metadata) => {
81
+ track(EXPRESS_CHECKOUT_EVENTS.FALLBACK_CHECKOUT, {
82
+ sku_id: skuId,
83
+ ...withEntryPoint(metadata)
84
+ });
73
85
  };
74
86
  var trackValidationFieldError = (field, errorType) => {
75
87
  track(`validation_${field}_${errorType}`, {});
@@ -0,0 +1,7 @@
1
+ export declare const priceZones: Readonly<Record<string, readonly string[]>>;
2
+ /**
3
+ * Returns the price-zone key that contains the given country code, or null if
4
+ * the country is not present in any known zone. The single lookup shared by
5
+ * billing countries, delivery countries and the delivery address rules.
6
+ */
7
+ export declare const getZoneByCountry: (country: string) => string | null;