@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/README.md
CHANGED
|
@@ -78,7 +78,7 @@ 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
84
|
#### Awaiting render completion — `whenReady()`
|
|
@@ -125,18 +125,32 @@ Consumers should listen for this event and continue payment orchestration.
|
|
|
125
125
|
- `ApplePayButton`: button component class.
|
|
126
126
|
- `whenReady(): Promise<void>` — resolves when the current render lifecycle completes (available or hidden). Resolves immediately if called before the element is connected.
|
|
127
127
|
- `createIfEnabled(offer, country, entryPoint?)`: returns a configured button or `null`.
|
|
128
|
-
- `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions — no homepage/Safari gate at `createIfEnabled` (device gating via `isApplePayAvailable` on mount)
|
|
128
|
+
- `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions — no homepage/Safari gate at `createIfEnabled` (device gating via `isApplePayAvailable` on mount).
|
|
129
129
|
- `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; wallet impression `entry_point` is `free_trial_banner`.
|
|
130
|
-
- `
|
|
130
|
+
- `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.
|
|
131
|
+
- `SUBSCRIBE`: same always-on-after-exclusions gate for `/subscribe` (sma-checkout); no Amplitude. Wallet impression `entry_point` is `subscribe`.
|
|
132
|
+
- `SALES_PAGE`: same always-on-after-exclusions gate for sma-checkout sales pages (Black Friday and other promotions); no Amplitude. Host-managed return URL like `SUBSCRIBE`; print offers excluded. Wallet impression `entry_point` is `sales_page`.
|
|
133
|
+
- `PAYWALL`: always-on after offer exclusions + Safari/Apple placement eligibility. No Amplitude experiment / `$exposure`.
|
|
131
134
|
- `REGWALL`: inert — always returns `null`.
|
|
135
|
+
- **Address parity — behind a flag.** `ADDRESS_PARITY_ENABLED` (`src/utils/addressParityFlag.ts`) ships `false`. When `true`, billing names/addresses must be Latin characters plus the approved diacritics (SMA-3066; the sheet shows "Please use Latin characters only.") and the purchase carries `strictAddressRules`, so the wallet-payments-api also truncates billing lines to the Commerce limits and maps Puerto Rico to US. Print delivery details are always held to these rules. Deploy the wallet-payments-api change first.
|
|
136
|
+
- **Button wording — behind a flag.** `CONTINUE_WITH_COPY_ENABLED` (`src/utils/buttonCopyFlag.ts`) ships `false`: the button reads "Subscribe with Apple Pay" on every surface, as before. Flip it to `true` in a release for "Continue with Apple Pay" (caption and accessible name).
|
|
137
|
+
- **Print offers (`bundle`, `insider_print`) — behind a flag.** `PRINT_OFFERS_ENABLED` (`src/utils/printOffersFlag.ts`) ships `false`: every entry point excludes print exactly as before, so releasing and bumping the package changes nothing. Flip it to `true` in a release to enable the feature. Even then, only entry points with `allowsPrintOffers: true` in `ENTRY_POINT_CONFIG` (`src/apple-pay-button.ts`) take print — currently only `SUBSCRIBE`; banners, popup, paywall and regwall never do. Hosts that update `button.offer` in place should use `getExcludedVariants(entryPoint)` (it honours the flag) instead of the deprecated `APPLE_PAY_EXCLUDED_VARIANTS`. For an allowed print offer the sheet additionally collects the delivery address, name and phone and:
|
|
138
|
+
- limits delivery to the offer's price zone minus the countries print cannot be delivered to (`src/data/no-delivery-countries.json`); an offer with no deliverable country hides the button;
|
|
139
|
+
- validates the address with the sma-checkout delivery-form rules (required fields by zone, Commerce Services length limits, US zip / Canadian postcode formats, phone required for IN and CN) and keeps the sheet open with field-level errors (`delivery-contact-details.ts`, rules in `utils/address-rules.ts`);
|
|
140
|
+
- sends `supportedDeliveryCountries` and the shipping contact to `/v1/wallet/purchase`, which re-validates and forwards the delivery address to Commerce Services. **Release order:** deploy the wallet-payments-api change before flipping the flag.
|
|
141
|
+
- Names and addresses must be Latin characters plus the approved diacritics for every purchase (SMA-3066), the same as sma-checkout; non-Latin input shows "Please use Latin characters only." in the sheet.
|
|
142
|
+
The address rules, zones and no-delivery list are copies of sma-checkout's; keep them in sync.
|
|
143
|
+
- **Where the user returns after purchase.** Each entry point sets a `ReturnUrlPolicy` in `ENTRY_POINT_CONFIG` (`src/apple-pay-button.ts`), which decides what is written to `localStorage['checkout-redirect']` (read by the onboarding app):
|
|
144
|
+
- `CURRENT_PAGE`: the page the button is on (banners, popup, paywall, regwall), e.g. back to the article.
|
|
145
|
+
- `HOST_MANAGED`: nothing is written, so the host's own value is kept (`SUBSCRIBE`: sma-checkout stores the article the user arrived from; with none stored, onboarding returns them to the home page).
|
|
146
|
+
- A new entry point must declare its policy, or it will not compile.
|
|
132
147
|
- `ApplePayModal`: modal component class.
|
|
133
|
-
- `ensureApplePayLogoSymbol()`: logo symbol injection helper.
|
|
134
|
-
- `APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY`: Amplitude flag key for paywalls experiment gating / `$exposure`.
|
|
135
148
|
- `Offer`: offer contract type used by component props.
|
|
136
149
|
|
|
137
150
|
### Breaking changes
|
|
138
151
|
|
|
139
|
-
- `
|
|
152
|
+
- `APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY`, `APPLE_PAY_EXPRESS_VARIANTS`, and `ApplePayExperimentFlagKey` are no longer exported. Paywalls are always-on after Safari/offer checks; drop those imports.
|
|
153
|
+
- `APPLE_PAY_EXPRESS_EXPERIMENT_KEY` (retired banners experiment flag) remains unpublished.
|
|
140
154
|
|
|
141
155
|
## Troubleshooting
|
|
142
156
|
|
|
@@ -146,8 +160,8 @@ Check:
|
|
|
146
160
|
|
|
147
161
|
- `configureApplePay(...)` was called before rendering (with a valid `merchantId` and `walletApiBaseUrl`)
|
|
148
162
|
- device/browser supports Apple Pay (Safari on Apple device required — enforced by `isApplePayAvailable` on mount)
|
|
149
|
-
- for paywalls:
|
|
150
|
-
- for banners
|
|
163
|
+
- for paywalls: Safari/Apple placement eligibility (or `?BYPASS_APPLE_PAY_CHECKS=1` for QA)
|
|
164
|
+
- for banners / `FREE_TRIAL_POPUP`: consumer kill switch off (no homepage/Safari gate at `createIfEnabled`)
|
|
151
165
|
- offer variant is not excluded (`bundle`, `insider_print`)
|
|
152
166
|
|
|
153
167
|
### Logged-in checkbox copy looks wrong
|
|
@@ -198,3 +212,7 @@ Story coverage matrix:
|
|
|
198
212
|
- `ApplePayButton` behavior and state variants are available as individual canvas stories in Storybook.
|
|
199
213
|
- `ApplePayModal` docs page shows the stable default example.
|
|
200
214
|
- `ApplePayModal` behavior and state variants are available as individual canvas stories in Storybook.
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|