@economist/web-apple-pay 2.0.0-beta.2 → 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 +26 -8
- package/dist/index.js +647 -349
- package/dist/src/apple-pay-button.d.ts +18 -16
- package/dist/src/apple-pay-button.js +636 -340
- package/dist/src/apple-pay-button.stories.js +633 -339
- package/dist/src/apple-pay-modal.js +44 -39
- package/dist/src/apple-pay-modal.stories.js +633 -339
- 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 +7 -28
- package/dist/src/constants.js +3 -7
- package/dist/src/index.d.ts +2 -4
- package/dist/src/index.js +647 -349
- 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 +5 -6
- 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 +0 -15
- package/dist/src/utils/expressCheckoutTracking.js +0 -27
- 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
package/dist/src/index.js
CHANGED
|
@@ -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>
|
|
@@ -567,15 +564,21 @@ var configureApplePay = (config) => {
|
|
|
567
564
|
var getApplePayConfig = () => runtimeConfig;
|
|
568
565
|
|
|
569
566
|
// src/utils/recaptcha.ts
|
|
567
|
+
var findScriptForKey = (siteKey) => Array.from(
|
|
568
|
+
document.querySelectorAll(
|
|
569
|
+
'script[src*="recaptcha/api.js"]'
|
|
570
|
+
)
|
|
571
|
+
).find((script) => script.src.includes(`render=${siteKey}`));
|
|
572
|
+
var pendingLoads = /* @__PURE__ */ new Map();
|
|
570
573
|
var loadRecaptchaScript = (siteKey) => {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
if (
|
|
577
|
-
|
|
578
|
-
|
|
574
|
+
const pending = pendingLoads.get(siteKey);
|
|
575
|
+
if (pending) return pending;
|
|
576
|
+
const ownScript = findScriptForKey(siteKey);
|
|
577
|
+
if (ownScript && typeof grecaptcha !== "undefined") return Promise.resolve();
|
|
578
|
+
const load = new Promise((resolve, reject) => {
|
|
579
|
+
if (ownScript) {
|
|
580
|
+
ownScript.addEventListener("load", () => resolve());
|
|
581
|
+
ownScript.addEventListener("error", () => {
|
|
579
582
|
reject(new Error("Failed to load existing reCAPTCHA script"));
|
|
580
583
|
});
|
|
581
584
|
return;
|
|
@@ -590,6 +593,9 @@ var loadRecaptchaScript = (siteKey) => {
|
|
|
590
593
|
};
|
|
591
594
|
document.head.appendChild(script);
|
|
592
595
|
});
|
|
596
|
+
pendingLoads.set(siteKey, load);
|
|
597
|
+
load.catch(() => pendingLoads.delete(siteKey));
|
|
598
|
+
return load;
|
|
593
599
|
};
|
|
594
600
|
var getRecaptchaToken = async (action) => {
|
|
595
601
|
const siteKey = getApplePayConfig()?.recaptchaSiteKey;
|
|
@@ -854,7 +860,6 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
|
|
|
854
860
|
if (this.querySelector(".apm-overlay")) {
|
|
855
861
|
return;
|
|
856
862
|
}
|
|
857
|
-
ensureApplePayLogoSymbol();
|
|
858
863
|
const template = document.createElement("template");
|
|
859
864
|
template.innerHTML = apple_pay_modal_template_default;
|
|
860
865
|
this.appendChild(template.content.cloneNode(true));
|
|
@@ -1007,8 +1012,13 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
|
|
|
1007
1012
|
// src/templates/apple-pay-button.template.html
|
|
1008
1013
|
var apple_pay_button_template_default = `<style>
|
|
1009
1014
|
/*
|
|
1010
|
-
* Entry CTA:
|
|
1011
|
-
*
|
|
1015
|
+
* Entry CTA: caption + Apple Pay wordmark, built from text (no SVG), as in Figma (Play Global Spec 3268:39728):
|
|
1016
|
+
* black #0d0d0d, 4px radius, 40px high, 8px 16px padding, 4px gap.
|
|
1017
|
+
* Marber tokens (as bound in Figma): caption size label-2-size (15px), line height label-3-leading (24px);
|
|
1018
|
+
* glyph + "Pay" 17px (label-3-size) with auto line height; padding spacing-xs / spacing-md; gap + radius spacing-2xs;
|
|
1019
|
+
* background london-5. Expected content widths in Figma: caption 98px, wordmark 42px, button content 176px.
|
|
1020
|
+
* Caption: SF Pro Regular. Wordmark: the Apple glyph (U+F8FF, Regular) + "Pay" (Medium 510).
|
|
1021
|
+
* SF Pro is the system font on Apple devices, which are the only devices Apple Pay is shown on.
|
|
1012
1022
|
*/
|
|
1013
1023
|
teg-apple-pay-button {
|
|
1014
1024
|
display: block;
|
|
@@ -1033,46 +1043,45 @@ var apple_pay_button_template_default = `<style>
|
|
|
1033
1043
|
min-width: 0;
|
|
1034
1044
|
height: 100%;
|
|
1035
1045
|
min-height: var(--apple-pay-height, 2.5rem);
|
|
1036
|
-
|
|
1046
|
+
/* Figma button content: 8px 16px */
|
|
1047
|
+
padding: var(--mb-spacing-xs, 0.5rem) var(--mb-spacing-md, 1rem);
|
|
1037
1048
|
box-sizing: border-box;
|
|
1038
|
-
background-color: var(--apple-pay-background-color, #
|
|
1049
|
+
background-color: var(--apple-pay-background-color, var(--mb-colour-greyscale-london-5, #0d0d0d));
|
|
1039
1050
|
color: var(--apple-pay-foreground-color, #fff);
|
|
1040
1051
|
border: none;
|
|
1041
|
-
border-radius: var(--apple-pay-border-radius, 0.25rem);
|
|
1052
|
+
border-radius: var(--apple-pay-border-radius, var(--mb-spacing-2xs, 0.25rem));
|
|
1042
1053
|
cursor: pointer;
|
|
1043
|
-
/*
|
|
1044
|
-
font-family:
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
line
|
|
1054
|
+
/* Figma: SF Pro (system font on Apple devices), Regular 15 / 24 */
|
|
1055
|
+
font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro', system-ui, sans-serif;
|
|
1056
|
+
font-size: var(--mb-typestyle-label-2-size, 0.9375rem);
|
|
1057
|
+
font-weight: 400;
|
|
1058
|
+
font-variation-settings: 'wdth' 100;
|
|
1059
|
+
/* Figma letter spacing 0 */
|
|
1060
|
+
letter-spacing: 0;
|
|
1061
|
+
/* Figma caption: line height is the label-3-leading token (24px) */
|
|
1062
|
+
line-height: var(--mb-typestyle-label-3-leading, 1.5rem);
|
|
1051
1063
|
}
|
|
1052
1064
|
|
|
1053
1065
|
teg-apple-pay-button .apple-pay-btn__label {
|
|
1054
1066
|
display: inline-flex;
|
|
1055
1067
|
align-items: center;
|
|
1056
|
-
/*
|
|
1057
|
-
gap: 0;
|
|
1068
|
+
/* Figma: 4px between the caption and the wordmark */
|
|
1069
|
+
gap: var(--mb-spacing-2xs, 0.25rem);
|
|
1058
1070
|
white-space: nowrap;
|
|
1059
1071
|
}
|
|
1060
1072
|
|
|
1061
|
-
teg-apple-pay-button .apple-pay-
|
|
1062
|
-
|
|
1063
|
-
|
|
1073
|
+
teg-apple-pay-button .apple-pay-btn__logo {
|
|
1074
|
+
display: inline-flex;
|
|
1075
|
+
align-items: baseline;
|
|
1076
|
+
/* Figma "Pay" layer: 17px (label-3 size) with AUTO line height (a 20px box centred in the 24px caption row),
|
|
1077
|
+
not the 24px leading token the caption uses. */
|
|
1078
|
+
font-size: var(--mb-typestyle-label-3-size, 1.0625rem);
|
|
1079
|
+
line-height: normal;
|
|
1064
1080
|
}
|
|
1065
1081
|
|
|
1066
|
-
teg-apple-pay-button .apple-pay-btn__logo {
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
/* Match caption font-size so mark aligns with text metrics */
|
|
1070
|
-
height: 1.05em;
|
|
1071
|
-
width: auto;
|
|
1072
|
-
aspect-ratio: 51 / 22;
|
|
1073
|
-
color: currentColor;
|
|
1074
|
-
/* Optical nudge \u2014 SVG viewBox sits slightly high vs EconomistSans caps */
|
|
1075
|
-
transform: translateY(0.06em);
|
|
1082
|
+
teg-apple-pay-button .apple-pay-btn__logo-word {
|
|
1083
|
+
font-weight: 510;
|
|
1084
|
+
font-variation-settings: 'wdth' 100;
|
|
1076
1085
|
}
|
|
1077
1086
|
|
|
1078
1087
|
teg-apple-pay-button .apple-pay-btn.wap-loading {
|
|
@@ -1109,6 +1118,7 @@ var apple_pay_button_template_default = `<style>
|
|
|
1109
1118
|
transform: translate(-50%, -50%) rotate(360deg);
|
|
1110
1119
|
}
|
|
1111
1120
|
}
|
|
1121
|
+
|
|
1112
1122
|
</style>
|
|
1113
1123
|
|
|
1114
1124
|
<div class="apple-pay-container" aria-label="Subscribe with Apple Pay">
|
|
@@ -1120,16 +1130,10 @@ var apple_pay_button_template_default = `<style>
|
|
|
1120
1130
|
>
|
|
1121
1131
|
<span class="apple-pay-btn__label"
|
|
1122
1132
|
><span class="apple-pay-btn__caption">Subscribe with</span
|
|
1123
|
-
><
|
|
1124
|
-
class="apple-pay-btn__logo"
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
viewBox="0 0 51 22"
|
|
1128
|
-
aria-hidden="true"
|
|
1129
|
-
role="img"
|
|
1130
|
-
>
|
|
1131
|
-
<use href="#apple-pay-logo" />
|
|
1132
|
-
</svg
|
|
1133
|
+
><span class="apple-pay-btn__logo" aria-hidden="true"
|
|
1134
|
+
><span class="apple-pay-btn__logo-glyph"></span
|
|
1135
|
+
><span class="apple-pay-btn__logo-word">Pay</span
|
|
1136
|
+
></span
|
|
1133
1137
|
></span>
|
|
1134
1138
|
<span class="apple-pay-btn__loading" aria-hidden="true">Loading...</span>
|
|
1135
1139
|
</button>
|
|
@@ -1143,7 +1147,7 @@ var isAppleDeviceOrSafari = () => {
|
|
|
1143
1147
|
return isIOSOrMacTouchDevice || isSafariBrowser;
|
|
1144
1148
|
};
|
|
1145
1149
|
var bypassApplePayChecks = () => new URLSearchParams(window.location.search).get("BYPASS_APPLE_PAY_CHECKS") !== null;
|
|
1146
|
-
var
|
|
1150
|
+
var isApplePayCapable = () => {
|
|
1147
1151
|
if (bypassApplePayChecks()) {
|
|
1148
1152
|
return true;
|
|
1149
1153
|
}
|
|
@@ -1155,18 +1159,21 @@ var isApplePayAvailable = async () => {
|
|
|
1155
1159
|
return false;
|
|
1156
1160
|
}
|
|
1157
1161
|
try {
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1162
|
+
return typeof applePaySession.canMakePayments === "function" && applePaySession.canMakePayments() && Boolean(getApplePayConfig()?.merchantId);
|
|
1163
|
+
} catch {
|
|
1164
|
+
return false;
|
|
1165
|
+
}
|
|
1166
|
+
};
|
|
1167
|
+
var isApplePayAvailable = async () => {
|
|
1168
|
+
if (bypassApplePayChecks()) {
|
|
1169
|
+
return true;
|
|
1170
|
+
}
|
|
1171
|
+
if (!isApplePayCapable()) {
|
|
1172
|
+
return false;
|
|
1173
|
+
}
|
|
1174
|
+
try {
|
|
1175
|
+
const merchantId = getApplePayConfig().merchantId;
|
|
1176
|
+
return await window.ApplePaySession.canMakePaymentsWithActiveCard(merchantId);
|
|
1170
1177
|
} catch {
|
|
1171
1178
|
return false;
|
|
1172
1179
|
}
|
|
@@ -1247,11 +1254,23 @@ var performPurchase = (data) => {
|
|
|
1247
1254
|
};
|
|
1248
1255
|
|
|
1249
1256
|
// src/clients/payment-checkout/session.ts
|
|
1257
|
+
var inFlight = null;
|
|
1250
1258
|
var getExpressCheckoutSession = () => {
|
|
1251
|
-
|
|
1259
|
+
if (inFlight) {
|
|
1260
|
+
return inFlight;
|
|
1261
|
+
}
|
|
1262
|
+
const request = apiFetch("/v1/wallet/session", {
|
|
1252
1263
|
method: "GET",
|
|
1253
1264
|
credentials: "include"
|
|
1254
1265
|
});
|
|
1266
|
+
inFlight = request;
|
|
1267
|
+
const clear = () => {
|
|
1268
|
+
if (inFlight === request) {
|
|
1269
|
+
inFlight = null;
|
|
1270
|
+
}
|
|
1271
|
+
};
|
|
1272
|
+
request.then(clear, clear);
|
|
1273
|
+
return request;
|
|
1255
1274
|
};
|
|
1256
1275
|
|
|
1257
1276
|
// src/utils/expressCheckoutRedirect.ts
|
|
@@ -1266,8 +1285,13 @@ function isAllowedRedirectUrl(url) {
|
|
|
1266
1285
|
return false;
|
|
1267
1286
|
}
|
|
1268
1287
|
}
|
|
1288
|
+
var CHECKOUT_REDIRECT_BY_POLICY = {
|
|
1289
|
+
["current_page" /* CURRENT_PAGE */]: (currentPageUrl) => currentPageUrl,
|
|
1290
|
+
["host_managed" /* HOST_MANAGED */]: () => null
|
|
1291
|
+
};
|
|
1292
|
+
var resolveCheckoutRedirectUrl = (policy, currentPageUrl) => CHECKOUT_REDIRECT_BY_POLICY[policy](currentPageUrl);
|
|
1269
1293
|
var writeCheckoutRedirect = (originUrl) => {
|
|
1270
|
-
if (!isAllowedRedirectUrl(originUrl)) return;
|
|
1294
|
+
if (originUrl === null || !isAllowedRedirectUrl(originUrl)) return;
|
|
1271
1295
|
try {
|
|
1272
1296
|
localStorage.setItem(CHECKOUT_REDIRECT_KEY, originUrl);
|
|
1273
1297
|
} catch {
|
|
@@ -1303,20 +1327,6 @@ var redirectToCheckoutFallback = (params) => {
|
|
|
1303
1327
|
return url.pathname + url.search;
|
|
1304
1328
|
};
|
|
1305
1329
|
|
|
1306
|
-
// src/constants.ts
|
|
1307
|
-
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
1308
|
-
ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
|
|
1309
|
-
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
1310
|
-
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
1311
|
-
ApplePayEntryPoint2["FREE_TRIAL_BANNER"] = "free_trial_banner";
|
|
1312
|
-
return ApplePayEntryPoint2;
|
|
1313
|
-
})(ApplePayEntryPoint || {});
|
|
1314
|
-
var APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-paywalls";
|
|
1315
|
-
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
1316
|
-
CONTROL: "control",
|
|
1317
|
-
TREATMENT: "treatment"
|
|
1318
|
-
};
|
|
1319
|
-
|
|
1320
1330
|
// src/utils/expressCheckoutTracking.ts
|
|
1321
1331
|
var EXPRESS_CHECKOUT_EVENTS = {
|
|
1322
1332
|
/** Wallet button displayed */
|
|
@@ -1354,26 +1364,6 @@ var track = (action, extra) => {
|
|
|
1354
1364
|
...extra
|
|
1355
1365
|
});
|
|
1356
1366
|
};
|
|
1357
|
-
var trackApplePayExperimentExposure = (variant, experimentKey, flagKey) => {
|
|
1358
|
-
const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
1359
|
-
if (!isActiveVariant) {
|
|
1360
|
-
return;
|
|
1361
|
-
}
|
|
1362
|
-
const exposures = window.__applePayExperimentExposures ?? {};
|
|
1363
|
-
window.__applePayExperimentExposures = exposures;
|
|
1364
|
-
const pathname = window.location?.pathname ?? "";
|
|
1365
|
-
const dedupeKey = `${pathname}:${flagKey}:${variant}`;
|
|
1366
|
-
if (exposures[dedupeKey]) {
|
|
1367
|
-
return;
|
|
1368
|
-
}
|
|
1369
|
-
exposures[dedupeKey] = true;
|
|
1370
|
-
emitTedlEvent({
|
|
1371
|
-
name: "$exposure",
|
|
1372
|
-
flag_key: flagKey,
|
|
1373
|
-
variant,
|
|
1374
|
-
...experimentKey ? { experiment_key: experimentKey } : {}
|
|
1375
|
-
});
|
|
1376
|
-
};
|
|
1377
1367
|
var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
|
|
1378
1368
|
track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
|
|
1379
1369
|
wallet_type: "apple_pay",
|
|
@@ -1418,21 +1408,10 @@ var trackValidationFieldError = (field, errorType) => {
|
|
|
1418
1408
|
var MSG_MISSING_REQUIRED_FIELD = "Missing required field";
|
|
1419
1409
|
var MSG_EMAIL_WRONG_FORMAT = "That email doesn\u2019t look right. Please enter a valid email address.";
|
|
1420
1410
|
var MSG_EMAIL_TOO_LONG = "This field must be 80 characters or less.";
|
|
1411
|
+
var MSG_NON_LATIN_CHARACTERS = "Please use Latin characters only.";
|
|
1412
|
+
var msgFieldTooLong = (label, max) => `${label} must be ${max} characters or less`;
|
|
1413
|
+
var MSG_UNSUPPORTED_DELIVERY_COUNTRY = "We can't deliver this print edition to that country. Try a different delivery address.";
|
|
1421
1414
|
var MSG_UNSUPPORTED_BILLING_COUNTRY = "Billing country does not match offer price zone";
|
|
1422
|
-
var BILLING_COUNTRY_MISMATCH_FALLBACK = "Country not supported for this purchase";
|
|
1423
|
-
var MSG_BILLING_COUNTRY_MISMATCH_REDIRECT = "This country isn\u2019t supported for this purchase. Try updating your billing address.";
|
|
1424
|
-
var buildCountryMismatchMessage = (countryCode) => {
|
|
1425
|
-
if (!countryCode) return BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
1426
|
-
try {
|
|
1427
|
-
const regionNames = new Intl.DisplayNames(["en"], { type: "region", fallback: "none" });
|
|
1428
|
-
const upper = countryCode.toUpperCase();
|
|
1429
|
-
const countryName = regionNames.of(upper);
|
|
1430
|
-
const isResolved = countryName && countryName !== upper && countryName !== "Unknown Region";
|
|
1431
|
-
return isResolved ? `${countryName} address required` : BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
1432
|
-
} catch {
|
|
1433
|
-
return BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
1434
|
-
}
|
|
1435
|
-
};
|
|
1436
1415
|
var MSG_PAYMENT_GENERIC_ERROR = "Something went wrong. Please check your payment and billing details and try again or contact us.";
|
|
1437
1416
|
var MSG_CONTACT_VALIDATION_INTERNAL = "Could not validate Apple Pay contact";
|
|
1438
1417
|
|
|
@@ -1470,7 +1449,12 @@ async function handleMerchantValidation(event, session, config) {
|
|
|
1470
1449
|
redirectToFallbackCheckout(config);
|
|
1471
1450
|
}
|
|
1472
1451
|
}
|
|
1452
|
+
var requiredShippingFields = (config) => [
|
|
1453
|
+
...config.delivery ? ["postalAddress", "name", "phone"] : [],
|
|
1454
|
+
...config.userLoggedIn ? [] : ["email"]
|
|
1455
|
+
];
|
|
1473
1456
|
function startApplePaySession(config) {
|
|
1457
|
+
const shippingFields = requiredShippingFields(config);
|
|
1474
1458
|
const paymentRequest = {
|
|
1475
1459
|
countryCode: config.countryCode,
|
|
1476
1460
|
currencyCode: config.currencyCode,
|
|
@@ -1481,14 +1465,33 @@ function startApplePaySession(config) {
|
|
|
1481
1465
|
amount: config.totalAmount
|
|
1482
1466
|
},
|
|
1483
1467
|
requiredBillingContactFields: ["postalAddress", "name"],
|
|
1484
|
-
|
|
1485
|
-
|
|
1468
|
+
...shippingFields.length > 0 && {
|
|
1469
|
+
requiredShippingContactFields: shippingFields
|
|
1470
|
+
}
|
|
1486
1471
|
};
|
|
1487
1472
|
try {
|
|
1488
1473
|
const session = new ApplePaySession(3, paymentRequest);
|
|
1489
1474
|
session.onvalidatemerchant = async (event) => {
|
|
1490
1475
|
await handleMerchantValidation(event, session, config);
|
|
1491
1476
|
};
|
|
1477
|
+
const delivery = config.delivery;
|
|
1478
|
+
if (delivery) {
|
|
1479
|
+
session.onshippingcontactselected = (event) => {
|
|
1480
|
+
const country = event.shippingContact.countryCode?.toUpperCase();
|
|
1481
|
+
session.completeShippingContactSelection({
|
|
1482
|
+
newTotal: paymentRequest.total,
|
|
1483
|
+
...country && !delivery.supportedCountries.includes(country) && {
|
|
1484
|
+
errors: [
|
|
1485
|
+
new ApplePayError(
|
|
1486
|
+
"shippingContactInvalid",
|
|
1487
|
+
"countryCode",
|
|
1488
|
+
MSG_UNSUPPORTED_DELIVERY_COUNTRY
|
|
1489
|
+
)
|
|
1490
|
+
]
|
|
1491
|
+
}
|
|
1492
|
+
});
|
|
1493
|
+
};
|
|
1494
|
+
}
|
|
1492
1495
|
session.onpaymentauthorized = (event) => {
|
|
1493
1496
|
trackWalletPaymentAuthorised(config.skuId);
|
|
1494
1497
|
config.onPaymentAuthorized(event, session).catch(() => {
|
|
@@ -1529,6 +1532,16 @@ var ContactValidationError = class extends Error {
|
|
|
1529
1532
|
}
|
|
1530
1533
|
};
|
|
1531
1534
|
|
|
1535
|
+
// src/utils/latin-characters.ts
|
|
1536
|
+
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";
|
|
1537
|
+
var LATIN_CHARACTERS_REGEX = new RegExp(
|
|
1538
|
+
`^[\\x20-\\x7E${SUPPORTED_DIACRITICS}]*$`
|
|
1539
|
+
);
|
|
1540
|
+
var isLatinCharacters = (value) => LATIN_CHARACTERS_REGEX.test(value);
|
|
1541
|
+
|
|
1542
|
+
// src/utils/addressParityFlag.ts
|
|
1543
|
+
var ADDRESS_PARITY_ENABLED = true;
|
|
1544
|
+
|
|
1532
1545
|
// src/clients/payment-checkout/billing-contact-details.ts
|
|
1533
1546
|
var countriesWithoutCityField = ["KY", "CK", "NR", "TC"];
|
|
1534
1547
|
var countriesRequiringAllFields = ["US", "CA", "GB"];
|
|
@@ -1576,6 +1589,35 @@ var validateCountrySupport = (errors, country, supportedBillingCountries) => {
|
|
|
1576
1589
|
);
|
|
1577
1590
|
}
|
|
1578
1591
|
};
|
|
1592
|
+
var validateLatinCharacters = (errors, contact, firstName, lastName) => {
|
|
1593
|
+
if (!isLatinCharacters(firstName) || !isLatinCharacters(lastName)) {
|
|
1594
|
+
pushFieldError(
|
|
1595
|
+
errors,
|
|
1596
|
+
"billing",
|
|
1597
|
+
"name",
|
|
1598
|
+
"format",
|
|
1599
|
+
MSG_NON_LATIN_CHARACTERS
|
|
1600
|
+
);
|
|
1601
|
+
}
|
|
1602
|
+
const addressFields = [
|
|
1603
|
+
["addressLines", contact.addressLines?.at(0)],
|
|
1604
|
+
["addressLines", contact.addressLines?.at(1)],
|
|
1605
|
+
["locality", contact.locality],
|
|
1606
|
+
["administrativeArea", contact.administrativeArea],
|
|
1607
|
+
["postalCode", contact.postalCode]
|
|
1608
|
+
];
|
|
1609
|
+
for (const [field, value] of addressFields) {
|
|
1610
|
+
if (value && !isLatinCharacters(value)) {
|
|
1611
|
+
pushFieldError(
|
|
1612
|
+
errors,
|
|
1613
|
+
"billing",
|
|
1614
|
+
field,
|
|
1615
|
+
"format",
|
|
1616
|
+
MSG_NON_LATIN_CHARACTERS
|
|
1617
|
+
);
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
};
|
|
1579
1621
|
var billingContactDetails = (contact, supportedBillingCountries) => {
|
|
1580
1622
|
const errors = [];
|
|
1581
1623
|
const country = contact.countryCode?.toUpperCase() || pushRequiredFieldError(errors, "billing", "country");
|
|
@@ -1583,6 +1625,9 @@ var billingContactDetails = (contact, supportedBillingCountries) => {
|
|
|
1583
1625
|
validateAddressFields(errors, contact, config);
|
|
1584
1626
|
const { firstName, lastName } = validateNameFields(errors, contact);
|
|
1585
1627
|
validateCountrySupport(errors, country, supportedBillingCountries);
|
|
1628
|
+
if (ADDRESS_PARITY_ENABLED) {
|
|
1629
|
+
validateLatinCharacters(errors, contact, firstName, lastName);
|
|
1630
|
+
}
|
|
1586
1631
|
if (errors.length > 0) {
|
|
1587
1632
|
throw new ContactValidationError(errors);
|
|
1588
1633
|
}
|
|
@@ -1622,123 +1667,6 @@ var shippingContactDetails = (shippingContact) => {
|
|
|
1622
1667
|
return { emailAddress };
|
|
1623
1668
|
};
|
|
1624
1669
|
|
|
1625
|
-
// src/clients/payment-checkout/payment-handler.ts
|
|
1626
|
-
var failApplePaySession = (session, errors = []) => {
|
|
1627
|
-
session.completePayment({
|
|
1628
|
-
status: ApplePaySession.STATUS_FAILURE,
|
|
1629
|
-
errors
|
|
1630
|
-
});
|
|
1631
|
-
};
|
|
1632
|
-
function parseWalletApiError(err) {
|
|
1633
|
-
const body = err instanceof ApiError ? err.body : err;
|
|
1634
|
-
if (body && typeof body === "object" && "errorType" in body && "message" in body) {
|
|
1635
|
-
return body;
|
|
1636
|
-
}
|
|
1637
|
-
return null;
|
|
1638
|
-
}
|
|
1639
|
-
function validateContacts(event, sessionData, supportedBillingCountries) {
|
|
1640
|
-
billingContactDetails(
|
|
1641
|
-
event.payment.billingContact,
|
|
1642
|
-
supportedBillingCountries
|
|
1643
|
-
);
|
|
1644
|
-
if (!sessionData.loggedIn) {
|
|
1645
|
-
return shippingContactDetails(event.payment.shippingContact).emailAddress;
|
|
1646
|
-
}
|
|
1647
|
-
return void 0;
|
|
1648
|
-
}
|
|
1649
|
-
function redirectFallback(skuId, returnUrl, country, options) {
|
|
1650
|
-
writeCheckoutRedirect(returnUrl);
|
|
1651
|
-
trackFallbackCheckout(skuId);
|
|
1652
|
-
window.location.href = redirectToCheckoutFallback({
|
|
1653
|
-
skuId,
|
|
1654
|
-
country,
|
|
1655
|
-
...options
|
|
1656
|
-
});
|
|
1657
|
-
}
|
|
1658
|
-
var ERROR_HANDLERS = {
|
|
1659
|
-
// emailError flows as an inline field error on the email input.
|
|
1660
|
-
// email pre-populates the input so the user doesn't have to retype it.
|
|
1661
|
-
EMAIL_COLLISION: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
1662
|
-
emailError: walletError.message,
|
|
1663
|
-
email: validatedEmail
|
|
1664
|
-
}),
|
|
1665
|
-
PAYMENT_DECLINED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1666
|
-
ELIGIBILITY_REJECTED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1667
|
-
REGISTRATION_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1668
|
-
ACCOUNT_CREATION_FAILED: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
1669
|
-
emailError: walletError.message,
|
|
1670
|
-
email: validatedEmail
|
|
1671
|
-
}),
|
|
1672
|
-
VALIDATION_ERROR: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1673
|
-
RECAPTCHA_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message })
|
|
1674
|
-
};
|
|
1675
|
-
function handleStructuredError(ctx) {
|
|
1676
|
-
const handler = ERROR_HANDLERS[ctx.walletError.errorType];
|
|
1677
|
-
if (handler) {
|
|
1678
|
-
handler(ctx);
|
|
1679
|
-
} else {
|
|
1680
|
-
redirectFallback(ctx.skuId, ctx.returnUrl, ctx.country, { inlineError: MSG_PAYMENT_GENERIC_ERROR });
|
|
1681
|
-
}
|
|
1682
|
-
}
|
|
1683
|
-
async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
1684
|
-
const { skuId, returnUrl, country } = config;
|
|
1685
|
-
let validatedEmail;
|
|
1686
|
-
try {
|
|
1687
|
-
validatedEmail = validateContacts(
|
|
1688
|
-
event,
|
|
1689
|
-
sessionData,
|
|
1690
|
-
config.supportedBillingCountries
|
|
1691
|
-
);
|
|
1692
|
-
const result = await performPurchase({
|
|
1693
|
-
applePayToken: event.payment.token,
|
|
1694
|
-
skuId: config.skuId,
|
|
1695
|
-
currency: config.currency,
|
|
1696
|
-
billingContact: event.payment.billingContact,
|
|
1697
|
-
...event.payment.shippingContact && {
|
|
1698
|
-
shippingContact: event.payment.shippingContact
|
|
1699
|
-
},
|
|
1700
|
-
recaptchaToken: config.recaptchaToken
|
|
1701
|
-
});
|
|
1702
|
-
trackWalletPaymentSuccess(skuId, result.basketId);
|
|
1703
|
-
session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
1704
|
-
const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
|
|
1705
|
-
const userStatus = sessionData.loggedIn ? "lex" : "nex";
|
|
1706
|
-
writeCheckoutRedirect(returnUrl);
|
|
1707
|
-
window.location.href = redirectToCheckoutComplete({
|
|
1708
|
-
basketId: result.basketId,
|
|
1709
|
-
status: userStatus,
|
|
1710
|
-
skuId: decodeSku(skuId),
|
|
1711
|
-
email: successEmail,
|
|
1712
|
-
country
|
|
1713
|
-
});
|
|
1714
|
-
} catch (err) {
|
|
1715
|
-
if (err instanceof ContactValidationError) {
|
|
1716
|
-
const isBillingCountryMismatch = err.errors.some(
|
|
1717
|
-
(e) => e.contactField === "countryCode"
|
|
1718
|
-
);
|
|
1719
|
-
if (isBillingCountryMismatch) {
|
|
1720
|
-
const countryCode = event.payment.billingContact?.countryCode;
|
|
1721
|
-
const userMessage = buildCountryMismatchMessage(countryCode);
|
|
1722
|
-
failApplePaySession(session, [
|
|
1723
|
-
new ApplePayError("billingContactInvalid", "countryCode", userMessage)
|
|
1724
|
-
]);
|
|
1725
|
-
redirectFallback(skuId, returnUrl, country, { inlineError: MSG_BILLING_COUNTRY_MISMATCH_REDIRECT });
|
|
1726
|
-
} else {
|
|
1727
|
-
failApplePaySession(session, err.errors);
|
|
1728
|
-
}
|
|
1729
|
-
return;
|
|
1730
|
-
}
|
|
1731
|
-
const walletError = parseWalletApiError(err);
|
|
1732
|
-
trackWalletPaymentFailure(skuId, walletError?.errorType ?? "UNKNOWN");
|
|
1733
|
-
failApplePaySession(session);
|
|
1734
|
-
if (!walletError) {
|
|
1735
|
-
redirectFallback(skuId, returnUrl, country, { inlineError: MSG_PAYMENT_GENERIC_ERROR });
|
|
1736
|
-
return;
|
|
1737
|
-
}
|
|
1738
|
-
handleStructuredError({ skuId, returnUrl, country, validatedEmail, walletError });
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
|
|
1742
1670
|
// src/data/price-zones.json
|
|
1743
1671
|
var price_zones_default = {
|
|
1744
1672
|
"AS-AS": [
|
|
@@ -1944,6 +1872,254 @@ var price_zones_default = {
|
|
|
1944
1872
|
"UK-UK": ["GB"]
|
|
1945
1873
|
};
|
|
1946
1874
|
|
|
1875
|
+
// src/utils/address-rules.ts
|
|
1876
|
+
var priceZones = price_zones_default;
|
|
1877
|
+
var ADDRESS_LIMITS = {
|
|
1878
|
+
address1: 35,
|
|
1879
|
+
address2: 35,
|
|
1880
|
+
city: 40,
|
|
1881
|
+
state: 40,
|
|
1882
|
+
postalCode: 20,
|
|
1883
|
+
phone: 35
|
|
1884
|
+
};
|
|
1885
|
+
var zoneOf = (country) => Object.keys(priceZones).find((zone) => priceZones[zone].includes(country));
|
|
1886
|
+
var COUNTRIES_REQUIRING_PHONE = ["IN", "CN"];
|
|
1887
|
+
var requiredDeliveryFields = (offerCountry, country) => {
|
|
1888
|
+
const zone = zoneOf(offerCountry);
|
|
1889
|
+
const fields = ["address1", "city"];
|
|
1890
|
+
if (zone === "AS-AU" || zone === "AS-JP" || zone === "NA-CA" || country === "US") {
|
|
1891
|
+
fields.push("state");
|
|
1892
|
+
}
|
|
1893
|
+
if ((zone !== "AS-HK" || country === "MO") && zone !== "CE-AF" && zone !== "CE-ME") {
|
|
1894
|
+
fields.push("postalCode");
|
|
1895
|
+
}
|
|
1896
|
+
if (COUNTRIES_REQUIRING_PHONE.includes(country)) fields.push("phone");
|
|
1897
|
+
return fields;
|
|
1898
|
+
};
|
|
1899
|
+
var postalCodeFormatError = (offerCountry, postalCode) => {
|
|
1900
|
+
if (!postalCode) return null;
|
|
1901
|
+
const zone = zoneOf(offerCountry);
|
|
1902
|
+
if (zone === "NA-US" && !/(^\d{5}$)|(^\d{5}-\d{4}$)/.test(postalCode)) {
|
|
1903
|
+
return "Zip code must be a valid US zip code";
|
|
1904
|
+
}
|
|
1905
|
+
if (zone === "NA-CA" && !/^[A-Za-z]\d[A-Za-z][ -]?\d[A-Za-z]\d$/.test(postalCode)) {
|
|
1906
|
+
return "Postal code must be a valid Canadian postal code";
|
|
1907
|
+
}
|
|
1908
|
+
return null;
|
|
1909
|
+
};
|
|
1910
|
+
var COUNTRY_CALLING_CODES = {
|
|
1911
|
+
IN: "91",
|
|
1912
|
+
CN: "86"
|
|
1913
|
+
};
|
|
1914
|
+
var normaliseDeliveryPhone = (raw, country) => {
|
|
1915
|
+
const trimmed = raw?.trim() ?? "";
|
|
1916
|
+
const digits = trimmed.replace(/[^0-9]+/g, "");
|
|
1917
|
+
if (!digits) return void 0;
|
|
1918
|
+
if (trimmed.startsWith("+")) return `+${digits}`;
|
|
1919
|
+
const callingCode = COUNTRY_CALLING_CODES[country];
|
|
1920
|
+
return callingCode ? `+${callingCode}${digits.replace(/^0+/, "")}` : void 0;
|
|
1921
|
+
};
|
|
1922
|
+
|
|
1923
|
+
// src/clients/payment-checkout/delivery-contact-details.ts
|
|
1924
|
+
var APPLE_FIELD = {
|
|
1925
|
+
address1: "addressLines",
|
|
1926
|
+
city: "locality",
|
|
1927
|
+
state: "administrativeArea",
|
|
1928
|
+
postalCode: "postalCode",
|
|
1929
|
+
phone: "phoneNumber"
|
|
1930
|
+
};
|
|
1931
|
+
var LABEL = {
|
|
1932
|
+
address1: "Address line 1",
|
|
1933
|
+
address2: "Address line 2",
|
|
1934
|
+
city: "City",
|
|
1935
|
+
state: "State",
|
|
1936
|
+
postalCode: "Postcode",
|
|
1937
|
+
phone: "Phone number"
|
|
1938
|
+
};
|
|
1939
|
+
var deliveryContactDetails = (contact, { offerCountry, supportedDeliveryCountries }) => {
|
|
1940
|
+
const errors = [];
|
|
1941
|
+
const fail = (field, type, message) => pushFieldError(errors, "shipping", field, type, message);
|
|
1942
|
+
const country = contact?.countryCode?.trim().toUpperCase() ?? "";
|
|
1943
|
+
const firstName = contact?.givenName?.trim() ?? "";
|
|
1944
|
+
const lastName = contact?.familyName?.trim() ?? "";
|
|
1945
|
+
const address1 = contact?.addressLines?.at(0)?.trim() ?? "";
|
|
1946
|
+
const address2 = contact?.addressLines?.at(1)?.trim() ?? "";
|
|
1947
|
+
const city = contact?.locality?.trim() ?? "";
|
|
1948
|
+
const state = contact?.administrativeArea?.trim() ?? "";
|
|
1949
|
+
const postalCode = contact?.postalCode?.trim() ?? "";
|
|
1950
|
+
const phone = normaliseDeliveryPhone(contact?.phoneNumber, country) ?? "";
|
|
1951
|
+
if (!country) {
|
|
1952
|
+
pushRequiredFieldError(errors, "shipping", "country");
|
|
1953
|
+
} else if (!supportedDeliveryCountries.includes(country)) {
|
|
1954
|
+
fail("countryCode", "not-supported", MSG_UNSUPPORTED_DELIVERY_COUNTRY);
|
|
1955
|
+
}
|
|
1956
|
+
if (!firstName || !lastName) {
|
|
1957
|
+
pushRequiredFieldError(errors, "shipping", "name");
|
|
1958
|
+
}
|
|
1959
|
+
const values = {
|
|
1960
|
+
address1,
|
|
1961
|
+
city,
|
|
1962
|
+
state,
|
|
1963
|
+
postalCode,
|
|
1964
|
+
phone
|
|
1965
|
+
};
|
|
1966
|
+
for (const field of requiredDeliveryFields(offerCountry, country)) {
|
|
1967
|
+
if (!values[field]) {
|
|
1968
|
+
pushRequiredFieldError(errors, "shipping", APPLE_FIELD[field]);
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
const limited = [
|
|
1972
|
+
["address1", "addressLines", address1, ADDRESS_LIMITS.address1],
|
|
1973
|
+
["address2", "addressLines", address2, ADDRESS_LIMITS.address2],
|
|
1974
|
+
["city", "locality", city, ADDRESS_LIMITS.city],
|
|
1975
|
+
["state", "administrativeArea", state, ADDRESS_LIMITS.state],
|
|
1976
|
+
["postalCode", "postalCode", postalCode, ADDRESS_LIMITS.postalCode],
|
|
1977
|
+
["phone", "phoneNumber", phone, ADDRESS_LIMITS.phone]
|
|
1978
|
+
];
|
|
1979
|
+
for (const [field, appleField, value, max] of limited) {
|
|
1980
|
+
if (value.length > max) {
|
|
1981
|
+
fail(appleField, "format", msgFieldTooLong(LABEL[field], max));
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
const formatError = postalCodeFormatError(offerCountry, postalCode);
|
|
1985
|
+
if (formatError) {
|
|
1986
|
+
fail("postalCode", "format", formatError);
|
|
1987
|
+
}
|
|
1988
|
+
const latin = [
|
|
1989
|
+
["name", firstName],
|
|
1990
|
+
["name", lastName],
|
|
1991
|
+
["addressLines", address1],
|
|
1992
|
+
["addressLines", address2],
|
|
1993
|
+
["locality", city],
|
|
1994
|
+
["administrativeArea", state],
|
|
1995
|
+
["postalCode", postalCode]
|
|
1996
|
+
];
|
|
1997
|
+
for (const [field, value] of latin) {
|
|
1998
|
+
if (!isLatinCharacters(value)) {
|
|
1999
|
+
fail(field, "format", MSG_NON_LATIN_CHARACTERS);
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
if (errors.length > 0) {
|
|
2003
|
+
throw new ContactValidationError(errors);
|
|
2004
|
+
}
|
|
2005
|
+
};
|
|
2006
|
+
|
|
2007
|
+
// src/clients/payment-checkout/payment-handler.ts
|
|
2008
|
+
var failApplePaySession = (session, errors = []) => {
|
|
2009
|
+
session.completePayment({
|
|
2010
|
+
status: ApplePaySession.STATUS_FAILURE,
|
|
2011
|
+
errors
|
|
2012
|
+
});
|
|
2013
|
+
};
|
|
2014
|
+
function parseWalletApiError(err) {
|
|
2015
|
+
const body = err instanceof ApiError ? err.body : err;
|
|
2016
|
+
if (body && typeof body === "object" && "errorType" in body && "message" in body) {
|
|
2017
|
+
return body;
|
|
2018
|
+
}
|
|
2019
|
+
return null;
|
|
2020
|
+
}
|
|
2021
|
+
function validateContacts(event, sessionData, supportedBillingCountries, delivery) {
|
|
2022
|
+
billingContactDetails(
|
|
2023
|
+
event.payment.billingContact,
|
|
2024
|
+
supportedBillingCountries
|
|
2025
|
+
);
|
|
2026
|
+
if (delivery) {
|
|
2027
|
+
deliveryContactDetails(event.payment.shippingContact, {
|
|
2028
|
+
offerCountry: delivery.offerCountry,
|
|
2029
|
+
supportedDeliveryCountries: delivery.supportedCountries
|
|
2030
|
+
});
|
|
2031
|
+
}
|
|
2032
|
+
if (!sessionData.loggedIn) {
|
|
2033
|
+
return shippingContactDetails(event.payment.shippingContact).emailAddress;
|
|
2034
|
+
}
|
|
2035
|
+
return void 0;
|
|
2036
|
+
}
|
|
2037
|
+
function redirectFallback(skuId, returnUrl, country, options) {
|
|
2038
|
+
writeCheckoutRedirect(returnUrl);
|
|
2039
|
+
trackFallbackCheckout(skuId);
|
|
2040
|
+
window.location.href = redirectToCheckoutFallback({
|
|
2041
|
+
skuId,
|
|
2042
|
+
country,
|
|
2043
|
+
...options
|
|
2044
|
+
});
|
|
2045
|
+
}
|
|
2046
|
+
var ERROR_HANDLERS = {
|
|
2047
|
+
// emailError flows as an inline field error on the email input.
|
|
2048
|
+
// email pre-populates the input so the user doesn't have to retype it.
|
|
2049
|
+
EMAIL_COLLISION: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
2050
|
+
emailError: walletError.message,
|
|
2051
|
+
email: validatedEmail
|
|
2052
|
+
}),
|
|
2053
|
+
PAYMENT_DECLINED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
2054
|
+
ELIGIBILITY_REJECTED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
2055
|
+
REGISTRATION_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
2056
|
+
ACCOUNT_CREATION_FAILED: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
2057
|
+
emailError: walletError.message,
|
|
2058
|
+
email: validatedEmail
|
|
2059
|
+
}),
|
|
2060
|
+
VALIDATION_ERROR: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
2061
|
+
RECAPTCHA_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message })
|
|
2062
|
+
};
|
|
2063
|
+
function handleStructuredError(ctx) {
|
|
2064
|
+
const handler = ERROR_HANDLERS[ctx.walletError.errorType];
|
|
2065
|
+
if (handler) {
|
|
2066
|
+
handler(ctx);
|
|
2067
|
+
} else {
|
|
2068
|
+
redirectFallback(ctx.skuId, ctx.returnUrl, ctx.country, { inlineError: MSG_PAYMENT_GENERIC_ERROR });
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
2072
|
+
const { skuId, returnUrl, country } = config;
|
|
2073
|
+
let validatedEmail;
|
|
2074
|
+
try {
|
|
2075
|
+
validatedEmail = validateContacts(
|
|
2076
|
+
event,
|
|
2077
|
+
sessionData,
|
|
2078
|
+
config.supportedBillingCountries,
|
|
2079
|
+
config.delivery
|
|
2080
|
+
);
|
|
2081
|
+
const result = await performPurchase({
|
|
2082
|
+
applePayToken: event.payment.token,
|
|
2083
|
+
skuId: config.skuId,
|
|
2084
|
+
currency: config.currency,
|
|
2085
|
+
billingContact: event.payment.billingContact,
|
|
2086
|
+
...event.payment.shippingContact && {
|
|
2087
|
+
shippingContact: event.payment.shippingContact
|
|
2088
|
+
},
|
|
2089
|
+
...config.delivery && {
|
|
2090
|
+
supportedDeliveryCountries: config.delivery.supportedCountries
|
|
2091
|
+
},
|
|
2092
|
+
...ADDRESS_PARITY_ENABLED ? { strictAddressRules: true } : {},
|
|
2093
|
+
recaptchaToken: config.recaptchaToken
|
|
2094
|
+
});
|
|
2095
|
+
trackWalletPaymentSuccess(skuId, result.basketId);
|
|
2096
|
+
session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
2097
|
+
const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
|
|
2098
|
+
const userStatus = sessionData.loggedIn ? "lex" : "nex";
|
|
2099
|
+
writeCheckoutRedirect(returnUrl);
|
|
2100
|
+
window.location.href = redirectToCheckoutComplete({
|
|
2101
|
+
basketId: result.basketId,
|
|
2102
|
+
status: userStatus,
|
|
2103
|
+
skuId: decodeSku(skuId),
|
|
2104
|
+
email: successEmail,
|
|
2105
|
+
country
|
|
2106
|
+
});
|
|
2107
|
+
} catch (err) {
|
|
2108
|
+
if (err instanceof ContactValidationError) {
|
|
2109
|
+
failApplePaySession(session, err.errors);
|
|
2110
|
+
return;
|
|
2111
|
+
}
|
|
2112
|
+
const walletError = parseWalletApiError(err);
|
|
2113
|
+
trackWalletPaymentFailure(skuId, walletError?.errorType ?? "UNKNOWN");
|
|
2114
|
+
failApplePaySession(session);
|
|
2115
|
+
if (!walletError) {
|
|
2116
|
+
redirectFallback(skuId, returnUrl, country, { inlineError: MSG_PAYMENT_GENERIC_ERROR });
|
|
2117
|
+
return;
|
|
2118
|
+
}
|
|
2119
|
+
handleStructuredError({ skuId, returnUrl, country, validatedEmail, walletError });
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
|
|
1947
2123
|
// src/data/eea-countries.json
|
|
1948
2124
|
var eea_countries_default = [
|
|
1949
2125
|
"AT",
|
|
@@ -1981,10 +2157,10 @@ var eea_countries_default = [
|
|
|
1981
2157
|
];
|
|
1982
2158
|
|
|
1983
2159
|
// src/utils/billing-countries.ts
|
|
1984
|
-
var
|
|
2160
|
+
var priceZones2 = price_zones_default;
|
|
1985
2161
|
var eeaCountries = eea_countries_default;
|
|
1986
|
-
var ALL_COUNTRY_CODES = Object.values(
|
|
1987
|
-
var getZoneByCountry = (country) => Object.keys(
|
|
2162
|
+
var ALL_COUNTRY_CODES = Object.values(priceZones2).flat();
|
|
2163
|
+
var getZoneByCountry = (country) => Object.keys(priceZones2).find((key) => priceZones2[key].includes(country)) ?? null;
|
|
1988
2164
|
var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
1989
2165
|
if (offerVariant === "bundle" || offerVariant === "insider_print") {
|
|
1990
2166
|
return [...ALL_COUNTRY_CODES];
|
|
@@ -1993,52 +2169,143 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1993
2169
|
if (!zone) {
|
|
1994
2170
|
return [...ALL_COUNTRY_CODES];
|
|
1995
2171
|
}
|
|
1996
|
-
const zoneCountries =
|
|
2172
|
+
const zoneCountries = priceZones2[zone];
|
|
1997
2173
|
if (eeaCountries.includes(offerCountry)) {
|
|
1998
2174
|
return Array.from(/* @__PURE__ */ new Set([...zoneCountries, ...eeaCountries]));
|
|
1999
2175
|
}
|
|
2000
2176
|
return [...zoneCountries];
|
|
2001
2177
|
};
|
|
2002
2178
|
|
|
2003
|
-
// src/
|
|
2004
|
-
var
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2179
|
+
// src/data/no-delivery-countries.json
|
|
2180
|
+
var no_delivery_countries_default = [
|
|
2181
|
+
"KH",
|
|
2182
|
+
"MM",
|
|
2183
|
+
"PK",
|
|
2184
|
+
"BI",
|
|
2185
|
+
"CV",
|
|
2186
|
+
"CF",
|
|
2187
|
+
"TD",
|
|
2188
|
+
"CG",
|
|
2189
|
+
"DJ",
|
|
2190
|
+
"EG",
|
|
2191
|
+
"GM",
|
|
2192
|
+
"GN",
|
|
2193
|
+
"GW",
|
|
2194
|
+
"LB",
|
|
2195
|
+
"LR",
|
|
2196
|
+
"LY",
|
|
2197
|
+
"ML",
|
|
2198
|
+
"MU",
|
|
2199
|
+
"RE",
|
|
2200
|
+
"SL",
|
|
2201
|
+
"AZ",
|
|
2202
|
+
"BY",
|
|
2203
|
+
"UA",
|
|
2204
|
+
"BM",
|
|
2205
|
+
"BO",
|
|
2206
|
+
"KY",
|
|
2207
|
+
"EC",
|
|
2208
|
+
"HN",
|
|
2209
|
+
"PA",
|
|
2210
|
+
"PE",
|
|
2211
|
+
"UY"
|
|
2212
|
+
];
|
|
2213
|
+
|
|
2214
|
+
// src/utils/delivery-countries.ts
|
|
2215
|
+
var priceZones3 = price_zones_default;
|
|
2216
|
+
var noDeliveryCountries = no_delivery_countries_default;
|
|
2217
|
+
var getSupportedDeliveryCountries = (offerCountry) => {
|
|
2218
|
+
const zone = Object.keys(priceZones3).find(
|
|
2219
|
+
(key) => priceZones3[key].includes(offerCountry)
|
|
2220
|
+
);
|
|
2221
|
+
if (!zone) return [];
|
|
2222
|
+
return priceZones3[zone].filter(
|
|
2223
|
+
(country) => !noDeliveryCountries.includes(country)
|
|
2224
|
+
);
|
|
2225
|
+
};
|
|
2226
|
+
|
|
2227
|
+
// src/utils/printOffersFlag.ts
|
|
2228
|
+
var PRINT_OFFERS_ENABLED = true;
|
|
2229
|
+
|
|
2230
|
+
// src/utils/buttonCopyFlag.ts
|
|
2231
|
+
var CONTINUE_WITH_COPY_ENABLED = true;
|
|
2232
|
+
var BUTTON_COPY = {
|
|
2233
|
+
subscribe: { caption: "Subscribe with", label: "Subscribe with Apple Pay" },
|
|
2234
|
+
continue: { caption: "Continue with", label: "Continue with Apple Pay" }
|
|
2008
2235
|
};
|
|
2236
|
+
var getButtonCopy = (enabled = CONTINUE_WITH_COPY_ENABLED) => enabled ? BUTTON_COPY.continue : BUTTON_COPY.subscribe;
|
|
2009
2237
|
|
|
2010
2238
|
// src/utils/applePayExpressEligibility.ts
|
|
2011
|
-
var
|
|
2239
|
+
var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
|
|
2240
|
+
|
|
2241
|
+
// src/constants.ts
|
|
2242
|
+
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
2243
|
+
ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
|
|
2244
|
+
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
2245
|
+
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
2246
|
+
ApplePayEntryPoint2["FREE_TRIAL_BANNER"] = "free_trial_banner";
|
|
2247
|
+
ApplePayEntryPoint2["FREE_TRIAL_POPUP"] = "free_trial_popup";
|
|
2248
|
+
ApplePayEntryPoint2["SUBSCRIBE"] = "subscribe";
|
|
2249
|
+
ApplePayEntryPoint2["SALES_PAGE"] = "sales_page";
|
|
2250
|
+
return ApplePayEntryPoint2;
|
|
2251
|
+
})(ApplePayEntryPoint || {});
|
|
2012
2252
|
|
|
2013
2253
|
// src/apple-pay-button.ts
|
|
2254
|
+
var PRINT_VARIANTS = ["bundle", "insider_print"];
|
|
2255
|
+
var NO_EXCLUSIONS = [];
|
|
2014
2256
|
var ENTRY_POINT_CONFIG = {
|
|
2015
2257
|
["dual_offer_banner" /* DUAL_OFFER_BANNER */]: {
|
|
2016
|
-
isEligible: () => true
|
|
2017
|
-
|
|
2258
|
+
isEligible: () => true,
|
|
2259
|
+
returnUrl: "current_page" /* CURRENT_PAGE */,
|
|
2260
|
+
allowsPrintOffers: false
|
|
2018
2261
|
},
|
|
2019
2262
|
["free_trial_banner" /* FREE_TRIAL_BANNER */]: {
|
|
2020
|
-
isEligible: () => true
|
|
2021
|
-
|
|
2263
|
+
isEligible: () => true,
|
|
2264
|
+
returnUrl: "current_page" /* CURRENT_PAGE */,
|
|
2265
|
+
allowsPrintOffers: false
|
|
2022
2266
|
},
|
|
2023
2267
|
["article_paywall" /* PAYWALL */]: {
|
|
2024
|
-
isEligible:
|
|
2025
|
-
|
|
2268
|
+
isEligible: isEligibleForApplePayExpressPaywall,
|
|
2269
|
+
returnUrl: "current_page" /* CURRENT_PAGE */,
|
|
2270
|
+
allowsPrintOffers: false
|
|
2026
2271
|
},
|
|
2027
2272
|
["article_regwall" /* REGWALL */]: {
|
|
2028
2273
|
isEligible: () => true,
|
|
2029
|
-
enabled: false
|
|
2274
|
+
enabled: false,
|
|
2275
|
+
returnUrl: "current_page" /* CURRENT_PAGE */,
|
|
2276
|
+
allowsPrintOffers: false
|
|
2277
|
+
},
|
|
2278
|
+
["free_trial_popup" /* FREE_TRIAL_POPUP */]: {
|
|
2279
|
+
isEligible: () => true,
|
|
2280
|
+
returnUrl: "current_page" /* CURRENT_PAGE */,
|
|
2281
|
+
allowsPrintOffers: false
|
|
2282
|
+
},
|
|
2283
|
+
["subscribe" /* SUBSCRIBE */]: {
|
|
2284
|
+
isEligible: () => true,
|
|
2285
|
+
// Always-on after offer exclusions — host (sma-checkout) owns rollout toggle
|
|
2286
|
+
// The offers page is not a place to return to: the host keeps the article the user arrived from (or home).
|
|
2287
|
+
returnUrl: "host_managed" /* HOST_MANAGED */,
|
|
2288
|
+
allowsPrintOffers: true
|
|
2289
|
+
},
|
|
2290
|
+
["sales_page" /* SALES_PAGE */]: {
|
|
2291
|
+
isEligible: () => true,
|
|
2292
|
+
// Host-owned page (sma-checkout), like /subscribe: the host keeps the user's return target.
|
|
2293
|
+
returnUrl: "host_managed" /* HOST_MANAGED */,
|
|
2294
|
+
// Print stays off until a sales page needs it; flip to true (and QA) to take print there.
|
|
2295
|
+
allowsPrintOffers: false
|
|
2030
2296
|
}
|
|
2031
2297
|
};
|
|
2032
|
-
var
|
|
2298
|
+
var DEFAULT_ENTRY_POINT = "dual_offer_banner" /* DUAL_OFFER_BANNER */;
|
|
2033
2299
|
var TOTAL_LABEL = "The Economist";
|
|
2034
2300
|
var DEFAULT_CURRENCY = "USD";
|
|
2035
2301
|
var DEFAULT_TOTAL = "0.00";
|
|
2036
2302
|
var SEL_CONTAINER = ".apple-pay-container";
|
|
2037
2303
|
var SEL_BUTTON = ".apple-pay-btn";
|
|
2038
|
-
var APPLE_PAY_EXCLUDED_VARIANTS =
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2304
|
+
var APPLE_PAY_EXCLUDED_VARIANTS = PRINT_VARIANTS;
|
|
2305
|
+
var getExcludedVariants = (entryPoint) => {
|
|
2306
|
+
const config = ENTRY_POINT_CONFIG[entryPoint || DEFAULT_ENTRY_POINT] ?? ENTRY_POINT_CONFIG[DEFAULT_ENTRY_POINT];
|
|
2307
|
+
return PRINT_OFFERS_ENABLED && config.allowsPrintOffers ? NO_EXCLUSIONS : PRINT_VARIANTS;
|
|
2308
|
+
};
|
|
2042
2309
|
var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
2043
2310
|
static tag = "teg-apple-pay-button";
|
|
2044
2311
|
static define() {
|
|
@@ -2048,26 +2315,18 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2048
2315
|
* Creates and configures an ApplePayButton when the entry point allows it.
|
|
2049
2316
|
*
|
|
2050
2317
|
* - `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions —
|
|
2051
|
-
* no homepage/Safari gate here
|
|
2052
|
-
*
|
|
2318
|
+
* no homepage/Safari gate here. Safari/Apple is enforced later by
|
|
2319
|
+
* `isApplePayAvailable()` on mount.
|
|
2053
2320
|
* - `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; distinct
|
|
2054
2321
|
* TEDL `entry_point` string (`free_trial_banner`) for wallet impression attribution.
|
|
2055
|
-
* - `
|
|
2056
|
-
* (`
|
|
2057
|
-
*
|
|
2322
|
+
* - `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate. Distinct TEDL
|
|
2323
|
+
* `entry_point` (`free_trial_popup`).
|
|
2324
|
+
* - `PAYWALL`: always-on after offer exclusions + Safari/Apple placement
|
|
2325
|
+
* eligibility. No Amplitude experiment / `$exposure`.
|
|
2058
2326
|
* - `REGWALL`: inert — always returns null.
|
|
2059
2327
|
*
|
|
2060
|
-
*
|
|
2061
|
-
* `
|
|
2062
|
-
* treatment (and without inflating `$exposure`). For banners there is no
|
|
2063
|
-
* experiment gate; `BYPASS_APPLE_PAY_CHECKS` only skips device checks in
|
|
2064
|
-
* `isApplePayAvailable()` on mount.
|
|
2065
|
-
*
|
|
2066
|
-
* **Eligibility:**
|
|
2067
|
-
* - `DUAL_OFFER_BANNER` / `FREE_TRIAL_BANNER` (or omitted): always eligible at
|
|
2068
|
-
* this gate (homepage placement is host-owned; Safari/Apple is enforced
|
|
2069
|
-
* later by `isApplePayAvailable()` on mount)
|
|
2070
|
-
* - `PAYWALL`: Safari/Apple device only (no homepage) — article paywalls
|
|
2328
|
+
* `BYPASS_APPLE_PAY_CHECKS` skips placement eligibility here and device checks
|
|
2329
|
+
* in `isApplePayAvailable()` on mount (QA on non-Apple browsers).
|
|
2071
2330
|
*
|
|
2072
2331
|
* @param offer - The offer to display in the Apple Pay flow.
|
|
2073
2332
|
* @param country - The user's country code.
|
|
@@ -2077,44 +2336,22 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2077
2336
|
if (!offer) {
|
|
2078
2337
|
return null;
|
|
2079
2338
|
}
|
|
2080
|
-
|
|
2081
|
-
return null;
|
|
2082
|
-
}
|
|
2083
|
-
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2084
|
-
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
2085
|
-
);
|
|
2086
|
-
const resolvedEntryPoint = entryPoint || "dual_offer_banner" /* DUAL_OFFER_BANNER */;
|
|
2339
|
+
const resolvedEntryPoint = entryPoint || DEFAULT_ENTRY_POINT;
|
|
2087
2340
|
const config = ENTRY_POINT_CONFIG[resolvedEntryPoint];
|
|
2088
2341
|
if (!config) {
|
|
2089
2342
|
return null;
|
|
2090
2343
|
}
|
|
2091
|
-
|
|
2344
|
+
if (getExcludedVariants(resolvedEntryPoint).includes(offer.product?.variant)) {
|
|
2345
|
+
return null;
|
|
2346
|
+
}
|
|
2347
|
+
const { isEligible: eligibilityCheck } = config;
|
|
2092
2348
|
const isEligible = eligibilityCheck();
|
|
2093
2349
|
if (config.enabled === false) {
|
|
2094
2350
|
return null;
|
|
2095
2351
|
}
|
|
2096
|
-
if (!
|
|
2352
|
+
if (!bypassApplePayChecks() && !isEligible) {
|
|
2097
2353
|
return null;
|
|
2098
2354
|
}
|
|
2099
|
-
if (experimentFlagKey) {
|
|
2100
|
-
const experimentValue = window.experimentIntegration?.getVariant?.(experimentFlagKey);
|
|
2101
|
-
const isExperimentVariant = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2102
|
-
if (isExperimentVariant && isEligible && !bypassApplePayChecks() && !hasUrlParamFlag) {
|
|
2103
|
-
void isApplePayAvailable().then((available) => {
|
|
2104
|
-
if (available) {
|
|
2105
|
-
trackApplePayExperimentExposure(
|
|
2106
|
-
experimentValue,
|
|
2107
|
-
getExperimentKeyFromNextData(experimentFlagKey),
|
|
2108
|
-
experimentFlagKey
|
|
2109
|
-
);
|
|
2110
|
-
}
|
|
2111
|
-
});
|
|
2112
|
-
}
|
|
2113
|
-
const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
2114
|
-
if (!isTreatment && !hasUrlParamFlag) {
|
|
2115
|
-
return null;
|
|
2116
|
-
}
|
|
2117
|
-
}
|
|
2118
2355
|
_ApplePayButton.define();
|
|
2119
2356
|
const button = document.createElement(_ApplePayButton.tag);
|
|
2120
2357
|
button.offer = offer;
|
|
@@ -2140,8 +2377,13 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2140
2377
|
#readyPromise = null;
|
|
2141
2378
|
#sessionData = null;
|
|
2142
2379
|
#paymentOptions = null;
|
|
2380
|
+
/** URL of the page the button is on (sent to payment options). */
|
|
2143
2381
|
#returnUrl = "";
|
|
2382
|
+
/** `checkout-redirect` to persist after purchase, per the entry point's `ReturnUrlPolicy`; `null` = leave it. */
|
|
2383
|
+
#checkoutRedirectUrl = null;
|
|
2144
2384
|
#supportedBillingCountries = [];
|
|
2385
|
+
/** Print (bundle) offers only: countries the offer can be delivered to; `null` for offers without delivery. */
|
|
2386
|
+
#supportedDeliveryCountries = null;
|
|
2145
2387
|
#entryPoint = "";
|
|
2146
2388
|
// ─── Public API ─────────────────────────────────────────────────────────────
|
|
2147
2389
|
get offer() {
|
|
@@ -2206,33 +2448,52 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2206
2448
|
this.#sessionData = null;
|
|
2207
2449
|
this.#paymentOptions = null;
|
|
2208
2450
|
this.#returnUrl = "";
|
|
2451
|
+
this.#checkoutRedirectUrl = null;
|
|
2209
2452
|
this.#supportedBillingCountries = [];
|
|
2453
|
+
this.#supportedDeliveryCountries = null;
|
|
2210
2454
|
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2211
2455
|
}
|
|
2212
2456
|
// ─── Render pipeline ────────────────────────────────────────────────────────
|
|
2213
2457
|
async #run() {
|
|
2214
2458
|
try {
|
|
2215
2459
|
this.#renderTemplate();
|
|
2460
|
+
this.#captureReturnUrl();
|
|
2461
|
+
const requests = this.#startWalletRequests();
|
|
2216
2462
|
if (await this.#checkAvailability()) return;
|
|
2217
2463
|
if (this.#checkOffer()) return;
|
|
2218
|
-
if (await this.#checkSession()) return;
|
|
2219
|
-
this.#captureReturnUrl();
|
|
2220
2464
|
this.#computeBillingCountries();
|
|
2221
|
-
if (
|
|
2465
|
+
if (this.#computeDeliveryCountries()) return;
|
|
2466
|
+
const [session, options] = await requests;
|
|
2467
|
+
if (this.#applySession(session)) return;
|
|
2468
|
+
if (this.#applyPaymentOptions(options)) return;
|
|
2222
2469
|
this.#finishLoading();
|
|
2223
2470
|
} catch {
|
|
2224
|
-
this
|
|
2225
|
-
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2471
|
+
this.#hide();
|
|
2226
2472
|
} finally {
|
|
2227
2473
|
this.#rendering = false;
|
|
2228
2474
|
}
|
|
2229
2475
|
}
|
|
2476
|
+
/**
|
|
2477
|
+
* Stop the loading spinner before tear-down so Safari does not leave a GPU
|
|
2478
|
+
* ghost of `.apple-pay-btn.wap-loading::before` after the container is removed.
|
|
2479
|
+
*/
|
|
2480
|
+
#hide() {
|
|
2481
|
+
const button = this.querySelector(SEL_BUTTON);
|
|
2482
|
+
if (button) {
|
|
2483
|
+
button.classList.remove("wap-loading");
|
|
2484
|
+
button.removeAttribute("aria-busy");
|
|
2485
|
+
button.getAnimations?.({ subtree: true }).forEach((animation) => animation.cancel());
|
|
2486
|
+
}
|
|
2487
|
+
this.getAnimations?.({ subtree: true }).forEach((animation) => animation.cancel());
|
|
2488
|
+
void this.offsetHeight;
|
|
2489
|
+
this.style.display = "none";
|
|
2490
|
+
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2491
|
+
}
|
|
2230
2492
|
/** Returns `true` (hide) when Apple Pay is unavailable on this device/browser. */
|
|
2231
2493
|
async #checkAvailability() {
|
|
2232
2494
|
const available = await isApplePayAvailable();
|
|
2233
2495
|
if (!available) {
|
|
2234
|
-
this
|
|
2235
|
-
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2496
|
+
this.#hide();
|
|
2236
2497
|
return true;
|
|
2237
2498
|
}
|
|
2238
2499
|
return false;
|
|
@@ -2241,11 +2502,17 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2241
2502
|
* Returns `true` (hide) when the user already has an active subscription or is B2B.
|
|
2242
2503
|
* Session fetch errors are swallowed — the component continues as an anonymous user.
|
|
2243
2504
|
*/
|
|
2244
|
-
|
|
2245
|
-
|
|
2505
|
+
/** Starts the session and payment-options calls together (neither depends on the other). */
|
|
2506
|
+
#startWalletRequests() {
|
|
2507
|
+
if (!this.#offer || !isApplePayCapable()) {
|
|
2508
|
+
return Promise.resolve([null, null]);
|
|
2509
|
+
}
|
|
2510
|
+
return Promise.all([this.#fetchSession(), this.#fetchPaymentOptions()]);
|
|
2511
|
+
}
|
|
2512
|
+
#applySession(session) {
|
|
2513
|
+
this.#sessionData = session;
|
|
2246
2514
|
if (this.#sessionData?.loggedIn && (this.#sessionData.userType === "active-subscription" || this.#sessionData.userType === "b2b-user")) {
|
|
2247
|
-
this
|
|
2248
|
-
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2515
|
+
this.#hide();
|
|
2249
2516
|
return true;
|
|
2250
2517
|
}
|
|
2251
2518
|
return false;
|
|
@@ -2253,8 +2520,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2253
2520
|
/** Returns `true` (hide) when no offer has been set before mount. */
|
|
2254
2521
|
#checkOffer() {
|
|
2255
2522
|
if (!this.#offer) {
|
|
2256
|
-
this
|
|
2257
|
-
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2523
|
+
this.#hide();
|
|
2258
2524
|
return true;
|
|
2259
2525
|
}
|
|
2260
2526
|
return false;
|
|
@@ -2262,6 +2528,11 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2262
2528
|
/** Captures the current page URL once at mount for reuse across the session lifetime. */
|
|
2263
2529
|
#captureReturnUrl() {
|
|
2264
2530
|
this.#returnUrl = captureOriginUrl();
|
|
2531
|
+
const config = ENTRY_POINT_CONFIG[this.#entryPoint || DEFAULT_ENTRY_POINT] ?? ENTRY_POINT_CONFIG[DEFAULT_ENTRY_POINT];
|
|
2532
|
+
this.#checkoutRedirectUrl = resolveCheckoutRedirectUrl(
|
|
2533
|
+
config.returnUrl,
|
|
2534
|
+
this.#returnUrl
|
|
2535
|
+
);
|
|
2265
2536
|
}
|
|
2266
2537
|
/**
|
|
2267
2538
|
* Computes supported billing countries once at mount.
|
|
@@ -2274,15 +2545,32 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2274
2545
|
this.#offer.product?.variant ?? ""
|
|
2275
2546
|
);
|
|
2276
2547
|
}
|
|
2548
|
+
/**
|
|
2549
|
+
* Print (bundle) offers need a delivery address, which the Apple Pay sheet collects. Returns `true` (hide)
|
|
2550
|
+
* when the offer has no country it can be delivered to, because no valid address could ever be entered.
|
|
2551
|
+
*/
|
|
2552
|
+
#computeDeliveryCountries() {
|
|
2553
|
+
const variant = this.#offer.product?.variant;
|
|
2554
|
+
if (!PRINT_VARIANTS.includes(variant)) {
|
|
2555
|
+
this.#supportedDeliveryCountries = null;
|
|
2556
|
+
return false;
|
|
2557
|
+
}
|
|
2558
|
+
const countries = getSupportedDeliveryCountries(this.#country);
|
|
2559
|
+
if (countries.length === 0) {
|
|
2560
|
+
this.#hide();
|
|
2561
|
+
return true;
|
|
2562
|
+
}
|
|
2563
|
+
this.#supportedDeliveryCountries = countries;
|
|
2564
|
+
return false;
|
|
2565
|
+
}
|
|
2277
2566
|
/**
|
|
2278
2567
|
* Returns `true` (hide) when the wallet BFF reports Apple Pay is unavailable
|
|
2279
2568
|
* for this offer. The response is cached and reused in `#initiateApplePay`.
|
|
2280
2569
|
*/
|
|
2281
|
-
|
|
2282
|
-
this.#paymentOptions =
|
|
2570
|
+
#applyPaymentOptions(options) {
|
|
2571
|
+
this.#paymentOptions = options;
|
|
2283
2572
|
if (!this.#paymentOptions?.options?.apple_pay) {
|
|
2284
|
-
this
|
|
2285
|
-
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2573
|
+
this.#hide();
|
|
2286
2574
|
return true;
|
|
2287
2575
|
}
|
|
2288
2576
|
return false;
|
|
@@ -2290,11 +2578,14 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2290
2578
|
/** Injects the button template and wires click and confirm event listeners. */
|
|
2291
2579
|
#renderTemplate() {
|
|
2292
2580
|
this.style.removeProperty("display");
|
|
2293
|
-
ensureApplePayLogoSymbol();
|
|
2294
2581
|
const template = document.createElement("template");
|
|
2295
2582
|
template.innerHTML = apple_pay_button_template_default;
|
|
2296
2583
|
this.appendChild(template.content.cloneNode(true));
|
|
2297
2584
|
const button = this.querySelector(SEL_BUTTON);
|
|
2585
|
+
const { caption, label } = getButtonCopy();
|
|
2586
|
+
this.querySelector(SEL_CONTAINER)?.setAttribute("aria-label", label);
|
|
2587
|
+
button.setAttribute("aria-label", label);
|
|
2588
|
+
this.querySelector(".apple-pay-btn__caption").textContent = caption;
|
|
2298
2589
|
button.classList.add("wap-loading");
|
|
2299
2590
|
button.setAttribute("disabled", "");
|
|
2300
2591
|
button.setAttribute("aria-disabled", "true");
|
|
@@ -2382,16 +2673,25 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2382
2673
|
totalAmount,
|
|
2383
2674
|
totalLabel: TOTAL_LABEL,
|
|
2384
2675
|
skuId,
|
|
2385
|
-
returnUrl: this.#
|
|
2676
|
+
returnUrl: this.#checkoutRedirectUrl,
|
|
2386
2677
|
userLoggedIn: sessionData.loggedIn,
|
|
2678
|
+
...this.#supportedDeliveryCountries && {
|
|
2679
|
+
delivery: { supportedCountries: this.#supportedDeliveryCountries }
|
|
2680
|
+
},
|
|
2387
2681
|
onPaymentAuthorized: async (event, session) => {
|
|
2388
2682
|
const recaptchaToken = await recaptchaTokenPromise;
|
|
2389
2683
|
return handlePaymentAuthorized(event, session, sessionData, {
|
|
2390
2684
|
skuId,
|
|
2391
2685
|
country,
|
|
2392
2686
|
currency: offer.price?.currency_code ?? DEFAULT_CURRENCY,
|
|
2393
|
-
returnUrl: this.#
|
|
2687
|
+
returnUrl: this.#checkoutRedirectUrl,
|
|
2394
2688
|
supportedBillingCountries: this.#supportedBillingCountries,
|
|
2689
|
+
...this.#supportedDeliveryCountries && {
|
|
2690
|
+
delivery: {
|
|
2691
|
+
offerCountry: country,
|
|
2692
|
+
supportedCountries: this.#supportedDeliveryCountries
|
|
2693
|
+
}
|
|
2694
|
+
},
|
|
2395
2695
|
recaptchaToken
|
|
2396
2696
|
});
|
|
2397
2697
|
}
|
|
@@ -2415,7 +2715,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2415
2715
|
);
|
|
2416
2716
|
} catch {
|
|
2417
2717
|
redirectToFallbackCheckout({
|
|
2418
|
-
returnUrl: this.#
|
|
2718
|
+
returnUrl: this.#checkoutRedirectUrl,
|
|
2419
2719
|
skuId,
|
|
2420
2720
|
countryCode: country
|
|
2421
2721
|
});
|
|
@@ -2430,12 +2730,10 @@ function defineApplePayElements() {
|
|
|
2430
2730
|
}
|
|
2431
2731
|
export {
|
|
2432
2732
|
APPLE_PAY_EXCLUDED_VARIANTS,
|
|
2433
|
-
APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY,
|
|
2434
|
-
APPLE_PAY_EXPRESS_VARIANTS,
|
|
2435
2733
|
ApplePayButton,
|
|
2436
2734
|
ApplePayEntryPoint,
|
|
2437
2735
|
ApplePayModal,
|
|
2438
2736
|
configureApplePay,
|
|
2439
2737
|
defineApplePayElements,
|
|
2440
|
-
|
|
2738
|
+
getExcludedVariants
|
|
2441
2739
|
};
|