@economist/web-apple-pay 1.15.1 → 1.15.2
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 +1 -1
- package/dist/index.js +15 -13
- package/dist/src/apple-pay-button.js +4 -2
- package/dist/src/apple-pay-button.stories.js +4 -2
- package/dist/src/apple-pay-modal.stories.js +4 -2
- 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 +15 -13
- package/dist/src/utils/expressCheckoutRedirect.d.ts +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -147,7 +147,7 @@ Consumers should listen for this event and continue payment orchestration.
|
|
|
147
147
|
- `createIfEnabled(offer, country, entryPoint?)`: returns a configured button or `null`.
|
|
148
148
|
- `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions — no homepage/Safari gate at `createIfEnabled` (device gating via `isApplePayAvailable` on mount).
|
|
149
149
|
- `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; wallet impression `entry_point` is `free_trial_banner`.
|
|
150
|
-
- `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.
|
|
151
151
|
- `SUBSCRIBE`: same always-on-after-exclusions gate for `/subscribe` (sma-checkout); no Amplitude. Wallet impression `entry_point` is `subscribe`.
|
|
152
152
|
- `PAYWALL`: always-on after offer exclusions + Safari/Apple placement eligibility. No Amplitude experiment / `$exposure`.
|
|
153
153
|
- `REGWALL`: inert — always returns `null`.
|
package/dist/index.js
CHANGED
|
@@ -1625,6 +1625,17 @@ var shippingContactDetails = (shippingContact) => {
|
|
|
1625
1625
|
return { emailAddress };
|
|
1626
1626
|
};
|
|
1627
1627
|
|
|
1628
|
+
// src/constants.ts
|
|
1629
|
+
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
1630
|
+
ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
|
|
1631
|
+
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
1632
|
+
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
1633
|
+
ApplePayEntryPoint2["FREE_TRIAL_BANNER"] = "free_trial_banner";
|
|
1634
|
+
ApplePayEntryPoint2["FREE_TRIAL_POPUP"] = "free_trial_popup";
|
|
1635
|
+
ApplePayEntryPoint2["SUBSCRIBE"] = "subscribe";
|
|
1636
|
+
return ApplePayEntryPoint2;
|
|
1637
|
+
})(ApplePayEntryPoint || {});
|
|
1638
|
+
|
|
1628
1639
|
// src/clients/payment-checkout/payment-handler.ts
|
|
1629
1640
|
var failApplePaySession = (session, errors = []) => {
|
|
1630
1641
|
session.completePayment({
|
|
@@ -1705,7 +1716,8 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1705
1716
|
trackWalletPaymentSuccess(skuId, result.basketId);
|
|
1706
1717
|
session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
1707
1718
|
const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
|
|
1708
|
-
const
|
|
1719
|
+
const isFreeTrialPopup = config.entryPoint === "free_trial_popup" /* FREE_TRIAL_POPUP */;
|
|
1720
|
+
const userStatus = isFreeTrialPopup && sessionData.loggedIn ? "nspc" : sessionData.loggedIn ? "lex" : "nex";
|
|
1709
1721
|
writeCheckoutRedirect(returnUrl);
|
|
1710
1722
|
window.location.href = redirectToCheckoutComplete({
|
|
1711
1723
|
basketId: result.basketId,
|
|
@@ -2009,17 +2021,6 @@ var isNativeButtonEnabled = (hostname = window.location.hostname, override, enab
|
|
|
2009
2021
|
// src/utils/applePayExpressEligibility.ts
|
|
2010
2022
|
var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
|
|
2011
2023
|
|
|
2012
|
-
// src/constants.ts
|
|
2013
|
-
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
2014
|
-
ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
|
|
2015
|
-
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
2016
|
-
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
2017
|
-
ApplePayEntryPoint2["FREE_TRIAL_BANNER"] = "free_trial_banner";
|
|
2018
|
-
ApplePayEntryPoint2["FREE_TRIAL_POPUP"] = "free_trial_popup";
|
|
2019
|
-
ApplePayEntryPoint2["SUBSCRIBE"] = "subscribe";
|
|
2020
|
-
return ApplePayEntryPoint2;
|
|
2021
|
-
})(ApplePayEntryPoint || {});
|
|
2022
|
-
|
|
2023
2024
|
// src/apple-pay-button.ts
|
|
2024
2025
|
var ENTRY_POINT_CONFIG = {
|
|
2025
2026
|
["dual_offer_banner" /* DUAL_OFFER_BANNER */]: {
|
|
@@ -2410,7 +2411,8 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2410
2411
|
currency: offer.price?.currency_code ?? DEFAULT_CURRENCY,
|
|
2411
2412
|
returnUrl: this.#checkoutRedirectUrl,
|
|
2412
2413
|
supportedBillingCountries: this.#supportedBillingCountries,
|
|
2413
|
-
recaptchaToken
|
|
2414
|
+
recaptchaToken,
|
|
2415
|
+
entryPoint: this.#entryPoint
|
|
2414
2416
|
});
|
|
2415
2417
|
}
|
|
2416
2418
|
};
|
|
@@ -1700,7 +1700,8 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1700
1700
|
trackWalletPaymentSuccess(skuId, result.basketId);
|
|
1701
1701
|
session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
1702
1702
|
const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
|
|
1703
|
-
const
|
|
1703
|
+
const isFreeTrialPopup = config.entryPoint === "free_trial_popup" /* FREE_TRIAL_POPUP */;
|
|
1704
|
+
const userStatus = isFreeTrialPopup && sessionData.loggedIn ? "nspc" : sessionData.loggedIn ? "lex" : "nex";
|
|
1704
1705
|
writeCheckoutRedirect(returnUrl);
|
|
1705
1706
|
window.location.href = redirectToCheckoutComplete({
|
|
1706
1707
|
basketId: result.basketId,
|
|
@@ -2394,7 +2395,8 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2394
2395
|
currency: offer.price?.currency_code ?? DEFAULT_CURRENCY,
|
|
2395
2396
|
returnUrl: this.#checkoutRedirectUrl,
|
|
2396
2397
|
supportedBillingCountries: this.#supportedBillingCountries,
|
|
2397
|
-
recaptchaToken
|
|
2398
|
+
recaptchaToken,
|
|
2399
|
+
entryPoint: this.#entryPoint
|
|
2398
2400
|
});
|
|
2399
2401
|
}
|
|
2400
2402
|
};
|
|
@@ -1708,7 +1708,8 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1708
1708
|
trackWalletPaymentSuccess(skuId, result.basketId);
|
|
1709
1709
|
session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
1710
1710
|
const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
|
|
1711
|
-
const
|
|
1711
|
+
const isFreeTrialPopup = config.entryPoint === "free_trial_popup" /* FREE_TRIAL_POPUP */;
|
|
1712
|
+
const userStatus = isFreeTrialPopup && sessionData.loggedIn ? "nspc" : sessionData.loggedIn ? "lex" : "nex";
|
|
1712
1713
|
writeCheckoutRedirect(returnUrl);
|
|
1713
1714
|
window.location.href = redirectToCheckoutComplete({
|
|
1714
1715
|
basketId: result.basketId,
|
|
@@ -2402,7 +2403,8 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2402
2403
|
currency: offer.price?.currency_code ?? DEFAULT_CURRENCY,
|
|
2403
2404
|
returnUrl: this.#checkoutRedirectUrl,
|
|
2404
2405
|
supportedBillingCountries: this.#supportedBillingCountries,
|
|
2405
|
-
recaptchaToken
|
|
2406
|
+
recaptchaToken,
|
|
2407
|
+
entryPoint: this.#entryPoint
|
|
2406
2408
|
});
|
|
2407
2409
|
}
|
|
2408
2410
|
};
|
|
@@ -1700,7 +1700,8 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1700
1700
|
trackWalletPaymentSuccess(skuId, result.basketId);
|
|
1701
1701
|
session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
1702
1702
|
const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
|
|
1703
|
-
const
|
|
1703
|
+
const isFreeTrialPopup = config.entryPoint === "free_trial_popup" /* FREE_TRIAL_POPUP */;
|
|
1704
|
+
const userStatus = isFreeTrialPopup && sessionData.loggedIn ? "nspc" : sessionData.loggedIn ? "lex" : "nex";
|
|
1704
1705
|
writeCheckoutRedirect(returnUrl);
|
|
1705
1706
|
window.location.href = redirectToCheckoutComplete({
|
|
1706
1707
|
basketId: result.basketId,
|
|
@@ -2394,7 +2395,8 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2394
2395
|
currency: offer.price?.currency_code ?? DEFAULT_CURRENCY,
|
|
2395
2396
|
returnUrl: this.#checkoutRedirectUrl,
|
|
2396
2397
|
supportedBillingCountries: this.#supportedBillingCountries,
|
|
2397
|
-
recaptchaToken
|
|
2398
|
+
recaptchaToken,
|
|
2399
|
+
entryPoint: this.#entryPoint
|
|
2398
2400
|
});
|
|
2399
2401
|
}
|
|
2400
2402
|
};
|
|
@@ -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;
|
|
@@ -22,5 +23,7 @@ export type PaymentHandlerConfig = {
|
|
|
22
23
|
returnUrl: string | null;
|
|
23
24
|
supportedBillingCountries: string[];
|
|
24
25
|
recaptchaToken: string;
|
|
26
|
+
/** When FREE_TRIAL_POPUP and the session is logged in, complete is opened with status=nspc. */
|
|
27
|
+
entryPoint?: ApplePayEntryPoint | '';
|
|
25
28
|
};
|
|
26
29
|
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
|
@@ -1625,6 +1625,17 @@ var shippingContactDetails = (shippingContact) => {
|
|
|
1625
1625
|
return { emailAddress };
|
|
1626
1626
|
};
|
|
1627
1627
|
|
|
1628
|
+
// src/constants.ts
|
|
1629
|
+
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
1630
|
+
ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
|
|
1631
|
+
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
1632
|
+
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
1633
|
+
ApplePayEntryPoint2["FREE_TRIAL_BANNER"] = "free_trial_banner";
|
|
1634
|
+
ApplePayEntryPoint2["FREE_TRIAL_POPUP"] = "free_trial_popup";
|
|
1635
|
+
ApplePayEntryPoint2["SUBSCRIBE"] = "subscribe";
|
|
1636
|
+
return ApplePayEntryPoint2;
|
|
1637
|
+
})(ApplePayEntryPoint || {});
|
|
1638
|
+
|
|
1628
1639
|
// src/clients/payment-checkout/payment-handler.ts
|
|
1629
1640
|
var failApplePaySession = (session, errors = []) => {
|
|
1630
1641
|
session.completePayment({
|
|
@@ -1705,7 +1716,8 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1705
1716
|
trackWalletPaymentSuccess(skuId, result.basketId);
|
|
1706
1717
|
session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
1707
1718
|
const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
|
|
1708
|
-
const
|
|
1719
|
+
const isFreeTrialPopup = config.entryPoint === "free_trial_popup" /* FREE_TRIAL_POPUP */;
|
|
1720
|
+
const userStatus = isFreeTrialPopup && sessionData.loggedIn ? "nspc" : sessionData.loggedIn ? "lex" : "nex";
|
|
1709
1721
|
writeCheckoutRedirect(returnUrl);
|
|
1710
1722
|
window.location.href = redirectToCheckoutComplete({
|
|
1711
1723
|
basketId: result.basketId,
|
|
@@ -2009,17 +2021,6 @@ var isNativeButtonEnabled = (hostname = window.location.hostname, override, enab
|
|
|
2009
2021
|
// src/utils/applePayExpressEligibility.ts
|
|
2010
2022
|
var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
|
|
2011
2023
|
|
|
2012
|
-
// src/constants.ts
|
|
2013
|
-
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
2014
|
-
ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
|
|
2015
|
-
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
2016
|
-
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
2017
|
-
ApplePayEntryPoint2["FREE_TRIAL_BANNER"] = "free_trial_banner";
|
|
2018
|
-
ApplePayEntryPoint2["FREE_TRIAL_POPUP"] = "free_trial_popup";
|
|
2019
|
-
ApplePayEntryPoint2["SUBSCRIBE"] = "subscribe";
|
|
2020
|
-
return ApplePayEntryPoint2;
|
|
2021
|
-
})(ApplePayEntryPoint || {});
|
|
2022
|
-
|
|
2023
2024
|
// src/apple-pay-button.ts
|
|
2024
2025
|
var ENTRY_POINT_CONFIG = {
|
|
2025
2026
|
["dual_offer_banner" /* DUAL_OFFER_BANNER */]: {
|
|
@@ -2410,7 +2411,8 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2410
2411
|
currency: offer.price?.currency_code ?? DEFAULT_CURRENCY,
|
|
2411
2412
|
returnUrl: this.#checkoutRedirectUrl,
|
|
2412
2413
|
supportedBillingCountries: this.#supportedBillingCountries,
|
|
2413
|
-
recaptchaToken
|
|
2414
|
+
recaptchaToken,
|
|
2415
|
+
entryPoint: this.#entryPoint
|
|
2414
2416
|
});
|
|
2415
2417
|
}
|
|
2416
2418
|
};
|
|
@@ -58,11 +58,12 @@ export declare const decodeSku: (sku: string) => string;
|
|
|
58
58
|
* Always appended when non-empty to preserve geo-context across the redirect.
|
|
59
59
|
*
|
|
60
60
|
* The origin article URL is written to localStorage by the caller via
|
|
61
|
-
* writeCheckoutRedirect()
|
|
61
|
+
* writeCheckoutRedirect() so sma-checkout can return the reader after
|
|
62
|
+
* passwordless confirmation (`nspc`) or after onboarding.
|
|
62
63
|
*/
|
|
63
64
|
export declare const redirectToCheckoutComplete: (params: {
|
|
64
65
|
basketId: string;
|
|
65
|
-
status: "nex" | "lex";
|
|
66
|
+
status: "nex" | "lex" | "nspc";
|
|
66
67
|
skuId: string;
|
|
67
68
|
email?: string;
|
|
68
69
|
country?: string;
|