@economist/web-apple-pay 1.15.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 +2 -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`.
|
|
@@ -220,3 +220,4 @@ Story coverage matrix:
|
|
|
220
220
|
- `ApplePayButton` behavior and state variants are available as individual canvas stories in Storybook.
|
|
221
221
|
- `ApplePayModal` docs page shows the stable default example.
|
|
222
222
|
- `ApplePayModal` behavior and state variants are available as individual canvas stories in Storybook.
|
|
223
|
+
|
package/dist/index.js
CHANGED
|
@@ -1611,6 +1611,17 @@ var shippingContactDetails = (shippingContact) => {
|
|
|
1611
1611
|
return { emailAddress };
|
|
1612
1612
|
};
|
|
1613
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
|
+
|
|
1614
1625
|
// src/clients/payment-checkout/payment-handler.ts
|
|
1615
1626
|
var failApplePaySession = (session, errors = []) => {
|
|
1616
1627
|
session.completePayment({
|
|
@@ -1691,7 +1702,8 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1691
1702
|
trackWalletPaymentSuccess(skuId, result.basketId);
|
|
1692
1703
|
session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
1693
1704
|
const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
|
|
1694
|
-
const
|
|
1705
|
+
const isFreeTrialPopup = config.entryPoint === "free_trial_popup" /* FREE_TRIAL_POPUP */;
|
|
1706
|
+
const userStatus = isFreeTrialPopup && sessionData.loggedIn ? "nspc" : sessionData.loggedIn ? "lex" : "nex";
|
|
1695
1707
|
writeCheckoutRedirect(returnUrl);
|
|
1696
1708
|
window.location.href = redirectToCheckoutComplete({
|
|
1697
1709
|
basketId: result.basketId,
|
|
@@ -1995,17 +2007,6 @@ var isNativeButtonEnabled = (hostname = window.location.hostname, override, enab
|
|
|
1995
2007
|
// src/utils/applePayExpressEligibility.ts
|
|
1996
2008
|
var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
|
|
1997
2009
|
|
|
1998
|
-
// src/constants.ts
|
|
1999
|
-
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
2000
|
-
ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
|
|
2001
|
-
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
2002
|
-
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
2003
|
-
ApplePayEntryPoint2["FREE_TRIAL_BANNER"] = "free_trial_banner";
|
|
2004
|
-
ApplePayEntryPoint2["FREE_TRIAL_POPUP"] = "free_trial_popup";
|
|
2005
|
-
ApplePayEntryPoint2["SUBSCRIBE"] = "subscribe";
|
|
2006
|
-
return ApplePayEntryPoint2;
|
|
2007
|
-
})(ApplePayEntryPoint || {});
|
|
2008
|
-
|
|
2009
2010
|
// src/apple-pay-button.ts
|
|
2010
2011
|
var ENTRY_POINT_CONFIG = {
|
|
2011
2012
|
["dual_offer_banner" /* DUAL_OFFER_BANNER */]: {
|
|
@@ -2379,7 +2380,8 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2379
2380
|
currency: offer.price?.currency_code ?? DEFAULT_CURRENCY,
|
|
2380
2381
|
returnUrl: this.#returnUrl,
|
|
2381
2382
|
supportedBillingCountries: this.#supportedBillingCountries,
|
|
2382
|
-
recaptchaToken
|
|
2383
|
+
recaptchaToken,
|
|
2384
|
+
entryPoint: this.#entryPoint
|
|
2383
2385
|
});
|
|
2384
2386
|
}
|
|
2385
2387
|
};
|
|
@@ -1686,7 +1686,8 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1686
1686
|
trackWalletPaymentSuccess(skuId, result.basketId);
|
|
1687
1687
|
session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
1688
1688
|
const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
|
|
1689
|
-
const
|
|
1689
|
+
const isFreeTrialPopup = config.entryPoint === "free_trial_popup" /* FREE_TRIAL_POPUP */;
|
|
1690
|
+
const userStatus = isFreeTrialPopup && sessionData.loggedIn ? "nspc" : sessionData.loggedIn ? "lex" : "nex";
|
|
1690
1691
|
writeCheckoutRedirect(returnUrl);
|
|
1691
1692
|
window.location.href = redirectToCheckoutComplete({
|
|
1692
1693
|
basketId: result.basketId,
|
|
@@ -2363,7 +2364,8 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2363
2364
|
currency: offer.price?.currency_code ?? DEFAULT_CURRENCY,
|
|
2364
2365
|
returnUrl: this.#returnUrl,
|
|
2365
2366
|
supportedBillingCountries: this.#supportedBillingCountries,
|
|
2366
|
-
recaptchaToken
|
|
2367
|
+
recaptchaToken,
|
|
2368
|
+
entryPoint: this.#entryPoint
|
|
2367
2369
|
});
|
|
2368
2370
|
}
|
|
2369
2371
|
};
|
|
@@ -1694,7 +1694,8 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1694
1694
|
trackWalletPaymentSuccess(skuId, result.basketId);
|
|
1695
1695
|
session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
1696
1696
|
const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
|
|
1697
|
-
const
|
|
1697
|
+
const isFreeTrialPopup = config.entryPoint === "free_trial_popup" /* FREE_TRIAL_POPUP */;
|
|
1698
|
+
const userStatus = isFreeTrialPopup && sessionData.loggedIn ? "nspc" : sessionData.loggedIn ? "lex" : "nex";
|
|
1698
1699
|
writeCheckoutRedirect(returnUrl);
|
|
1699
1700
|
window.location.href = redirectToCheckoutComplete({
|
|
1700
1701
|
basketId: result.basketId,
|
|
@@ -2371,7 +2372,8 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2371
2372
|
currency: offer.price?.currency_code ?? DEFAULT_CURRENCY,
|
|
2372
2373
|
returnUrl: this.#returnUrl,
|
|
2373
2374
|
supportedBillingCountries: this.#supportedBillingCountries,
|
|
2374
|
-
recaptchaToken
|
|
2375
|
+
recaptchaToken,
|
|
2376
|
+
entryPoint: this.#entryPoint
|
|
2375
2377
|
});
|
|
2376
2378
|
}
|
|
2377
2379
|
};
|
|
@@ -1686,7 +1686,8 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1686
1686
|
trackWalletPaymentSuccess(skuId, result.basketId);
|
|
1687
1687
|
session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
1688
1688
|
const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
|
|
1689
|
-
const
|
|
1689
|
+
const isFreeTrialPopup = config.entryPoint === "free_trial_popup" /* FREE_TRIAL_POPUP */;
|
|
1690
|
+
const userStatus = isFreeTrialPopup && sessionData.loggedIn ? "nspc" : sessionData.loggedIn ? "lex" : "nex";
|
|
1690
1691
|
writeCheckoutRedirect(returnUrl);
|
|
1691
1692
|
window.location.href = redirectToCheckoutComplete({
|
|
1692
1693
|
basketId: result.basketId,
|
|
@@ -2363,7 +2364,8 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2363
2364
|
currency: offer.price?.currency_code ?? DEFAULT_CURRENCY,
|
|
2364
2365
|
returnUrl: this.#returnUrl,
|
|
2365
2366
|
supportedBillingCountries: this.#supportedBillingCountries,
|
|
2366
|
-
recaptchaToken
|
|
2367
|
+
recaptchaToken,
|
|
2368
|
+
entryPoint: this.#entryPoint
|
|
2367
2369
|
});
|
|
2368
2370
|
}
|
|
2369
2371
|
};
|
|
@@ -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
|
@@ -1611,6 +1611,17 @@ var shippingContactDetails = (shippingContact) => {
|
|
|
1611
1611
|
return { emailAddress };
|
|
1612
1612
|
};
|
|
1613
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
|
+
|
|
1614
1625
|
// src/clients/payment-checkout/payment-handler.ts
|
|
1615
1626
|
var failApplePaySession = (session, errors = []) => {
|
|
1616
1627
|
session.completePayment({
|
|
@@ -1691,7 +1702,8 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1691
1702
|
trackWalletPaymentSuccess(skuId, result.basketId);
|
|
1692
1703
|
session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
1693
1704
|
const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
|
|
1694
|
-
const
|
|
1705
|
+
const isFreeTrialPopup = config.entryPoint === "free_trial_popup" /* FREE_TRIAL_POPUP */;
|
|
1706
|
+
const userStatus = isFreeTrialPopup && sessionData.loggedIn ? "nspc" : sessionData.loggedIn ? "lex" : "nex";
|
|
1695
1707
|
writeCheckoutRedirect(returnUrl);
|
|
1696
1708
|
window.location.href = redirectToCheckoutComplete({
|
|
1697
1709
|
basketId: result.basketId,
|
|
@@ -1995,17 +2007,6 @@ var isNativeButtonEnabled = (hostname = window.location.hostname, override, enab
|
|
|
1995
2007
|
// src/utils/applePayExpressEligibility.ts
|
|
1996
2008
|
var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
|
|
1997
2009
|
|
|
1998
|
-
// src/constants.ts
|
|
1999
|
-
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
2000
|
-
ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
|
|
2001
|
-
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
2002
|
-
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
2003
|
-
ApplePayEntryPoint2["FREE_TRIAL_BANNER"] = "free_trial_banner";
|
|
2004
|
-
ApplePayEntryPoint2["FREE_TRIAL_POPUP"] = "free_trial_popup";
|
|
2005
|
-
ApplePayEntryPoint2["SUBSCRIBE"] = "subscribe";
|
|
2006
|
-
return ApplePayEntryPoint2;
|
|
2007
|
-
})(ApplePayEntryPoint || {});
|
|
2008
|
-
|
|
2009
2010
|
// src/apple-pay-button.ts
|
|
2010
2011
|
var ENTRY_POINT_CONFIG = {
|
|
2011
2012
|
["dual_offer_banner" /* DUAL_OFFER_BANNER */]: {
|
|
@@ -2379,7 +2380,8 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2379
2380
|
currency: offer.price?.currency_code ?? DEFAULT_CURRENCY,
|
|
2380
2381
|
returnUrl: this.#returnUrl,
|
|
2381
2382
|
supportedBillingCountries: this.#supportedBillingCountries,
|
|
2382
|
-
recaptchaToken
|
|
2383
|
+
recaptchaToken,
|
|
2384
|
+
entryPoint: this.#entryPoint
|
|
2383
2385
|
});
|
|
2384
2386
|
}
|
|
2385
2387
|
};
|
|
@@ -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;
|
package/package.json
CHANGED