@economist/web-apple-pay 1.14.0 → 1.15.1-beta.1
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 +23 -2
- package/dist/index.js +72 -13
- package/dist/src/apple-pay-button.js +61 -2
- package/dist/src/apple-pay-button.stories.js +61 -2
- package/dist/src/apple-pay-modal.stories.js +61 -2
- package/dist/src/clients/payment-checkout/config.d.ts +5 -0
- package/dist/src/clients/payment-checkout/payment-handler.d.ts +3 -0
- package/dist/src/clients/payment-checkout/payment-handler.js +2 -1
- package/dist/src/index.js +72 -13
- package/dist/src/types/offer.types.d.ts +1 -1
- package/dist/src/utils/expressCheckoutRedirect.d.ts +3 -2
- package/dist/src/utils/nativeButtonFlag.d.ts +12 -0
- package/dist/src/utils/nativeButtonFlag.js +18 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -78,9 +78,29 @@ If `merchantId` is not configured, Apple Pay availability checks return `false`
|
|
|
78
78
|
|
|
79
79
|
- Requires `offer` and `country` before click flow is meaningful.
|
|
80
80
|
- Checks Apple Pay availability on connect; if unavailable, it hides.
|
|
81
|
-
- Skips rendering for excluded variants (`bundle`, `insider_print`).
|
|
81
|
+
- Skips rendering for excluded variants (`bundle`, `insider_print`). Every other `ProductVariant` (including `play`) is eligible; billing countries are restricted to the offer's price zone.
|
|
82
82
|
- Forwards `data-logged-in` from button to modal (`modal.dataset.loggedIn`).
|
|
83
83
|
|
|
84
|
+
#### Native Apple Pay button
|
|
85
|
+
|
|
86
|
+
**Feature flag:** it is on for `localhost`, `dev.*` and `stage.*`, and **off in production** until
|
|
87
|
+
`NATIVE_BUTTON_ENABLED_IN_PRODUCTION` (`src/utils/nativeButtonFlag.ts`) is flipped to `true` in a release. It fails
|
|
88
|
+
closed: any other host (www.economist.com, previews, IPs) keeps the custom button. A host can force it either way
|
|
89
|
+
with `configureApplePay({ ..., nativeButton: true | false })`. The flag sets a `data-native-button` attribute on
|
|
90
|
+
`teg-apple-pay-button`, and the native CSS only applies when that attribute is present.
|
|
91
|
+
|
|
92
|
+
Once loading finishes, the button uses Apple's **native CSS button** (`-webkit-appearance: -apple-pay-button`)
|
|
93
|
+
wherever the browser supports it (Safari / iOS). Safari draws Apple's own artwork, so it follows Apple's design
|
|
94
|
+
guidelines, and because it is built into WebKit there is **no SDK script and no extra request** (safe for walls and
|
|
95
|
+
banners). Other browsers, and the loading spinner state, use the package's custom button as the fallback.
|
|
96
|
+
|
|
97
|
+
- Apple controls colour and wording: `--apple-pay-background-color`, `--apple-pay-foreground-color` and the
|
|
98
|
+
"Subscribe with" caption/logo do not apply to the native button.
|
|
99
|
+
- Optional overrides: `--apple-pay-button-type` (`plain`, `buy`, `subscribe`, `check-out`, ...; default `subscribe`)
|
|
100
|
+
and `--apple-pay-button-style` (`black`, `white`, `white-outline`; default `black`).
|
|
101
|
+
- Size and radius still follow `--apple-pay-height` and `--apple-pay-border-radius`.
|
|
102
|
+
- jsdom cannot render this, so tests assert the template contract. Verify visually in Safari.
|
|
103
|
+
|
|
84
104
|
#### Awaiting render completion — `whenReady()`
|
|
85
105
|
|
|
86
106
|
Use `whenReady()` to await the component's render lifecycle after appending it
|
|
@@ -127,7 +147,7 @@ Consumers should listen for this event and continue payment orchestration.
|
|
|
127
147
|
- `createIfEnabled(offer, country, entryPoint?)`: returns a configured button or `null`.
|
|
128
148
|
- `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions — no homepage/Safari gate at `createIfEnabled` (device gating via `isApplePayAvailable` on mount).
|
|
129
149
|
- `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; wallet impression `entry_point` is `free_trial_banner`.
|
|
130
|
-
- `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate. Wallet impression `entry_point` is `free_trial_popup`.
|
|
150
|
+
- `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate. Wallet impression `entry_point` is `free_trial_popup`. On payment success for a logged-in reader, `/checkout/complete` is opened with `status=nspc`. An anonymous popup stays `nex`. Other entry points stay `lex` or `nex`. The origin URL is still written to `checkout-redirect` for sma-checkout.
|
|
131
151
|
- `SUBSCRIBE`: same always-on-after-exclusions gate for `/subscribe` (sma-checkout); no Amplitude. Wallet impression `entry_point` is `subscribe`.
|
|
132
152
|
- `PAYWALL`: always-on after offer exclusions + Safari/Apple placement eligibility. No Amplitude experiment / `$exposure`.
|
|
133
153
|
- `REGWALL`: inert — always returns `null`.
|
|
@@ -200,3 +220,4 @@ Story coverage matrix:
|
|
|
200
220
|
- `ApplePayButton` behavior and state variants are available as individual canvas stories in Storybook.
|
|
201
221
|
- `ApplePayModal` docs page shows the stable default example.
|
|
202
222
|
- `ApplePayModal` behavior and state variants are available as individual canvas stories in Storybook.
|
|
223
|
+
|
package/dist/index.js
CHANGED
|
@@ -1111,6 +1111,41 @@ var apple_pay_button_template_default = `<style>
|
|
|
1111
1111
|
transform: translate(-50%, -50%) rotate(360deg);
|
|
1112
1112
|
}
|
|
1113
1113
|
}
|
|
1114
|
+
|
|
1115
|
+
/*
|
|
1116
|
+
* Native Apple Pay button. Safari (and iOS) draw Apple's own artwork for this appearance, which keeps the
|
|
1117
|
+
* button compliant with Apple's design guidelines. It is built into WebKit: no SDK script and no network
|
|
1118
|
+
* request, so it costs nothing on latency-sensitive surfaces (walls, banners).
|
|
1119
|
+
*
|
|
1120
|
+
* Gated by the \`data-native-button\` attribute (feature flag, see utils/nativeButtonFlag.ts: on for
|
|
1121
|
+
* localhost/dev/stage, off for production until flipped). Applied only where the browser supports it and
|
|
1122
|
+
* only once loading has finished: the spinner
|
|
1123
|
+
* (.wap-loading) needs the custom button. Everywhere else (non-WebKit browsers, or the QA bypass on a
|
|
1124
|
+
* browser without support) the custom button above remains the fallback.
|
|
1125
|
+
*
|
|
1126
|
+
* Apple controls colour and wording, so --apple-pay-background-color / --apple-pay-foreground-color and
|
|
1127
|
+
* the caption/logo are ignored here. Override with:
|
|
1128
|
+
* --apple-pay-button-type (plain | buy | subscribe | check-out | ...) default: subscribe
|
|
1129
|
+
* --apple-pay-button-style (black | white | white-outline) default: black
|
|
1130
|
+
* Size and radius still follow --apple-pay-height and --apple-pay-border-radius.
|
|
1131
|
+
*/
|
|
1132
|
+
@supports (-webkit-appearance: -apple-pay-button) {
|
|
1133
|
+
teg-apple-pay-button[data-native-button] .apple-pay-btn:not(.wap-loading) {
|
|
1134
|
+
-webkit-appearance: -apple-pay-button;
|
|
1135
|
+
appearance: -apple-pay-button;
|
|
1136
|
+
-apple-pay-button-type: var(--apple-pay-button-type, subscribe);
|
|
1137
|
+
-apple-pay-button-style: var(--apple-pay-button-style, black);
|
|
1138
|
+
min-height: var(--apple-pay-height, 2.5rem);
|
|
1139
|
+
border-radius: var(--apple-pay-border-radius, 0.25rem);
|
|
1140
|
+
font-size: 0;
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
teg-apple-pay-button[data-native-button]
|
|
1144
|
+
.apple-pay-btn:not(.wap-loading)
|
|
1145
|
+
.apple-pay-btn__label {
|
|
1146
|
+
display: none;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1114
1149
|
</style>
|
|
1115
1150
|
|
|
1116
1151
|
<div class="apple-pay-container" aria-label="Subscribe with Apple Pay">
|
|
@@ -1576,6 +1611,17 @@ var shippingContactDetails = (shippingContact) => {
|
|
|
1576
1611
|
return { emailAddress };
|
|
1577
1612
|
};
|
|
1578
1613
|
|
|
1614
|
+
// src/constants.ts
|
|
1615
|
+
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
1616
|
+
ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
|
|
1617
|
+
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
1618
|
+
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
1619
|
+
ApplePayEntryPoint2["FREE_TRIAL_BANNER"] = "free_trial_banner";
|
|
1620
|
+
ApplePayEntryPoint2["FREE_TRIAL_POPUP"] = "free_trial_popup";
|
|
1621
|
+
ApplePayEntryPoint2["SUBSCRIBE"] = "subscribe";
|
|
1622
|
+
return ApplePayEntryPoint2;
|
|
1623
|
+
})(ApplePayEntryPoint || {});
|
|
1624
|
+
|
|
1579
1625
|
// src/clients/payment-checkout/payment-handler.ts
|
|
1580
1626
|
var failApplePaySession = (session, errors = []) => {
|
|
1581
1627
|
session.completePayment({
|
|
@@ -1656,7 +1702,8 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1656
1702
|
trackWalletPaymentSuccess(skuId, result.basketId);
|
|
1657
1703
|
session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
1658
1704
|
const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
|
|
1659
|
-
const
|
|
1705
|
+
const isFreeTrialPopup = config.entryPoint === "free_trial_popup" /* FREE_TRIAL_POPUP */;
|
|
1706
|
+
const userStatus = isFreeTrialPopup && sessionData.loggedIn ? "nspc" : sessionData.loggedIn ? "lex" : "nex";
|
|
1660
1707
|
writeCheckoutRedirect(returnUrl);
|
|
1661
1708
|
window.location.href = redirectToCheckoutComplete({
|
|
1662
1709
|
basketId: result.basketId,
|
|
@@ -1942,20 +1989,24 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1942
1989
|
return [...zoneCountries];
|
|
1943
1990
|
};
|
|
1944
1991
|
|
|
1992
|
+
// src/utils/nativeButtonFlag.ts
|
|
1993
|
+
var NATIVE_BUTTON_ENABLED_IN_PRODUCTION = false;
|
|
1994
|
+
var NON_PRODUCTION_FIRST_LABELS = ["localhost", "dev", "stage"];
|
|
1995
|
+
var isNativeButtonEnabled = (hostname = window.location.hostname, override, enabledInProduction = NATIVE_BUTTON_ENABLED_IN_PRODUCTION) => {
|
|
1996
|
+
if (override !== void 0) {
|
|
1997
|
+
return override;
|
|
1998
|
+
}
|
|
1999
|
+
if (enabledInProduction) {
|
|
2000
|
+
return true;
|
|
2001
|
+
}
|
|
2002
|
+
const isBareLocalhost = hostname === "localhost";
|
|
2003
|
+
const isEnvSubdomain = hostname.split(".").length > 1 && NON_PRODUCTION_FIRST_LABELS.includes(hostname.split(".")[0]);
|
|
2004
|
+
return isBareLocalhost || isEnvSubdomain;
|
|
2005
|
+
};
|
|
2006
|
+
|
|
1945
2007
|
// src/utils/applePayExpressEligibility.ts
|
|
1946
2008
|
var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
|
|
1947
2009
|
|
|
1948
|
-
// src/constants.ts
|
|
1949
|
-
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
1950
|
-
ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
|
|
1951
|
-
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
1952
|
-
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
1953
|
-
ApplePayEntryPoint2["FREE_TRIAL_BANNER"] = "free_trial_banner";
|
|
1954
|
-
ApplePayEntryPoint2["FREE_TRIAL_POPUP"] = "free_trial_popup";
|
|
1955
|
-
ApplePayEntryPoint2["SUBSCRIBE"] = "subscribe";
|
|
1956
|
-
return ApplePayEntryPoint2;
|
|
1957
|
-
})(ApplePayEntryPoint || {});
|
|
1958
|
-
|
|
1959
2010
|
// src/apple-pay-button.ts
|
|
1960
2011
|
var ENTRY_POINT_CONFIG = {
|
|
1961
2012
|
["dual_offer_banner" /* DUAL_OFFER_BANNER */]: {
|
|
@@ -2224,6 +2275,13 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2224
2275
|
const template = document.createElement("template");
|
|
2225
2276
|
template.innerHTML = apple_pay_button_template_default;
|
|
2226
2277
|
this.appendChild(template.content.cloneNode(true));
|
|
2278
|
+
this.toggleAttribute(
|
|
2279
|
+
"data-native-button",
|
|
2280
|
+
isNativeButtonEnabled(
|
|
2281
|
+
window.location.hostname,
|
|
2282
|
+
getApplePayConfig()?.nativeButton
|
|
2283
|
+
)
|
|
2284
|
+
);
|
|
2227
2285
|
const button = this.querySelector(SEL_BUTTON);
|
|
2228
2286
|
button.classList.add("wap-loading");
|
|
2229
2287
|
button.setAttribute("disabled", "");
|
|
@@ -2322,7 +2380,8 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2322
2380
|
currency: offer.price?.currency_code ?? DEFAULT_CURRENCY,
|
|
2323
2381
|
returnUrl: this.#returnUrl,
|
|
2324
2382
|
supportedBillingCountries: this.#supportedBillingCountries,
|
|
2325
|
-
recaptchaToken
|
|
2383
|
+
recaptchaToken,
|
|
2384
|
+
entryPoint: this.#entryPoint
|
|
2326
2385
|
});
|
|
2327
2386
|
}
|
|
2328
2387
|
};
|
|
@@ -1106,6 +1106,41 @@ var apple_pay_button_template_default = `<style>
|
|
|
1106
1106
|
transform: translate(-50%, -50%) rotate(360deg);
|
|
1107
1107
|
}
|
|
1108
1108
|
}
|
|
1109
|
+
|
|
1110
|
+
/*
|
|
1111
|
+
* Native Apple Pay button. Safari (and iOS) draw Apple's own artwork for this appearance, which keeps the
|
|
1112
|
+
* button compliant with Apple's design guidelines. It is built into WebKit: no SDK script and no network
|
|
1113
|
+
* request, so it costs nothing on latency-sensitive surfaces (walls, banners).
|
|
1114
|
+
*
|
|
1115
|
+
* Gated by the \`data-native-button\` attribute (feature flag, see utils/nativeButtonFlag.ts: on for
|
|
1116
|
+
* localhost/dev/stage, off for production until flipped). Applied only where the browser supports it and
|
|
1117
|
+
* only once loading has finished: the spinner
|
|
1118
|
+
* (.wap-loading) needs the custom button. Everywhere else (non-WebKit browsers, or the QA bypass on a
|
|
1119
|
+
* browser without support) the custom button above remains the fallback.
|
|
1120
|
+
*
|
|
1121
|
+
* Apple controls colour and wording, so --apple-pay-background-color / --apple-pay-foreground-color and
|
|
1122
|
+
* the caption/logo are ignored here. Override with:
|
|
1123
|
+
* --apple-pay-button-type (plain | buy | subscribe | check-out | ...) default: subscribe
|
|
1124
|
+
* --apple-pay-button-style (black | white | white-outline) default: black
|
|
1125
|
+
* Size and radius still follow --apple-pay-height and --apple-pay-border-radius.
|
|
1126
|
+
*/
|
|
1127
|
+
@supports (-webkit-appearance: -apple-pay-button) {
|
|
1128
|
+
teg-apple-pay-button[data-native-button] .apple-pay-btn:not(.wap-loading) {
|
|
1129
|
+
-webkit-appearance: -apple-pay-button;
|
|
1130
|
+
appearance: -apple-pay-button;
|
|
1131
|
+
-apple-pay-button-type: var(--apple-pay-button-type, subscribe);
|
|
1132
|
+
-apple-pay-button-style: var(--apple-pay-button-style, black);
|
|
1133
|
+
min-height: var(--apple-pay-height, 2.5rem);
|
|
1134
|
+
border-radius: var(--apple-pay-border-radius, 0.25rem);
|
|
1135
|
+
font-size: 0;
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
teg-apple-pay-button[data-native-button]
|
|
1139
|
+
.apple-pay-btn:not(.wap-loading)
|
|
1140
|
+
.apple-pay-btn__label {
|
|
1141
|
+
display: none;
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1109
1144
|
</style>
|
|
1110
1145
|
|
|
1111
1146
|
<div class="apple-pay-container" aria-label="Subscribe with Apple Pay">
|
|
@@ -1651,7 +1686,8 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1651
1686
|
trackWalletPaymentSuccess(skuId, result.basketId);
|
|
1652
1687
|
session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
1653
1688
|
const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
|
|
1654
|
-
const
|
|
1689
|
+
const isFreeTrialPopup = config.entryPoint === "free_trial_popup" /* FREE_TRIAL_POPUP */;
|
|
1690
|
+
const userStatus = isFreeTrialPopup && sessionData.loggedIn ? "nspc" : sessionData.loggedIn ? "lex" : "nex";
|
|
1655
1691
|
writeCheckoutRedirect(returnUrl);
|
|
1656
1692
|
window.location.href = redirectToCheckoutComplete({
|
|
1657
1693
|
basketId: result.basketId,
|
|
@@ -1937,6 +1973,21 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1937
1973
|
return [...zoneCountries];
|
|
1938
1974
|
};
|
|
1939
1975
|
|
|
1976
|
+
// src/utils/nativeButtonFlag.ts
|
|
1977
|
+
var NATIVE_BUTTON_ENABLED_IN_PRODUCTION = false;
|
|
1978
|
+
var NON_PRODUCTION_FIRST_LABELS = ["localhost", "dev", "stage"];
|
|
1979
|
+
var isNativeButtonEnabled = (hostname = window.location.hostname, override, enabledInProduction = NATIVE_BUTTON_ENABLED_IN_PRODUCTION) => {
|
|
1980
|
+
if (override !== void 0) {
|
|
1981
|
+
return override;
|
|
1982
|
+
}
|
|
1983
|
+
if (enabledInProduction) {
|
|
1984
|
+
return true;
|
|
1985
|
+
}
|
|
1986
|
+
const isBareLocalhost = hostname === "localhost";
|
|
1987
|
+
const isEnvSubdomain = hostname.split(".").length > 1 && NON_PRODUCTION_FIRST_LABELS.includes(hostname.split(".")[0]);
|
|
1988
|
+
return isBareLocalhost || isEnvSubdomain;
|
|
1989
|
+
};
|
|
1990
|
+
|
|
1940
1991
|
// src/utils/applePayExpressEligibility.ts
|
|
1941
1992
|
var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
|
|
1942
1993
|
|
|
@@ -2208,6 +2259,13 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2208
2259
|
const template = document.createElement("template");
|
|
2209
2260
|
template.innerHTML = apple_pay_button_template_default;
|
|
2210
2261
|
this.appendChild(template.content.cloneNode(true));
|
|
2262
|
+
this.toggleAttribute(
|
|
2263
|
+
"data-native-button",
|
|
2264
|
+
isNativeButtonEnabled(
|
|
2265
|
+
window.location.hostname,
|
|
2266
|
+
getApplePayConfig()?.nativeButton
|
|
2267
|
+
)
|
|
2268
|
+
);
|
|
2211
2269
|
const button = this.querySelector(SEL_BUTTON);
|
|
2212
2270
|
button.classList.add("wap-loading");
|
|
2213
2271
|
button.setAttribute("disabled", "");
|
|
@@ -2306,7 +2364,8 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2306
2364
|
currency: offer.price?.currency_code ?? DEFAULT_CURRENCY,
|
|
2307
2365
|
returnUrl: this.#returnUrl,
|
|
2308
2366
|
supportedBillingCountries: this.#supportedBillingCountries,
|
|
2309
|
-
recaptchaToken
|
|
2367
|
+
recaptchaToken,
|
|
2368
|
+
entryPoint: this.#entryPoint
|
|
2310
2369
|
});
|
|
2311
2370
|
}
|
|
2312
2371
|
};
|
|
@@ -1114,6 +1114,41 @@ var apple_pay_button_template_default = `<style>
|
|
|
1114
1114
|
transform: translate(-50%, -50%) rotate(360deg);
|
|
1115
1115
|
}
|
|
1116
1116
|
}
|
|
1117
|
+
|
|
1118
|
+
/*
|
|
1119
|
+
* Native Apple Pay button. Safari (and iOS) draw Apple's own artwork for this appearance, which keeps the
|
|
1120
|
+
* button compliant with Apple's design guidelines. It is built into WebKit: no SDK script and no network
|
|
1121
|
+
* request, so it costs nothing on latency-sensitive surfaces (walls, banners).
|
|
1122
|
+
*
|
|
1123
|
+
* Gated by the \`data-native-button\` attribute (feature flag, see utils/nativeButtonFlag.ts: on for
|
|
1124
|
+
* localhost/dev/stage, off for production until flipped). Applied only where the browser supports it and
|
|
1125
|
+
* only once loading has finished: the spinner
|
|
1126
|
+
* (.wap-loading) needs the custom button. Everywhere else (non-WebKit browsers, or the QA bypass on a
|
|
1127
|
+
* browser without support) the custom button above remains the fallback.
|
|
1128
|
+
*
|
|
1129
|
+
* Apple controls colour and wording, so --apple-pay-background-color / --apple-pay-foreground-color and
|
|
1130
|
+
* the caption/logo are ignored here. Override with:
|
|
1131
|
+
* --apple-pay-button-type (plain | buy | subscribe | check-out | ...) default: subscribe
|
|
1132
|
+
* --apple-pay-button-style (black | white | white-outline) default: black
|
|
1133
|
+
* Size and radius still follow --apple-pay-height and --apple-pay-border-radius.
|
|
1134
|
+
*/
|
|
1135
|
+
@supports (-webkit-appearance: -apple-pay-button) {
|
|
1136
|
+
teg-apple-pay-button[data-native-button] .apple-pay-btn:not(.wap-loading) {
|
|
1137
|
+
-webkit-appearance: -apple-pay-button;
|
|
1138
|
+
appearance: -apple-pay-button;
|
|
1139
|
+
-apple-pay-button-type: var(--apple-pay-button-type, subscribe);
|
|
1140
|
+
-apple-pay-button-style: var(--apple-pay-button-style, black);
|
|
1141
|
+
min-height: var(--apple-pay-height, 2.5rem);
|
|
1142
|
+
border-radius: var(--apple-pay-border-radius, 0.25rem);
|
|
1143
|
+
font-size: 0;
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
teg-apple-pay-button[data-native-button]
|
|
1147
|
+
.apple-pay-btn:not(.wap-loading)
|
|
1148
|
+
.apple-pay-btn__label {
|
|
1149
|
+
display: none;
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1117
1152
|
</style>
|
|
1118
1153
|
|
|
1119
1154
|
<div class="apple-pay-container" aria-label="Subscribe with Apple Pay">
|
|
@@ -1659,7 +1694,8 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1659
1694
|
trackWalletPaymentSuccess(skuId, result.basketId);
|
|
1660
1695
|
session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
1661
1696
|
const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
|
|
1662
|
-
const
|
|
1697
|
+
const isFreeTrialPopup = config.entryPoint === "free_trial_popup" /* FREE_TRIAL_POPUP */;
|
|
1698
|
+
const userStatus = isFreeTrialPopup && sessionData.loggedIn ? "nspc" : sessionData.loggedIn ? "lex" : "nex";
|
|
1663
1699
|
writeCheckoutRedirect(returnUrl);
|
|
1664
1700
|
window.location.href = redirectToCheckoutComplete({
|
|
1665
1701
|
basketId: result.basketId,
|
|
@@ -1945,6 +1981,21 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1945
1981
|
return [...zoneCountries];
|
|
1946
1982
|
};
|
|
1947
1983
|
|
|
1984
|
+
// src/utils/nativeButtonFlag.ts
|
|
1985
|
+
var NATIVE_BUTTON_ENABLED_IN_PRODUCTION = false;
|
|
1986
|
+
var NON_PRODUCTION_FIRST_LABELS = ["localhost", "dev", "stage"];
|
|
1987
|
+
var isNativeButtonEnabled = (hostname = window.location.hostname, override, enabledInProduction = NATIVE_BUTTON_ENABLED_IN_PRODUCTION) => {
|
|
1988
|
+
if (override !== void 0) {
|
|
1989
|
+
return override;
|
|
1990
|
+
}
|
|
1991
|
+
if (enabledInProduction) {
|
|
1992
|
+
return true;
|
|
1993
|
+
}
|
|
1994
|
+
const isBareLocalhost = hostname === "localhost";
|
|
1995
|
+
const isEnvSubdomain = hostname.split(".").length > 1 && NON_PRODUCTION_FIRST_LABELS.includes(hostname.split(".")[0]);
|
|
1996
|
+
return isBareLocalhost || isEnvSubdomain;
|
|
1997
|
+
};
|
|
1998
|
+
|
|
1948
1999
|
// src/utils/applePayExpressEligibility.ts
|
|
1949
2000
|
var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
|
|
1950
2001
|
|
|
@@ -2216,6 +2267,13 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2216
2267
|
const template = document.createElement("template");
|
|
2217
2268
|
template.innerHTML = apple_pay_button_template_default;
|
|
2218
2269
|
this.appendChild(template.content.cloneNode(true));
|
|
2270
|
+
this.toggleAttribute(
|
|
2271
|
+
"data-native-button",
|
|
2272
|
+
isNativeButtonEnabled(
|
|
2273
|
+
window.location.hostname,
|
|
2274
|
+
getApplePayConfig()?.nativeButton
|
|
2275
|
+
)
|
|
2276
|
+
);
|
|
2219
2277
|
const button = this.querySelector(SEL_BUTTON);
|
|
2220
2278
|
button.classList.add("wap-loading");
|
|
2221
2279
|
button.setAttribute("disabled", "");
|
|
@@ -2314,7 +2372,8 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2314
2372
|
currency: offer.price?.currency_code ?? DEFAULT_CURRENCY,
|
|
2315
2373
|
returnUrl: this.#returnUrl,
|
|
2316
2374
|
supportedBillingCountries: this.#supportedBillingCountries,
|
|
2317
|
-
recaptchaToken
|
|
2375
|
+
recaptchaToken,
|
|
2376
|
+
entryPoint: this.#entryPoint
|
|
2318
2377
|
});
|
|
2319
2378
|
}
|
|
2320
2379
|
};
|
|
@@ -1106,6 +1106,41 @@ var apple_pay_button_template_default = `<style>
|
|
|
1106
1106
|
transform: translate(-50%, -50%) rotate(360deg);
|
|
1107
1107
|
}
|
|
1108
1108
|
}
|
|
1109
|
+
|
|
1110
|
+
/*
|
|
1111
|
+
* Native Apple Pay button. Safari (and iOS) draw Apple's own artwork for this appearance, which keeps the
|
|
1112
|
+
* button compliant with Apple's design guidelines. It is built into WebKit: no SDK script and no network
|
|
1113
|
+
* request, so it costs nothing on latency-sensitive surfaces (walls, banners).
|
|
1114
|
+
*
|
|
1115
|
+
* Gated by the \`data-native-button\` attribute (feature flag, see utils/nativeButtonFlag.ts: on for
|
|
1116
|
+
* localhost/dev/stage, off for production until flipped). Applied only where the browser supports it and
|
|
1117
|
+
* only once loading has finished: the spinner
|
|
1118
|
+
* (.wap-loading) needs the custom button. Everywhere else (non-WebKit browsers, or the QA bypass on a
|
|
1119
|
+
* browser without support) the custom button above remains the fallback.
|
|
1120
|
+
*
|
|
1121
|
+
* Apple controls colour and wording, so --apple-pay-background-color / --apple-pay-foreground-color and
|
|
1122
|
+
* the caption/logo are ignored here. Override with:
|
|
1123
|
+
* --apple-pay-button-type (plain | buy | subscribe | check-out | ...) default: subscribe
|
|
1124
|
+
* --apple-pay-button-style (black | white | white-outline) default: black
|
|
1125
|
+
* Size and radius still follow --apple-pay-height and --apple-pay-border-radius.
|
|
1126
|
+
*/
|
|
1127
|
+
@supports (-webkit-appearance: -apple-pay-button) {
|
|
1128
|
+
teg-apple-pay-button[data-native-button] .apple-pay-btn:not(.wap-loading) {
|
|
1129
|
+
-webkit-appearance: -apple-pay-button;
|
|
1130
|
+
appearance: -apple-pay-button;
|
|
1131
|
+
-apple-pay-button-type: var(--apple-pay-button-type, subscribe);
|
|
1132
|
+
-apple-pay-button-style: var(--apple-pay-button-style, black);
|
|
1133
|
+
min-height: var(--apple-pay-height, 2.5rem);
|
|
1134
|
+
border-radius: var(--apple-pay-border-radius, 0.25rem);
|
|
1135
|
+
font-size: 0;
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
teg-apple-pay-button[data-native-button]
|
|
1139
|
+
.apple-pay-btn:not(.wap-loading)
|
|
1140
|
+
.apple-pay-btn__label {
|
|
1141
|
+
display: none;
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1109
1144
|
</style>
|
|
1110
1145
|
|
|
1111
1146
|
<div class="apple-pay-container" aria-label="Subscribe with Apple Pay">
|
|
@@ -1651,7 +1686,8 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1651
1686
|
trackWalletPaymentSuccess(skuId, result.basketId);
|
|
1652
1687
|
session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
1653
1688
|
const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
|
|
1654
|
-
const
|
|
1689
|
+
const isFreeTrialPopup = config.entryPoint === "free_trial_popup" /* FREE_TRIAL_POPUP */;
|
|
1690
|
+
const userStatus = isFreeTrialPopup && sessionData.loggedIn ? "nspc" : sessionData.loggedIn ? "lex" : "nex";
|
|
1655
1691
|
writeCheckoutRedirect(returnUrl);
|
|
1656
1692
|
window.location.href = redirectToCheckoutComplete({
|
|
1657
1693
|
basketId: result.basketId,
|
|
@@ -1937,6 +1973,21 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1937
1973
|
return [...zoneCountries];
|
|
1938
1974
|
};
|
|
1939
1975
|
|
|
1976
|
+
// src/utils/nativeButtonFlag.ts
|
|
1977
|
+
var NATIVE_BUTTON_ENABLED_IN_PRODUCTION = false;
|
|
1978
|
+
var NON_PRODUCTION_FIRST_LABELS = ["localhost", "dev", "stage"];
|
|
1979
|
+
var isNativeButtonEnabled = (hostname = window.location.hostname, override, enabledInProduction = NATIVE_BUTTON_ENABLED_IN_PRODUCTION) => {
|
|
1980
|
+
if (override !== void 0) {
|
|
1981
|
+
return override;
|
|
1982
|
+
}
|
|
1983
|
+
if (enabledInProduction) {
|
|
1984
|
+
return true;
|
|
1985
|
+
}
|
|
1986
|
+
const isBareLocalhost = hostname === "localhost";
|
|
1987
|
+
const isEnvSubdomain = hostname.split(".").length > 1 && NON_PRODUCTION_FIRST_LABELS.includes(hostname.split(".")[0]);
|
|
1988
|
+
return isBareLocalhost || isEnvSubdomain;
|
|
1989
|
+
};
|
|
1990
|
+
|
|
1940
1991
|
// src/utils/applePayExpressEligibility.ts
|
|
1941
1992
|
var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
|
|
1942
1993
|
|
|
@@ -2208,6 +2259,13 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2208
2259
|
const template = document.createElement("template");
|
|
2209
2260
|
template.innerHTML = apple_pay_button_template_default;
|
|
2210
2261
|
this.appendChild(template.content.cloneNode(true));
|
|
2262
|
+
this.toggleAttribute(
|
|
2263
|
+
"data-native-button",
|
|
2264
|
+
isNativeButtonEnabled(
|
|
2265
|
+
window.location.hostname,
|
|
2266
|
+
getApplePayConfig()?.nativeButton
|
|
2267
|
+
)
|
|
2268
|
+
);
|
|
2211
2269
|
const button = this.querySelector(SEL_BUTTON);
|
|
2212
2270
|
button.classList.add("wap-loading");
|
|
2213
2271
|
button.setAttribute("disabled", "");
|
|
@@ -2306,7 +2364,8 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2306
2364
|
currency: offer.price?.currency_code ?? DEFAULT_CURRENCY,
|
|
2307
2365
|
returnUrl: this.#returnUrl,
|
|
2308
2366
|
supportedBillingCountries: this.#supportedBillingCountries,
|
|
2309
|
-
recaptchaToken
|
|
2367
|
+
recaptchaToken,
|
|
2368
|
+
entryPoint: this.#entryPoint
|
|
2310
2369
|
});
|
|
2311
2370
|
}
|
|
2312
2371
|
};
|
|
@@ -3,6 +3,11 @@ export interface ApplePayRuntimeConfig {
|
|
|
3
3
|
recaptchaSiteKey?: string;
|
|
4
4
|
debugBypassEnabled?: boolean;
|
|
5
5
|
walletApiBaseUrl: string;
|
|
6
|
+
/**
|
|
7
|
+
* Force Apple's native CSS button on/off, overriding the built-in flag
|
|
8
|
+
* (default: on for localhost/dev/stage, off for production).
|
|
9
|
+
*/
|
|
10
|
+
nativeButton?: boolean;
|
|
6
11
|
}
|
|
7
12
|
export declare const configureApplePay: (config: ApplePayRuntimeConfig) => void;
|
|
8
13
|
export declare const getApplePayConfig: () => ApplePayRuntimeConfig | null;
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* 4. Handling structured BFF errors → deterministic UI actions per errorType
|
|
15
15
|
*/
|
|
16
16
|
import type { SessionResponse } from './types';
|
|
17
|
+
import { ApplePayEntryPoint } from '../../constants';
|
|
17
18
|
export type PaymentHandlerConfig = {
|
|
18
19
|
skuId: string;
|
|
19
20
|
country: string;
|
|
@@ -21,5 +22,7 @@ export type PaymentHandlerConfig = {
|
|
|
21
22
|
returnUrl: string;
|
|
22
23
|
supportedBillingCountries: string[];
|
|
23
24
|
recaptchaToken: string;
|
|
25
|
+
/** When FREE_TRIAL_POPUP and the session is logged in, complete is opened with status=nspc. */
|
|
26
|
+
entryPoint?: ApplePayEntryPoint | '';
|
|
24
27
|
};
|
|
25
28
|
export declare function handlePaymentAuthorized(event: ApplePayJS.ApplePayPaymentAuthorizedEvent, session: ApplePaySession, sessionData: SessionResponse, config: PaymentHandlerConfig): Promise<void>;
|
|
@@ -364,7 +364,8 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
364
364
|
trackWalletPaymentSuccess(skuId, result.basketId);
|
|
365
365
|
session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
366
366
|
const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
|
|
367
|
-
const
|
|
367
|
+
const isFreeTrialPopup = config.entryPoint === "free_trial_popup" /* FREE_TRIAL_POPUP */;
|
|
368
|
+
const userStatus = isFreeTrialPopup && sessionData.loggedIn ? "nspc" : sessionData.loggedIn ? "lex" : "nex";
|
|
368
369
|
writeCheckoutRedirect(returnUrl);
|
|
369
370
|
window.location.href = redirectToCheckoutComplete({
|
|
370
371
|
basketId: result.basketId,
|
package/dist/src/index.js
CHANGED
|
@@ -1111,6 +1111,41 @@ var apple_pay_button_template_default = `<style>
|
|
|
1111
1111
|
transform: translate(-50%, -50%) rotate(360deg);
|
|
1112
1112
|
}
|
|
1113
1113
|
}
|
|
1114
|
+
|
|
1115
|
+
/*
|
|
1116
|
+
* Native Apple Pay button. Safari (and iOS) draw Apple's own artwork for this appearance, which keeps the
|
|
1117
|
+
* button compliant with Apple's design guidelines. It is built into WebKit: no SDK script and no network
|
|
1118
|
+
* request, so it costs nothing on latency-sensitive surfaces (walls, banners).
|
|
1119
|
+
*
|
|
1120
|
+
* Gated by the \`data-native-button\` attribute (feature flag, see utils/nativeButtonFlag.ts: on for
|
|
1121
|
+
* localhost/dev/stage, off for production until flipped). Applied only where the browser supports it and
|
|
1122
|
+
* only once loading has finished: the spinner
|
|
1123
|
+
* (.wap-loading) needs the custom button. Everywhere else (non-WebKit browsers, or the QA bypass on a
|
|
1124
|
+
* browser without support) the custom button above remains the fallback.
|
|
1125
|
+
*
|
|
1126
|
+
* Apple controls colour and wording, so --apple-pay-background-color / --apple-pay-foreground-color and
|
|
1127
|
+
* the caption/logo are ignored here. Override with:
|
|
1128
|
+
* --apple-pay-button-type (plain | buy | subscribe | check-out | ...) default: subscribe
|
|
1129
|
+
* --apple-pay-button-style (black | white | white-outline) default: black
|
|
1130
|
+
* Size and radius still follow --apple-pay-height and --apple-pay-border-radius.
|
|
1131
|
+
*/
|
|
1132
|
+
@supports (-webkit-appearance: -apple-pay-button) {
|
|
1133
|
+
teg-apple-pay-button[data-native-button] .apple-pay-btn:not(.wap-loading) {
|
|
1134
|
+
-webkit-appearance: -apple-pay-button;
|
|
1135
|
+
appearance: -apple-pay-button;
|
|
1136
|
+
-apple-pay-button-type: var(--apple-pay-button-type, subscribe);
|
|
1137
|
+
-apple-pay-button-style: var(--apple-pay-button-style, black);
|
|
1138
|
+
min-height: var(--apple-pay-height, 2.5rem);
|
|
1139
|
+
border-radius: var(--apple-pay-border-radius, 0.25rem);
|
|
1140
|
+
font-size: 0;
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
teg-apple-pay-button[data-native-button]
|
|
1144
|
+
.apple-pay-btn:not(.wap-loading)
|
|
1145
|
+
.apple-pay-btn__label {
|
|
1146
|
+
display: none;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1114
1149
|
</style>
|
|
1115
1150
|
|
|
1116
1151
|
<div class="apple-pay-container" aria-label="Subscribe with Apple Pay">
|
|
@@ -1576,6 +1611,17 @@ var shippingContactDetails = (shippingContact) => {
|
|
|
1576
1611
|
return { emailAddress };
|
|
1577
1612
|
};
|
|
1578
1613
|
|
|
1614
|
+
// src/constants.ts
|
|
1615
|
+
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
1616
|
+
ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
|
|
1617
|
+
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
1618
|
+
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
1619
|
+
ApplePayEntryPoint2["FREE_TRIAL_BANNER"] = "free_trial_banner";
|
|
1620
|
+
ApplePayEntryPoint2["FREE_TRIAL_POPUP"] = "free_trial_popup";
|
|
1621
|
+
ApplePayEntryPoint2["SUBSCRIBE"] = "subscribe";
|
|
1622
|
+
return ApplePayEntryPoint2;
|
|
1623
|
+
})(ApplePayEntryPoint || {});
|
|
1624
|
+
|
|
1579
1625
|
// src/clients/payment-checkout/payment-handler.ts
|
|
1580
1626
|
var failApplePaySession = (session, errors = []) => {
|
|
1581
1627
|
session.completePayment({
|
|
@@ -1656,7 +1702,8 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1656
1702
|
trackWalletPaymentSuccess(skuId, result.basketId);
|
|
1657
1703
|
session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
1658
1704
|
const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
|
|
1659
|
-
const
|
|
1705
|
+
const isFreeTrialPopup = config.entryPoint === "free_trial_popup" /* FREE_TRIAL_POPUP */;
|
|
1706
|
+
const userStatus = isFreeTrialPopup && sessionData.loggedIn ? "nspc" : sessionData.loggedIn ? "lex" : "nex";
|
|
1660
1707
|
writeCheckoutRedirect(returnUrl);
|
|
1661
1708
|
window.location.href = redirectToCheckoutComplete({
|
|
1662
1709
|
basketId: result.basketId,
|
|
@@ -1942,20 +1989,24 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1942
1989
|
return [...zoneCountries];
|
|
1943
1990
|
};
|
|
1944
1991
|
|
|
1992
|
+
// src/utils/nativeButtonFlag.ts
|
|
1993
|
+
var NATIVE_BUTTON_ENABLED_IN_PRODUCTION = false;
|
|
1994
|
+
var NON_PRODUCTION_FIRST_LABELS = ["localhost", "dev", "stage"];
|
|
1995
|
+
var isNativeButtonEnabled = (hostname = window.location.hostname, override, enabledInProduction = NATIVE_BUTTON_ENABLED_IN_PRODUCTION) => {
|
|
1996
|
+
if (override !== void 0) {
|
|
1997
|
+
return override;
|
|
1998
|
+
}
|
|
1999
|
+
if (enabledInProduction) {
|
|
2000
|
+
return true;
|
|
2001
|
+
}
|
|
2002
|
+
const isBareLocalhost = hostname === "localhost";
|
|
2003
|
+
const isEnvSubdomain = hostname.split(".").length > 1 && NON_PRODUCTION_FIRST_LABELS.includes(hostname.split(".")[0]);
|
|
2004
|
+
return isBareLocalhost || isEnvSubdomain;
|
|
2005
|
+
};
|
|
2006
|
+
|
|
1945
2007
|
// src/utils/applePayExpressEligibility.ts
|
|
1946
2008
|
var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
|
|
1947
2009
|
|
|
1948
|
-
// src/constants.ts
|
|
1949
|
-
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
1950
|
-
ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
|
|
1951
|
-
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
1952
|
-
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
1953
|
-
ApplePayEntryPoint2["FREE_TRIAL_BANNER"] = "free_trial_banner";
|
|
1954
|
-
ApplePayEntryPoint2["FREE_TRIAL_POPUP"] = "free_trial_popup";
|
|
1955
|
-
ApplePayEntryPoint2["SUBSCRIBE"] = "subscribe";
|
|
1956
|
-
return ApplePayEntryPoint2;
|
|
1957
|
-
})(ApplePayEntryPoint || {});
|
|
1958
|
-
|
|
1959
2010
|
// src/apple-pay-button.ts
|
|
1960
2011
|
var ENTRY_POINT_CONFIG = {
|
|
1961
2012
|
["dual_offer_banner" /* DUAL_OFFER_BANNER */]: {
|
|
@@ -2224,6 +2275,13 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2224
2275
|
const template = document.createElement("template");
|
|
2225
2276
|
template.innerHTML = apple_pay_button_template_default;
|
|
2226
2277
|
this.appendChild(template.content.cloneNode(true));
|
|
2278
|
+
this.toggleAttribute(
|
|
2279
|
+
"data-native-button",
|
|
2280
|
+
isNativeButtonEnabled(
|
|
2281
|
+
window.location.hostname,
|
|
2282
|
+
getApplePayConfig()?.nativeButton
|
|
2283
|
+
)
|
|
2284
|
+
);
|
|
2227
2285
|
const button = this.querySelector(SEL_BUTTON);
|
|
2228
2286
|
button.classList.add("wap-loading");
|
|
2229
2287
|
button.setAttribute("disabled", "");
|
|
@@ -2322,7 +2380,8 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2322
2380
|
currency: offer.price?.currency_code ?? DEFAULT_CURRENCY,
|
|
2323
2381
|
returnUrl: this.#returnUrl,
|
|
2324
2382
|
supportedBillingCountries: this.#supportedBillingCountries,
|
|
2325
|
-
recaptchaToken
|
|
2383
|
+
recaptchaToken,
|
|
2384
|
+
entryPoint: this.#entryPoint
|
|
2326
2385
|
});
|
|
2327
2386
|
}
|
|
2328
2387
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ProductVariant = 'bundle' | 'digital' | 'espresso' | 'espressopod' | 'podcast' | 'insider_digital' | 'insider_print';
|
|
1
|
+
export type ProductVariant = 'bundle' | 'digital' | 'espresso' | 'espressopod' | 'podcast' | 'insider_digital' | 'play' | 'insider_print';
|
|
2
2
|
export type PeriodUnit = 'week' | 'month' | 'year';
|
|
3
3
|
export type Period = {
|
|
4
4
|
duration: number;
|
|
@@ -42,11 +42,12 @@ export declare const decodeSku: (sku: string) => string;
|
|
|
42
42
|
* Always appended when non-empty to preserve geo-context across the redirect.
|
|
43
43
|
*
|
|
44
44
|
* The origin article URL is written to localStorage by the caller via
|
|
45
|
-
* writeCheckoutRedirect()
|
|
45
|
+
* writeCheckoutRedirect() so sma-checkout can return the reader after
|
|
46
|
+
* passwordless confirmation (`nspc`) or after onboarding.
|
|
46
47
|
*/
|
|
47
48
|
export declare const redirectToCheckoutComplete: (params: {
|
|
48
49
|
basketId: string;
|
|
49
|
-
status: "nex" | "lex";
|
|
50
|
+
status: "nex" | "lex" | "nspc";
|
|
50
51
|
skuId: string;
|
|
51
52
|
email?: string;
|
|
52
53
|
country?: string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feature flag for Apple's native CSS button (see README "Native Apple Pay button").
|
|
3
|
+
*
|
|
4
|
+
* It is on for known non-production hosts (localhost, dev, stage) so it can be tested, and OFF for
|
|
5
|
+
* production until this constant is flipped to `true` in a release.
|
|
6
|
+
*
|
|
7
|
+
* Fails closed: only `localhost`, `dev.*` and `stage.*` count as non-production. Any other host
|
|
8
|
+
* (www.economist.com, previews, IPs, tunnels) keeps the custom button while the flag is off.
|
|
9
|
+
* A host can force either value with `configureApplePay({ nativeButton })`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const NATIVE_BUTTON_ENABLED_IN_PRODUCTION = false;
|
|
12
|
+
export declare const isNativeButtonEnabled: (hostname?: string, override?: boolean, enabledInProduction?: boolean) => boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/utils/nativeButtonFlag.ts
|
|
2
|
+
var NATIVE_BUTTON_ENABLED_IN_PRODUCTION = false;
|
|
3
|
+
var NON_PRODUCTION_FIRST_LABELS = ["localhost", "dev", "stage"];
|
|
4
|
+
var isNativeButtonEnabled = (hostname = window.location.hostname, override, enabledInProduction = NATIVE_BUTTON_ENABLED_IN_PRODUCTION) => {
|
|
5
|
+
if (override !== void 0) {
|
|
6
|
+
return override;
|
|
7
|
+
}
|
|
8
|
+
if (enabledInProduction) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
const isBareLocalhost = hostname === "localhost";
|
|
12
|
+
const isEnvSubdomain = hostname.split(".").length > 1 && NON_PRODUCTION_FIRST_LABELS.includes(hostname.split(".")[0]);
|
|
13
|
+
return isBareLocalhost || isEnvSubdomain;
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
NATIVE_BUTTON_ENABLED_IN_PRODUCTION,
|
|
17
|
+
isNativeButtonEnabled
|
|
18
|
+
};
|
package/package.json
CHANGED