@economist/web-apple-pay 1.7.6 → 1.7.7

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.
@@ -71,7 +71,7 @@ function ensureApplePayLogoSymbol() {
71
71
  return;
72
72
  }
73
73
  const tmp = document.createElement("div");
74
- tmp.innerHTML = `<svg aria-hidden="true" style="display:none" id="${LOGO_DEFS_ID}"><defs><symbol id="apple-pay-logo" viewBox="0 0 51 22"><path d="${LOGO_PATH}" fill="white"/></symbol></defs></svg>`;
74
+ tmp.innerHTML = `<svg aria-hidden="true" style="display:none" id="${LOGO_DEFS_ID}"><defs><symbol id="apple-pay-logo" viewBox="0 0 51 22"><path d="${LOGO_PATH}" fill="currentColor"/></symbol></defs></svg>`;
75
75
  document.body.prepend(tmp.firstElementChild);
76
76
  }
77
77
 
@@ -109,16 +109,32 @@ var apple_pay_modal_template_default = `<style>
109
109
  position: absolute;
110
110
  top: 1.5rem;
111
111
  right: 1.3125rem;
112
- background: none;
112
+ background: transparent;
113
113
  border: none;
114
114
  cursor: pointer;
115
115
  padding: 0;
116
+ width: 1.5rem;
117
+ height: 1.5rem;
116
118
  display: flex;
117
119
  align-items: center;
118
120
  justify-content: center;
121
+ color: var(--mb-colour-greyscale-london-20, #1a1a1a);
122
+ transition:
123
+ background-color ease-in-out 0.2s,
124
+ color ease-in-out 0.2s;
125
+ }
126
+
127
+ .apm__close:hover {
128
+ color: var(--mb-colour-base-chicago-30, #333333);
129
+ }
130
+
131
+ .apm__close:active {
132
+ background-color: var(--mb-colour-base-chicago-90, #e6e6e6);
133
+ color: var(--mb-colour-base-chicago-30, #333333);
119
134
  }
120
135
 
121
136
  .apm__close:focus {
137
+ background-color: var(--mb-colour-base-chicago-90, #e6e6e6);
122
138
  outline: solid 0.125rem var(--focus-border-color, #121212);
123
139
  border-radius: 0.25rem;
124
140
  }
@@ -301,10 +317,6 @@ var apple_pay_modal_template_default = `<style>
301
317
  cursor: pointer;
302
318
  color: #fff;
303
319
  text-align: center;
304
- font-family: var(
305
- --mb-typeface-sans,
306
- var(--wall-type-system-sans, system-ui, sans-serif)
307
- );
308
320
  font-size: 1.25rem;
309
321
  font-style: normal;
310
322
  font-weight: 500;
@@ -421,7 +433,7 @@ var apple_pay_modal_template_default = `<style>
421
433
  fill-rule="evenodd"
422
434
  clip-rule="evenodd"
423
435
  d="M18.75 6.60964L17.3904 5.25L12 10.6404L6.60964 5.25L5.25 6.60964L10.6404 12L5.25 17.3904L6.60964 18.75L12 13.3596L17.3904 18.75L18.75 17.3904L13.3596 12L18.75 6.60964Z"
424
- fill="#333333"
436
+ fill="currentColor"
425
437
  />
426
438
  </g>
427
439
  <defs>
@@ -687,6 +699,8 @@ function renewalPeriodText(unit, duration) {
687
699
  return "";
688
700
  }
689
701
  }
702
+ var LI_SEPARATOR = "\0LI_SEP\0";
703
+ var P_SEPARATOR = "\0P_SEP\0";
690
704
  function buildTermsContext(offer, country) {
691
705
  const isUS = country === "US";
692
706
  const isCA = country === "CA";
@@ -723,19 +737,19 @@ function freeTrialTerms(offer, ctx) {
723
737
  const trialDuration = offer.subscription_options?.trial_period?.duration ?? 1;
724
738
  const trialDateStr = `on ${getRenewalDateText(trialUnit, trialDuration)}${ctx.verificationText}`;
725
739
  if (ctx.isUS) {
726
- return `Your subscription renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${trialDateStr} when your free trial ends, until cancelled{{liSeparator}}You\u2019ll be charged the rate in effect at each renewal until cancelled. ${ctx.usCancelNote}${ctx.taxFootnote}`;
740
+ return `Your subscription renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${trialDateStr} when your free trial ends, until cancelled${LI_SEPARATOR}You\u2019ll be charged the rate in effect at each renewal until cancelled. ${ctx.usCancelNote}${ctx.taxFootnote}`;
727
741
  }
728
- return `Your subscription renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${trialDateStr} when your free trial ends, until cancelled{{liSeparator}}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime}${ctx.taxFootnote}`;
742
+ return `Your subscription renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${trialDateStr} when your free trial ends, until cancelled${LI_SEPARATOR}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime}${ctx.taxFootnote}`;
729
743
  }
730
744
  function nytTerms(ctx) {
731
745
  const nytAccessText = "Your complimentary access to The New York Times is for one year only and does not auto-renew. We will send your instructions on how to redeem access to The New York Times by email.";
732
746
  if (ctx.isUS) {
733
- return `Your subscription to <em>The Economist</em> auto-renews ${ctx.periodText} until cancelled{{liSeparator}}Your subscription renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${ctx.renewalDateStr}{{liSeparator}}You\u2019ll be charged the rate in effect at each renewal until cancelled. ${ctx.usCancelNote}${ctx.taxFootnote}{{pSeparator}}${nytAccessText}`;
747
+ return `Your subscription to <em>The Economist</em> auto-renews ${ctx.periodText} until cancelled${LI_SEPARATOR}Your subscription renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${ctx.renewalDateStr}${LI_SEPARATOR}You\u2019ll be charged the rate in effect at each renewal until cancelled. ${ctx.usCancelNote}${ctx.taxFootnote}${P_SEPARATOR}${nytAccessText}`;
734
748
  }
735
749
  if (ctx.isCA) {
736
- return `Your subscription to <em>The Economist</em> auto-renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${ctx.periodText} ${ctx.renewalDateStr} until cancelled.{{liSeparator}}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime}${ctx.taxFootnote}{{pSeparator}}${nytAccessText}`;
750
+ return `Your subscription to <em>The Economist</em> auto-renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${ctx.periodText} ${ctx.renewalDateStr} until cancelled.${LI_SEPARATOR}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime}${ctx.taxFootnote}${P_SEPARATOR}${nytAccessText}`;
737
751
  }
738
- return `Your subscription to <em>The Economist</em> auto-renews at ${ctx.renewalPriceText} ${ctx.periodText} ${ctx.renewalDateStr} until cancelled{{liSeparator}}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime} ${nytAccessText}`;
752
+ return `Your subscription to <em>The Economist</em> auto-renews at ${ctx.renewalPriceText} ${ctx.periodText} ${ctx.renewalDateStr} until cancelled${LI_SEPARATOR}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime} ${nytAccessText}`;
739
753
  }
740
754
  function minTermContractTerms(offer, ctx) {
741
755
  const duePrice = formatPrice(offer.price.purchase, offer.price.currency_code);
@@ -745,28 +759,28 @@ function minTermContractTerms(offer, ctx) {
745
759
  const contractLength = mtDuration && mtUnit ? `${mtDuration} ${mtUnit}` : "";
746
760
  const initialContractText = contractLength ? `your initial ${contractLength} contract` : "your initial contract";
747
761
  const mtRenewalDateText = mtUnit && mtDuration ? getRenewalDateText(mtUnit, Number(mtDuration)) : ctx.renewalDateText;
748
- return `You\u2019ll be charged ${duePrice} a month for the duration of ${initialContractText}{{liSeparator}}Your subscription auto-renews annually at ${ctx.renewalPriceText} a month on ${mtRenewalDateText} until cancelled{{liSeparator}}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime}`;
762
+ return `You\u2019ll be charged ${duePrice} a month for the duration of ${initialContractText}${LI_SEPARATOR}Your subscription auto-renews annually at ${ctx.renewalPriceText} a month on ${mtRenewalDateText} until cancelled${LI_SEPARATOR}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime}`;
749
763
  }
750
764
  function paidTrialTerms(offer, ctx) {
751
765
  const trialUnit = offer.subscription_options?.trial_period?.unit ?? ctx.unit;
752
766
  const trialDuration = offer.subscription_options?.trial_period?.duration ?? ctx.duration;
753
767
  const trialDateText = getRenewalDateText(trialUnit, trialDuration);
754
768
  if (ctx.isUS) {
755
- return `Your subscription auto-renews ${ctx.periodText} until cancelled{{liSeparator}}Your subscription renews at ${ctx.renewalPriceText}${ctx.taxSuffix} on ${trialDateText} when your paid trial ends{{liSeparator}}You\u2019ll be charged the rate in effect at each renewal. ${ctx.usCancelNote}${ctx.taxFootnote}`;
769
+ return `Your subscription auto-renews ${ctx.periodText} until cancelled${LI_SEPARATOR}Your subscription renews at ${ctx.renewalPriceText}${ctx.taxSuffix} on ${trialDateText} when your paid trial ends${LI_SEPARATOR}You\u2019ll be charged the rate in effect at each renewal. ${ctx.usCancelNote}${ctx.taxFootnote}`;
756
770
  }
757
- return `Your subscription auto-renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${ctx.periodText} on ${trialDateText} when your paid trial ends, until cancelled{{liSeparator}}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime}${ctx.taxFootnote}`;
771
+ return `Your subscription auto-renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${ctx.periodText} on ${trialDateText} when your paid trial ends, until cancelled${LI_SEPARATOR}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime}${ctx.taxFootnote}`;
758
772
  }
759
773
  function autoRenewalTerms(ctx) {
760
774
  if (ctx.isUS) {
761
- return `Your subscription auto-renews ${ctx.periodText} until cancelled{{liSeparator}}Your subscription renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${ctx.renewalDateStr}{{liSeparator}}You\u2019ll be charged the rate in effect at each renewal until cancelled. ${ctx.usCancelNote}${ctx.taxFootnote}`;
775
+ return `Your subscription auto-renews ${ctx.periodText} until cancelled${LI_SEPARATOR}Your subscription renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${ctx.renewalDateStr}${LI_SEPARATOR}You\u2019ll be charged the rate in effect at each renewal until cancelled. ${ctx.usCancelNote}${ctx.taxFootnote}`;
762
776
  }
763
- return `Your subscription auto-renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${ctx.periodText} ${ctx.renewalDateStr} until cancelled{{liSeparator}}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime}${ctx.taxFootnote}`;
777
+ return `Your subscription auto-renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${ctx.periodText} ${ctx.renewalDateStr} until cancelled${LI_SEPARATOR}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime}${ctx.taxFootnote}`;
764
778
  }
765
779
  function noAutoRenewalTerms(ctx) {
766
780
  if (ctx.isUS || ctx.isCA) {
767
- return `Your subscription does not renew automatically${ctx.taxFootnote}{{liSeparator}}`;
781
+ return `Your subscription does not renew automatically${ctx.taxFootnote}${LI_SEPARATOR}`;
768
782
  }
769
- return `Your subscription does not renew automatically{{liSeparator}}`;
783
+ return `Your subscription does not renew automatically${LI_SEPARATOR}`;
770
784
  }
771
785
  function generateApplePayModalTerms(offer, country) {
772
786
  const ctx = buildTermsContext(offer, country);
@@ -789,9 +803,9 @@ function generateApplePayModalTerms(offer, country) {
789
803
  return noAutoRenewalTerms(ctx);
790
804
  }
791
805
  function renderTermsHtml(termsText) {
792
- const renewalTextLists = termsText.split("{{liSeparator}}");
806
+ const renewalTextLists = termsText.split(LI_SEPARATOR);
793
807
  const lastPart = renewalTextLists.pop() || "";
794
- const renewalTextParagraphs = lastPart.split("{{pSeparator}}");
808
+ const renewalTextParagraphs = lastPart.split(P_SEPARATOR);
795
809
  const ulHtml = `<ul class="apm__terms-bullets">${renewalTextLists.map((value) => `<li>${value}</li>`).join("")}</ul>`;
796
810
  const paragraphHtml = renewalTextParagraphs.filter(Boolean).map((value) => `<p class="apm__terms-legal">${value}</p>`).join("");
797
811
  return ulHtml + paragraphHtml;
@@ -1034,8 +1048,8 @@ var apple_pay_button_template_default = `<style>
1034
1048
  min-width: 0;
1035
1049
  height: 100%;
1036
1050
  min-height: var(--apple-pay-height, 2.75rem);
1037
- background-color: #000;
1038
- color: #fff;
1051
+ background-color: var(--apple-pay-background-color, #000);
1052
+ color: var(--apple-pay-foreground-color, #fff);
1039
1053
  border: none;
1040
1054
  border-radius: var(--apple-pay-border-radius, 1.375rem);
1041
1055
  cursor: pointer;
@@ -1047,6 +1061,7 @@ var apple_pay_button_template_default = `<style>
1047
1061
  teg-apple-pay-button .apple-pay-btn svg {
1048
1062
  flex-shrink: 0;
1049
1063
  display: block;
1064
+ color: currentColor;
1050
1065
  }
1051
1066
 
1052
1067
  teg-apple-pay-button .apple-pay-btn.wap-loading {
@@ -1061,8 +1076,8 @@ var apple_pay_button_template_default = `<style>
1061
1076
  left: 50%;
1062
1077
  width: 1.25rem;
1063
1078
  height: 1.25rem;
1064
- border: 2px solid rgba(255, 255, 255, 0.25);
1065
- border-top-color: #fff;
1079
+ border: 2px solid var(--apple-pay-spinner-track-color, rgba(255, 255, 255, 0.25));
1080
+ border-top-color: var(--apple-pay-spinner-head-color, currentColor);
1066
1081
  border-radius: 50%;
1067
1082
  animation: wap-button-spinner 0.8s linear infinite;
1068
1083
  }
@@ -1226,13 +1241,25 @@ var getExpressCheckoutSession = () => {
1226
1241
  };
1227
1242
 
1228
1243
  // src/utils/expressCheckoutRedirect.ts
1229
- var captureOriginUrl = () => window.location.href;
1230
- var buildQueryString = () => {
1231
- const countryCode = new URLSearchParams(window.location.search).get(
1232
- "country"
1233
- );
1234
- return countryCode ? `&country=${encodeURIComponent(countryCode)}` : "";
1244
+ var CHECKOUT_REDIRECT_KEY = "checkout-redirect";
1245
+ var ALLOWED_REDIRECT_HOSTNAME = "economist.com";
1246
+ function isAllowedRedirectUrl(url) {
1247
+ if (url.startsWith("/")) return !url.startsWith("//");
1248
+ try {
1249
+ const { hostname } = new URL(url);
1250
+ return hostname === ALLOWED_REDIRECT_HOSTNAME || hostname.endsWith(`.${ALLOWED_REDIRECT_HOSTNAME}`);
1251
+ } catch {
1252
+ return false;
1253
+ }
1254
+ }
1255
+ var writeCheckoutRedirect = (originUrl) => {
1256
+ if (!isAllowedRedirectUrl(originUrl)) return;
1257
+ try {
1258
+ localStorage.setItem(CHECKOUT_REDIRECT_KEY, originUrl);
1259
+ } catch {
1260
+ }
1235
1261
  };
1262
+ var captureOriginUrl = () => window.location.href;
1236
1263
  var decodeSku = (sku) => {
1237
1264
  try {
1238
1265
  return atob(sku.substring(sku.indexOf("-") + 1));
@@ -1243,14 +1270,11 @@ var decodeSku = (sku) => {
1243
1270
  var redirectToCheckoutComplete = (params) => {
1244
1271
  const url = new URL("/checkout/complete", window.location.origin);
1245
1272
  url.searchParams.set("basketId", params.basketId);
1246
- if (params.queryString) {
1247
- const qs = params.queryString.startsWith("?") ? params.queryString.slice(1) : params.queryString;
1248
- new URLSearchParams(qs).forEach((v, k) => url.searchParams.set(k, v));
1249
- }
1250
1273
  url.searchParams.set("lmo_offer", params.skuId);
1251
1274
  url.searchParams.set("status", params.status);
1252
1275
  url.searchParams.set("redirectToCheckout", "true");
1253
- url.searchParams.set("returnUrl", params.returnUrl);
1276
+ if (params.email) url.searchParams.set("email", params.email);
1277
+ if (params.country) url.searchParams.set("country", params.country);
1254
1278
  return url.pathname + url.search;
1255
1279
  };
1256
1280
  var redirectToCheckoutFallback = (params) => {
@@ -1261,7 +1285,7 @@ var redirectToCheckoutFallback = (params) => {
1261
1285
  url.searchParams.set("inlineError", params.inlineError);
1262
1286
  if (params.email) url.searchParams.set("email", params.email);
1263
1287
  if (params.emailError) url.searchParams.set("emailError", params.emailError);
1264
- url.searchParams.set("returnUrl", params.returnUrl);
1288
+ if (params.country) url.searchParams.set("country", params.country);
1265
1289
  return url.pathname + url.search;
1266
1290
  };
1267
1291
 
@@ -1345,17 +1369,16 @@ var MSG_EMAIL_WRONG_FORMAT = "That email doesn\u2019t look right. Please enter a
1345
1369
  var MSG_EMAIL_TOO_LONG = "This field must be 80 characters or less.";
1346
1370
  var MSG_UNSUPPORTED_BILLING_COUNTRY = "Billing country does not match offer price zone";
1347
1371
  var MSG_PAYMENT_GENERIC_ERROR = "Something went wrong. Please check your payment and billing details and try again or contact us.";
1348
- var MSG_RECAPTCHA_VALIDATION_FAILED = "Security check failed. Please try again.";
1349
- var MSG_EMAIL_COLLISION = "This email address is already linked to an account. Please log in, or try a different email address.";
1350
1372
  var MSG_CONTACT_VALIDATION_INTERNAL = "Could not validate Apple Pay contact";
1351
1373
 
1352
1374
  // src/clients/payment-checkout/apple-session.ts
1353
1375
  function redirectToFallbackCheckout(config) {
1376
+ writeCheckoutRedirect(config.returnUrl);
1354
1377
  trackFallbackCheckout(config.skuId);
1355
1378
  window.location.href = redirectToCheckoutFallback({
1356
1379
  skuId: config.skuId,
1357
- returnUrl: config.returnUrl,
1358
- inlineError: MSG_PAYMENT_GENERIC_ERROR
1380
+ inlineError: MSG_PAYMENT_GENERIC_ERROR,
1381
+ country: config.countryCode
1359
1382
  });
1360
1383
  }
1361
1384
  async function handleMerchantValidation(event, session, config) {
@@ -1534,8 +1557,6 @@ var shippingContactDetails = (shippingContact) => {
1534
1557
  };
1535
1558
 
1536
1559
  // src/clients/payment-checkout/payment-handler.ts
1537
- var MSG_ELIGIBILITY = "Something went wrong, please try again";
1538
- var MSG_REGISTRATION = "We couldn't create your account. Please enter your email or try a different login method.";
1539
1560
  var failApplePaySession = (session, errors = []) => {
1540
1561
  session.completePayment({
1541
1562
  status: ApplePaySession.STATUS_FAILURE,
@@ -1559,37 +1580,42 @@ function validateContacts(event, sessionData, supportedBillingCountries) {
1559
1580
  }
1560
1581
  return void 0;
1561
1582
  }
1562
- function redirectFallback(skuId, returnUrl, options) {
1583
+ function redirectFallback(skuId, returnUrl, country, options) {
1584
+ writeCheckoutRedirect(returnUrl);
1563
1585
  trackFallbackCheckout(skuId);
1564
1586
  window.location.href = redirectToCheckoutFallback({
1565
1587
  skuId,
1566
- returnUrl,
1588
+ country,
1567
1589
  ...options
1568
1590
  });
1569
1591
  }
1570
1592
  var ERROR_HANDLERS = {
1571
- EMAIL_COLLISION: ({ skuId, returnUrl, validatedEmail }) => redirectFallback(skuId, returnUrl, {
1572
- emailError: MSG_EMAIL_COLLISION,
1593
+ // emailError flows as an inline field error on the email input.
1594
+ // email pre-populates the input so the user doesn't have to retype it.
1595
+ EMAIL_COLLISION: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
1596
+ emailError: walletError.message,
1597
+ email: validatedEmail
1598
+ }),
1599
+ PAYMENT_DECLINED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
1600
+ ELIGIBILITY_REJECTED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
1601
+ REGISTRATION_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
1602
+ ACCOUNT_CREATION_FAILED: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
1603
+ emailError: walletError.message,
1573
1604
  email: validatedEmail
1574
1605
  }),
1575
- PAYMENT_DECLINED: ({ skuId, returnUrl }) => (
1576
- // Matches sma-checkout catch-all: always redirect with generic inlineError.
1577
- redirectFallback(skuId, returnUrl, { inlineError: MSG_PAYMENT_GENERIC_ERROR })
1578
- ),
1579
- ELIGIBILITY_REJECTED: ({ skuId, returnUrl }) => redirectFallback(skuId, returnUrl, { inlineError: MSG_ELIGIBILITY }),
1580
- REGISTRATION_FAILED: ({ skuId, returnUrl }) => redirectFallback(skuId, returnUrl, { inlineError: MSG_REGISTRATION }),
1581
- VALIDATION_ERROR: ({ skuId, returnUrl }) => redirectFallback(skuId, returnUrl, { inlineError: MSG_RECAPTCHA_VALIDATION_FAILED })
1606
+ VALIDATION_ERROR: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
1607
+ RECAPTCHA_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message })
1582
1608
  };
1583
1609
  function handleStructuredError(ctx) {
1584
1610
  const handler = ERROR_HANDLERS[ctx.walletError.errorType];
1585
1611
  if (handler) {
1586
1612
  handler(ctx);
1587
1613
  } else {
1588
- redirectFallback(ctx.skuId, ctx.returnUrl, { inlineError: MSG_PAYMENT_GENERIC_ERROR });
1614
+ redirectFallback(ctx.skuId, ctx.returnUrl, ctx.country, { inlineError: MSG_PAYMENT_GENERIC_ERROR });
1589
1615
  }
1590
1616
  }
1591
1617
  async function handlePaymentAuthorized(event, session, sessionData, config) {
1592
- const { skuId, returnUrl, queryString } = config;
1618
+ const { skuId, returnUrl, country } = config;
1593
1619
  let validatedEmail;
1594
1620
  try {
1595
1621
  validatedEmail = validateContacts(
@@ -1609,13 +1635,15 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
1609
1635
  });
1610
1636
  trackWalletPaymentSuccess(skuId, result.basketId);
1611
1637
  session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
1638
+ const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
1612
1639
  const userStatus = sessionData.loggedIn ? "lex" : "nex";
1640
+ writeCheckoutRedirect(returnUrl);
1613
1641
  window.location.href = redirectToCheckoutComplete({
1614
1642
  basketId: result.basketId,
1615
1643
  status: userStatus,
1616
1644
  skuId: decodeSku(skuId),
1617
- returnUrl,
1618
- queryString
1645
+ email: successEmail,
1646
+ country
1619
1647
  });
1620
1648
  } catch (err) {
1621
1649
  if (err instanceof ContactValidationError) {
@@ -1627,10 +1655,10 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
1627
1655
  trackWalletPaymentFailure(skuId, walletError?.errorType ?? "UNKNOWN");
1628
1656
  failApplePaySession(session);
1629
1657
  if (!walletError) {
1630
- redirectFallback(skuId, returnUrl, { inlineError: MSG_PAYMENT_GENERIC_ERROR });
1658
+ redirectFallback(skuId, returnUrl, country, { inlineError: MSG_PAYMENT_GENERIC_ERROR });
1631
1659
  return;
1632
1660
  }
1633
- handleStructuredError({ skuId, returnUrl, validatedEmail, walletError });
1661
+ handleStructuredError({ skuId, returnUrl, country, validatedEmail, walletError });
1634
1662
  }
1635
1663
  }
1636
1664
 
@@ -2216,7 +2244,6 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2216
2244
  country,
2217
2245
  currency: offer.price?.currency_code ?? DEFAULT_CURRENCY,
2218
2246
  returnUrl: this.#returnUrl,
2219
- queryString: buildQueryString(),
2220
2247
  supportedBillingCountries: this.#supportedBillingCountries,
2221
2248
  recaptchaTokens
2222
2249
  })
@@ -6,7 +6,7 @@ function ensureApplePayLogoSymbol() {
6
6
  return;
7
7
  }
8
8
  const tmp = document.createElement("div");
9
- tmp.innerHTML = `<svg aria-hidden="true" style="display:none" id="${LOGO_DEFS_ID}"><defs><symbol id="apple-pay-logo" viewBox="0 0 51 22"><path d="${LOGO_PATH}" fill="white"/></symbol></defs></svg>`;
9
+ tmp.innerHTML = `<svg aria-hidden="true" style="display:none" id="${LOGO_DEFS_ID}"><defs><symbol id="apple-pay-logo" viewBox="0 0 51 22"><path d="${LOGO_PATH}" fill="currentColor"/></symbol></defs></svg>`;
10
10
  document.body.prepend(tmp.firstElementChild);
11
11
  }
12
12
  export {
@@ -71,7 +71,7 @@ function ensureApplePayLogoSymbol() {
71
71
  return;
72
72
  }
73
73
  const tmp = document.createElement("div");
74
- tmp.innerHTML = `<svg aria-hidden="true" style="display:none" id="${LOGO_DEFS_ID}"><defs><symbol id="apple-pay-logo" viewBox="0 0 51 22"><path d="${LOGO_PATH}" fill="white"/></symbol></defs></svg>`;
74
+ tmp.innerHTML = `<svg aria-hidden="true" style="display:none" id="${LOGO_DEFS_ID}"><defs><symbol id="apple-pay-logo" viewBox="0 0 51 22"><path d="${LOGO_PATH}" fill="currentColor"/></symbol></defs></svg>`;
75
75
  document.body.prepend(tmp.firstElementChild);
76
76
  }
77
77
 
@@ -109,16 +109,32 @@ var apple_pay_modal_template_default = `<style>
109
109
  position: absolute;
110
110
  top: 1.5rem;
111
111
  right: 1.3125rem;
112
- background: none;
112
+ background: transparent;
113
113
  border: none;
114
114
  cursor: pointer;
115
115
  padding: 0;
116
+ width: 1.5rem;
117
+ height: 1.5rem;
116
118
  display: flex;
117
119
  align-items: center;
118
120
  justify-content: center;
121
+ color: var(--mb-colour-greyscale-london-20, #1a1a1a);
122
+ transition:
123
+ background-color ease-in-out 0.2s,
124
+ color ease-in-out 0.2s;
125
+ }
126
+
127
+ .apm__close:hover {
128
+ color: var(--mb-colour-base-chicago-30, #333333);
129
+ }
130
+
131
+ .apm__close:active {
132
+ background-color: var(--mb-colour-base-chicago-90, #e6e6e6);
133
+ color: var(--mb-colour-base-chicago-30, #333333);
119
134
  }
120
135
 
121
136
  .apm__close:focus {
137
+ background-color: var(--mb-colour-base-chicago-90, #e6e6e6);
122
138
  outline: solid 0.125rem var(--focus-border-color, #121212);
123
139
  border-radius: 0.25rem;
124
140
  }
@@ -301,10 +317,6 @@ var apple_pay_modal_template_default = `<style>
301
317
  cursor: pointer;
302
318
  color: #fff;
303
319
  text-align: center;
304
- font-family: var(
305
- --mb-typeface-sans,
306
- var(--wall-type-system-sans, system-ui, sans-serif)
307
- );
308
320
  font-size: 1.25rem;
309
321
  font-style: normal;
310
322
  font-weight: 500;
@@ -421,7 +433,7 @@ var apple_pay_modal_template_default = `<style>
421
433
  fill-rule="evenodd"
422
434
  clip-rule="evenodd"
423
435
  d="M18.75 6.60964L17.3904 5.25L12 10.6404L6.60964 5.25L5.25 6.60964L10.6404 12L5.25 17.3904L6.60964 18.75L12 13.3596L17.3904 18.75L18.75 17.3904L13.3596 12L18.75 6.60964Z"
424
- fill="#333333"
436
+ fill="currentColor"
425
437
  />
426
438
  </g>
427
439
  <defs>
@@ -679,6 +691,8 @@ function renewalPeriodText(unit, duration) {
679
691
  return "";
680
692
  }
681
693
  }
694
+ var LI_SEPARATOR = "\0LI_SEP\0";
695
+ var P_SEPARATOR = "\0P_SEP\0";
682
696
  function buildTermsContext(offer, country) {
683
697
  const isUS = country === "US";
684
698
  const isCA = country === "CA";
@@ -715,19 +729,19 @@ function freeTrialTerms(offer, ctx) {
715
729
  const trialDuration = offer.subscription_options?.trial_period?.duration ?? 1;
716
730
  const trialDateStr = `on ${getRenewalDateText(trialUnit, trialDuration)}${ctx.verificationText}`;
717
731
  if (ctx.isUS) {
718
- return `Your subscription renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${trialDateStr} when your free trial ends, until cancelled{{liSeparator}}You\u2019ll be charged the rate in effect at each renewal until cancelled. ${ctx.usCancelNote}${ctx.taxFootnote}`;
732
+ return `Your subscription renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${trialDateStr} when your free trial ends, until cancelled${LI_SEPARATOR}You\u2019ll be charged the rate in effect at each renewal until cancelled. ${ctx.usCancelNote}${ctx.taxFootnote}`;
719
733
  }
720
- return `Your subscription renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${trialDateStr} when your free trial ends, until cancelled{{liSeparator}}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime}${ctx.taxFootnote}`;
734
+ return `Your subscription renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${trialDateStr} when your free trial ends, until cancelled${LI_SEPARATOR}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime}${ctx.taxFootnote}`;
721
735
  }
722
736
  function nytTerms(ctx) {
723
737
  const nytAccessText = "Your complimentary access to The New York Times is for one year only and does not auto-renew. We will send your instructions on how to redeem access to The New York Times by email.";
724
738
  if (ctx.isUS) {
725
- return `Your subscription to <em>The Economist</em> auto-renews ${ctx.periodText} until cancelled{{liSeparator}}Your subscription renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${ctx.renewalDateStr}{{liSeparator}}You\u2019ll be charged the rate in effect at each renewal until cancelled. ${ctx.usCancelNote}${ctx.taxFootnote}{{pSeparator}}${nytAccessText}`;
739
+ return `Your subscription to <em>The Economist</em> auto-renews ${ctx.periodText} until cancelled${LI_SEPARATOR}Your subscription renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${ctx.renewalDateStr}${LI_SEPARATOR}You\u2019ll be charged the rate in effect at each renewal until cancelled. ${ctx.usCancelNote}${ctx.taxFootnote}${P_SEPARATOR}${nytAccessText}`;
726
740
  }
727
741
  if (ctx.isCA) {
728
- return `Your subscription to <em>The Economist</em> auto-renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${ctx.periodText} ${ctx.renewalDateStr} until cancelled.{{liSeparator}}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime}${ctx.taxFootnote}{{pSeparator}}${nytAccessText}`;
742
+ return `Your subscription to <em>The Economist</em> auto-renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${ctx.periodText} ${ctx.renewalDateStr} until cancelled.${LI_SEPARATOR}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime}${ctx.taxFootnote}${P_SEPARATOR}${nytAccessText}`;
729
743
  }
730
- return `Your subscription to <em>The Economist</em> auto-renews at ${ctx.renewalPriceText} ${ctx.periodText} ${ctx.renewalDateStr} until cancelled{{liSeparator}}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime} ${nytAccessText}`;
744
+ return `Your subscription to <em>The Economist</em> auto-renews at ${ctx.renewalPriceText} ${ctx.periodText} ${ctx.renewalDateStr} until cancelled${LI_SEPARATOR}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime} ${nytAccessText}`;
731
745
  }
732
746
  function minTermContractTerms(offer, ctx) {
733
747
  const duePrice = formatPrice(offer.price.purchase, offer.price.currency_code);
@@ -737,28 +751,28 @@ function minTermContractTerms(offer, ctx) {
737
751
  const contractLength = mtDuration && mtUnit ? `${mtDuration} ${mtUnit}` : "";
738
752
  const initialContractText = contractLength ? `your initial ${contractLength} contract` : "your initial contract";
739
753
  const mtRenewalDateText = mtUnit && mtDuration ? getRenewalDateText(mtUnit, Number(mtDuration)) : ctx.renewalDateText;
740
- return `You\u2019ll be charged ${duePrice} a month for the duration of ${initialContractText}{{liSeparator}}Your subscription auto-renews annually at ${ctx.renewalPriceText} a month on ${mtRenewalDateText} until cancelled{{liSeparator}}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime}`;
754
+ return `You\u2019ll be charged ${duePrice} a month for the duration of ${initialContractText}${LI_SEPARATOR}Your subscription auto-renews annually at ${ctx.renewalPriceText} a month on ${mtRenewalDateText} until cancelled${LI_SEPARATOR}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime}`;
741
755
  }
742
756
  function paidTrialTerms(offer, ctx) {
743
757
  const trialUnit = offer.subscription_options?.trial_period?.unit ?? ctx.unit;
744
758
  const trialDuration = offer.subscription_options?.trial_period?.duration ?? ctx.duration;
745
759
  const trialDateText = getRenewalDateText(trialUnit, trialDuration);
746
760
  if (ctx.isUS) {
747
- return `Your subscription auto-renews ${ctx.periodText} until cancelled{{liSeparator}}Your subscription renews at ${ctx.renewalPriceText}${ctx.taxSuffix} on ${trialDateText} when your paid trial ends{{liSeparator}}You\u2019ll be charged the rate in effect at each renewal. ${ctx.usCancelNote}${ctx.taxFootnote}`;
761
+ return `Your subscription auto-renews ${ctx.periodText} until cancelled${LI_SEPARATOR}Your subscription renews at ${ctx.renewalPriceText}${ctx.taxSuffix} on ${trialDateText} when your paid trial ends${LI_SEPARATOR}You\u2019ll be charged the rate in effect at each renewal. ${ctx.usCancelNote}${ctx.taxFootnote}`;
748
762
  }
749
- return `Your subscription auto-renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${ctx.periodText} on ${trialDateText} when your paid trial ends, until cancelled{{liSeparator}}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime}${ctx.taxFootnote}`;
763
+ return `Your subscription auto-renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${ctx.periodText} on ${trialDateText} when your paid trial ends, until cancelled${LI_SEPARATOR}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime}${ctx.taxFootnote}`;
750
764
  }
751
765
  function autoRenewalTerms(ctx) {
752
766
  if (ctx.isUS) {
753
- return `Your subscription auto-renews ${ctx.periodText} until cancelled{{liSeparator}}Your subscription renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${ctx.renewalDateStr}{{liSeparator}}You\u2019ll be charged the rate in effect at each renewal until cancelled. ${ctx.usCancelNote}${ctx.taxFootnote}`;
767
+ return `Your subscription auto-renews ${ctx.periodText} until cancelled${LI_SEPARATOR}Your subscription renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${ctx.renewalDateStr}${LI_SEPARATOR}You\u2019ll be charged the rate in effect at each renewal until cancelled. ${ctx.usCancelNote}${ctx.taxFootnote}`;
754
768
  }
755
- return `Your subscription auto-renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${ctx.periodText} ${ctx.renewalDateStr} until cancelled{{liSeparator}}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime}${ctx.taxFootnote}`;
769
+ return `Your subscription auto-renews at ${ctx.renewalPriceText}${ctx.taxSuffix} ${ctx.periodText} ${ctx.renewalDateStr} until cancelled${LI_SEPARATOR}You\u2019ll be charged the rate in effect at each renewal. ${ctx.cancelAnytime}${ctx.taxFootnote}`;
756
770
  }
757
771
  function noAutoRenewalTerms(ctx) {
758
772
  if (ctx.isUS || ctx.isCA) {
759
- return `Your subscription does not renew automatically${ctx.taxFootnote}{{liSeparator}}`;
773
+ return `Your subscription does not renew automatically${ctx.taxFootnote}${LI_SEPARATOR}`;
760
774
  }
761
- return `Your subscription does not renew automatically{{liSeparator}}`;
775
+ return `Your subscription does not renew automatically${LI_SEPARATOR}`;
762
776
  }
763
777
  function generateApplePayModalTerms(offer, country) {
764
778
  const ctx = buildTermsContext(offer, country);
@@ -781,9 +795,9 @@ function generateApplePayModalTerms(offer, country) {
781
795
  return noAutoRenewalTerms(ctx);
782
796
  }
783
797
  function renderTermsHtml(termsText) {
784
- const renewalTextLists = termsText.split("{{liSeparator}}");
798
+ const renewalTextLists = termsText.split(LI_SEPARATOR);
785
799
  const lastPart = renewalTextLists.pop() || "";
786
- const renewalTextParagraphs = lastPart.split("{{pSeparator}}");
800
+ const renewalTextParagraphs = lastPart.split(P_SEPARATOR);
787
801
  const ulHtml = `<ul class="apm__terms-bullets">${renewalTextLists.map((value) => `<li>${value}</li>`).join("")}</ul>`;
788
802
  const paragraphHtml = renewalTextParagraphs.filter(Boolean).map((value) => `<p class="apm__terms-legal">${value}</p>`).join("");
789
803
  return ulHtml + paragraphHtml;