@economist/web-apple-pay 2.0.0-beta.1 → 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.
Files changed (51) hide show
  1. package/README.md +34 -12
  2. package/dist/index.js +661 -351
  3. package/dist/src/apple-pay-button.d.ts +21 -14
  4. package/dist/src/apple-pay-button.js +650 -343
  5. package/dist/src/apple-pay-button.stories.js +647 -342
  6. package/dist/src/apple-pay-modal.js +44 -39
  7. package/dist/src/apple-pay-modal.stories.js +647 -342
  8. package/dist/src/clients/payment-checkout/apple-session.d.ts +14 -1
  9. package/dist/src/clients/payment-checkout/apple-session.js +46 -11
  10. package/dist/src/clients/payment-checkout/billing-contact-details.js +43 -0
  11. package/dist/src/clients/payment-checkout/delivery-contact-details.d.ts +16 -0
  12. package/dist/src/clients/payment-checkout/delivery-contact-details.js +395 -0
  13. package/dist/src/clients/payment-checkout/detects.d.ts +5 -0
  14. package/dist/src/clients/payment-checkout/detects.js +18 -14
  15. package/dist/src/clients/payment-checkout/messages.d.ts +6 -0
  16. package/dist/src/clients/payment-checkout/messages.js +7 -1
  17. package/dist/src/clients/payment-checkout/payment-handler.d.ts +10 -1
  18. package/dist/src/clients/payment-checkout/payment-handler.js +397 -30
  19. package/dist/src/clients/payment-checkout/session.js +13 -1
  20. package/dist/src/clients/payment-checkout/types.d.ts +7 -0
  21. package/dist/src/constants.d.ts +8 -28
  22. package/dist/src/constants.js +4 -7
  23. package/dist/src/index.d.ts +2 -4
  24. package/dist/src/index.js +661 -351
  25. package/dist/src/types/offer.types.d.ts +1 -1
  26. package/dist/src/utils/address-rules.d.ts +23 -0
  27. package/dist/src/utils/address-rules.js +258 -0
  28. package/dist/src/utils/addressParityFlag.d.ts +13 -0
  29. package/dist/src/utils/addressParityFlag.js +5 -0
  30. package/dist/src/utils/applePayExpressEligibility.d.ts +7 -9
  31. package/dist/src/utils/applePayExpressEligibility.js +2 -2
  32. package/dist/src/utils/buttonCopyFlag.d.ts +22 -0
  33. package/dist/src/utils/buttonCopyFlag.js +12 -0
  34. package/dist/src/utils/delivery-countries.d.ts +9 -0
  35. package/dist/src/utils/delivery-countries.js +255 -0
  36. package/dist/src/utils/expressCheckoutRedirect.d.ts +20 -2
  37. package/dist/src/utils/expressCheckoutRedirect.js +13 -1
  38. package/dist/src/utils/expressCheckoutTracking.d.ts +10 -16
  39. package/dist/src/utils/expressCheckoutTracking.js +5 -29
  40. package/dist/src/utils/latin-characters.d.ts +3 -0
  41. package/dist/src/utils/latin-characters.js +10 -0
  42. package/dist/src/utils/printOffersFlag.d.ts +11 -0
  43. package/dist/src/utils/printOffersFlag.js +5 -0
  44. package/dist/src/utils/recaptcha.d.ts +3 -2
  45. package/dist/src/utils/recaptcha.js +17 -8
  46. package/package.json +1 -1
  47. package/dist/src/apple-pay-logo.d.ts +0 -1
  48. package/dist/src/apple-pay-logo.js +0 -14
  49. package/dist/src/types/experiment-integration.d.js +0 -0
  50. package/dist/src/utils/getExperimentKeyFromNextData.d.ts +0 -8
  51. package/dist/src/utils/getExperimentKeyFromNextData.js +0 -9
@@ -1,6 +1,16 @@
1
1
  import type { Offer, ProductVariant } from './types/offer.types';
2
2
  import { ApplePayEntryPoint } from './constants';
3
+ /**
4
+ * @deprecated Print offers are now excluded per entry point; use `getExcludedVariants(entryPoint)`. Kept as
5
+ * the default (surfaces that do not take print offers) so existing hosts behave exactly as before.
6
+ */
3
7
  export declare const APPLE_PAY_EXCLUDED_VARIANTS: readonly ProductVariant[];
8
+ /**
9
+ * Variants an entry point never offers Apple Pay for (unknown / missing entry points use the default
10
+ * entry point's rule, as in `createIfEnabled`). Hosts that update `button.offer` in place use this to apply
11
+ * the same rule `createIfEnabled` applies on creation.
12
+ */
13
+ export declare const getExcludedVariants: (entryPoint?: ApplePayEntryPoint) => readonly ProductVariant[];
4
14
  export declare class ApplePayButton extends HTMLElement {
5
15
  #private;
6
16
  static readonly tag = "teg-apple-pay-button";
@@ -8,22 +18,19 @@ export declare class ApplePayButton extends HTMLElement {
8
18
  /**
9
19
  * Creates and configures an ApplePayButton when the entry point allows it.
10
20
  *
11
- * - `DUAL_OFFER_BANNER` (or omitted): always-on after eligibility / exclusions —
12
- * no banners experiment read and no banners `$exposure`.
13
- * - `PAYWALL`: experiment-gated via {@link APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY}
14
- * (`treatment` or QA URL param). The host must set up
15
- * `window.experimentIntegration` before calling for this entry point.
21
+ * - `DUAL_OFFER_BANNER` (or omitted): always-on after offer exclusions —
22
+ * no homepage/Safari gate here. Safari/Apple is enforced later by
23
+ * `isApplePayAvailable()` on mount.
24
+ * - `FREE_TRIAL_BANNER`: same always-on-after-exclusions gate as Dual; distinct
25
+ * TEDL `entry_point` string (`free_trial_banner`) for wallet impression attribution.
26
+ * - `FREE_TRIAL_POPUP`: same always-on-after-exclusions gate. Distinct TEDL
27
+ * `entry_point` (`free_trial_popup`).
28
+ * - `PAYWALL`: always-on after offer exclusions + Safari/Apple placement
29
+ * eligibility. No Amplitude experiment / `$exposure`.
16
30
  * - `REGWALL`: inert — always returns null.
17
31
  *
18
- * **PAYWALL only — transition period:** the legacy
19
- * `FEATURE_APPLE_PAY_EXPRESS_CHECKOUT` URL param can show the button without
20
- * treatment (and without inflating `$exposure`). For banners, the same URL
21
- * param / `BYPASS_APPLE_PAY_CHECKS` only bypass **eligibility**, not an
22
- * experiment gate.
23
- *
24
- * **Eligibility:**
25
- * - `DUAL_OFFER_BANNER` (or omitted): homepage + Safari/iPhone
26
- * - `PAYWALL`: Safari/Apple device only (no homepage) — article paywalls
32
+ * `BYPASS_APPLE_PAY_CHECKS` skips placement eligibility here and device checks
33
+ * in `isApplePayAvailable()` on mount (QA on non-Apple browsers).
27
34
  *
28
35
  * @param offer - The offer to display in the Apple Pay flow.
29
36
  * @param country - The user's country code.