@economist/web-apple-pay 1.7.5 → 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;
@@ -320,28 +332,41 @@ var apple_pay_modal_template_default = `<style>
320
332
  cursor: not-allowed;
321
333
  }
322
334
 
323
- .apm__cta[aria-busy="true"] > * {
324
- visibility: hidden;
335
+ .apm__cta-content {
336
+ display: flex;
337
+ align-items: center;
338
+ gap: 0.375rem;
339
+ }
340
+
341
+ .apm__cta-label {
342
+ display: inline-flex;
343
+ align-items: center;
344
+ gap: 0.375rem;
345
+ }
346
+
347
+ .apm__cta-loading {
348
+ display: none;
325
349
  }
326
350
 
327
- .apm__cta[aria-busy="true"]::after {
351
+ .apm__cta[aria-busy="true"]::before {
328
352
  content: '';
329
353
  position: absolute;
330
- left: 50%;
331
354
  top: 50%;
332
- margin-left: -0.625rem;
333
- margin-top: -0.625rem;
355
+ left: 50%;
334
356
  width: 1.25rem;
335
357
  height: 1.25rem;
336
- border: 2px solid rgba(255, 255, 255, 0.2);
358
+ border: 2px solid rgba(255, 255, 255, 0.25);
337
359
  border-top-color: #fff;
338
360
  border-radius: 50%;
339
361
  animation: apm-cta-spinner 0.8s linear infinite;
340
362
  }
341
363
 
342
364
  @keyframes apm-cta-spinner {
365
+ from {
366
+ transform: translate(-50%, -50%) rotate(0deg);
367
+ }
343
368
  to {
344
- transform: rotate(360deg);
369
+ transform: translate(-50%, -50%) rotate(360deg);
345
370
  }
346
371
  }
347
372
 
@@ -408,7 +433,7 @@ var apple_pay_modal_template_default = `<style>
408
433
  fill-rule="evenodd"
409
434
  clip-rule="evenodd"
410
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"
411
- fill="#333333"
436
+ fill="currentColor"
412
437
  />
413
438
  </g>
414
439
  <defs>
@@ -518,11 +543,14 @@ var apple_pay_modal_template_default = `<style>
518
543
  </div>
519
544
  <button class="apm__cta" id="apple-pay-modal-cta" aria-label="Continue with Apple Pay">
520
545
  <span class="apm__cta-content">
521
- Continue with
522
- <svg width="51" height="22" aria-hidden="true" role="img">
523
- <use href="#apple-pay-logo" />
524
- </svg>
546
+ <span class="apm__cta-label">
547
+ Continue with
548
+ <svg width="51" height="22" aria-hidden="true" role="img">
549
+ <use href="#apple-pay-logo" />
550
+ </svg>
551
+ </span>
525
552
  </span>
553
+ <span class="apm__cta-loading" aria-hidden="true">Loading...</span>
526
554
  </button>
527
555
  </div>
528
556
  </div>
@@ -663,6 +691,8 @@ function renewalPeriodText(unit, duration) {
663
691
  return "";
664
692
  }
665
693
  }
694
+ var LI_SEPARATOR = "\0LI_SEP\0";
695
+ var P_SEPARATOR = "\0P_SEP\0";
666
696
  function buildTermsContext(offer, country) {
667
697
  const isUS = country === "US";
668
698
  const isCA = country === "CA";
@@ -699,19 +729,19 @@ function freeTrialTerms(offer, ctx) {
699
729
  const trialDuration = offer.subscription_options?.trial_period?.duration ?? 1;
700
730
  const trialDateStr = `on ${getRenewalDateText(trialUnit, trialDuration)}${ctx.verificationText}`;
701
731
  if (ctx.isUS) {
702
- 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}`;
703
733
  }
704
- 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}`;
705
735
  }
706
736
  function nytTerms(ctx) {
707
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.";
708
738
  if (ctx.isUS) {
709
- 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}`;
710
740
  }
711
741
  if (ctx.isCA) {
712
- 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}`;
713
743
  }
714
- 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}`;
715
745
  }
716
746
  function minTermContractTerms(offer, ctx) {
717
747
  const duePrice = formatPrice(offer.price.purchase, offer.price.currency_code);
@@ -721,28 +751,28 @@ function minTermContractTerms(offer, ctx) {
721
751
  const contractLength = mtDuration && mtUnit ? `${mtDuration} ${mtUnit}` : "";
722
752
  const initialContractText = contractLength ? `your initial ${contractLength} contract` : "your initial contract";
723
753
  const mtRenewalDateText = mtUnit && mtDuration ? getRenewalDateText(mtUnit, Number(mtDuration)) : ctx.renewalDateText;
724
- 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}`;
725
755
  }
726
756
  function paidTrialTerms(offer, ctx) {
727
757
  const trialUnit = offer.subscription_options?.trial_period?.unit ?? ctx.unit;
728
758
  const trialDuration = offer.subscription_options?.trial_period?.duration ?? ctx.duration;
729
759
  const trialDateText = getRenewalDateText(trialUnit, trialDuration);
730
760
  if (ctx.isUS) {
731
- 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}`;
732
762
  }
733
- 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}`;
734
764
  }
735
765
  function autoRenewalTerms(ctx) {
736
766
  if (ctx.isUS) {
737
- 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}`;
738
768
  }
739
- 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}`;
740
770
  }
741
771
  function noAutoRenewalTerms(ctx) {
742
772
  if (ctx.isUS || ctx.isCA) {
743
- return `Your subscription does not renew automatically${ctx.taxFootnote}{{liSeparator}}`;
773
+ return `Your subscription does not renew automatically${ctx.taxFootnote}${LI_SEPARATOR}`;
744
774
  }
745
- return `Your subscription does not renew automatically{{liSeparator}}`;
775
+ return `Your subscription does not renew automatically${LI_SEPARATOR}`;
746
776
  }
747
777
  function generateApplePayModalTerms(offer, country) {
748
778
  const ctx = buildTermsContext(offer, country);
@@ -765,9 +795,9 @@ function generateApplePayModalTerms(offer, country) {
765
795
  return noAutoRenewalTerms(ctx);
766
796
  }
767
797
  function renderTermsHtml(termsText) {
768
- const renewalTextLists = termsText.split("{{liSeparator}}");
798
+ const renewalTextLists = termsText.split(LI_SEPARATOR);
769
799
  const lastPart = renewalTextLists.pop() || "";
770
- const renewalTextParagraphs = lastPart.split("{{pSeparator}}");
800
+ const renewalTextParagraphs = lastPart.split(P_SEPARATOR);
771
801
  const ulHtml = `<ul class="apm__terms-bullets">${renewalTextLists.map((value) => `<li>${value}</li>`).join("")}</ul>`;
772
802
  const paragraphHtml = renewalTextParagraphs.filter(Boolean).map((value) => `<p class="apm__terms-legal">${value}</p>`).join("");
773
803
  return ulHtml + paragraphHtml;
@@ -1010,8 +1040,8 @@ var apple_pay_button_template_default = `<style>
1010
1040
  min-width: 0;
1011
1041
  height: 100%;
1012
1042
  min-height: var(--apple-pay-height, 2.75rem);
1013
- background-color: #000;
1014
- color: #fff;
1043
+ background-color: var(--apple-pay-background-color, #000);
1044
+ color: var(--apple-pay-foreground-color, #fff);
1015
1045
  border: none;
1016
1046
  border-radius: var(--apple-pay-border-radius, 1.375rem);
1017
1047
  cursor: pointer;
@@ -1023,6 +1053,7 @@ var apple_pay_button_template_default = `<style>
1023
1053
  teg-apple-pay-button .apple-pay-btn svg {
1024
1054
  flex-shrink: 0;
1025
1055
  display: block;
1056
+ color: currentColor;
1026
1057
  }
1027
1058
 
1028
1059
  teg-apple-pay-button .apple-pay-btn.wap-loading {
@@ -1030,28 +1061,34 @@ var apple_pay_button_template_default = `<style>
1030
1061
  cursor: default;
1031
1062
  }
1032
1063
 
1033
- teg-apple-pay-button .apple-pay-btn.wap-loading svg {
1034
- visibility: hidden;
1035
- }
1036
-
1037
- teg-apple-pay-button .apple-pay-btn.wap-loading::after {
1064
+ teg-apple-pay-button .apple-pay-btn.wap-loading::before {
1038
1065
  content: '';
1039
1066
  position: absolute;
1040
- left: 50%;
1041
1067
  top: 50%;
1042
- margin-left: -0.625rem;
1043
- margin-top: -0.625rem;
1068
+ left: 50%;
1044
1069
  width: 1.25rem;
1045
1070
  height: 1.25rem;
1046
- border: 2px solid rgba(255, 255, 255, 0.2);
1047
- border-top-color: #fff;
1071
+ border: 2px solid var(--apple-pay-spinner-track-color, rgba(255, 255, 255, 0.25));
1072
+ border-top-color: var(--apple-pay-spinner-head-color, currentColor);
1048
1073
  border-radius: 50%;
1049
1074
  animation: wap-button-spinner 0.8s linear infinite;
1050
1075
  }
1051
1076
 
1077
+ teg-apple-pay-button .apple-pay-btn__logo {
1078
+ display: inline-flex;
1079
+ align-items: center;
1080
+ }
1081
+
1082
+ teg-apple-pay-button .apple-pay-btn__loading {
1083
+ display: none;
1084
+ }
1085
+
1052
1086
  @keyframes wap-button-spinner {
1087
+ from {
1088
+ transform: translate(-50%, -50%) rotate(0deg);
1089
+ }
1053
1090
  to {
1054
- transform: rotate(360deg);
1091
+ transform: translate(-50%, -50%) rotate(360deg);
1055
1092
  }
1056
1093
  }
1057
1094
  </style>
@@ -1063,9 +1100,12 @@ var apple_pay_button_template_default = `<style>
1063
1100
  aria-label="Pay with Apple Pay"
1064
1101
  data-analytics="paywall:apple-pay-checkout"
1065
1102
  >
1066
- <svg width="51" height="22" aria-label="Apple Pay" role="img">
1067
- <use href="#apple-pay-logo" />
1068
- </svg>
1103
+ <span class="apple-pay-btn__logo">
1104
+ <svg width="51" height="22" aria-label="Apple Pay" role="img">
1105
+ <use href="#apple-pay-logo" />
1106
+ </svg>
1107
+ </span>
1108
+ <span class="apple-pay-btn__loading" aria-hidden="true">Loading...</span>
1069
1109
  </button>
1070
1110
  </div>
1071
1111
  `;
@@ -1193,13 +1233,25 @@ var getExpressCheckoutSession = () => {
1193
1233
  };
1194
1234
 
1195
1235
  // src/utils/expressCheckoutRedirect.ts
1196
- var captureOriginUrl = () => window.location.href;
1197
- var buildQueryString = () => {
1198
- const countryCode = new URLSearchParams(window.location.search).get(
1199
- "country"
1200
- );
1201
- return countryCode ? `&country=${encodeURIComponent(countryCode)}` : "";
1236
+ var CHECKOUT_REDIRECT_KEY = "checkout-redirect";
1237
+ var ALLOWED_REDIRECT_HOSTNAME = "economist.com";
1238
+ function isAllowedRedirectUrl(url) {
1239
+ if (url.startsWith("/")) return !url.startsWith("//");
1240
+ try {
1241
+ const { hostname } = new URL(url);
1242
+ return hostname === ALLOWED_REDIRECT_HOSTNAME || hostname.endsWith(`.${ALLOWED_REDIRECT_HOSTNAME}`);
1243
+ } catch {
1244
+ return false;
1245
+ }
1246
+ }
1247
+ var writeCheckoutRedirect = (originUrl) => {
1248
+ if (!isAllowedRedirectUrl(originUrl)) return;
1249
+ try {
1250
+ localStorage.setItem(CHECKOUT_REDIRECT_KEY, originUrl);
1251
+ } catch {
1252
+ }
1202
1253
  };
1254
+ var captureOriginUrl = () => window.location.href;
1203
1255
  var decodeSku = (sku) => {
1204
1256
  try {
1205
1257
  return atob(sku.substring(sku.indexOf("-") + 1));
@@ -1210,14 +1262,11 @@ var decodeSku = (sku) => {
1210
1262
  var redirectToCheckoutComplete = (params) => {
1211
1263
  const url = new URL("/checkout/complete", window.location.origin);
1212
1264
  url.searchParams.set("basketId", params.basketId);
1213
- if (params.queryString) {
1214
- const qs = params.queryString.startsWith("?") ? params.queryString.slice(1) : params.queryString;
1215
- new URLSearchParams(qs).forEach((v, k) => url.searchParams.set(k, v));
1216
- }
1217
1265
  url.searchParams.set("lmo_offer", params.skuId);
1218
1266
  url.searchParams.set("status", params.status);
1219
1267
  url.searchParams.set("redirectToCheckout", "true");
1220
- url.searchParams.set("returnUrl", params.returnUrl);
1268
+ if (params.email) url.searchParams.set("email", params.email);
1269
+ if (params.country) url.searchParams.set("country", params.country);
1221
1270
  return url.pathname + url.search;
1222
1271
  };
1223
1272
  var redirectToCheckoutFallback = (params) => {
@@ -1228,7 +1277,7 @@ var redirectToCheckoutFallback = (params) => {
1228
1277
  url.searchParams.set("inlineError", params.inlineError);
1229
1278
  if (params.email) url.searchParams.set("email", params.email);
1230
1279
  if (params.emailError) url.searchParams.set("emailError", params.emailError);
1231
- url.searchParams.set("returnUrl", params.returnUrl);
1280
+ if (params.country) url.searchParams.set("country", params.country);
1232
1281
  return url.pathname + url.search;
1233
1282
  };
1234
1283
 
@@ -1312,17 +1361,16 @@ var MSG_EMAIL_WRONG_FORMAT = "That email doesn\u2019t look right. Please enter a
1312
1361
  var MSG_EMAIL_TOO_LONG = "This field must be 80 characters or less.";
1313
1362
  var MSG_UNSUPPORTED_BILLING_COUNTRY = "Billing country does not match offer price zone";
1314
1363
  var MSG_PAYMENT_GENERIC_ERROR = "Something went wrong. Please check your payment and billing details and try again or contact us.";
1315
- var MSG_RECAPTCHA_VALIDATION_FAILED = "Security check failed. Please try again.";
1316
- var MSG_EMAIL_COLLISION = "This email address is already linked to an account. Please log in, or try a different email address.";
1317
1364
  var MSG_CONTACT_VALIDATION_INTERNAL = "Could not validate Apple Pay contact";
1318
1365
 
1319
1366
  // src/clients/payment-checkout/apple-session.ts
1320
1367
  function redirectToFallbackCheckout(config) {
1368
+ writeCheckoutRedirect(config.returnUrl);
1321
1369
  trackFallbackCheckout(config.skuId);
1322
1370
  window.location.href = redirectToCheckoutFallback({
1323
1371
  skuId: config.skuId,
1324
- returnUrl: config.returnUrl,
1325
- inlineError: MSG_PAYMENT_GENERIC_ERROR
1372
+ inlineError: MSG_PAYMENT_GENERIC_ERROR,
1373
+ country: config.countryCode
1326
1374
  });
1327
1375
  }
1328
1376
  async function handleMerchantValidation(event, session, config) {
@@ -1501,8 +1549,6 @@ var shippingContactDetails = (shippingContact) => {
1501
1549
  };
1502
1550
 
1503
1551
  // src/clients/payment-checkout/payment-handler.ts
1504
- var MSG_ELIGIBILITY = "Something went wrong, please try again";
1505
- var MSG_REGISTRATION = "We couldn't create your account. Please enter your email or try a different login method.";
1506
1552
  var failApplePaySession = (session, errors = []) => {
1507
1553
  session.completePayment({
1508
1554
  status: ApplePaySession.STATUS_FAILURE,
@@ -1526,37 +1572,42 @@ function validateContacts(event, sessionData, supportedBillingCountries) {
1526
1572
  }
1527
1573
  return void 0;
1528
1574
  }
1529
- function redirectFallback(skuId, returnUrl, options) {
1575
+ function redirectFallback(skuId, returnUrl, country, options) {
1576
+ writeCheckoutRedirect(returnUrl);
1530
1577
  trackFallbackCheckout(skuId);
1531
1578
  window.location.href = redirectToCheckoutFallback({
1532
1579
  skuId,
1533
- returnUrl,
1580
+ country,
1534
1581
  ...options
1535
1582
  });
1536
1583
  }
1537
1584
  var ERROR_HANDLERS = {
1538
- EMAIL_COLLISION: ({ skuId, returnUrl, validatedEmail }) => redirectFallback(skuId, returnUrl, {
1539
- emailError: MSG_EMAIL_COLLISION,
1585
+ // emailError flows as an inline field error on the email input.
1586
+ // email pre-populates the input so the user doesn't have to retype it.
1587
+ EMAIL_COLLISION: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
1588
+ emailError: walletError.message,
1589
+ email: validatedEmail
1590
+ }),
1591
+ PAYMENT_DECLINED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
1592
+ ELIGIBILITY_REJECTED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
1593
+ REGISTRATION_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
1594
+ ACCOUNT_CREATION_FAILED: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
1595
+ emailError: walletError.message,
1540
1596
  email: validatedEmail
1541
1597
  }),
1542
- PAYMENT_DECLINED: ({ skuId, returnUrl }) => (
1543
- // Matches sma-checkout catch-all: always redirect with generic inlineError.
1544
- redirectFallback(skuId, returnUrl, { inlineError: MSG_PAYMENT_GENERIC_ERROR })
1545
- ),
1546
- ELIGIBILITY_REJECTED: ({ skuId, returnUrl }) => redirectFallback(skuId, returnUrl, { inlineError: MSG_ELIGIBILITY }),
1547
- REGISTRATION_FAILED: ({ skuId, returnUrl }) => redirectFallback(skuId, returnUrl, { inlineError: MSG_REGISTRATION }),
1548
- VALIDATION_ERROR: ({ skuId, returnUrl }) => redirectFallback(skuId, returnUrl, { inlineError: MSG_RECAPTCHA_VALIDATION_FAILED })
1598
+ VALIDATION_ERROR: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
1599
+ RECAPTCHA_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message })
1549
1600
  };
1550
1601
  function handleStructuredError(ctx) {
1551
1602
  const handler = ERROR_HANDLERS[ctx.walletError.errorType];
1552
1603
  if (handler) {
1553
1604
  handler(ctx);
1554
1605
  } else {
1555
- redirectFallback(ctx.skuId, ctx.returnUrl, { inlineError: MSG_PAYMENT_GENERIC_ERROR });
1606
+ redirectFallback(ctx.skuId, ctx.returnUrl, ctx.country, { inlineError: MSG_PAYMENT_GENERIC_ERROR });
1556
1607
  }
1557
1608
  }
1558
1609
  async function handlePaymentAuthorized(event, session, sessionData, config) {
1559
- const { skuId, returnUrl, queryString } = config;
1610
+ const { skuId, returnUrl, country } = config;
1560
1611
  let validatedEmail;
1561
1612
  try {
1562
1613
  validatedEmail = validateContacts(
@@ -1576,13 +1627,15 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
1576
1627
  });
1577
1628
  trackWalletPaymentSuccess(skuId, result.basketId);
1578
1629
  session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
1630
+ const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
1579
1631
  const userStatus = sessionData.loggedIn ? "lex" : "nex";
1632
+ writeCheckoutRedirect(returnUrl);
1580
1633
  window.location.href = redirectToCheckoutComplete({
1581
1634
  basketId: result.basketId,
1582
1635
  status: userStatus,
1583
1636
  skuId: decodeSku(skuId),
1584
- returnUrl,
1585
- queryString
1637
+ email: successEmail,
1638
+ country
1586
1639
  });
1587
1640
  } catch (err) {
1588
1641
  if (err instanceof ContactValidationError) {
@@ -1594,10 +1647,10 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
1594
1647
  trackWalletPaymentFailure(skuId, walletError?.errorType ?? "UNKNOWN");
1595
1648
  failApplePaySession(session);
1596
1649
  if (!walletError) {
1597
- redirectFallback(skuId, returnUrl, { inlineError: MSG_PAYMENT_GENERIC_ERROR });
1650
+ redirectFallback(skuId, returnUrl, country, { inlineError: MSG_PAYMENT_GENERIC_ERROR });
1598
1651
  return;
1599
1652
  }
1600
- handleStructuredError({ skuId, returnUrl, validatedEmail, walletError });
1653
+ handleStructuredError({ skuId, returnUrl, country, validatedEmail, walletError });
1601
1654
  }
1602
1655
  }
1603
1656
 
@@ -2183,7 +2236,6 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2183
2236
  country,
2184
2237
  currency: offer.price?.currency_code ?? DEFAULT_CURRENCY,
2185
2238
  returnUrl: this.#returnUrl,
2186
- queryString: buildQueryString(),
2187
2239
  supportedBillingCountries: this.#supportedBillingCountries,
2188
2240
  recaptchaTokens
2189
2241
  })