@economist/web-apple-pay 1.16.0-beta.1 → 1.16.0

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.
Files changed (30) hide show
  1. package/README.md +8 -15
  2. package/dist/index.js +154 -136
  3. package/dist/src/apple-pay-button.js +154 -136
  4. package/dist/src/apple-pay-button.stories.js +154 -136
  5. package/dist/src/apple-pay-modal.stories.js +154 -136
  6. package/dist/src/clients/payment-checkout/apple-session.d.ts +3 -1
  7. package/dist/src/clients/payment-checkout/apple-session.js +19 -9
  8. package/dist/src/clients/payment-checkout/billing-contact-details.js +1 -6
  9. package/dist/src/clients/payment-checkout/delivery-contact-details.js +6 -4
  10. package/dist/src/clients/payment-checkout/detects.js +3 -3
  11. package/dist/src/clients/payment-checkout/payment-handler.js +79 -42
  12. package/dist/src/clients/payment-checkout/types.d.ts +1 -1
  13. package/dist/src/index.js +154 -136
  14. package/dist/src/utils/address-rules.d.ts +6 -0
  15. package/dist/src/utils/address-rules.js +6 -4
  16. package/dist/src/utils/billing-countries.js +46 -37
  17. package/dist/src/utils/delivery-countries.js +39 -38
  18. package/dist/src/utils/expressCheckoutTracking.d.ts +13 -5
  19. package/dist/src/utils/expressCheckoutTracking.js +22 -10
  20. package/dist/src/utils/price-zones.d.ts +7 -0
  21. package/dist/src/utils/price-zones.js +212 -0
  22. package/dist/src/utils/print-variants.d.ts +5 -0
  23. package/dist/src/utils/print-variants.js +10 -0
  24. package/dist/src/utils/printOffersFlag.d.ts +3 -3
  25. package/dist/src/utils/printOffersFlag.js +1 -1
  26. package/package.json +1 -1
  27. package/dist/src/utils/addressParityFlag.d.ts +0 -13
  28. package/dist/src/utils/addressParityFlag.js +0 -5
  29. package/dist/src/utils/buttonCopyFlag.d.ts +0 -22
  30. package/dist/src/utils/buttonCopyFlag.js +0 -12
package/README.md CHANGED
@@ -132,26 +132,17 @@ Consumers should listen for this event and continue payment orchestration.
132
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
133
  - `PAYWALL`: always-on after offer exclusions + Safari/Apple placement eligibility. No Amplitude experiment / `$exposure`.
134
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:
135
+ - **Analytics.** The entry point is sent as `entry_point` on every TEDL funnel event: `express_wallet_impression`, `express_wallet_click`, `wallet_payment_sheet_open`, `wallet_payment_authorised`, `wallet_payment_success`, `wallet_payment_failure` and `fallback_checkout`. It is left out when the host does not set one. The per-field `validation_*` events do not carry it.
136
+ - **Print offers (`bundle`, `insider_print`) — behind a flag, off by default.** `PRINT_OFFERS_ENABLED` (compiled into the release, ships `false`): `false` excludes print on every entry point; `true` enables 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
137
  - 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
138
  - 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.
139
+ - sends `supportedDeliveryCountries` and the shipping contact to `/v1/wallet/purchase` (with the phone number as normalised by the validator, e.g. `098765 43210` for IN becomes `+919876543210`; one that cannot be normalised is left out), which re-validates and forwards the delivery address to Commerce Services. **Release order:** deploy the wallet-payments-api change before releasing with the flag `true`;
140
+ - reports billing and delivery field errors together, so the sheet shows every bad field at once.
141
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.
142
+ - **Return after purchase.** Banners, popup, paywall and regwall return the user to the page the button is on. `SUBSCRIBE` and `SALES_PAGE` leave the return target to the host (sma-checkout keeps the article the user arrived from).
147
143
  - `ApplePayModal`: modal component class.
148
144
  - `Offer`: offer contract type used by component props.
149
145
 
150
- ### Breaking changes
151
-
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.
154
-
155
146
  ## Troubleshooting
156
147
 
157
148
  ### Button does not appear
@@ -162,7 +153,7 @@ Check:
162
153
  - device/browser supports Apple Pay (Safari on Apple device required — enforced by `isApplePayAvailable` on mount)
163
154
  - for paywalls: Safari/Apple placement eligibility (or `?BYPASS_APPLE_PAY_CHECKS=1` for QA)
164
155
  - for banners / `FREE_TRIAL_POPUP`: consumer kill switch off (no homepage/Safari gate at `createIfEnabled`)
165
- - offer variant is not excluded (`bundle`, `insider_print`)
156
+ - offer variant is not excluded (`bundle`, `insider_print`; print is excluded everywhere while `PRINT_OFFERS_ENABLED` is `false`)
166
157
 
167
158
  ### Logged-in checkbox copy looks wrong
168
159
 
@@ -212,3 +203,5 @@ Story coverage matrix:
212
203
  - `ApplePayButton` behavior and state variants are available as individual canvas stories in Storybook.
213
204
  - `ApplePayModal` docs page shows the stable default example.
214
205
  - `ApplePayModal` behavior and state variants are available as individual canvas stories in Storybook.
206
+
207
+ Print offers ship disabled (`PRINT_OFFERS_ENABLED` is `false`); see the Public API section above.