@economist/web-apple-pay 2.0.0-beta.1 → 2.0.0-beta.3
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 +34 -12
- package/dist/index.js +661 -351
- package/dist/src/apple-pay-button.d.ts +21 -14
- package/dist/src/apple-pay-button.js +650 -343
- package/dist/src/apple-pay-button.stories.js +647 -342
- package/dist/src/apple-pay-modal.js +44 -39
- package/dist/src/apple-pay-modal.stories.js +647 -342
- package/dist/src/clients/payment-checkout/apple-session.d.ts +14 -1
- package/dist/src/clients/payment-checkout/apple-session.js +46 -11
- package/dist/src/clients/payment-checkout/billing-contact-details.js +43 -0
- package/dist/src/clients/payment-checkout/delivery-contact-details.d.ts +16 -0
- package/dist/src/clients/payment-checkout/delivery-contact-details.js +395 -0
- package/dist/src/clients/payment-checkout/detects.d.ts +5 -0
- package/dist/src/clients/payment-checkout/detects.js +18 -14
- package/dist/src/clients/payment-checkout/messages.d.ts +6 -0
- package/dist/src/clients/payment-checkout/messages.js +7 -1
- package/dist/src/clients/payment-checkout/payment-handler.d.ts +10 -1
- package/dist/src/clients/payment-checkout/payment-handler.js +397 -30
- package/dist/src/clients/payment-checkout/session.js +13 -1
- package/dist/src/clients/payment-checkout/types.d.ts +7 -0
- package/dist/src/constants.d.ts +8 -28
- package/dist/src/constants.js +4 -7
- package/dist/src/index.d.ts +2 -4
- package/dist/src/index.js +661 -351
- package/dist/src/types/offer.types.d.ts +1 -1
- package/dist/src/utils/address-rules.d.ts +23 -0
- package/dist/src/utils/address-rules.js +258 -0
- package/dist/src/utils/addressParityFlag.d.ts +13 -0
- package/dist/src/utils/addressParityFlag.js +5 -0
- package/dist/src/utils/applePayExpressEligibility.d.ts +7 -9
- package/dist/src/utils/applePayExpressEligibility.js +2 -2
- package/dist/src/utils/buttonCopyFlag.d.ts +22 -0
- package/dist/src/utils/buttonCopyFlag.js +12 -0
- package/dist/src/utils/delivery-countries.d.ts +9 -0
- package/dist/src/utils/delivery-countries.js +255 -0
- package/dist/src/utils/expressCheckoutRedirect.d.ts +20 -2
- package/dist/src/utils/expressCheckoutRedirect.js +13 -1
- package/dist/src/utils/expressCheckoutTracking.d.ts +10 -16
- package/dist/src/utils/expressCheckoutTracking.js +5 -29
- package/dist/src/utils/latin-characters.d.ts +3 -0
- package/dist/src/utils/latin-characters.js +10 -0
- package/dist/src/utils/printOffersFlag.d.ts +11 -0
- package/dist/src/utils/printOffersFlag.js +5 -0
- package/dist/src/utils/recaptcha.d.ts +3 -2
- package/dist/src/utils/recaptcha.js +17 -8
- package/package.json +1 -1
- package/dist/src/apple-pay-logo.d.ts +0 -1
- package/dist/src/apple-pay-logo.js +0 -14
- package/dist/src/types/experiment-integration.d.js +0 -0
- package/dist/src/utils/getExperimentKeyFromNextData.d.ts +0 -8
- package/dist/src/utils/getExperimentKeyFromNextData.js +0 -9
|
@@ -63,18 +63,6 @@ function formatPrice(price, currencyCode, shouldFixDecimalPlaces = true, roundUp
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
// src/apple-pay-logo.ts
|
|
67
|
-
var LOGO_DEFS_ID = "apple-pay-logo-defs";
|
|
68
|
-
var LOGO_PATH = "M10.2651 4.21143C10.4299 4.21143 10.7106 4.23763 11.1074 4.29004C11.5042 4.34245 11.9385 4.49219 12.4102 4.73926C12.8893 4.97884 13.3236 5.37939 13.7129 5.94092C13.6904 5.96338 13.5819 6.04574 13.3872 6.18799C13.1925 6.32275 12.9754 6.5249 12.7358 6.79443C12.4963 7.05648 12.2866 7.39339 12.1069 7.80518C11.9272 8.20947 11.8374 8.69238 11.8374 9.25391C11.8374 9.89779 11.9497 10.4443 12.1743 10.8936C12.4064 11.3428 12.6722 11.7059 12.9717 11.9829C13.2786 12.2524 13.5482 12.4508 13.7803 12.5781C14.0199 12.7054 14.1471 12.7728 14.1621 12.7803C14.1546 12.8102 14.0573 13.076 13.8701 13.5776C13.6904 14.0793 13.391 14.637 12.9717 15.251C12.6048 15.7826 12.208 16.2729 11.7812 16.7222C11.362 17.1714 10.8566 17.396 10.2651 17.396C9.86833 17.396 9.54264 17.3398 9.28809 17.2275C9.03353 17.1077 8.77148 16.9917 8.50195 16.8794C8.23242 16.7596 7.8693 16.6997 7.4126 16.6997C6.97087 16.6997 6.60026 16.7596 6.30078 16.8794C6.00879 16.9992 5.72803 17.119 5.4585 17.2388C5.19645 17.3586 4.88574 17.4185 4.52637 17.4185C3.97982 17.4185 3.50065 17.2013 3.08887 16.7671C2.67708 16.3328 2.25407 15.8125 1.81982 15.2061C1.3182 14.4873 0.887695 13.6113 0.52832 12.5781C0.176432 11.5374 0.000488281 10.4893 0.000488281 9.43359C0.000488281 8.30306 0.213867 7.35596 0.640625 6.59229C1.06738 5.82113 1.61393 5.24089 2.28027 4.85156C2.9541 4.45475 3.65039 4.25635 4.36914 4.25635C4.75098 4.25635 5.11035 4.31999 5.44727 4.44727C5.78418 4.56706 6.09863 4.69059 6.39062 4.81787C6.6901 4.94515 6.95964 5.00879 7.19922 5.00879C7.43132 5.00879 7.70085 4.94141 8.00781 4.80664C8.31478 4.67188 8.65918 4.54085 9.04102 4.41357C9.42285 4.27881 9.83089 4.21143 10.2651 4.21143ZM9.64746 2.78516C9.35547 3.13704 8.98861 3.43278 8.54688 3.67236C8.10514 3.90446 7.68587 4.02051 7.28906 4.02051C7.20671 4.02051 7.12809 4.01302 7.05322 3.99805C7.04574 3.97559 7.03825 3.93441 7.03076 3.87451C7.02327 3.81462 7.01953 3.75098 7.01953 3.68359C7.01953 3.23438 7.11686 2.80013 7.31152 2.38086C7.50618 1.9541 7.72705 1.60221 7.97412 1.3252C8.28857 0.950846 8.68538 0.640137 9.16455 0.393066C9.64372 0.145996 10.1004 0.014974 10.5347 0C10.5571 0.0973307 10.5684 0.213379 10.5684 0.348145C10.5684 0.797363 10.4823 1.23535 10.3101 1.66211C10.1379 2.08138 9.91699 2.45573 9.64746 2.78516ZM17.6885 11.5112V9.71436H22.0459C23.2064 9.71436 24.1048 9.41488 24.7412 8.81592C25.3776 8.20947 25.6958 7.37467 25.6958 6.31152V6.28906C25.6958 5.21842 25.3776 4.38363 24.7412 3.78467C24.1048 3.18571 23.2064 2.88623 22.0459 2.88623H17.6885V1.08936H22.5625C23.5807 1.08936 24.4792 1.30648 25.2578 1.74072C26.0365 2.17497 26.6466 2.78141 27.0884 3.56006C27.5376 4.3387 27.7622 5.24089 27.7622 6.2666V6.28906C27.7622 7.31478 27.5376 8.2207 27.0884 9.00684C26.6466 9.79297 26.0365 10.4069 25.2578 10.8486C24.4792 11.2904 23.5807 11.5112 22.5625 11.5112H17.6885ZM16.6777 17.2949V1.08936H18.6992V17.2949H16.6777ZM32.6699 17.5195C31.9062 17.5195 31.2249 17.3735 30.626 17.0815C30.0345 16.7896 29.5703 16.3778 29.2334 15.8462C28.904 15.3071 28.7393 14.682 28.7393 13.9707V13.9482C28.7393 13.2594 28.9077 12.668 29.2446 12.1738C29.5815 11.6797 30.0682 11.2904 30.7046 11.0059C31.3485 10.7139 32.1234 10.5417 33.0293 10.4893L37.3979 10.2422V11.7695L33.2539 12.0278C32.4303 12.0728 31.8052 12.2599 31.3784 12.5894C30.9517 12.9188 30.7383 13.3643 30.7383 13.9258V13.9482C30.7383 14.5322 30.9554 14.9927 31.3896 15.3296C31.8239 15.659 32.3929 15.8237 33.0967 15.8237C33.7331 15.8237 34.2983 15.6927 34.7925 15.4307C35.2941 15.1686 35.6909 14.813 35.9829 14.3638C36.2749 13.9071 36.4209 13.3979 36.4209 12.8364V9.27637C36.4209 8.55762 36.1963 7.99609 35.7471 7.5918C35.2979 7.1875 34.6502 6.98535 33.8042 6.98535C33.063 6.98535 32.4603 7.13883 31.9961 7.4458C31.5394 7.74528 31.2474 8.14958 31.1201 8.65869L31.0977 8.7373H29.1885L29.1997 8.625C29.2746 7.98861 29.5067 7.41585 29.896 6.90674C30.2928 6.39762 30.8244 5.99707 31.4907 5.70508C32.1646 5.4056 32.9469 5.25586 33.8379 5.25586C34.7812 5.25586 35.5898 5.41683 36.2637 5.73877C36.945 6.05322 37.4653 6.50244 37.8247 7.08643C38.1916 7.66292 38.375 8.35173 38.375 9.15283V17.2949H36.4209V15.4307H36.3311C36.0915 15.8574 35.7845 16.228 35.4102 16.5425C35.0433 16.8569 34.6278 17.1003 34.1636 17.2725C33.6994 17.4372 33.2015 17.5195 32.6699 17.5195ZM42.1484 21.3267C41.9837 21.3267 41.8115 21.3192 41.6318 21.3042C41.4521 21.2892 41.2987 21.2705 41.1714 21.248V19.6421C41.2612 19.6646 41.366 19.6795 41.4858 19.687C41.6056 19.702 41.7292 19.7095 41.8564 19.7095C42.4554 19.7095 42.9383 19.5897 43.3052 19.3501C43.672 19.1105 43.9678 18.6576 44.1924 17.9912L44.4282 17.3062L40.0371 5.48047H42.126L45.6187 15.981L45.0796 15.2734H45.7759L45.248 15.981L48.7407 5.48047H50.7959L46.1802 18.0249C45.8807 18.826 45.555 19.4661 45.2031 19.9453C44.8512 20.432 44.432 20.7839 43.9453 21.001C43.4587 21.2181 42.8597 21.3267 42.1484 21.3267Z";
|
|
69
|
-
function ensureApplePayLogoSymbol() {
|
|
70
|
-
if (document.getElementById(LOGO_DEFS_ID)) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
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="currentColor"/></symbol></defs></svg>`;
|
|
75
|
-
document.body.prepend(tmp.firstElementChild);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
66
|
// src/templates/apple-pay-modal.template.html
|
|
79
67
|
var apple_pay_modal_template_default = `<style>
|
|
80
68
|
.apm-overlay {
|
|
@@ -83,8 +71,10 @@ var apple_pay_modal_template_default = `<style>
|
|
|
83
71
|
left: 0;
|
|
84
72
|
width: 100%;
|
|
85
73
|
height: 100%;
|
|
86
|
-
|
|
87
|
-
|
|
74
|
+
/* Above acquisition DualOfferBanner (1000) and Engagement ribbon (96).
|
|
75
|
+
Was 97 for wall/ribbon hosts only; hosts without a ribbon clamp need this. */
|
|
76
|
+
z-index: 1100;
|
|
77
|
+
background: rgba(13, 13, 13, 0.3);
|
|
88
78
|
display: flex;
|
|
89
79
|
align-items: center;
|
|
90
80
|
justify-content: center;
|
|
@@ -95,8 +85,8 @@ var apple_pay_modal_template_default = `<style>
|
|
|
95
85
|
.apm {
|
|
96
86
|
position: relative;
|
|
97
87
|
background: #fff;
|
|
98
|
-
border-radius:
|
|
99
|
-
border:
|
|
88
|
+
border-radius: var(--mb-spacing-xs, 0.5rem);
|
|
89
|
+
border: none;
|
|
100
90
|
padding: var(--mb-spacing-lg, 1.5rem);
|
|
101
91
|
width: 25rem;
|
|
102
92
|
max-width: 25rem;
|
|
@@ -159,6 +149,10 @@ var apple_pay_modal_template_default = `<style>
|
|
|
159
149
|
margin: 0 0 0.75rem 0;
|
|
160
150
|
}
|
|
161
151
|
|
|
152
|
+
.apm__due-today strong {
|
|
153
|
+
font-weight: var(--mb-font-weight-semibold, 600);
|
|
154
|
+
}
|
|
155
|
+
|
|
162
156
|
.apm__rule {
|
|
163
157
|
border: none;
|
|
164
158
|
border-top: 0.0625rem solid #d9d9d9;
|
|
@@ -176,7 +170,7 @@ var apple_pay_modal_template_default = `<style>
|
|
|
176
170
|
}
|
|
177
171
|
|
|
178
172
|
.apm__terms-bullets {
|
|
179
|
-
list-style:
|
|
173
|
+
list-style: square outside;
|
|
180
174
|
padding-left: 1.25rem;
|
|
181
175
|
margin: 0 0 0.75rem 0;
|
|
182
176
|
}
|
|
@@ -370,9 +364,18 @@ var apple_pay_modal_template_default = `<style>
|
|
|
370
364
|
}
|
|
371
365
|
}
|
|
372
366
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
display:
|
|
367
|
+
/* Text wordmark, same as the entry button (Figma Play Global Spec 3268:39728): Apple glyph + "Pay" (510) */
|
|
368
|
+
.apm__cta-logo {
|
|
369
|
+
display: inline-flex;
|
|
370
|
+
align-items: baseline;
|
|
371
|
+
font-size: var(--mb-typestyle-label-3-size, 1.0625rem);
|
|
372
|
+
line-height: normal;
|
|
373
|
+
font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro', system-ui, sans-serif;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
.apm__cta-logo-word {
|
|
377
|
+
font-weight: 510;
|
|
378
|
+
font-variation-settings: 'wdth' 100;
|
|
376
379
|
}
|
|
377
380
|
|
|
378
381
|
@media (min-width: 22.5rem) and (max-width: 37.5rem) {
|
|
@@ -382,12 +385,6 @@ var apple_pay_modal_template_default = `<style>
|
|
|
382
385
|
}
|
|
383
386
|
}
|
|
384
387
|
|
|
385
|
-
@media (min-width: 37.5625rem) {
|
|
386
|
-
.apm {
|
|
387
|
-
border-radius: 0.5rem;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
|
|
391
388
|
@media (max-width: 22.4375rem) {
|
|
392
389
|
.apm {
|
|
393
390
|
width: 20rem;
|
|
@@ -539,15 +536,15 @@ var apple_pay_modal_template_default = `<style>
|
|
|
539
536
|
fill="#C91D42"
|
|
540
537
|
/>
|
|
541
538
|
</svg>
|
|
542
|
-
Please accept
|
|
539
|
+
Please accept to continue
|
|
543
540
|
</div>
|
|
544
541
|
<button class="apm__cta" id="apple-pay-modal-cta" aria-label="Continue with Apple Pay">
|
|
545
542
|
<span class="apm__cta-content">
|
|
546
543
|
<span class="apm__cta-label">
|
|
547
544
|
Continue with
|
|
548
|
-
<
|
|
549
|
-
|
|
550
|
-
|
|
545
|
+
<span class="apm__cta-logo" aria-hidden="true"
|
|
546
|
+
><span></span><span class="apm__cta-logo-word">Pay</span></span
|
|
547
|
+
>
|
|
551
548
|
</span>
|
|
552
549
|
</span>
|
|
553
550
|
<span class="apm__cta-loading" aria-hidden="true">Loading...</span>
|
|
@@ -562,15 +559,21 @@ var runtimeConfig = null;
|
|
|
562
559
|
var getApplePayConfig = () => runtimeConfig;
|
|
563
560
|
|
|
564
561
|
// src/utils/recaptcha.ts
|
|
562
|
+
var findScriptForKey = (siteKey) => Array.from(
|
|
563
|
+
document.querySelectorAll(
|
|
564
|
+
'script[src*="recaptcha/api.js"]'
|
|
565
|
+
)
|
|
566
|
+
).find((script) => script.src.includes(`render=${siteKey}`));
|
|
567
|
+
var pendingLoads = /* @__PURE__ */ new Map();
|
|
565
568
|
var loadRecaptchaScript = (siteKey) => {
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
if (
|
|
572
|
-
|
|
573
|
-
|
|
569
|
+
const pending = pendingLoads.get(siteKey);
|
|
570
|
+
if (pending) return pending;
|
|
571
|
+
const ownScript = findScriptForKey(siteKey);
|
|
572
|
+
if (ownScript && typeof grecaptcha !== "undefined") return Promise.resolve();
|
|
573
|
+
const load = new Promise((resolve, reject) => {
|
|
574
|
+
if (ownScript) {
|
|
575
|
+
ownScript.addEventListener("load", () => resolve());
|
|
576
|
+
ownScript.addEventListener("error", () => {
|
|
574
577
|
reject(new Error("Failed to load existing reCAPTCHA script"));
|
|
575
578
|
});
|
|
576
579
|
return;
|
|
@@ -585,6 +588,9 @@ var loadRecaptchaScript = (siteKey) => {
|
|
|
585
588
|
};
|
|
586
589
|
document.head.appendChild(script);
|
|
587
590
|
});
|
|
591
|
+
pendingLoads.set(siteKey, load);
|
|
592
|
+
load.catch(() => pendingLoads.delete(siteKey));
|
|
593
|
+
return load;
|
|
588
594
|
};
|
|
589
595
|
var getRecaptchaToken = async (action) => {
|
|
590
596
|
const siteKey = getApplePayConfig()?.recaptchaSiteKey;
|
|
@@ -849,7 +855,6 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
|
|
|
849
855
|
if (this.querySelector(".apm-overlay")) {
|
|
850
856
|
return;
|
|
851
857
|
}
|
|
852
|
-
ensureApplePayLogoSymbol();
|
|
853
858
|
const template = document.createElement("template");
|
|
854
859
|
template.innerHTML = apple_pay_modal_template_default;
|
|
855
860
|
this.appendChild(template.content.cloneNode(true));
|
|
@@ -1002,8 +1007,13 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
|
|
|
1002
1007
|
// src/templates/apple-pay-button.template.html
|
|
1003
1008
|
var apple_pay_button_template_default = `<style>
|
|
1004
1009
|
/*
|
|
1005
|
-
* Entry CTA:
|
|
1006
|
-
*
|
|
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).
|
|
1016
|
+
* SF Pro is the system font on Apple devices, which are the only devices Apple Pay is shown on.
|
|
1007
1017
|
*/
|
|
1008
1018
|
teg-apple-pay-button {
|
|
1009
1019
|
display: block;
|
|
@@ -1028,46 +1038,45 @@ var apple_pay_button_template_default = `<style>
|
|
|
1028
1038
|
min-width: 0;
|
|
1029
1039
|
height: 100%;
|
|
1030
1040
|
min-height: var(--apple-pay-height, 2.5rem);
|
|
1031
|
-
|
|
1041
|
+
/* Figma button content: 8px 16px */
|
|
1042
|
+
padding: var(--mb-spacing-xs, 0.5rem) var(--mb-spacing-md, 1rem);
|
|
1032
1043
|
box-sizing: border-box;
|
|
1033
|
-
background-color: var(--apple-pay-background-color, #
|
|
1044
|
+
background-color: var(--apple-pay-background-color, var(--mb-colour-greyscale-london-5, #0d0d0d));
|
|
1034
1045
|
color: var(--apple-pay-foreground-color, #fff);
|
|
1035
1046
|
border: none;
|
|
1036
|
-
border-radius: var(--apple-pay-border-radius, 0.25rem);
|
|
1047
|
+
border-radius: var(--apple-pay-border-radius, var(--mb-spacing-2xs, 0.25rem));
|
|
1037
1048
|
cursor: pointer;
|
|
1038
|
-
/*
|
|
1039
|
-
font-family:
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
line
|
|
1049
|
+
/* Figma: SF Pro (system font on Apple devices), Regular 15 / 24 */
|
|
1050
|
+
font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro', system-ui, sans-serif;
|
|
1051
|
+
font-size: var(--mb-typestyle-label-2-size, 0.9375rem);
|
|
1052
|
+
font-weight: 400;
|
|
1053
|
+
font-variation-settings: 'wdth' 100;
|
|
1054
|
+
/* Figma letter spacing 0 */
|
|
1055
|
+
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);
|
|
1046
1058
|
}
|
|
1047
1059
|
|
|
1048
1060
|
teg-apple-pay-button .apple-pay-btn__label {
|
|
1049
1061
|
display: inline-flex;
|
|
1050
1062
|
align-items: center;
|
|
1051
|
-
/*
|
|
1052
|
-
gap: 0;
|
|
1063
|
+
/* Figma: 4px between the caption and the wordmark */
|
|
1064
|
+
gap: var(--mb-spacing-2xs, 0.25rem);
|
|
1053
1065
|
white-space: nowrap;
|
|
1054
1066
|
}
|
|
1055
1067
|
|
|
1056
|
-
teg-apple-pay-button .apple-pay-
|
|
1057
|
-
|
|
1058
|
-
|
|
1068
|
+
teg-apple-pay-button .apple-pay-btn__logo {
|
|
1069
|
+
display: inline-flex;
|
|
1070
|
+
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. */
|
|
1073
|
+
font-size: var(--mb-typestyle-label-3-size, 1.0625rem);
|
|
1074
|
+
line-height: normal;
|
|
1059
1075
|
}
|
|
1060
1076
|
|
|
1061
|
-
teg-apple-pay-button .apple-pay-btn__logo {
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
/* Match caption font-size so mark aligns with text metrics */
|
|
1065
|
-
height: 1.05em;
|
|
1066
|
-
width: auto;
|
|
1067
|
-
aspect-ratio: 51 / 22;
|
|
1068
|
-
color: currentColor;
|
|
1069
|
-
/* Optical nudge \u2014 SVG viewBox sits slightly high vs EconomistSans caps */
|
|
1070
|
-
transform: translateY(0.06em);
|
|
1077
|
+
teg-apple-pay-button .apple-pay-btn__logo-word {
|
|
1078
|
+
font-weight: 510;
|
|
1079
|
+
font-variation-settings: 'wdth' 100;
|
|
1071
1080
|
}
|
|
1072
1081
|
|
|
1073
1082
|
teg-apple-pay-button .apple-pay-btn.wap-loading {
|
|
@@ -1104,6 +1113,7 @@ var apple_pay_button_template_default = `<style>
|
|
|
1104
1113
|
transform: translate(-50%, -50%) rotate(360deg);
|
|
1105
1114
|
}
|
|
1106
1115
|
}
|
|
1116
|
+
|
|
1107
1117
|
</style>
|
|
1108
1118
|
|
|
1109
1119
|
<div class="apple-pay-container" aria-label="Subscribe with Apple Pay">
|
|
@@ -1115,16 +1125,10 @@ var apple_pay_button_template_default = `<style>
|
|
|
1115
1125
|
>
|
|
1116
1126
|
<span class="apple-pay-btn__label"
|
|
1117
1127
|
><span class="apple-pay-btn__caption">Subscribe with</span
|
|
1118
|
-
><
|
|
1119
|
-
class="apple-pay-btn__logo"
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
viewBox="0 0 51 22"
|
|
1123
|
-
aria-hidden="true"
|
|
1124
|
-
role="img"
|
|
1125
|
-
>
|
|
1126
|
-
<use href="#apple-pay-logo" />
|
|
1127
|
-
</svg
|
|
1128
|
+
><span class="apple-pay-btn__logo" aria-hidden="true"
|
|
1129
|
+
><span class="apple-pay-btn__logo-glyph"></span
|
|
1130
|
+
><span class="apple-pay-btn__logo-word">Pay</span
|
|
1131
|
+
></span
|
|
1128
1132
|
></span>
|
|
1129
1133
|
<span class="apple-pay-btn__loading" aria-hidden="true">Loading...</span>
|
|
1130
1134
|
</button>
|
|
@@ -1138,7 +1142,7 @@ var isAppleDeviceOrSafari = () => {
|
|
|
1138
1142
|
return isIOSOrMacTouchDevice || isSafariBrowser;
|
|
1139
1143
|
};
|
|
1140
1144
|
var bypassApplePayChecks = () => new URLSearchParams(window.location.search).get("BYPASS_APPLE_PAY_CHECKS") !== null;
|
|
1141
|
-
var
|
|
1145
|
+
var isApplePayCapable = () => {
|
|
1142
1146
|
if (bypassApplePayChecks()) {
|
|
1143
1147
|
return true;
|
|
1144
1148
|
}
|
|
@@ -1150,18 +1154,21 @@ var isApplePayAvailable = async () => {
|
|
|
1150
1154
|
return false;
|
|
1151
1155
|
}
|
|
1152
1156
|
try {
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1157
|
+
return typeof applePaySession.canMakePayments === "function" && applePaySession.canMakePayments() && Boolean(getApplePayConfig()?.merchantId);
|
|
1158
|
+
} catch {
|
|
1159
|
+
return false;
|
|
1160
|
+
}
|
|
1161
|
+
};
|
|
1162
|
+
var isApplePayAvailable = async () => {
|
|
1163
|
+
if (bypassApplePayChecks()) {
|
|
1164
|
+
return true;
|
|
1165
|
+
}
|
|
1166
|
+
if (!isApplePayCapable()) {
|
|
1167
|
+
return false;
|
|
1168
|
+
}
|
|
1169
|
+
try {
|
|
1170
|
+
const merchantId = getApplePayConfig().merchantId;
|
|
1171
|
+
return await window.ApplePaySession.canMakePaymentsWithActiveCard(merchantId);
|
|
1165
1172
|
} catch {
|
|
1166
1173
|
return false;
|
|
1167
1174
|
}
|
|
@@ -1242,11 +1249,23 @@ var performPurchase = (data) => {
|
|
|
1242
1249
|
};
|
|
1243
1250
|
|
|
1244
1251
|
// src/clients/payment-checkout/session.ts
|
|
1252
|
+
var inFlight = null;
|
|
1245
1253
|
var getExpressCheckoutSession = () => {
|
|
1246
|
-
|
|
1254
|
+
if (inFlight) {
|
|
1255
|
+
return inFlight;
|
|
1256
|
+
}
|
|
1257
|
+
const request = apiFetch("/v1/wallet/session", {
|
|
1247
1258
|
method: "GET",
|
|
1248
1259
|
credentials: "include"
|
|
1249
1260
|
});
|
|
1261
|
+
inFlight = request;
|
|
1262
|
+
const clear = () => {
|
|
1263
|
+
if (inFlight === request) {
|
|
1264
|
+
inFlight = null;
|
|
1265
|
+
}
|
|
1266
|
+
};
|
|
1267
|
+
request.then(clear, clear);
|
|
1268
|
+
return request;
|
|
1250
1269
|
};
|
|
1251
1270
|
|
|
1252
1271
|
// src/utils/expressCheckoutRedirect.ts
|
|
@@ -1261,8 +1280,13 @@ function isAllowedRedirectUrl(url) {
|
|
|
1261
1280
|
return false;
|
|
1262
1281
|
}
|
|
1263
1282
|
}
|
|
1283
|
+
var CHECKOUT_REDIRECT_BY_POLICY = {
|
|
1284
|
+
["current_page" /* CURRENT_PAGE */]: (currentPageUrl) => currentPageUrl,
|
|
1285
|
+
["host_managed" /* HOST_MANAGED */]: () => null
|
|
1286
|
+
};
|
|
1287
|
+
var resolveCheckoutRedirectUrl = (policy, currentPageUrl) => CHECKOUT_REDIRECT_BY_POLICY[policy](currentPageUrl);
|
|
1264
1288
|
var writeCheckoutRedirect = (originUrl) => {
|
|
1265
|
-
if (!isAllowedRedirectUrl(originUrl)) return;
|
|
1289
|
+
if (originUrl === null || !isAllowedRedirectUrl(originUrl)) return;
|
|
1266
1290
|
try {
|
|
1267
1291
|
localStorage.setItem(CHECKOUT_REDIRECT_KEY, originUrl);
|
|
1268
1292
|
} catch {
|
|
@@ -1298,13 +1322,6 @@ var redirectToCheckoutFallback = (params) => {
|
|
|
1298
1322
|
return url.pathname + url.search;
|
|
1299
1323
|
};
|
|
1300
1324
|
|
|
1301
|
-
// src/constants.ts
|
|
1302
|
-
var APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-paywalls";
|
|
1303
|
-
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
1304
|
-
CONTROL: "control",
|
|
1305
|
-
TREATMENT: "treatment"
|
|
1306
|
-
};
|
|
1307
|
-
|
|
1308
1325
|
// src/utils/expressCheckoutTracking.ts
|
|
1309
1326
|
var EXPRESS_CHECKOUT_EVENTS = {
|
|
1310
1327
|
/** Wallet button displayed */
|
|
@@ -1342,26 +1359,6 @@ var track = (action, extra) => {
|
|
|
1342
1359
|
...extra
|
|
1343
1360
|
});
|
|
1344
1361
|
};
|
|
1345
|
-
var trackApplePayExperimentExposure = (variant, experimentKey, flagKey) => {
|
|
1346
|
-
const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
1347
|
-
if (!isActiveVariant) {
|
|
1348
|
-
return;
|
|
1349
|
-
}
|
|
1350
|
-
const exposures = window.__applePayExperimentExposures ?? {};
|
|
1351
|
-
window.__applePayExperimentExposures = exposures;
|
|
1352
|
-
const pathname = window.location?.pathname ?? "";
|
|
1353
|
-
const dedupeKey = `${pathname}:${flagKey}:${variant}`;
|
|
1354
|
-
if (exposures[dedupeKey]) {
|
|
1355
|
-
return;
|
|
1356
|
-
}
|
|
1357
|
-
exposures[dedupeKey] = true;
|
|
1358
|
-
emitTedlEvent({
|
|
1359
|
-
name: "$exposure",
|
|
1360
|
-
flag_key: flagKey,
|
|
1361
|
-
variant,
|
|
1362
|
-
...experimentKey ? { experiment_key: experimentKey } : {}
|
|
1363
|
-
});
|
|
1364
|
-
};
|
|
1365
1362
|
var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
|
|
1366
1363
|
track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
|
|
1367
1364
|
wallet_type: "apple_pay",
|
|
@@ -1371,8 +1368,11 @@ var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
|
|
|
1371
1368
|
device: getDevice()
|
|
1372
1369
|
});
|
|
1373
1370
|
};
|
|
1374
|
-
var trackExpressWalletClick = (skuId) => {
|
|
1375
|
-
track(EXPRESS_CHECKOUT_EVENTS.BUTTON_CLICK, {
|
|
1371
|
+
var trackExpressWalletClick = (skuId, { entryPoint } = {}) => {
|
|
1372
|
+
track(EXPRESS_CHECKOUT_EVENTS.BUTTON_CLICK, {
|
|
1373
|
+
sku_id: skuId,
|
|
1374
|
+
...entryPoint ? { entry_point: entryPoint } : {}
|
|
1375
|
+
});
|
|
1376
1376
|
};
|
|
1377
1377
|
var trackWalletPaymentSheetOpen = (skuId) => {
|
|
1378
1378
|
track(EXPRESS_CHECKOUT_EVENTS.SHEET_OPEN, { sku_id: skuId });
|
|
@@ -1403,21 +1403,10 @@ var trackValidationFieldError = (field, errorType) => {
|
|
|
1403
1403
|
var MSG_MISSING_REQUIRED_FIELD = "Missing required field";
|
|
1404
1404
|
var MSG_EMAIL_WRONG_FORMAT = "That email doesn\u2019t look right. Please enter a valid email address.";
|
|
1405
1405
|
var MSG_EMAIL_TOO_LONG = "This field must be 80 characters or less.";
|
|
1406
|
+
var MSG_NON_LATIN_CHARACTERS = "Please use Latin characters only.";
|
|
1407
|
+
var msgFieldTooLong = (label, max) => `${label} must be ${max} characters or less`;
|
|
1408
|
+
var MSG_UNSUPPORTED_DELIVERY_COUNTRY = "We can't deliver this print edition to that country. Try a different delivery address.";
|
|
1406
1409
|
var MSG_UNSUPPORTED_BILLING_COUNTRY = "Billing country does not match offer price zone";
|
|
1407
|
-
var BILLING_COUNTRY_MISMATCH_FALLBACK = "Country not supported for this purchase";
|
|
1408
|
-
var MSG_BILLING_COUNTRY_MISMATCH_REDIRECT = "This country isn\u2019t supported for this purchase. Try updating your billing address.";
|
|
1409
|
-
var buildCountryMismatchMessage = (countryCode) => {
|
|
1410
|
-
if (!countryCode) return BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
1411
|
-
try {
|
|
1412
|
-
const regionNames = new Intl.DisplayNames(["en"], { type: "region", fallback: "none" });
|
|
1413
|
-
const upper = countryCode.toUpperCase();
|
|
1414
|
-
const countryName = regionNames.of(upper);
|
|
1415
|
-
const isResolved = countryName && countryName !== upper && countryName !== "Unknown Region";
|
|
1416
|
-
return isResolved ? `${countryName} address required` : BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
1417
|
-
} catch {
|
|
1418
|
-
return BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
1419
|
-
}
|
|
1420
|
-
};
|
|
1421
1410
|
var MSG_PAYMENT_GENERIC_ERROR = "Something went wrong. Please check your payment and billing details and try again or contact us.";
|
|
1422
1411
|
var MSG_CONTACT_VALIDATION_INTERNAL = "Could not validate Apple Pay contact";
|
|
1423
1412
|
|
|
@@ -1455,7 +1444,12 @@ async function handleMerchantValidation(event, session, config) {
|
|
|
1455
1444
|
redirectToFallbackCheckout(config);
|
|
1456
1445
|
}
|
|
1457
1446
|
}
|
|
1447
|
+
var requiredShippingFields = (config) => [
|
|
1448
|
+
...config.delivery ? ["postalAddress", "name", "phone"] : [],
|
|
1449
|
+
...config.userLoggedIn ? [] : ["email"]
|
|
1450
|
+
];
|
|
1458
1451
|
function startApplePaySession(config) {
|
|
1452
|
+
const shippingFields = requiredShippingFields(config);
|
|
1459
1453
|
const paymentRequest = {
|
|
1460
1454
|
countryCode: config.countryCode,
|
|
1461
1455
|
currencyCode: config.currencyCode,
|
|
@@ -1466,14 +1460,33 @@ function startApplePaySession(config) {
|
|
|
1466
1460
|
amount: config.totalAmount
|
|
1467
1461
|
},
|
|
1468
1462
|
requiredBillingContactFields: ["postalAddress", "name"],
|
|
1469
|
-
|
|
1470
|
-
|
|
1463
|
+
...shippingFields.length > 0 && {
|
|
1464
|
+
requiredShippingContactFields: shippingFields
|
|
1465
|
+
}
|
|
1471
1466
|
};
|
|
1472
1467
|
try {
|
|
1473
1468
|
const session = new ApplePaySession(3, paymentRequest);
|
|
1474
1469
|
session.onvalidatemerchant = async (event) => {
|
|
1475
1470
|
await handleMerchantValidation(event, session, config);
|
|
1476
1471
|
};
|
|
1472
|
+
const delivery = config.delivery;
|
|
1473
|
+
if (delivery) {
|
|
1474
|
+
session.onshippingcontactselected = (event) => {
|
|
1475
|
+
const country = event.shippingContact.countryCode?.toUpperCase();
|
|
1476
|
+
session.completeShippingContactSelection({
|
|
1477
|
+
newTotal: paymentRequest.total,
|
|
1478
|
+
...country && !delivery.supportedCountries.includes(country) && {
|
|
1479
|
+
errors: [
|
|
1480
|
+
new ApplePayError(
|
|
1481
|
+
"shippingContactInvalid",
|
|
1482
|
+
"countryCode",
|
|
1483
|
+
MSG_UNSUPPORTED_DELIVERY_COUNTRY
|
|
1484
|
+
)
|
|
1485
|
+
]
|
|
1486
|
+
}
|
|
1487
|
+
});
|
|
1488
|
+
};
|
|
1489
|
+
}
|
|
1477
1490
|
session.onpaymentauthorized = (event) => {
|
|
1478
1491
|
trackWalletPaymentAuthorised(config.skuId);
|
|
1479
1492
|
config.onPaymentAuthorized(event, session).catch(() => {
|
|
@@ -1514,6 +1527,16 @@ var ContactValidationError = class extends Error {
|
|
|
1514
1527
|
}
|
|
1515
1528
|
};
|
|
1516
1529
|
|
|
1530
|
+
// src/utils/latin-characters.ts
|
|
1531
|
+
var SUPPORTED_DIACRITICS = "\xE0\xE1\xE2\u0101\u0103\u0105\u0227\u01CE\u0201\u0203\xC0\xC1\xC2\u0100\u0102\u0104\u0226\u01CD\u0200\u0202\xE3\xE4\xC3\xC4\xE6\xC6\xE5\xC5\xE8\xE9\xEA\u1EBD\xEB\u0113\u0115\u0119\u0117\u011B\u0205\u0207\xC8\xC9\xCA\u1EBC\xCB\u0112\u0114\u0118\u0116\u011A\u0204\u0206\xEC\xED\xEE\u0129\xEF\u012B\u012D\u012F\u01D0\u0209\u020B\xCC\xCD\xCE\u0128\xCF\u012A\u012C\u012E\u01CF\u0208\u020A\xF2\xF3\xF4\xF5\u014D\u014F\u01EB\u022F\u0151\u01D2\u020D\u020F\xD2\xD3\xD4\xD5\u014C\u014E\u01EA\u022E\u0150\u01D1\u020C\u020E\xF6\xD6\xF8\xD8\u016F\xF9\xFA\xFB\u0169\u016B\u016D\u0173\u0171\u01D4\u0215\u0217\u016E\xD9\xDA\xDB\u0168\u016A\u016C\u0172\u0170\u01D3\u0214\u0216\xFC\xDC\u1EF3\xFD\u0177\u1EF9\xFF\u0233\u1E8F\u1EF2\xDD\u0176\u1EF8\u0178\u0232\u1E8E\xE7\xC7\u0107\u010D\u0106\u010C\xDF\xFE\xDE\xAA\u0159\u0155\u0158\u0154\u0142\u013E\u013A\u013C\u0141\u013D\u0139\u013B\xF1\u0144\u0148\u0146\xD1\u0143\u0147\u0145\u015B\u0161\u015A\u0160\u015F\u0219\u015E\u0218\u017A\u017C\u017E\u0179\u017B\u017D\u010F\xF0\u010E\xD0\u0165\u021B\u0164\u021A\u011F\u0123\u011E\u0122\u0137\u0136\u2019";
|
|
1532
|
+
var LATIN_CHARACTERS_REGEX = new RegExp(
|
|
1533
|
+
`^[\\x20-\\x7E${SUPPORTED_DIACRITICS}]*$`
|
|
1534
|
+
);
|
|
1535
|
+
var isLatinCharacters = (value) => LATIN_CHARACTERS_REGEX.test(value);
|
|
1536
|
+
|
|
1537
|
+
// src/utils/addressParityFlag.ts
|
|
1538
|
+
var ADDRESS_PARITY_ENABLED = true;
|
|
1539
|
+
|
|
1517
1540
|
// src/clients/payment-checkout/billing-contact-details.ts
|
|
1518
1541
|
var countriesWithoutCityField = ["KY", "CK", "NR", "TC"];
|
|
1519
1542
|
var countriesRequiringAllFields = ["US", "CA", "GB"];
|
|
@@ -1561,6 +1584,35 @@ var validateCountrySupport = (errors, country, supportedBillingCountries) => {
|
|
|
1561
1584
|
);
|
|
1562
1585
|
}
|
|
1563
1586
|
};
|
|
1587
|
+
var validateLatinCharacters = (errors, contact, firstName, lastName) => {
|
|
1588
|
+
if (!isLatinCharacters(firstName) || !isLatinCharacters(lastName)) {
|
|
1589
|
+
pushFieldError(
|
|
1590
|
+
errors,
|
|
1591
|
+
"billing",
|
|
1592
|
+
"name",
|
|
1593
|
+
"format",
|
|
1594
|
+
MSG_NON_LATIN_CHARACTERS
|
|
1595
|
+
);
|
|
1596
|
+
}
|
|
1597
|
+
const addressFields = [
|
|
1598
|
+
["addressLines", contact.addressLines?.at(0)],
|
|
1599
|
+
["addressLines", contact.addressLines?.at(1)],
|
|
1600
|
+
["locality", contact.locality],
|
|
1601
|
+
["administrativeArea", contact.administrativeArea],
|
|
1602
|
+
["postalCode", contact.postalCode]
|
|
1603
|
+
];
|
|
1604
|
+
for (const [field, value] of addressFields) {
|
|
1605
|
+
if (value && !isLatinCharacters(value)) {
|
|
1606
|
+
pushFieldError(
|
|
1607
|
+
errors,
|
|
1608
|
+
"billing",
|
|
1609
|
+
field,
|
|
1610
|
+
"format",
|
|
1611
|
+
MSG_NON_LATIN_CHARACTERS
|
|
1612
|
+
);
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
};
|
|
1564
1616
|
var billingContactDetails = (contact, supportedBillingCountries) => {
|
|
1565
1617
|
const errors = [];
|
|
1566
1618
|
const country = contact.countryCode?.toUpperCase() || pushRequiredFieldError(errors, "billing", "country");
|
|
@@ -1568,6 +1620,9 @@ var billingContactDetails = (contact, supportedBillingCountries) => {
|
|
|
1568
1620
|
validateAddressFields(errors, contact, config);
|
|
1569
1621
|
const { firstName, lastName } = validateNameFields(errors, contact);
|
|
1570
1622
|
validateCountrySupport(errors, country, supportedBillingCountries);
|
|
1623
|
+
if (ADDRESS_PARITY_ENABLED) {
|
|
1624
|
+
validateLatinCharacters(errors, contact, firstName, lastName);
|
|
1625
|
+
}
|
|
1571
1626
|
if (errors.length > 0) {
|
|
1572
1627
|
throw new ContactValidationError(errors);
|
|
1573
1628
|
}
|
|
@@ -1607,123 +1662,6 @@ var shippingContactDetails = (shippingContact) => {
|
|
|
1607
1662
|
return { emailAddress };
|
|
1608
1663
|
};
|
|
1609
1664
|
|
|
1610
|
-
// src/clients/payment-checkout/payment-handler.ts
|
|
1611
|
-
var failApplePaySession = (session, errors = []) => {
|
|
1612
|
-
session.completePayment({
|
|
1613
|
-
status: ApplePaySession.STATUS_FAILURE,
|
|
1614
|
-
errors
|
|
1615
|
-
});
|
|
1616
|
-
};
|
|
1617
|
-
function parseWalletApiError(err) {
|
|
1618
|
-
const body = err instanceof ApiError ? err.body : err;
|
|
1619
|
-
if (body && typeof body === "object" && "errorType" in body && "message" in body) {
|
|
1620
|
-
return body;
|
|
1621
|
-
}
|
|
1622
|
-
return null;
|
|
1623
|
-
}
|
|
1624
|
-
function validateContacts(event, sessionData, supportedBillingCountries) {
|
|
1625
|
-
billingContactDetails(
|
|
1626
|
-
event.payment.billingContact,
|
|
1627
|
-
supportedBillingCountries
|
|
1628
|
-
);
|
|
1629
|
-
if (!sessionData.loggedIn) {
|
|
1630
|
-
return shippingContactDetails(event.payment.shippingContact).emailAddress;
|
|
1631
|
-
}
|
|
1632
|
-
return void 0;
|
|
1633
|
-
}
|
|
1634
|
-
function redirectFallback(skuId, returnUrl, country, options) {
|
|
1635
|
-
writeCheckoutRedirect(returnUrl);
|
|
1636
|
-
trackFallbackCheckout(skuId);
|
|
1637
|
-
window.location.href = redirectToCheckoutFallback({
|
|
1638
|
-
skuId,
|
|
1639
|
-
country,
|
|
1640
|
-
...options
|
|
1641
|
-
});
|
|
1642
|
-
}
|
|
1643
|
-
var ERROR_HANDLERS = {
|
|
1644
|
-
// emailError flows as an inline field error on the email input.
|
|
1645
|
-
// email pre-populates the input so the user doesn't have to retype it.
|
|
1646
|
-
EMAIL_COLLISION: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
1647
|
-
emailError: walletError.message,
|
|
1648
|
-
email: validatedEmail
|
|
1649
|
-
}),
|
|
1650
|
-
PAYMENT_DECLINED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1651
|
-
ELIGIBILITY_REJECTED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1652
|
-
REGISTRATION_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1653
|
-
ACCOUNT_CREATION_FAILED: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
1654
|
-
emailError: walletError.message,
|
|
1655
|
-
email: validatedEmail
|
|
1656
|
-
}),
|
|
1657
|
-
VALIDATION_ERROR: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1658
|
-
RECAPTCHA_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message })
|
|
1659
|
-
};
|
|
1660
|
-
function handleStructuredError(ctx) {
|
|
1661
|
-
const handler = ERROR_HANDLERS[ctx.walletError.errorType];
|
|
1662
|
-
if (handler) {
|
|
1663
|
-
handler(ctx);
|
|
1664
|
-
} else {
|
|
1665
|
-
redirectFallback(ctx.skuId, ctx.returnUrl, ctx.country, { inlineError: MSG_PAYMENT_GENERIC_ERROR });
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
|
-
async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
1669
|
-
const { skuId, returnUrl, country } = config;
|
|
1670
|
-
let validatedEmail;
|
|
1671
|
-
try {
|
|
1672
|
-
validatedEmail = validateContacts(
|
|
1673
|
-
event,
|
|
1674
|
-
sessionData,
|
|
1675
|
-
config.supportedBillingCountries
|
|
1676
|
-
);
|
|
1677
|
-
const result = await performPurchase({
|
|
1678
|
-
applePayToken: event.payment.token,
|
|
1679
|
-
skuId: config.skuId,
|
|
1680
|
-
currency: config.currency,
|
|
1681
|
-
billingContact: event.payment.billingContact,
|
|
1682
|
-
...event.payment.shippingContact && {
|
|
1683
|
-
shippingContact: event.payment.shippingContact
|
|
1684
|
-
},
|
|
1685
|
-
recaptchaToken: config.recaptchaToken
|
|
1686
|
-
});
|
|
1687
|
-
trackWalletPaymentSuccess(skuId, result.basketId);
|
|
1688
|
-
session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
1689
|
-
const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
|
|
1690
|
-
const userStatus = sessionData.loggedIn ? "lex" : "nex";
|
|
1691
|
-
writeCheckoutRedirect(returnUrl);
|
|
1692
|
-
window.location.href = redirectToCheckoutComplete({
|
|
1693
|
-
basketId: result.basketId,
|
|
1694
|
-
status: userStatus,
|
|
1695
|
-
skuId: decodeSku(skuId),
|
|
1696
|
-
email: successEmail,
|
|
1697
|
-
country
|
|
1698
|
-
});
|
|
1699
|
-
} catch (err) {
|
|
1700
|
-
if (err instanceof ContactValidationError) {
|
|
1701
|
-
const isBillingCountryMismatch = err.errors.some(
|
|
1702
|
-
(e) => e.contactField === "countryCode"
|
|
1703
|
-
);
|
|
1704
|
-
if (isBillingCountryMismatch) {
|
|
1705
|
-
const countryCode = event.payment.billingContact?.countryCode;
|
|
1706
|
-
const userMessage = buildCountryMismatchMessage(countryCode);
|
|
1707
|
-
failApplePaySession(session, [
|
|
1708
|
-
new ApplePayError("billingContactInvalid", "countryCode", userMessage)
|
|
1709
|
-
]);
|
|
1710
|
-
redirectFallback(skuId, returnUrl, country, { inlineError: MSG_BILLING_COUNTRY_MISMATCH_REDIRECT });
|
|
1711
|
-
} else {
|
|
1712
|
-
failApplePaySession(session, err.errors);
|
|
1713
|
-
}
|
|
1714
|
-
return;
|
|
1715
|
-
}
|
|
1716
|
-
const walletError = parseWalletApiError(err);
|
|
1717
|
-
trackWalletPaymentFailure(skuId, walletError?.errorType ?? "UNKNOWN");
|
|
1718
|
-
failApplePaySession(session);
|
|
1719
|
-
if (!walletError) {
|
|
1720
|
-
redirectFallback(skuId, returnUrl, country, { inlineError: MSG_PAYMENT_GENERIC_ERROR });
|
|
1721
|
-
return;
|
|
1722
|
-
}
|
|
1723
|
-
handleStructuredError({ skuId, returnUrl, country, validatedEmail, walletError });
|
|
1724
|
-
}
|
|
1725
|
-
}
|
|
1726
|
-
|
|
1727
1665
|
// src/data/price-zones.json
|
|
1728
1666
|
var price_zones_default = {
|
|
1729
1667
|
"AS-AS": [
|
|
@@ -1929,6 +1867,254 @@ var price_zones_default = {
|
|
|
1929
1867
|
"UK-UK": ["GB"]
|
|
1930
1868
|
};
|
|
1931
1869
|
|
|
1870
|
+
// src/utils/address-rules.ts
|
|
1871
|
+
var priceZones = price_zones_default;
|
|
1872
|
+
var ADDRESS_LIMITS = {
|
|
1873
|
+
address1: 35,
|
|
1874
|
+
address2: 35,
|
|
1875
|
+
city: 40,
|
|
1876
|
+
state: 40,
|
|
1877
|
+
postalCode: 20,
|
|
1878
|
+
phone: 35
|
|
1879
|
+
};
|
|
1880
|
+
var zoneOf = (country) => Object.keys(priceZones).find((zone) => priceZones[zone].includes(country));
|
|
1881
|
+
var COUNTRIES_REQUIRING_PHONE = ["IN", "CN"];
|
|
1882
|
+
var requiredDeliveryFields = (offerCountry, country) => {
|
|
1883
|
+
const zone = zoneOf(offerCountry);
|
|
1884
|
+
const fields = ["address1", "city"];
|
|
1885
|
+
if (zone === "AS-AU" || zone === "AS-JP" || zone === "NA-CA" || country === "US") {
|
|
1886
|
+
fields.push("state");
|
|
1887
|
+
}
|
|
1888
|
+
if ((zone !== "AS-HK" || country === "MO") && zone !== "CE-AF" && zone !== "CE-ME") {
|
|
1889
|
+
fields.push("postalCode");
|
|
1890
|
+
}
|
|
1891
|
+
if (COUNTRIES_REQUIRING_PHONE.includes(country)) fields.push("phone");
|
|
1892
|
+
return fields;
|
|
1893
|
+
};
|
|
1894
|
+
var postalCodeFormatError = (offerCountry, postalCode) => {
|
|
1895
|
+
if (!postalCode) return null;
|
|
1896
|
+
const zone = zoneOf(offerCountry);
|
|
1897
|
+
if (zone === "NA-US" && !/(^\d{5}$)|(^\d{5}-\d{4}$)/.test(postalCode)) {
|
|
1898
|
+
return "Zip code must be a valid US zip code";
|
|
1899
|
+
}
|
|
1900
|
+
if (zone === "NA-CA" && !/^[A-Za-z]\d[A-Za-z][ -]?\d[A-Za-z]\d$/.test(postalCode)) {
|
|
1901
|
+
return "Postal code must be a valid Canadian postal code";
|
|
1902
|
+
}
|
|
1903
|
+
return null;
|
|
1904
|
+
};
|
|
1905
|
+
var COUNTRY_CALLING_CODES = {
|
|
1906
|
+
IN: "91",
|
|
1907
|
+
CN: "86"
|
|
1908
|
+
};
|
|
1909
|
+
var normaliseDeliveryPhone = (raw, country) => {
|
|
1910
|
+
const trimmed = raw?.trim() ?? "";
|
|
1911
|
+
const digits = trimmed.replace(/[^0-9]+/g, "");
|
|
1912
|
+
if (!digits) return void 0;
|
|
1913
|
+
if (trimmed.startsWith("+")) return `+${digits}`;
|
|
1914
|
+
const callingCode = COUNTRY_CALLING_CODES[country];
|
|
1915
|
+
return callingCode ? `+${callingCode}${digits.replace(/^0+/, "")}` : void 0;
|
|
1916
|
+
};
|
|
1917
|
+
|
|
1918
|
+
// src/clients/payment-checkout/delivery-contact-details.ts
|
|
1919
|
+
var APPLE_FIELD = {
|
|
1920
|
+
address1: "addressLines",
|
|
1921
|
+
city: "locality",
|
|
1922
|
+
state: "administrativeArea",
|
|
1923
|
+
postalCode: "postalCode",
|
|
1924
|
+
phone: "phoneNumber"
|
|
1925
|
+
};
|
|
1926
|
+
var LABEL = {
|
|
1927
|
+
address1: "Address line 1",
|
|
1928
|
+
address2: "Address line 2",
|
|
1929
|
+
city: "City",
|
|
1930
|
+
state: "State",
|
|
1931
|
+
postalCode: "Postcode",
|
|
1932
|
+
phone: "Phone number"
|
|
1933
|
+
};
|
|
1934
|
+
var deliveryContactDetails = (contact, { offerCountry, supportedDeliveryCountries }) => {
|
|
1935
|
+
const errors = [];
|
|
1936
|
+
const fail = (field, type, message) => pushFieldError(errors, "shipping", field, type, message);
|
|
1937
|
+
const country = contact?.countryCode?.trim().toUpperCase() ?? "";
|
|
1938
|
+
const firstName = contact?.givenName?.trim() ?? "";
|
|
1939
|
+
const lastName = contact?.familyName?.trim() ?? "";
|
|
1940
|
+
const address1 = contact?.addressLines?.at(0)?.trim() ?? "";
|
|
1941
|
+
const address2 = contact?.addressLines?.at(1)?.trim() ?? "";
|
|
1942
|
+
const city = contact?.locality?.trim() ?? "";
|
|
1943
|
+
const state = contact?.administrativeArea?.trim() ?? "";
|
|
1944
|
+
const postalCode = contact?.postalCode?.trim() ?? "";
|
|
1945
|
+
const phone = normaliseDeliveryPhone(contact?.phoneNumber, country) ?? "";
|
|
1946
|
+
if (!country) {
|
|
1947
|
+
pushRequiredFieldError(errors, "shipping", "country");
|
|
1948
|
+
} else if (!supportedDeliveryCountries.includes(country)) {
|
|
1949
|
+
fail("countryCode", "not-supported", MSG_UNSUPPORTED_DELIVERY_COUNTRY);
|
|
1950
|
+
}
|
|
1951
|
+
if (!firstName || !lastName) {
|
|
1952
|
+
pushRequiredFieldError(errors, "shipping", "name");
|
|
1953
|
+
}
|
|
1954
|
+
const values = {
|
|
1955
|
+
address1,
|
|
1956
|
+
city,
|
|
1957
|
+
state,
|
|
1958
|
+
postalCode,
|
|
1959
|
+
phone
|
|
1960
|
+
};
|
|
1961
|
+
for (const field of requiredDeliveryFields(offerCountry, country)) {
|
|
1962
|
+
if (!values[field]) {
|
|
1963
|
+
pushRequiredFieldError(errors, "shipping", APPLE_FIELD[field]);
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
const limited = [
|
|
1967
|
+
["address1", "addressLines", address1, ADDRESS_LIMITS.address1],
|
|
1968
|
+
["address2", "addressLines", address2, ADDRESS_LIMITS.address2],
|
|
1969
|
+
["city", "locality", city, ADDRESS_LIMITS.city],
|
|
1970
|
+
["state", "administrativeArea", state, ADDRESS_LIMITS.state],
|
|
1971
|
+
["postalCode", "postalCode", postalCode, ADDRESS_LIMITS.postalCode],
|
|
1972
|
+
["phone", "phoneNumber", phone, ADDRESS_LIMITS.phone]
|
|
1973
|
+
];
|
|
1974
|
+
for (const [field, appleField, value, max] of limited) {
|
|
1975
|
+
if (value.length > max) {
|
|
1976
|
+
fail(appleField, "format", msgFieldTooLong(LABEL[field], max));
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
const formatError = postalCodeFormatError(offerCountry, postalCode);
|
|
1980
|
+
if (formatError) {
|
|
1981
|
+
fail("postalCode", "format", formatError);
|
|
1982
|
+
}
|
|
1983
|
+
const latin = [
|
|
1984
|
+
["name", firstName],
|
|
1985
|
+
["name", lastName],
|
|
1986
|
+
["addressLines", address1],
|
|
1987
|
+
["addressLines", address2],
|
|
1988
|
+
["locality", city],
|
|
1989
|
+
["administrativeArea", state],
|
|
1990
|
+
["postalCode", postalCode]
|
|
1991
|
+
];
|
|
1992
|
+
for (const [field, value] of latin) {
|
|
1993
|
+
if (!isLatinCharacters(value)) {
|
|
1994
|
+
fail(field, "format", MSG_NON_LATIN_CHARACTERS);
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
if (errors.length > 0) {
|
|
1998
|
+
throw new ContactValidationError(errors);
|
|
1999
|
+
}
|
|
2000
|
+
};
|
|
2001
|
+
|
|
2002
|
+
// src/clients/payment-checkout/payment-handler.ts
|
|
2003
|
+
var failApplePaySession = (session, errors = []) => {
|
|
2004
|
+
session.completePayment({
|
|
2005
|
+
status: ApplePaySession.STATUS_FAILURE,
|
|
2006
|
+
errors
|
|
2007
|
+
});
|
|
2008
|
+
};
|
|
2009
|
+
function parseWalletApiError(err) {
|
|
2010
|
+
const body = err instanceof ApiError ? err.body : err;
|
|
2011
|
+
if (body && typeof body === "object" && "errorType" in body && "message" in body) {
|
|
2012
|
+
return body;
|
|
2013
|
+
}
|
|
2014
|
+
return null;
|
|
2015
|
+
}
|
|
2016
|
+
function validateContacts(event, sessionData, supportedBillingCountries, delivery) {
|
|
2017
|
+
billingContactDetails(
|
|
2018
|
+
event.payment.billingContact,
|
|
2019
|
+
supportedBillingCountries
|
|
2020
|
+
);
|
|
2021
|
+
if (delivery) {
|
|
2022
|
+
deliveryContactDetails(event.payment.shippingContact, {
|
|
2023
|
+
offerCountry: delivery.offerCountry,
|
|
2024
|
+
supportedDeliveryCountries: delivery.supportedCountries
|
|
2025
|
+
});
|
|
2026
|
+
}
|
|
2027
|
+
if (!sessionData.loggedIn) {
|
|
2028
|
+
return shippingContactDetails(event.payment.shippingContact).emailAddress;
|
|
2029
|
+
}
|
|
2030
|
+
return void 0;
|
|
2031
|
+
}
|
|
2032
|
+
function redirectFallback(skuId, returnUrl, country, options) {
|
|
2033
|
+
writeCheckoutRedirect(returnUrl);
|
|
2034
|
+
trackFallbackCheckout(skuId);
|
|
2035
|
+
window.location.href = redirectToCheckoutFallback({
|
|
2036
|
+
skuId,
|
|
2037
|
+
country,
|
|
2038
|
+
...options
|
|
2039
|
+
});
|
|
2040
|
+
}
|
|
2041
|
+
var ERROR_HANDLERS = {
|
|
2042
|
+
// emailError flows as an inline field error on the email input.
|
|
2043
|
+
// email pre-populates the input so the user doesn't have to retype it.
|
|
2044
|
+
EMAIL_COLLISION: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
2045
|
+
emailError: walletError.message,
|
|
2046
|
+
email: validatedEmail
|
|
2047
|
+
}),
|
|
2048
|
+
PAYMENT_DECLINED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
2049
|
+
ELIGIBILITY_REJECTED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
2050
|
+
REGISTRATION_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
2051
|
+
ACCOUNT_CREATION_FAILED: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
2052
|
+
emailError: walletError.message,
|
|
2053
|
+
email: validatedEmail
|
|
2054
|
+
}),
|
|
2055
|
+
VALIDATION_ERROR: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
2056
|
+
RECAPTCHA_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message })
|
|
2057
|
+
};
|
|
2058
|
+
function handleStructuredError(ctx) {
|
|
2059
|
+
const handler = ERROR_HANDLERS[ctx.walletError.errorType];
|
|
2060
|
+
if (handler) {
|
|
2061
|
+
handler(ctx);
|
|
2062
|
+
} else {
|
|
2063
|
+
redirectFallback(ctx.skuId, ctx.returnUrl, ctx.country, { inlineError: MSG_PAYMENT_GENERIC_ERROR });
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
2067
|
+
const { skuId, returnUrl, country } = config;
|
|
2068
|
+
let validatedEmail;
|
|
2069
|
+
try {
|
|
2070
|
+
validatedEmail = validateContacts(
|
|
2071
|
+
event,
|
|
2072
|
+
sessionData,
|
|
2073
|
+
config.supportedBillingCountries,
|
|
2074
|
+
config.delivery
|
|
2075
|
+
);
|
|
2076
|
+
const result = await performPurchase({
|
|
2077
|
+
applePayToken: event.payment.token,
|
|
2078
|
+
skuId: config.skuId,
|
|
2079
|
+
currency: config.currency,
|
|
2080
|
+
billingContact: event.payment.billingContact,
|
|
2081
|
+
...event.payment.shippingContact && {
|
|
2082
|
+
shippingContact: event.payment.shippingContact
|
|
2083
|
+
},
|
|
2084
|
+
...config.delivery && {
|
|
2085
|
+
supportedDeliveryCountries: config.delivery.supportedCountries
|
|
2086
|
+
},
|
|
2087
|
+
...ADDRESS_PARITY_ENABLED ? { strictAddressRules: true } : {},
|
|
2088
|
+
recaptchaToken: config.recaptchaToken
|
|
2089
|
+
});
|
|
2090
|
+
trackWalletPaymentSuccess(skuId, result.basketId);
|
|
2091
|
+
session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
2092
|
+
const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
|
|
2093
|
+
const userStatus = sessionData.loggedIn ? "lex" : "nex";
|
|
2094
|
+
writeCheckoutRedirect(returnUrl);
|
|
2095
|
+
window.location.href = redirectToCheckoutComplete({
|
|
2096
|
+
basketId: result.basketId,
|
|
2097
|
+
status: userStatus,
|
|
2098
|
+
skuId: decodeSku(skuId),
|
|
2099
|
+
email: successEmail,
|
|
2100
|
+
country
|
|
2101
|
+
});
|
|
2102
|
+
} catch (err) {
|
|
2103
|
+
if (err instanceof ContactValidationError) {
|
|
2104
|
+
failApplePaySession(session, err.errors);
|
|
2105
|
+
return;
|
|
2106
|
+
}
|
|
2107
|
+
const walletError = parseWalletApiError(err);
|
|
2108
|
+
trackWalletPaymentFailure(skuId, walletError?.errorType ?? "UNKNOWN");
|
|
2109
|
+
failApplePaySession(session);
|
|
2110
|
+
if (!walletError) {
|
|
2111
|
+
redirectFallback(skuId, returnUrl, country, { inlineError: MSG_PAYMENT_GENERIC_ERROR });
|
|
2112
|
+
return;
|
|
2113
|
+
}
|
|
2114
|
+
handleStructuredError({ skuId, returnUrl, country, validatedEmail, walletError });
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
|
|
1932
2118
|
// src/data/eea-countries.json
|
|
1933
2119
|
var eea_countries_default = [
|
|
1934
2120
|
"AT",
|
|
@@ -1966,10 +2152,10 @@ var eea_countries_default = [
|
|
|
1966
2152
|
];
|
|
1967
2153
|
|
|
1968
2154
|
// src/utils/billing-countries.ts
|
|
1969
|
-
var
|
|
2155
|
+
var priceZones2 = price_zones_default;
|
|
1970
2156
|
var eeaCountries = eea_countries_default;
|
|
1971
|
-
var ALL_COUNTRY_CODES = Object.values(
|
|
1972
|
-
var getZoneByCountry = (country) => Object.keys(
|
|
2157
|
+
var ALL_COUNTRY_CODES = Object.values(priceZones2).flat();
|
|
2158
|
+
var getZoneByCountry = (country) => Object.keys(priceZones2).find((key) => priceZones2[key].includes(country)) ?? null;
|
|
1973
2159
|
var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
1974
2160
|
if (offerVariant === "bundle" || offerVariant === "insider_print") {
|
|
1975
2161
|
return [...ALL_COUNTRY_CODES];
|
|
@@ -1978,50 +2164,131 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1978
2164
|
if (!zone) {
|
|
1979
2165
|
return [...ALL_COUNTRY_CODES];
|
|
1980
2166
|
}
|
|
1981
|
-
const zoneCountries =
|
|
2167
|
+
const zoneCountries = priceZones2[zone];
|
|
1982
2168
|
if (eeaCountries.includes(offerCountry)) {
|
|
1983
2169
|
return Array.from(/* @__PURE__ */ new Set([...zoneCountries, ...eeaCountries]));
|
|
1984
2170
|
}
|
|
1985
2171
|
return [...zoneCountries];
|
|
1986
2172
|
};
|
|
1987
2173
|
|
|
1988
|
-
// src/
|
|
1989
|
-
var
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
2174
|
+
// src/data/no-delivery-countries.json
|
|
2175
|
+
var no_delivery_countries_default = [
|
|
2176
|
+
"KH",
|
|
2177
|
+
"MM",
|
|
2178
|
+
"PK",
|
|
2179
|
+
"BI",
|
|
2180
|
+
"CV",
|
|
2181
|
+
"CF",
|
|
2182
|
+
"TD",
|
|
2183
|
+
"CG",
|
|
2184
|
+
"DJ",
|
|
2185
|
+
"EG",
|
|
2186
|
+
"GM",
|
|
2187
|
+
"GN",
|
|
2188
|
+
"GW",
|
|
2189
|
+
"LB",
|
|
2190
|
+
"LR",
|
|
2191
|
+
"LY",
|
|
2192
|
+
"ML",
|
|
2193
|
+
"MU",
|
|
2194
|
+
"RE",
|
|
2195
|
+
"SL",
|
|
2196
|
+
"AZ",
|
|
2197
|
+
"BY",
|
|
2198
|
+
"UA",
|
|
2199
|
+
"BM",
|
|
2200
|
+
"BO",
|
|
2201
|
+
"KY",
|
|
2202
|
+
"EC",
|
|
2203
|
+
"HN",
|
|
2204
|
+
"PA",
|
|
2205
|
+
"PE",
|
|
2206
|
+
"UY"
|
|
2207
|
+
];
|
|
2208
|
+
|
|
2209
|
+
// src/utils/delivery-countries.ts
|
|
2210
|
+
var priceZones3 = price_zones_default;
|
|
2211
|
+
var noDeliveryCountries = no_delivery_countries_default;
|
|
2212
|
+
var getSupportedDeliveryCountries = (offerCountry) => {
|
|
2213
|
+
const zone = Object.keys(priceZones3).find(
|
|
2214
|
+
(key) => priceZones3[key].includes(offerCountry)
|
|
2215
|
+
);
|
|
2216
|
+
if (!zone) return [];
|
|
2217
|
+
return priceZones3[zone].filter(
|
|
2218
|
+
(country) => !noDeliveryCountries.includes(country)
|
|
2219
|
+
);
|
|
2220
|
+
};
|
|
2221
|
+
|
|
2222
|
+
// src/utils/printOffersFlag.ts
|
|
2223
|
+
var PRINT_OFFERS_ENABLED = true;
|
|
2224
|
+
|
|
2225
|
+
// src/utils/buttonCopyFlag.ts
|
|
2226
|
+
var CONTINUE_WITH_COPY_ENABLED = true;
|
|
2227
|
+
var BUTTON_COPY = {
|
|
2228
|
+
subscribe: { caption: "Subscribe with", label: "Subscribe with Apple Pay" },
|
|
2229
|
+
continue: { caption: "Continue with", label: "Continue with Apple Pay" }
|
|
1993
2230
|
};
|
|
2231
|
+
var getButtonCopy = (enabled = CONTINUE_WITH_COPY_ENABLED) => enabled ? BUTTON_COPY.continue : BUTTON_COPY.subscribe;
|
|
1994
2232
|
|
|
1995
2233
|
// src/utils/applePayExpressEligibility.ts
|
|
1996
|
-
var
|
|
1997
|
-
var isEligibleForApplePayExpressBanner = () => isApplePayExpressHomepage() && isAppleDeviceOrSafari();
|
|
1998
|
-
var isEligibleForApplePayExpressPaywallExperiment = () => isAppleDeviceOrSafari();
|
|
2234
|
+
var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
|
|
1999
2235
|
|
|
2000
2236
|
// src/apple-pay-button.ts
|
|
2237
|
+
var PRINT_VARIANTS = ["bundle", "insider_print"];
|
|
2238
|
+
var NO_EXCLUSIONS = [];
|
|
2001
2239
|
var ENTRY_POINT_CONFIG = {
|
|
2002
2240
|
["dual_offer_banner" /* DUAL_OFFER_BANNER */]: {
|
|
2003
|
-
isEligible:
|
|
2004
|
-
|
|
2241
|
+
isEligible: () => true,
|
|
2242
|
+
returnUrl: "current_page" /* CURRENT_PAGE */,
|
|
2243
|
+
allowsPrintOffers: false
|
|
2244
|
+
},
|
|
2245
|
+
["free_trial_banner" /* FREE_TRIAL_BANNER */]: {
|
|
2246
|
+
isEligible: () => true,
|
|
2247
|
+
returnUrl: "current_page" /* CURRENT_PAGE */,
|
|
2248
|
+
allowsPrintOffers: false
|
|
2005
2249
|
},
|
|
2006
2250
|
["article_paywall" /* PAYWALL */]: {
|
|
2007
|
-
isEligible:
|
|
2008
|
-
|
|
2251
|
+
isEligible: isEligibleForApplePayExpressPaywall,
|
|
2252
|
+
returnUrl: "current_page" /* CURRENT_PAGE */,
|
|
2253
|
+
allowsPrintOffers: false
|
|
2009
2254
|
},
|
|
2010
2255
|
["article_regwall" /* REGWALL */]: {
|
|
2011
2256
|
isEligible: () => true,
|
|
2012
|
-
enabled: false
|
|
2257
|
+
enabled: false,
|
|
2258
|
+
returnUrl: "current_page" /* CURRENT_PAGE */,
|
|
2259
|
+
allowsPrintOffers: false
|
|
2260
|
+
},
|
|
2261
|
+
["free_trial_popup" /* FREE_TRIAL_POPUP */]: {
|
|
2262
|
+
isEligible: () => true,
|
|
2263
|
+
returnUrl: "current_page" /* CURRENT_PAGE */,
|
|
2264
|
+
allowsPrintOffers: false
|
|
2265
|
+
},
|
|
2266
|
+
["subscribe" /* SUBSCRIBE */]: {
|
|
2267
|
+
isEligible: () => true,
|
|
2268
|
+
// Always-on after offer exclusions — host (sma-checkout) owns rollout toggle
|
|
2269
|
+
// The offers page is not a place to return to: the host keeps the article the user arrived from (or home).
|
|
2270
|
+
returnUrl: "host_managed" /* HOST_MANAGED */,
|
|
2271
|
+
allowsPrintOffers: true
|
|
2272
|
+
},
|
|
2273
|
+
["sales_page" /* SALES_PAGE */]: {
|
|
2274
|
+
isEligible: () => true,
|
|
2275
|
+
// Host-owned page (sma-checkout), like /subscribe: the host keeps the user's return target.
|
|
2276
|
+
returnUrl: "host_managed" /* HOST_MANAGED */,
|
|
2277
|
+
// Print stays off until a sales page needs it; flip to true (and QA) to take print there.
|
|
2278
|
+
allowsPrintOffers: false
|
|
2013
2279
|
}
|
|
2014
2280
|
};
|
|
2015
|
-
var
|
|
2281
|
+
var DEFAULT_ENTRY_POINT = "dual_offer_banner" /* DUAL_OFFER_BANNER */;
|
|
2016
2282
|
var TOTAL_LABEL = "The Economist";
|
|
2017
2283
|
var DEFAULT_CURRENCY = "USD";
|
|
2018
2284
|
var DEFAULT_TOTAL = "0.00";
|
|
2019
2285
|
var SEL_CONTAINER = ".apple-pay-container";
|
|
2020
2286
|
var SEL_BUTTON = ".apple-pay-btn";
|
|
2021
|
-
var APPLE_PAY_EXCLUDED_VARIANTS =
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2287
|
+
var APPLE_PAY_EXCLUDED_VARIANTS = PRINT_VARIANTS;
|
|
2288
|
+
var getExcludedVariants = (entryPoint) => {
|
|
2289
|
+
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;
|
|
2291
|
+
};
|
|
2025
2292
|
var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
2026
2293
|
static tag = "teg-apple-pay-button";
|
|
2027
2294
|
static define() {
|
|
@@ -2030,22 +2297,19 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2030
2297
|
/**
|
|
2031
2298
|
* Creates and configures an ApplePayButton when the entry point allows it.
|
|
2032
2299
|
*
|
|
2033
|
-
* - `DUAL_OFFER_BANNER` (or omitted): always-on after
|
|
2034
|
-
* no
|
|
2035
|
-
*
|
|
2036
|
-
*
|
|
2037
|
-
* `
|
|
2300
|
+
* - `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions —
|
|
2301
|
+
* no homepage/Safari gate here. Safari/Apple is enforced later by
|
|
2302
|
+
* `isApplePayAvailable()` on mount.
|
|
2303
|
+
* - `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; distinct
|
|
2304
|
+
* TEDL `entry_point` string (`free_trial_banner`) for wallet impression attribution.
|
|
2305
|
+
* - `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate. Distinct TEDL
|
|
2306
|
+
* `entry_point` (`free_trial_popup`).
|
|
2307
|
+
* - `PAYWALL`: always-on after offer exclusions + Safari/Apple placement
|
|
2308
|
+
* eligibility. No Amplitude experiment / `$exposure`.
|
|
2038
2309
|
* - `REGWALL`: inert — always returns null.
|
|
2039
2310
|
*
|
|
2040
|
-
*
|
|
2041
|
-
* `
|
|
2042
|
-
* treatment (and without inflating `$exposure`). For banners, the same URL
|
|
2043
|
-
* param / `BYPASS_APPLE_PAY_CHECKS` only bypass **eligibility**, not an
|
|
2044
|
-
* experiment gate.
|
|
2045
|
-
*
|
|
2046
|
-
* **Eligibility:**
|
|
2047
|
-
* - `DUAL_OFFER_BANNER` (or omitted): homepage + Safari/iPhone
|
|
2048
|
-
* - `PAYWALL`: Safari/Apple device only (no homepage) — article paywalls
|
|
2311
|
+
* `BYPASS_APPLE_PAY_CHECKS` skips placement eligibility here and device checks
|
|
2312
|
+
* in `isApplePayAvailable()` on mount (QA on non-Apple browsers).
|
|
2049
2313
|
*
|
|
2050
2314
|
* @param offer - The offer to display in the Apple Pay flow.
|
|
2051
2315
|
* @param country - The user's country code.
|
|
@@ -2055,46 +2319,22 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2055
2319
|
if (!offer) {
|
|
2056
2320
|
return null;
|
|
2057
2321
|
}
|
|
2058
|
-
|
|
2059
|
-
return null;
|
|
2060
|
-
}
|
|
2061
|
-
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2062
|
-
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
2063
|
-
);
|
|
2064
|
-
const resolvedEntryPoint = entryPoint || "dual_offer_banner" /* DUAL_OFFER_BANNER */;
|
|
2322
|
+
const resolvedEntryPoint = entryPoint || DEFAULT_ENTRY_POINT;
|
|
2065
2323
|
const config = ENTRY_POINT_CONFIG[resolvedEntryPoint];
|
|
2066
2324
|
if (!config) {
|
|
2067
2325
|
return null;
|
|
2068
2326
|
}
|
|
2069
|
-
|
|
2327
|
+
if (getExcludedVariants(resolvedEntryPoint).includes(offer.product?.variant)) {
|
|
2328
|
+
return null;
|
|
2329
|
+
}
|
|
2330
|
+
const { isEligible: eligibilityCheck } = config;
|
|
2070
2331
|
const isEligible = eligibilityCheck();
|
|
2071
2332
|
if (config.enabled === false) {
|
|
2072
2333
|
return null;
|
|
2073
2334
|
}
|
|
2074
|
-
if (!
|
|
2335
|
+
if (!bypassApplePayChecks() && !isEligible) {
|
|
2075
2336
|
return null;
|
|
2076
2337
|
}
|
|
2077
|
-
if (experimentFlagKey) {
|
|
2078
|
-
const experimentValue = window.experimentIntegration?.getVariant?.(
|
|
2079
|
-
experimentFlagKey
|
|
2080
|
-
);
|
|
2081
|
-
const isExperimentVariant = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2082
|
-
if (isExperimentVariant && isEligible && !bypassApplePayChecks() && !hasUrlParamFlag) {
|
|
2083
|
-
void isApplePayAvailable().then((available) => {
|
|
2084
|
-
if (available) {
|
|
2085
|
-
trackApplePayExperimentExposure(
|
|
2086
|
-
experimentValue,
|
|
2087
|
-
getExperimentKeyFromNextData(experimentFlagKey),
|
|
2088
|
-
experimentFlagKey
|
|
2089
|
-
);
|
|
2090
|
-
}
|
|
2091
|
-
});
|
|
2092
|
-
}
|
|
2093
|
-
const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2094
|
-
if (!isTreatment && !hasUrlParamFlag) {
|
|
2095
|
-
return null;
|
|
2096
|
-
}
|
|
2097
|
-
}
|
|
2098
2338
|
_ApplePayButton.define();
|
|
2099
2339
|
const button = document.createElement(_ApplePayButton.tag);
|
|
2100
2340
|
button.offer = offer;
|
|
@@ -2120,8 +2360,13 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2120
2360
|
#readyPromise = null;
|
|
2121
2361
|
#sessionData = null;
|
|
2122
2362
|
#paymentOptions = null;
|
|
2363
|
+
/** URL of the page the button is on (sent to payment options). */
|
|
2123
2364
|
#returnUrl = "";
|
|
2365
|
+
/** `checkout-redirect` to persist after purchase, per the entry point's `ReturnUrlPolicy`; `null` = leave it. */
|
|
2366
|
+
#checkoutRedirectUrl = null;
|
|
2124
2367
|
#supportedBillingCountries = [];
|
|
2368
|
+
/** Print (bundle) offers only: countries the offer can be delivered to; `null` for offers without delivery. */
|
|
2369
|
+
#supportedDeliveryCountries = null;
|
|
2125
2370
|
#entryPoint = "";
|
|
2126
2371
|
// ─── Public API ─────────────────────────────────────────────────────────────
|
|
2127
2372
|
get offer() {
|
|
@@ -2186,33 +2431,52 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2186
2431
|
this.#sessionData = null;
|
|
2187
2432
|
this.#paymentOptions = null;
|
|
2188
2433
|
this.#returnUrl = "";
|
|
2434
|
+
this.#checkoutRedirectUrl = null;
|
|
2189
2435
|
this.#supportedBillingCountries = [];
|
|
2436
|
+
this.#supportedDeliveryCountries = null;
|
|
2190
2437
|
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2191
2438
|
}
|
|
2192
2439
|
// ─── Render pipeline ────────────────────────────────────────────────────────
|
|
2193
2440
|
async #run() {
|
|
2194
2441
|
try {
|
|
2195
2442
|
this.#renderTemplate();
|
|
2443
|
+
this.#captureReturnUrl();
|
|
2444
|
+
const requests = this.#startWalletRequests();
|
|
2196
2445
|
if (await this.#checkAvailability()) return;
|
|
2197
2446
|
if (this.#checkOffer()) return;
|
|
2198
|
-
if (await this.#checkSession()) return;
|
|
2199
|
-
this.#captureReturnUrl();
|
|
2200
2447
|
this.#computeBillingCountries();
|
|
2201
|
-
if (
|
|
2448
|
+
if (this.#computeDeliveryCountries()) return;
|
|
2449
|
+
const [session, options] = await requests;
|
|
2450
|
+
if (this.#applySession(session)) return;
|
|
2451
|
+
if (this.#applyPaymentOptions(options)) return;
|
|
2202
2452
|
this.#finishLoading();
|
|
2203
2453
|
} catch {
|
|
2204
|
-
this
|
|
2205
|
-
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2454
|
+
this.#hide();
|
|
2206
2455
|
} finally {
|
|
2207
2456
|
this.#rendering = false;
|
|
2208
2457
|
}
|
|
2209
2458
|
}
|
|
2459
|
+
/**
|
|
2460
|
+
* Stop the loading spinner before tear-down so Safari does not leave a GPU
|
|
2461
|
+
* ghost of `.apple-pay-btn.wap-loading::before` after the container is removed.
|
|
2462
|
+
*/
|
|
2463
|
+
#hide() {
|
|
2464
|
+
const button = this.querySelector(SEL_BUTTON);
|
|
2465
|
+
if (button) {
|
|
2466
|
+
button.classList.remove("wap-loading");
|
|
2467
|
+
button.removeAttribute("aria-busy");
|
|
2468
|
+
button.getAnimations?.({ subtree: true }).forEach((animation) => animation.cancel());
|
|
2469
|
+
}
|
|
2470
|
+
this.getAnimations?.({ subtree: true }).forEach((animation) => animation.cancel());
|
|
2471
|
+
void this.offsetHeight;
|
|
2472
|
+
this.style.display = "none";
|
|
2473
|
+
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2474
|
+
}
|
|
2210
2475
|
/** Returns `true` (hide) when Apple Pay is unavailable on this device/browser. */
|
|
2211
2476
|
async #checkAvailability() {
|
|
2212
2477
|
const available = await isApplePayAvailable();
|
|
2213
2478
|
if (!available) {
|
|
2214
|
-
this
|
|
2215
|
-
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2479
|
+
this.#hide();
|
|
2216
2480
|
return true;
|
|
2217
2481
|
}
|
|
2218
2482
|
return false;
|
|
@@ -2221,11 +2485,17 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2221
2485
|
* Returns `true` (hide) when the user already has an active subscription or is B2B.
|
|
2222
2486
|
* Session fetch errors are swallowed — the component continues as an anonymous user.
|
|
2223
2487
|
*/
|
|
2224
|
-
|
|
2225
|
-
|
|
2488
|
+
/** Starts the session and payment-options calls together (neither depends on the other). */
|
|
2489
|
+
#startWalletRequests() {
|
|
2490
|
+
if (!this.#offer || !isApplePayCapable()) {
|
|
2491
|
+
return Promise.resolve([null, null]);
|
|
2492
|
+
}
|
|
2493
|
+
return Promise.all([this.#fetchSession(), this.#fetchPaymentOptions()]);
|
|
2494
|
+
}
|
|
2495
|
+
#applySession(session) {
|
|
2496
|
+
this.#sessionData = session;
|
|
2226
2497
|
if (this.#sessionData?.loggedIn && (this.#sessionData.userType === "active-subscription" || this.#sessionData.userType === "b2b-user")) {
|
|
2227
|
-
this
|
|
2228
|
-
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2498
|
+
this.#hide();
|
|
2229
2499
|
return true;
|
|
2230
2500
|
}
|
|
2231
2501
|
return false;
|
|
@@ -2233,8 +2503,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2233
2503
|
/** Returns `true` (hide) when no offer has been set before mount. */
|
|
2234
2504
|
#checkOffer() {
|
|
2235
2505
|
if (!this.#offer) {
|
|
2236
|
-
this
|
|
2237
|
-
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2506
|
+
this.#hide();
|
|
2238
2507
|
return true;
|
|
2239
2508
|
}
|
|
2240
2509
|
return false;
|
|
@@ -2242,6 +2511,11 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2242
2511
|
/** Captures the current page URL once at mount for reuse across the session lifetime. */
|
|
2243
2512
|
#captureReturnUrl() {
|
|
2244
2513
|
this.#returnUrl = captureOriginUrl();
|
|
2514
|
+
const config = ENTRY_POINT_CONFIG[this.#entryPoint || DEFAULT_ENTRY_POINT] ?? ENTRY_POINT_CONFIG[DEFAULT_ENTRY_POINT];
|
|
2515
|
+
this.#checkoutRedirectUrl = resolveCheckoutRedirectUrl(
|
|
2516
|
+
config.returnUrl,
|
|
2517
|
+
this.#returnUrl
|
|
2518
|
+
);
|
|
2245
2519
|
}
|
|
2246
2520
|
/**
|
|
2247
2521
|
* Computes supported billing countries once at mount.
|
|
@@ -2254,15 +2528,32 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2254
2528
|
this.#offer.product?.variant ?? ""
|
|
2255
2529
|
);
|
|
2256
2530
|
}
|
|
2531
|
+
/**
|
|
2532
|
+
* Print (bundle) offers need a delivery address, which the Apple Pay sheet collects. Returns `true` (hide)
|
|
2533
|
+
* when the offer has no country it can be delivered to, because no valid address could ever be entered.
|
|
2534
|
+
*/
|
|
2535
|
+
#computeDeliveryCountries() {
|
|
2536
|
+
const variant = this.#offer.product?.variant;
|
|
2537
|
+
if (!PRINT_VARIANTS.includes(variant)) {
|
|
2538
|
+
this.#supportedDeliveryCountries = null;
|
|
2539
|
+
return false;
|
|
2540
|
+
}
|
|
2541
|
+
const countries = getSupportedDeliveryCountries(this.#country);
|
|
2542
|
+
if (countries.length === 0) {
|
|
2543
|
+
this.#hide();
|
|
2544
|
+
return true;
|
|
2545
|
+
}
|
|
2546
|
+
this.#supportedDeliveryCountries = countries;
|
|
2547
|
+
return false;
|
|
2548
|
+
}
|
|
2257
2549
|
/**
|
|
2258
2550
|
* Returns `true` (hide) when the wallet BFF reports Apple Pay is unavailable
|
|
2259
2551
|
* for this offer. The response is cached and reused in `#initiateApplePay`.
|
|
2260
2552
|
*/
|
|
2261
|
-
|
|
2262
|
-
this.#paymentOptions =
|
|
2553
|
+
#applyPaymentOptions(options) {
|
|
2554
|
+
this.#paymentOptions = options;
|
|
2263
2555
|
if (!this.#paymentOptions?.options?.apple_pay) {
|
|
2264
|
-
this
|
|
2265
|
-
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2556
|
+
this.#hide();
|
|
2266
2557
|
return true;
|
|
2267
2558
|
}
|
|
2268
2559
|
return false;
|
|
@@ -2270,11 +2561,14 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2270
2561
|
/** Injects the button template and wires click and confirm event listeners. */
|
|
2271
2562
|
#renderTemplate() {
|
|
2272
2563
|
this.style.removeProperty("display");
|
|
2273
|
-
ensureApplePayLogoSymbol();
|
|
2274
2564
|
const template = document.createElement("template");
|
|
2275
2565
|
template.innerHTML = apple_pay_button_template_default;
|
|
2276
2566
|
this.appendChild(template.content.cloneNode(true));
|
|
2277
2567
|
const button = this.querySelector(SEL_BUTTON);
|
|
2568
|
+
const { caption, label } = getButtonCopy();
|
|
2569
|
+
this.querySelector(SEL_CONTAINER)?.setAttribute("aria-label", label);
|
|
2570
|
+
button.setAttribute("aria-label", label);
|
|
2571
|
+
this.querySelector(".apple-pay-btn__caption").textContent = caption;
|
|
2278
2572
|
button.classList.add("wap-loading");
|
|
2279
2573
|
button.setAttribute("disabled", "");
|
|
2280
2574
|
button.setAttribute("aria-disabled", "true");
|
|
@@ -2315,7 +2609,10 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2315
2609
|
if (document.querySelector(ApplePayModal.tag)) {
|
|
2316
2610
|
return;
|
|
2317
2611
|
}
|
|
2318
|
-
trackExpressWalletClick(
|
|
2612
|
+
trackExpressWalletClick(
|
|
2613
|
+
this.#offer.sku_id,
|
|
2614
|
+
this.#entryPoint ? { entryPoint: this.#entryPoint } : void 0
|
|
2615
|
+
);
|
|
2319
2616
|
ApplePayModal.define();
|
|
2320
2617
|
const modal = document.createElement(ApplePayModal.tag);
|
|
2321
2618
|
modal.offer = this.#offer;
|
|
@@ -2359,16 +2656,25 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2359
2656
|
totalAmount,
|
|
2360
2657
|
totalLabel: TOTAL_LABEL,
|
|
2361
2658
|
skuId,
|
|
2362
|
-
returnUrl: this.#
|
|
2659
|
+
returnUrl: this.#checkoutRedirectUrl,
|
|
2363
2660
|
userLoggedIn: sessionData.loggedIn,
|
|
2661
|
+
...this.#supportedDeliveryCountries && {
|
|
2662
|
+
delivery: { supportedCountries: this.#supportedDeliveryCountries }
|
|
2663
|
+
},
|
|
2364
2664
|
onPaymentAuthorized: async (event, session) => {
|
|
2365
2665
|
const recaptchaToken = await recaptchaTokenPromise;
|
|
2366
2666
|
return handlePaymentAuthorized(event, session, sessionData, {
|
|
2367
2667
|
skuId,
|
|
2368
2668
|
country,
|
|
2369
2669
|
currency: offer.price?.currency_code ?? DEFAULT_CURRENCY,
|
|
2370
|
-
returnUrl: this.#
|
|
2670
|
+
returnUrl: this.#checkoutRedirectUrl,
|
|
2371
2671
|
supportedBillingCountries: this.#supportedBillingCountries,
|
|
2672
|
+
...this.#supportedDeliveryCountries && {
|
|
2673
|
+
delivery: {
|
|
2674
|
+
offerCountry: country,
|
|
2675
|
+
supportedCountries: this.#supportedDeliveryCountries
|
|
2676
|
+
}
|
|
2677
|
+
},
|
|
2372
2678
|
recaptchaToken
|
|
2373
2679
|
});
|
|
2374
2680
|
}
|
|
@@ -2392,7 +2698,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2392
2698
|
);
|
|
2393
2699
|
} catch {
|
|
2394
2700
|
redirectToFallbackCheckout({
|
|
2395
|
-
returnUrl: this.#
|
|
2701
|
+
returnUrl: this.#checkoutRedirectUrl,
|
|
2396
2702
|
skuId,
|
|
2397
2703
|
countryCode: country
|
|
2398
2704
|
});
|
|
@@ -2401,5 +2707,6 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2401
2707
|
};
|
|
2402
2708
|
export {
|
|
2403
2709
|
APPLE_PAY_EXCLUDED_VARIANTS,
|
|
2404
|
-
ApplePayButton
|
|
2710
|
+
ApplePayButton,
|
|
2711
|
+
getExcludedVariants
|
|
2405
2712
|
};
|