@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.
Files changed (51) hide show
  1. package/README.md +26 -8
  2. package/dist/index.js +647 -349
  3. package/dist/src/apple-pay-button.d.ts +18 -16
  4. package/dist/src/apple-pay-button.js +636 -340
  5. package/dist/src/apple-pay-button.stories.js +633 -339
  6. package/dist/src/apple-pay-modal.js +44 -39
  7. package/dist/src/apple-pay-modal.stories.js +633 -339
  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 +7 -28
  22. package/dist/src/constants.js +3 -7
  23. package/dist/src/index.d.ts +2 -4
  24. package/dist/src/index.js +647 -349
  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 +5 -6
  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 +0 -15
  39. package/dist/src/utils/expressCheckoutTracking.js +0 -27
  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,4 +1,4 @@
1
- export type ProductVariant = 'bundle' | 'digital' | 'espresso' | 'espressopod' | 'podcast' | 'insider_digital' | 'insider_print';
1
+ export type ProductVariant = 'bundle' | 'digital' | 'espresso' | 'espressopod' | 'podcast' | 'insider_digital' | 'play' | 'insider_print';
2
2
  export type PeriodUnit = 'week' | 'month' | 'year';
3
3
  export type Period = {
4
4
  duration: number;
@@ -0,0 +1,23 @@
1
+ export type DeliveryField = 'address1' | 'city' | 'state' | 'postalCode' | 'phone';
2
+ /** Commerce Services length limits (sma-checkout `validations.ts`). */
3
+ export declare const ADDRESS_LIMITS: {
4
+ readonly address1: 35;
5
+ readonly address2: 35;
6
+ readonly city: 40;
7
+ readonly state: 40;
8
+ readonly postalCode: 20;
9
+ readonly phone: 35;
10
+ };
11
+ /**
12
+ * Required delivery fields for an offer in `offerCountry` delivering to `country`
13
+ * (sma-checkout `required.ts`; address1 and city are always required).
14
+ */
15
+ export declare const requiredDeliveryFields: (offerCountry: string, country: string) => DeliveryField[];
16
+ /** Postcode format rules by zone (sma-checkout `validations.ts`). Returns an error message or null. */
17
+ export declare const postalCodeFormatError: (offerCountry: string, postalCode: string) => string | null;
18
+ /**
19
+ * Normalises a wallet phone number like sma-checkout's delivery form (digits only, leading zeros stripped,
20
+ * country code prefixed). An international number (`+…`) is used as given; a national number is only prefixed
21
+ * for the countries that require a phone (IN, CN) and is otherwise omitted rather than guessed.
22
+ */
23
+ export declare const normaliseDeliveryPhone: (raw: string | undefined, country: string) => string | undefined;
@@ -0,0 +1,258 @@
1
+ // src/data/price-zones.json
2
+ var price_zones_default = {
3
+ "AS-AS": [
4
+ "BD",
5
+ "BT",
6
+ "CK",
7
+ "FJ",
8
+ "ID",
9
+ "KH",
10
+ "KI",
11
+ "LA",
12
+ "LK",
13
+ "MH",
14
+ "MM",
15
+ "MN",
16
+ "MV",
17
+ "NC",
18
+ "NF",
19
+ "NP",
20
+ "NR",
21
+ "PF",
22
+ "PG",
23
+ "PK",
24
+ "PW",
25
+ "SB",
26
+ "TH",
27
+ "TL",
28
+ "TO",
29
+ "TV",
30
+ "VN",
31
+ "VU",
32
+ "WS"
33
+ ],
34
+ "AS-AU": ["AU"],
35
+ "AS-CN": ["CN"],
36
+ "AS-HK": ["HK", "MO"],
37
+ "AS-IN": ["IN"],
38
+ "AS-JP": ["JP"],
39
+ "AS-KR": ["KR"],
40
+ "AS-MY": ["MY"],
41
+ "AS-NZ": ["NZ"],
42
+ "AS-PH": ["PH"],
43
+ "AS-SG": ["BN", "SG"],
44
+ "AS-TW": ["TW"],
45
+ "CE-AF": [
46
+ "DZ",
47
+ "AO",
48
+ "BJ",
49
+ "BW",
50
+ "BF",
51
+ "BI",
52
+ "CM",
53
+ "CV",
54
+ "CF",
55
+ "TD",
56
+ "CG",
57
+ "CD",
58
+ "CI",
59
+ "DJ",
60
+ "EG",
61
+ "GQ",
62
+ "ER",
63
+ "ET",
64
+ "GA",
65
+ "GM",
66
+ "GH",
67
+ "GN",
68
+ "GW",
69
+ "IL",
70
+ "JO",
71
+ "KE",
72
+ "LB",
73
+ "LS",
74
+ "LR",
75
+ "LY",
76
+ "MG",
77
+ "MW",
78
+ "ML",
79
+ "MR",
80
+ "MU",
81
+ "MA",
82
+ "MZ",
83
+ "NA",
84
+ "NE",
85
+ "NG",
86
+ "PS",
87
+ "RE",
88
+ "RW",
89
+ "ST",
90
+ "SN",
91
+ "SC",
92
+ "SL",
93
+ "ZA",
94
+ "SZ",
95
+ "TZ",
96
+ "TG",
97
+ "TN",
98
+ "UG",
99
+ "ZM",
100
+ "ZW"
101
+ ],
102
+ "CE-CH": ["LI", "CH"],
103
+ "CE-DK": ["FO", "GL", "DK"],
104
+ "CE-EU": [
105
+ "AL",
106
+ "AD",
107
+ "AM",
108
+ "AT",
109
+ "AZ",
110
+ "BY",
111
+ "BE",
112
+ "BA",
113
+ "BG",
114
+ "HR",
115
+ "CY",
116
+ "CZ",
117
+ "EE",
118
+ "FI",
119
+ "FR",
120
+ "GE",
121
+ "DE",
122
+ "GI",
123
+ "GR",
124
+ "HU",
125
+ "IS",
126
+ "IE",
127
+ "IT",
128
+ "KZ",
129
+ "XK",
130
+ "KG",
131
+ "LV",
132
+ "LT",
133
+ "LU",
134
+ "MT",
135
+ "MD",
136
+ "MC",
137
+ "ME",
138
+ "NL",
139
+ "PL",
140
+ "PT",
141
+ "MK",
142
+ "RO",
143
+ "RS",
144
+ "SK",
145
+ "SI",
146
+ "ES",
147
+ "TJ",
148
+ "TR",
149
+ "TM",
150
+ "UA",
151
+ "UZ"
152
+ ],
153
+ "CE-ME": ["AE", "BH", "KW", "OM", "QA", "SA"],
154
+ "CE-NO": ["NO"],
155
+ "CE-SE": ["SE"],
156
+ "LA-LA": [
157
+ "AI",
158
+ "AG",
159
+ "AR",
160
+ "AW",
161
+ "BS",
162
+ "BB",
163
+ "BZ",
164
+ "BM",
165
+ "BO",
166
+ "BR",
167
+ "KY",
168
+ "CL",
169
+ "CO",
170
+ "CR",
171
+ "DM",
172
+ "DO",
173
+ "EC",
174
+ "SV",
175
+ "FK",
176
+ "GF",
177
+ "GD",
178
+ "GT",
179
+ "GY",
180
+ "HT",
181
+ "HN",
182
+ "JM",
183
+ "MQ",
184
+ "MX",
185
+ "MS",
186
+ "NI",
187
+ "MP",
188
+ "PA",
189
+ "PY",
190
+ "PE",
191
+ "KN",
192
+ "LC",
193
+ "VC",
194
+ "SR",
195
+ "TT",
196
+ "TC",
197
+ "UY",
198
+ "VG",
199
+ "VI"
200
+ ],
201
+ "NA-CA": ["CA"],
202
+ "NA-US": ["AS", "GU", "FM", "PR", "US"],
203
+ "UK-UK": ["GB"]
204
+ };
205
+
206
+ // src/utils/address-rules.ts
207
+ var priceZones = price_zones_default;
208
+ var ADDRESS_LIMITS = {
209
+ address1: 35,
210
+ address2: 35,
211
+ city: 40,
212
+ state: 40,
213
+ postalCode: 20,
214
+ phone: 35
215
+ };
216
+ var zoneOf = (country) => Object.keys(priceZones).find((zone) => priceZones[zone].includes(country));
217
+ var COUNTRIES_REQUIRING_PHONE = ["IN", "CN"];
218
+ var requiredDeliveryFields = (offerCountry, country) => {
219
+ const zone = zoneOf(offerCountry);
220
+ const fields = ["address1", "city"];
221
+ if (zone === "AS-AU" || zone === "AS-JP" || zone === "NA-CA" || country === "US") {
222
+ fields.push("state");
223
+ }
224
+ if ((zone !== "AS-HK" || country === "MO") && zone !== "CE-AF" && zone !== "CE-ME") {
225
+ fields.push("postalCode");
226
+ }
227
+ if (COUNTRIES_REQUIRING_PHONE.includes(country)) fields.push("phone");
228
+ return fields;
229
+ };
230
+ var postalCodeFormatError = (offerCountry, postalCode) => {
231
+ if (!postalCode) return null;
232
+ const zone = zoneOf(offerCountry);
233
+ if (zone === "NA-US" && !/(^\d{5}$)|(^\d{5}-\d{4}$)/.test(postalCode)) {
234
+ return "Zip code must be a valid US zip code";
235
+ }
236
+ if (zone === "NA-CA" && !/^[A-Za-z]\d[A-Za-z][ -]?\d[A-Za-z]\d$/.test(postalCode)) {
237
+ return "Postal code must be a valid Canadian postal code";
238
+ }
239
+ return null;
240
+ };
241
+ var COUNTRY_CALLING_CODES = {
242
+ IN: "91",
243
+ CN: "86"
244
+ };
245
+ var normaliseDeliveryPhone = (raw, country) => {
246
+ const trimmed = raw?.trim() ?? "";
247
+ const digits = trimmed.replace(/[^0-9]+/g, "");
248
+ if (!digits) return void 0;
249
+ if (trimmed.startsWith("+")) return `+${digits}`;
250
+ const callingCode = COUNTRY_CALLING_CODES[country];
251
+ return callingCode ? `+${callingCode}${digits.replace(/^0+/, "")}` : void 0;
252
+ };
253
+ export {
254
+ ADDRESS_LIMITS,
255
+ normaliseDeliveryPhone,
256
+ postalCodeFormatError,
257
+ requiredDeliveryFields
258
+ };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Feature flag for sma-checkout address parity on wallet purchases (SMA-3066 and related).
3
+ *
4
+ * `false` (default): billing details are validated and sent exactly as before, so releasing and bumping the
5
+ * package changes nothing for existing purchases.
6
+ * `true`: billing names and addresses must be Latin characters plus the approved diacritics (the sheet stays open
7
+ * with "Please use Latin characters only."), and the purchase carries `strictAddressRules` so the
8
+ * wallet-payments-api also truncates billing lines to the Commerce limits and maps Puerto Rico to US.
9
+ *
10
+ * Delivery details for print offers are always held to these rules; they only exist when print is enabled.
11
+ * Flip this constant in a release once QA'd. Deploy the wallet-payments-api change first.
12
+ */
13
+ export declare const ADDRESS_PARITY_ENABLED = true;
@@ -0,0 +1,5 @@
1
+ // src/utils/addressParityFlag.ts
2
+ var ADDRESS_PARITY_ENABLED = true;
3
+ export {
4
+ ADDRESS_PARITY_ENABLED
5
+ };
@@ -1,11 +1,10 @@
1
1
  /**
2
2
  * Host-side placement eligibility helpers for Apple Pay Express.
3
3
  *
4
- * Paywalls: used by createIfEnabled after offer exclusions so experiment
5
- * $exposure is Safari/Apple-gated. Banners: createIfEnabled does not call
6
- * the banner helper (always-on after offer exclusions); Safari/Apple still
7
- * runs later via isApplePayAvailable() on mount. Exposure (paywalls) is
8
- * further gated on isApplePayAvailable() (BYPASS_APPLE_PAY_CHECKS respected).
4
+ * Paywalls: used by createIfEnabled after offer exclusions so the button is
5
+ * Safari/Apple-gated. Banners: createIfEnabled does not call the banner helper
6
+ * (always-on after offer exclusions); Safari/Apple still runs later via
7
+ * isApplePayAvailable() on mount.
9
8
  */
10
9
  export declare const isApplePayExpressHomepage: (pathname?: string) => boolean;
11
10
  /**
@@ -18,4 +17,4 @@ export declare const isEligibleForApplePayExpressBanner: () => boolean;
18
17
  * Article paywalls (`ApplePayEntryPoint.PAYWALL`): Safari/Apple device only.
19
18
  * Homepage targeting does not apply — paywalls render on article pages.
20
19
  */
21
- export declare const isEligibleForApplePayExpressPaywallExperiment: () => boolean;
20
+ export declare const isEligibleForApplePayExpressPaywall: () => boolean;
@@ -8,9 +8,9 @@ var isAppleDeviceOrSafari = () => {
8
8
  // src/utils/applePayExpressEligibility.ts
9
9
  var isApplePayExpressHomepage = (pathname = window.location.pathname) => pathname === "/";
10
10
  var isEligibleForApplePayExpressBanner = () => isApplePayExpressHomepage() && isAppleDeviceOrSafari();
11
- var isEligibleForApplePayExpressPaywallExperiment = () => isAppleDeviceOrSafari();
11
+ var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
12
12
  export {
13
13
  isApplePayExpressHomepage,
14
14
  isEligibleForApplePayExpressBanner,
15
- isEligibleForApplePayExpressPaywallExperiment
15
+ isEligibleForApplePayExpressPaywall
16
16
  };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Feature flag for the button wording on every surface (banners, walls, popup, /subscribe).
3
+ *
4
+ * `false` (default): "Subscribe with Apple Pay", exactly as before, so releasing and bumping the package changes
5
+ * nothing visible.
6
+ * `true`: "Continue with Apple Pay" (caption and accessible name).
7
+ *
8
+ * Flip this constant in a release to switch the wording.
9
+ */
10
+ export declare const CONTINUE_WITH_COPY_ENABLED = true;
11
+ export declare const BUTTON_COPY: {
12
+ readonly subscribe: {
13
+ readonly caption: "Subscribe with";
14
+ readonly label: "Subscribe with Apple Pay";
15
+ };
16
+ readonly continue: {
17
+ readonly caption: "Continue with";
18
+ readonly label: "Continue with Apple Pay";
19
+ };
20
+ };
21
+ /** The caption and accessible name the button should show for the current flag value. */
22
+ export declare const getButtonCopy: (enabled?: boolean) => (typeof BUTTON_COPY)[keyof typeof BUTTON_COPY];
@@ -0,0 +1,12 @@
1
+ // src/utils/buttonCopyFlag.ts
2
+ var CONTINUE_WITH_COPY_ENABLED = true;
3
+ var BUTTON_COPY = {
4
+ subscribe: { caption: "Subscribe with", label: "Subscribe with Apple Pay" },
5
+ continue: { caption: "Continue with", label: "Continue with Apple Pay" }
6
+ };
7
+ var getButtonCopy = (enabled = CONTINUE_WITH_COPY_ENABLED) => enabled ? BUTTON_COPY.continue : BUTTON_COPY.subscribe;
8
+ export {
9
+ BUTTON_COPY,
10
+ CONTINUE_WITH_COPY_ENABLED,
11
+ getButtonCopy
12
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Countries a print (bundle) offer can be delivered to: the offer's price zone minus the countries print
3
+ * cannot be delivered to. Mirrors sma-checkout `options.ts` (`deliveryCountriesOrderedByLabel` filtered by the
4
+ * offer zone).
5
+ *
6
+ * Unlike sma-checkout (which throws), an unknown zone yields `[]`: with no delivery country there is no valid
7
+ * address, so the caller must not offer Apple Pay for it (fail closed, as a web component cannot throw).
8
+ */
9
+ export declare const getSupportedDeliveryCountries: (offerCountry: string) => string[];
@@ -0,0 +1,255 @@
1
+ // src/data/price-zones.json
2
+ var price_zones_default = {
3
+ "AS-AS": [
4
+ "BD",
5
+ "BT",
6
+ "CK",
7
+ "FJ",
8
+ "ID",
9
+ "KH",
10
+ "KI",
11
+ "LA",
12
+ "LK",
13
+ "MH",
14
+ "MM",
15
+ "MN",
16
+ "MV",
17
+ "NC",
18
+ "NF",
19
+ "NP",
20
+ "NR",
21
+ "PF",
22
+ "PG",
23
+ "PK",
24
+ "PW",
25
+ "SB",
26
+ "TH",
27
+ "TL",
28
+ "TO",
29
+ "TV",
30
+ "VN",
31
+ "VU",
32
+ "WS"
33
+ ],
34
+ "AS-AU": ["AU"],
35
+ "AS-CN": ["CN"],
36
+ "AS-HK": ["HK", "MO"],
37
+ "AS-IN": ["IN"],
38
+ "AS-JP": ["JP"],
39
+ "AS-KR": ["KR"],
40
+ "AS-MY": ["MY"],
41
+ "AS-NZ": ["NZ"],
42
+ "AS-PH": ["PH"],
43
+ "AS-SG": ["BN", "SG"],
44
+ "AS-TW": ["TW"],
45
+ "CE-AF": [
46
+ "DZ",
47
+ "AO",
48
+ "BJ",
49
+ "BW",
50
+ "BF",
51
+ "BI",
52
+ "CM",
53
+ "CV",
54
+ "CF",
55
+ "TD",
56
+ "CG",
57
+ "CD",
58
+ "CI",
59
+ "DJ",
60
+ "EG",
61
+ "GQ",
62
+ "ER",
63
+ "ET",
64
+ "GA",
65
+ "GM",
66
+ "GH",
67
+ "GN",
68
+ "GW",
69
+ "IL",
70
+ "JO",
71
+ "KE",
72
+ "LB",
73
+ "LS",
74
+ "LR",
75
+ "LY",
76
+ "MG",
77
+ "MW",
78
+ "ML",
79
+ "MR",
80
+ "MU",
81
+ "MA",
82
+ "MZ",
83
+ "NA",
84
+ "NE",
85
+ "NG",
86
+ "PS",
87
+ "RE",
88
+ "RW",
89
+ "ST",
90
+ "SN",
91
+ "SC",
92
+ "SL",
93
+ "ZA",
94
+ "SZ",
95
+ "TZ",
96
+ "TG",
97
+ "TN",
98
+ "UG",
99
+ "ZM",
100
+ "ZW"
101
+ ],
102
+ "CE-CH": ["LI", "CH"],
103
+ "CE-DK": ["FO", "GL", "DK"],
104
+ "CE-EU": [
105
+ "AL",
106
+ "AD",
107
+ "AM",
108
+ "AT",
109
+ "AZ",
110
+ "BY",
111
+ "BE",
112
+ "BA",
113
+ "BG",
114
+ "HR",
115
+ "CY",
116
+ "CZ",
117
+ "EE",
118
+ "FI",
119
+ "FR",
120
+ "GE",
121
+ "DE",
122
+ "GI",
123
+ "GR",
124
+ "HU",
125
+ "IS",
126
+ "IE",
127
+ "IT",
128
+ "KZ",
129
+ "XK",
130
+ "KG",
131
+ "LV",
132
+ "LT",
133
+ "LU",
134
+ "MT",
135
+ "MD",
136
+ "MC",
137
+ "ME",
138
+ "NL",
139
+ "PL",
140
+ "PT",
141
+ "MK",
142
+ "RO",
143
+ "RS",
144
+ "SK",
145
+ "SI",
146
+ "ES",
147
+ "TJ",
148
+ "TR",
149
+ "TM",
150
+ "UA",
151
+ "UZ"
152
+ ],
153
+ "CE-ME": ["AE", "BH", "KW", "OM", "QA", "SA"],
154
+ "CE-NO": ["NO"],
155
+ "CE-SE": ["SE"],
156
+ "LA-LA": [
157
+ "AI",
158
+ "AG",
159
+ "AR",
160
+ "AW",
161
+ "BS",
162
+ "BB",
163
+ "BZ",
164
+ "BM",
165
+ "BO",
166
+ "BR",
167
+ "KY",
168
+ "CL",
169
+ "CO",
170
+ "CR",
171
+ "DM",
172
+ "DO",
173
+ "EC",
174
+ "SV",
175
+ "FK",
176
+ "GF",
177
+ "GD",
178
+ "GT",
179
+ "GY",
180
+ "HT",
181
+ "HN",
182
+ "JM",
183
+ "MQ",
184
+ "MX",
185
+ "MS",
186
+ "NI",
187
+ "MP",
188
+ "PA",
189
+ "PY",
190
+ "PE",
191
+ "KN",
192
+ "LC",
193
+ "VC",
194
+ "SR",
195
+ "TT",
196
+ "TC",
197
+ "UY",
198
+ "VG",
199
+ "VI"
200
+ ],
201
+ "NA-CA": ["CA"],
202
+ "NA-US": ["AS", "GU", "FM", "PR", "US"],
203
+ "UK-UK": ["GB"]
204
+ };
205
+
206
+ // src/data/no-delivery-countries.json
207
+ var no_delivery_countries_default = [
208
+ "KH",
209
+ "MM",
210
+ "PK",
211
+ "BI",
212
+ "CV",
213
+ "CF",
214
+ "TD",
215
+ "CG",
216
+ "DJ",
217
+ "EG",
218
+ "GM",
219
+ "GN",
220
+ "GW",
221
+ "LB",
222
+ "LR",
223
+ "LY",
224
+ "ML",
225
+ "MU",
226
+ "RE",
227
+ "SL",
228
+ "AZ",
229
+ "BY",
230
+ "UA",
231
+ "BM",
232
+ "BO",
233
+ "KY",
234
+ "EC",
235
+ "HN",
236
+ "PA",
237
+ "PE",
238
+ "UY"
239
+ ];
240
+
241
+ // src/utils/delivery-countries.ts
242
+ var priceZones = price_zones_default;
243
+ var noDeliveryCountries = no_delivery_countries_default;
244
+ var getSupportedDeliveryCountries = (offerCountry) => {
245
+ const zone = Object.keys(priceZones).find(
246
+ (key) => priceZones[key].includes(offerCountry)
247
+ );
248
+ if (!zone) return [];
249
+ return priceZones[zone].filter(
250
+ (country) => !noDeliveryCountries.includes(country)
251
+ );
252
+ };
253
+ export {
254
+ getSupportedDeliveryCountries
255
+ };
@@ -7,7 +7,23 @@
7
7
  *
8
8
  * Matches sma-checkout: src/lib/navigate-to-checkout/index.tsx
9
9
  */
10
- export declare const writeCheckoutRedirect: (originUrl: string) => void;
10
+ /**
11
+ * What the post-checkout "return to" target (`checkout-redirect`, read by the onboarding app once the user has
12
+ * finished onboarding) should be. Chosen per entry point in `ENTRY_POINT_CONFIG` (apple-pay-button.ts).
13
+ */
14
+ export declare enum ReturnUrlPolicy {
15
+ /** Return the user to the page the button is on, e.g. the article behind a paywall. */
16
+ CURRENT_PAGE = "current_page",
17
+ /**
18
+ * Leave `checkout-redirect` untouched: the host owns it. sma-checkout's /subscribe pages store the article the
19
+ * user arrived from (and never themselves), so overwriting it would send the user back to the offers page.
20
+ * With nothing stored, onboarding returns the user to the home page.
21
+ */
22
+ HOST_MANAGED = "host_managed"
23
+ }
24
+ export declare const resolveCheckoutRedirectUrl: (policy: ReturnUrlPolicy, currentPageUrl: string) => string | null;
25
+ /** Persists the return target. `null` (see `ReturnUrlPolicy.HOST_MANAGED`) leaves the stored value as it is. */
26
+ export declare const writeCheckoutRedirect: (originUrl: string | null) => void;
11
27
  /**
12
28
  * Captures the current page URL (the article the user is reading).
13
29
  * Must be called before any redirect occurs.
@@ -42,7 +58,9 @@ export declare const decodeSku: (sku: string) => string;
42
58
  * Always appended when non-empty to preserve geo-context across the redirect.
43
59
  *
44
60
  * The origin article URL is written to localStorage by the caller via
45
- * writeCheckoutRedirect() before this redirect fires.
61
+ * writeCheckoutRedirect(). sma-checkout uses that, plus the wall's
62
+ * checkout-return-to-article opt-in when present, to send the reader
63
+ * back to the article or onboarding.
46
64
  */
47
65
  export declare const redirectToCheckoutComplete: (params: {
48
66
  basketId: string;