@economist/web-apple-pay 1.15.3-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.
- package/README.md +13 -34
- package/dist/index.js +615 -314
- package/dist/src/apple-pay-button.d.ts +10 -0
- package/dist/src/apple-pay-button.js +604 -303
- package/dist/src/apple-pay-button.stories.js +601 -302
- package/dist/src/apple-pay-modal.js +24 -30
- package/dist/src/apple-pay-modal.stories.js +601 -302
- package/dist/src/clients/payment-checkout/apple-session.d.ts +15 -1
- package/dist/src/clients/payment-checkout/apple-session.js +47 -11
- package/dist/src/clients/payment-checkout/billing-contact-details.js +38 -0
- package/dist/src/clients/payment-checkout/config.d.ts +0 -5
- package/dist/src/clients/payment-checkout/delivery-contact-details.d.ts +16 -0
- package/dist/src/clients/payment-checkout/delivery-contact-details.js +397 -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 +9 -1
- package/dist/src/clients/payment-checkout/payment-handler.js +459 -28
- 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 +3 -1
- package/dist/src/constants.js +1 -0
- package/dist/src/index.d.ts +1 -2
- package/dist/src/index.js +615 -314
- package/dist/src/utils/address-rules.d.ts +29 -0
- package/dist/src/utils/address-rules.js +260 -0
- package/dist/src/utils/billing-countries.js +46 -37
- package/dist/src/utils/delivery-countries.d.ts +9 -0
- package/dist/src/utils/delivery-countries.js +256 -0
- package/dist/src/utils/expressCheckoutRedirect.d.ts +2 -2
- package/dist/src/utils/expressCheckoutTracking.d.ts +13 -5
- package/dist/src/utils/expressCheckoutTracking.js +22 -10
- package/dist/src/utils/latin-characters.d.ts +3 -0
- package/dist/src/utils/latin-characters.js +10 -0
- package/dist/src/utils/price-zones.d.ts +7 -0
- package/dist/src/utils/price-zones.js +212 -0
- package/dist/src/utils/print-variants.d.ts +5 -0
- package/dist/src/utils/print-variants.js +10 -0
- package/dist/src/utils/printOffersFlag.d.ts +11 -0
- package/dist/src/utils/printOffersFlag.js +5 -0
- 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/utils/nativeButtonFlag.d.ts +0 -12
- package/dist/src/utils/nativeButtonFlag.js +0 -18
package/README.md
CHANGED
|
@@ -20,8 +20,6 @@ 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
|
-
|
|
25
23
|
## Quick start
|
|
26
24
|
|
|
27
25
|
### 1) Configure runtime values
|
|
@@ -83,26 +81,6 @@ If `merchantId` is not configured, Apple Pay availability checks return `false`
|
|
|
83
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.
|
|
84
82
|
- Forwards `data-logged-in` from button to modal (`modal.dataset.loggedIn`).
|
|
85
83
|
|
|
86
|
-
#### Native Apple Pay button
|
|
87
|
-
|
|
88
|
-
**Feature flag:** it is on for `localhost`, `dev.*` and `stage.*`, and **off in production** until
|
|
89
|
-
`NATIVE_BUTTON_ENABLED_IN_PRODUCTION` (`src/utils/nativeButtonFlag.ts`) is flipped to `true` in a release. It fails
|
|
90
|
-
closed: any other host (www.economist.com, previews, IPs) keeps the custom button. A host can force it either way
|
|
91
|
-
with `configureApplePay({ ..., nativeButton: true | false })`. The flag sets a `data-native-button` attribute on
|
|
92
|
-
`teg-apple-pay-button`, and the native CSS only applies when that attribute is present.
|
|
93
|
-
|
|
94
|
-
Once loading finishes, the button uses Apple's **native CSS button** (`-webkit-appearance: -apple-pay-button`)
|
|
95
|
-
wherever the browser supports it (Safari / iOS). Safari draws Apple's own artwork, so it follows Apple's design
|
|
96
|
-
guidelines, and because it is built into WebKit there is **no SDK script and no extra request** (safe for walls and
|
|
97
|
-
banners). Other browsers, and the loading spinner state, use the package's custom button as the fallback.
|
|
98
|
-
|
|
99
|
-
- Apple controls colour and wording: `--apple-pay-background-color`, `--apple-pay-foreground-color` and the
|
|
100
|
-
"Subscribe with" caption/logo do not apply to the native button.
|
|
101
|
-
- Optional overrides: `--apple-pay-button-type` (`plain`, `buy`, `subscribe`, `check-out`, ...; default `subscribe`)
|
|
102
|
-
and `--apple-pay-button-style` (`black`, `white`, `white-outline`; default `black`).
|
|
103
|
-
- Size and radius still follow `--apple-pay-height` and `--apple-pay-border-radius`.
|
|
104
|
-
- jsdom cannot render this, so tests assert the template contract. Verify visually in Safari.
|
|
105
|
-
|
|
106
84
|
#### Awaiting render completion — `whenReady()`
|
|
107
85
|
|
|
108
86
|
Use `whenReady()` to await the component's render lifecycle after appending it
|
|
@@ -149,23 +127,22 @@ Consumers should listen for this event and continue payment orchestration.
|
|
|
149
127
|
- `createIfEnabled(offer, country, entryPoint?)`: returns a configured button or `null`.
|
|
150
128
|
- `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions — no homepage/Safari gate at `createIfEnabled` (device gating via `isApplePayAvailable` on mount).
|
|
151
129
|
- `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; wallet impression `entry_point` is `free_trial_banner`.
|
|
152
|
-
- `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate. Wallet impression `entry_point` is `free_trial_popup`.
|
|
130
|
+
- `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.
|
|
153
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`.
|
|
154
133
|
- `PAYWALL`: always-on after offer exclusions + Safari/Apple placement eligibility. No Amplitude experiment / `$exposure`.
|
|
155
134
|
- `REGWALL`: inert — always returns `null`.
|
|
156
|
-
- **
|
|
157
|
-
|
|
158
|
-
-
|
|
159
|
-
-
|
|
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:
|
|
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;
|
|
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`);
|
|
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
|
+
- 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
|
+
- **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).
|
|
160
143
|
- `ApplePayModal`: modal component class.
|
|
161
|
-
- `ensureApplePayLogoSymbol()`: logo symbol injection helper.
|
|
162
144
|
- `Offer`: offer contract type used by component props.
|
|
163
145
|
|
|
164
|
-
### Breaking changes
|
|
165
|
-
|
|
166
|
-
- `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.
|
|
167
|
-
- `APPLE_PAY_EXPRESS_EXPERIMENT_KEY` (retired banners experiment flag) remains unpublished.
|
|
168
|
-
|
|
169
146
|
## Troubleshooting
|
|
170
147
|
|
|
171
148
|
### Button does not appear
|
|
@@ -176,7 +153,7 @@ Check:
|
|
|
176
153
|
- device/browser supports Apple Pay (Safari on Apple device required — enforced by `isApplePayAvailable` on mount)
|
|
177
154
|
- for paywalls: Safari/Apple placement eligibility (or `?BYPASS_APPLE_PAY_CHECKS=1` for QA)
|
|
178
155
|
- for banners / `FREE_TRIAL_POPUP`: consumer kill switch off (no homepage/Safari gate at `createIfEnabled`)
|
|
179
|
-
- 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`)
|
|
180
157
|
|
|
181
158
|
### Logged-in checkbox copy looks wrong
|
|
182
159
|
|
|
@@ -226,3 +203,5 @@ Story coverage matrix:
|
|
|
226
203
|
- `ApplePayButton` behavior and state variants are available as individual canvas stories in Storybook.
|
|
227
204
|
- `ApplePayModal` docs page shows the stable default example.
|
|
228
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.
|