@economist/web-apple-pay 1.15.2 → 1.15.3-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 +3 -1
- package/dist/index.js +12 -13
- package/dist/src/apple-pay-button.js +1 -2
- package/dist/src/apple-pay-button.stories.js +1 -2
- package/dist/src/apple-pay-modal.stories.js +1 -2
- package/dist/src/clients/payment-checkout/payment-handler.d.ts +1 -1
- package/dist/src/clients/payment-checkout/payment-handler.js +1 -2
- package/dist/src/index.js +12 -13
- package/dist/src/utils/expressCheckoutRedirect.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,6 +20,8 @@ It is intentionally UI-focused. Consumer applications own backend payment orches
|
|
|
20
20
|
npm install --save @economist/web-apple-pay
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
Pre-release builds from the `beta` branch install as `@economist/web-apple-pay@beta`.
|
|
24
|
+
|
|
23
25
|
## Quick start
|
|
24
26
|
|
|
25
27
|
### 1) Configure runtime values
|
|
@@ -147,7 +149,7 @@ Consumers should listen for this event and continue payment orchestration.
|
|
|
147
149
|
- `createIfEnabled(offer, country, entryPoint?)`: returns a configured button or `null`.
|
|
148
150
|
- `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions — no homepage/Safari gate at `createIfEnabled` (device gating via `isApplePayAvailable` on mount).
|
|
149
151
|
- `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`.
|
|
152
|
+
- `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate. Wallet impression `entry_point` is `free_trial_popup`. Payment success uses the same complete statuses as other entry points (`lex` logged-in, `nex` anonymous). The origin URL is still written to `checkout-redirect` for sma-checkout.
|
|
151
153
|
- `SUBSCRIBE`: same always-on-after-exclusions gate for `/subscribe` (sma-checkout); no Amplitude. Wallet impression `entry_point` is `subscribe`.
|
|
152
154
|
- `PAYWALL`: always-on after offer exclusions + Safari/Apple placement eligibility. No Amplitude experiment / `$exposure`.
|
|
153
155
|
- `REGWALL`: inert — always returns `null`.
|
package/dist/index.js
CHANGED
|
@@ -1625,17 +1625,6 @@ 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
|
-
|
|
1639
1628
|
// src/clients/payment-checkout/payment-handler.ts
|
|
1640
1629
|
var failApplePaySession = (session, errors = []) => {
|
|
1641
1630
|
session.completePayment({
|
|
@@ -1716,8 +1705,7 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1716
1705
|
trackWalletPaymentSuccess(skuId, result.basketId);
|
|
1717
1706
|
session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
1718
1707
|
const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
|
|
1719
|
-
const
|
|
1720
|
-
const userStatus = isFreeTrialPopup && sessionData.loggedIn ? "nspc" : sessionData.loggedIn ? "lex" : "nex";
|
|
1708
|
+
const userStatus = sessionData.loggedIn ? "lex" : "nex";
|
|
1721
1709
|
writeCheckoutRedirect(returnUrl);
|
|
1722
1710
|
window.location.href = redirectToCheckoutComplete({
|
|
1723
1711
|
basketId: result.basketId,
|
|
@@ -2021,6 +2009,17 @@ var isNativeButtonEnabled = (hostname = window.location.hostname, override, enab
|
|
|
2021
2009
|
// src/utils/applePayExpressEligibility.ts
|
|
2022
2010
|
var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
|
|
2023
2011
|
|
|
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
|
+
|
|
2024
2023
|
// src/apple-pay-button.ts
|
|
2025
2024
|
var ENTRY_POINT_CONFIG = {
|
|
2026
2025
|
["dual_offer_banner" /* DUAL_OFFER_BANNER */]: {
|
|
@@ -1700,8 +1700,7 @@ 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
|
|
1704
|
-
const userStatus = isFreeTrialPopup && sessionData.loggedIn ? "nspc" : sessionData.loggedIn ? "lex" : "nex";
|
|
1703
|
+
const userStatus = sessionData.loggedIn ? "lex" : "nex";
|
|
1705
1704
|
writeCheckoutRedirect(returnUrl);
|
|
1706
1705
|
window.location.href = redirectToCheckoutComplete({
|
|
1707
1706
|
basketId: result.basketId,
|
|
@@ -1708,8 +1708,7 @@ 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
|
|
1712
|
-
const userStatus = isFreeTrialPopup && sessionData.loggedIn ? "nspc" : sessionData.loggedIn ? "lex" : "nex";
|
|
1711
|
+
const userStatus = sessionData.loggedIn ? "lex" : "nex";
|
|
1713
1712
|
writeCheckoutRedirect(returnUrl);
|
|
1714
1713
|
window.location.href = redirectToCheckoutComplete({
|
|
1715
1714
|
basketId: result.basketId,
|
|
@@ -1700,8 +1700,7 @@ 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
|
|
1704
|
-
const userStatus = isFreeTrialPopup && sessionData.loggedIn ? "nspc" : sessionData.loggedIn ? "lex" : "nex";
|
|
1703
|
+
const userStatus = sessionData.loggedIn ? "lex" : "nex";
|
|
1705
1704
|
writeCheckoutRedirect(returnUrl);
|
|
1706
1705
|
window.location.href = redirectToCheckoutComplete({
|
|
1707
1706
|
basketId: result.basketId,
|
|
@@ -23,7 +23,7 @@ export type PaymentHandlerConfig = {
|
|
|
23
23
|
returnUrl: string | null;
|
|
24
24
|
supportedBillingCountries: string[];
|
|
25
25
|
recaptchaToken: string;
|
|
26
|
-
/**
|
|
26
|
+
/** Host entry point. Complete status is `lex` / `nex` from the session, not from this. */
|
|
27
27
|
entryPoint?: ApplePayEntryPoint | '';
|
|
28
28
|
};
|
|
29
29
|
export declare function handlePaymentAuthorized(event: ApplePayJS.ApplePayPaymentAuthorizedEvent, session: ApplePaySession, sessionData: SessionResponse, config: PaymentHandlerConfig): Promise<void>;
|
|
@@ -364,8 +364,7 @@ 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
|
|
368
|
-
const userStatus = isFreeTrialPopup && sessionData.loggedIn ? "nspc" : sessionData.loggedIn ? "lex" : "nex";
|
|
367
|
+
const userStatus = sessionData.loggedIn ? "lex" : "nex";
|
|
369
368
|
writeCheckoutRedirect(returnUrl);
|
|
370
369
|
window.location.href = redirectToCheckoutComplete({
|
|
371
370
|
basketId: result.basketId,
|
package/dist/src/index.js
CHANGED
|
@@ -1625,17 +1625,6 @@ 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
|
-
|
|
1639
1628
|
// src/clients/payment-checkout/payment-handler.ts
|
|
1640
1629
|
var failApplePaySession = (session, errors = []) => {
|
|
1641
1630
|
session.completePayment({
|
|
@@ -1716,8 +1705,7 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1716
1705
|
trackWalletPaymentSuccess(skuId, result.basketId);
|
|
1717
1706
|
session.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
1718
1707
|
const successEmail = sessionData.loggedIn ? sessionData.emailAddress : validatedEmail;
|
|
1719
|
-
const
|
|
1720
|
-
const userStatus = isFreeTrialPopup && sessionData.loggedIn ? "nspc" : sessionData.loggedIn ? "lex" : "nex";
|
|
1708
|
+
const userStatus = sessionData.loggedIn ? "lex" : "nex";
|
|
1721
1709
|
writeCheckoutRedirect(returnUrl);
|
|
1722
1710
|
window.location.href = redirectToCheckoutComplete({
|
|
1723
1711
|
basketId: result.basketId,
|
|
@@ -2021,6 +2009,17 @@ var isNativeButtonEnabled = (hostname = window.location.hostname, override, enab
|
|
|
2021
2009
|
// src/utils/applePayExpressEligibility.ts
|
|
2022
2010
|
var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
|
|
2023
2011
|
|
|
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
|
+
|
|
2024
2023
|
// src/apple-pay-button.ts
|
|
2025
2024
|
var ENTRY_POINT_CONFIG = {
|
|
2026
2025
|
["dual_offer_banner" /* DUAL_OFFER_BANNER */]: {
|
|
@@ -59,11 +59,11 @@ export declare const decodeSku: (sku: string) => string;
|
|
|
59
59
|
*
|
|
60
60
|
* The origin article URL is written to localStorage by the caller via
|
|
61
61
|
* writeCheckoutRedirect() so sma-checkout can return the reader after
|
|
62
|
-
* passwordless confirmation
|
|
62
|
+
* passwordless confirmation or after onboarding.
|
|
63
63
|
*/
|
|
64
64
|
export declare const redirectToCheckoutComplete: (params: {
|
|
65
65
|
basketId: string;
|
|
66
|
-
status: "nex" | "lex"
|
|
66
|
+
status: "nex" | "lex";
|
|
67
67
|
skuId: string;
|
|
68
68
|
email?: string;
|
|
69
69
|
country?: string;
|
package/package.json
CHANGED