@economist/web-apple-pay 2.0.0-beta.2 → 2.0.0-beta.4
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 +20 -12
- package/dist/index.js +681 -361
- package/dist/src/apple-pay-button.d.ts +18 -16
- package/dist/src/apple-pay-button.js +670 -352
- package/dist/src/apple-pay-button.stories.js +667 -351
- package/dist/src/apple-pay-modal.js +44 -39
- package/dist/src/apple-pay-modal.stories.js +667 -351
- package/dist/src/clients/payment-checkout/apple-session.d.ts +14 -1
- package/dist/src/clients/payment-checkout/apple-session.js +66 -17
- 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 +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 +10 -1
- package/dist/src/clients/payment-checkout/payment-handler.js +414 -36
- package/dist/src/clients/payment-checkout/session.js +13 -1
- package/dist/src/clients/payment-checkout/types.d.ts +11 -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 +681 -361
- package/dist/src/types/offer.types.d.ts +1 -1
- package/dist/src/utils/address-rules.d.ts +29 -0
- package/dist/src/utils/address-rules.js +260 -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/billing-countries.js +46 -37
- 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 +13 -20
- package/dist/src/utils/expressCheckoutTracking.js +22 -37
- 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/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
|
@@ -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,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delivery address rules for print (bundle) offers. Ported from sma-checkout
|
|
3
|
+
* `src/hooks/use-address-form-config/address-rules` (required.ts, validations.ts) so an Apple Pay delivery
|
|
4
|
+
* address is held to the same rules as the checkout form. The wallet-payments-api re-validates the same rules
|
|
5
|
+
* server-side. Keep all three in sync.
|
|
6
|
+
*/
|
|
7
|
+
export type DeliveryField = 'address1' | 'city' | 'state' | 'postalCode' | 'phone';
|
|
8
|
+
/** Commerce Services length limits (sma-checkout `validations.ts`). */
|
|
9
|
+
export declare const ADDRESS_LIMITS: {
|
|
10
|
+
readonly address1: 35;
|
|
11
|
+
readonly address2: 35;
|
|
12
|
+
readonly city: 40;
|
|
13
|
+
readonly state: 40;
|
|
14
|
+
readonly postalCode: 20;
|
|
15
|
+
readonly phone: 35;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Required delivery fields for an offer in `offerCountry` delivering to `country`
|
|
19
|
+
* (sma-checkout `required.ts`; address1 and city are always required).
|
|
20
|
+
*/
|
|
21
|
+
export declare const requiredDeliveryFields: (offerCountry: string, country: string) => DeliveryField[];
|
|
22
|
+
/** Postcode format rules by zone (sma-checkout `validations.ts`). Returns an error message or null. */
|
|
23
|
+
export declare const postalCodeFormatError: (offerCountry: string, postalCode: string) => string | null;
|
|
24
|
+
/**
|
|
25
|
+
* Normalises a wallet phone number like sma-checkout's delivery form (digits only, leading zeros stripped,
|
|
26
|
+
* country code prefixed). An international number (`+…`) is used as given; a national number is only prefixed
|
|
27
|
+
* for the countries that require a phone (IN, CN) and is otherwise omitted rather than guessed.
|
|
28
|
+
*/
|
|
29
|
+
export declare const normaliseDeliveryPhone: (raw: string | undefined, country: string) => string | undefined;
|
|
@@ -0,0 +1,260 @@
|
|
|
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/price-zones.ts
|
|
207
|
+
var priceZones = price_zones_default;
|
|
208
|
+
var getZoneByCountry = (country) => Object.keys(priceZones).find((key) => priceZones[key].includes(country)) ?? null;
|
|
209
|
+
|
|
210
|
+
// src/utils/address-rules.ts
|
|
211
|
+
var ADDRESS_LIMITS = {
|
|
212
|
+
address1: 35,
|
|
213
|
+
address2: 35,
|
|
214
|
+
city: 40,
|
|
215
|
+
state: 40,
|
|
216
|
+
postalCode: 20,
|
|
217
|
+
phone: 35
|
|
218
|
+
};
|
|
219
|
+
var COUNTRIES_REQUIRING_PHONE = ["IN", "CN"];
|
|
220
|
+
var requiredDeliveryFields = (offerCountry, country) => {
|
|
221
|
+
const zone = getZoneByCountry(offerCountry);
|
|
222
|
+
const fields = ["address1", "city"];
|
|
223
|
+
if (zone === "AS-AU" || zone === "AS-JP" || zone === "NA-CA" || country === "US") {
|
|
224
|
+
fields.push("state");
|
|
225
|
+
}
|
|
226
|
+
if ((zone !== "AS-HK" || country === "MO") && zone !== "CE-AF" && zone !== "CE-ME") {
|
|
227
|
+
fields.push("postalCode");
|
|
228
|
+
}
|
|
229
|
+
if (COUNTRIES_REQUIRING_PHONE.includes(country)) fields.push("phone");
|
|
230
|
+
return fields;
|
|
231
|
+
};
|
|
232
|
+
var postalCodeFormatError = (offerCountry, postalCode) => {
|
|
233
|
+
if (!postalCode) return null;
|
|
234
|
+
const zone = getZoneByCountry(offerCountry);
|
|
235
|
+
if (zone === "NA-US" && !/(^\d{5}$)|(^\d{5}-\d{4}$)/.test(postalCode)) {
|
|
236
|
+
return "Zip code must be a valid US zip code";
|
|
237
|
+
}
|
|
238
|
+
if (zone === "NA-CA" && !/^[A-Za-z]\d[A-Za-z][ -]?\d[A-Za-z]\d$/.test(postalCode)) {
|
|
239
|
+
return "Postal code must be a valid Canadian postal code";
|
|
240
|
+
}
|
|
241
|
+
return null;
|
|
242
|
+
};
|
|
243
|
+
var COUNTRY_CALLING_CODES = {
|
|
244
|
+
IN: "91",
|
|
245
|
+
CN: "86"
|
|
246
|
+
};
|
|
247
|
+
var normaliseDeliveryPhone = (raw, country) => {
|
|
248
|
+
const trimmed = raw?.trim() ?? "";
|
|
249
|
+
const digits = trimmed.replace(/[^0-9]+/g, "");
|
|
250
|
+
if (!digits) return void 0;
|
|
251
|
+
if (trimmed.startsWith("+")) return `+${digits}`;
|
|
252
|
+
const callingCode = COUNTRY_CALLING_CODES[country];
|
|
253
|
+
return callingCode ? `+${callingCode}${digits.replace(/^0+/, "")}` : void 0;
|
|
254
|
+
};
|
|
255
|
+
export {
|
|
256
|
+
ADDRESS_LIMITS,
|
|
257
|
+
normaliseDeliveryPhone,
|
|
258
|
+
postalCodeFormatError,
|
|
259
|
+
requiredDeliveryFields
|
|
260
|
+
};
|
|
@@ -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;
|
|
@@ -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
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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
|
|
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
|
|
11
|
+
var isEligibleForApplePayExpressPaywall = () => isAppleDeviceOrSafari();
|
|
12
12
|
export {
|
|
13
13
|
isApplePayExpressHomepage,
|
|
14
14
|
isEligibleForApplePayExpressBanner,
|
|
15
|
-
|
|
15
|
+
isEligibleForApplePayExpressPaywall
|
|
16
16
|
};
|
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
// src/data/eea-countries.json
|
|
2
|
+
var eea_countries_default = [
|
|
3
|
+
"AT",
|
|
4
|
+
"BE",
|
|
5
|
+
"BG",
|
|
6
|
+
"HR",
|
|
7
|
+
"CY",
|
|
8
|
+
"CZ",
|
|
9
|
+
"DK",
|
|
10
|
+
"EE",
|
|
11
|
+
"FO",
|
|
12
|
+
"FI",
|
|
13
|
+
"FR",
|
|
14
|
+
"DE",
|
|
15
|
+
"GR",
|
|
16
|
+
"GL",
|
|
17
|
+
"HU",
|
|
18
|
+
"IS",
|
|
19
|
+
"IE",
|
|
20
|
+
"IT",
|
|
21
|
+
"LV",
|
|
22
|
+
"LI",
|
|
23
|
+
"LT",
|
|
24
|
+
"LU",
|
|
25
|
+
"MT",
|
|
26
|
+
"NL",
|
|
27
|
+
"NO",
|
|
28
|
+
"PL",
|
|
29
|
+
"PT",
|
|
30
|
+
"RO",
|
|
31
|
+
"SK",
|
|
32
|
+
"SI",
|
|
33
|
+
"ES",
|
|
34
|
+
"SE"
|
|
35
|
+
];
|
|
36
|
+
|
|
1
37
|
// src/data/price-zones.json
|
|
2
38
|
var price_zones_default = {
|
|
3
39
|
"AS-AS": [
|
|
@@ -203,49 +239,22 @@ var price_zones_default = {
|
|
|
203
239
|
"UK-UK": ["GB"]
|
|
204
240
|
};
|
|
205
241
|
|
|
206
|
-
// src/
|
|
207
|
-
var
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
"
|
|
213
|
-
"
|
|
214
|
-
"DK",
|
|
215
|
-
"EE",
|
|
216
|
-
"FO",
|
|
217
|
-
"FI",
|
|
218
|
-
"FR",
|
|
219
|
-
"DE",
|
|
220
|
-
"GR",
|
|
221
|
-
"GL",
|
|
222
|
-
"HU",
|
|
223
|
-
"IS",
|
|
224
|
-
"IE",
|
|
225
|
-
"IT",
|
|
226
|
-
"LV",
|
|
227
|
-
"LI",
|
|
228
|
-
"LT",
|
|
229
|
-
"LU",
|
|
230
|
-
"MT",
|
|
231
|
-
"NL",
|
|
232
|
-
"NO",
|
|
233
|
-
"PL",
|
|
234
|
-
"PT",
|
|
235
|
-
"RO",
|
|
236
|
-
"SK",
|
|
237
|
-
"SI",
|
|
238
|
-
"ES",
|
|
239
|
-
"SE"
|
|
242
|
+
// src/utils/price-zones.ts
|
|
243
|
+
var priceZones = price_zones_default;
|
|
244
|
+
var getZoneByCountry = (country) => Object.keys(priceZones).find((key) => priceZones[key].includes(country)) ?? null;
|
|
245
|
+
|
|
246
|
+
// src/utils/print-variants.ts
|
|
247
|
+
var PRINT_VARIANTS = [
|
|
248
|
+
"bundle",
|
|
249
|
+
"insider_print"
|
|
240
250
|
];
|
|
251
|
+
var isPrintVariant = (variant) => PRINT_VARIANTS.includes(variant ?? "");
|
|
241
252
|
|
|
242
253
|
// src/utils/billing-countries.ts
|
|
243
|
-
var priceZones = price_zones_default;
|
|
244
254
|
var eeaCountries = eea_countries_default;
|
|
245
255
|
var ALL_COUNTRY_CODES = Object.values(priceZones).flat();
|
|
246
|
-
var getZoneByCountry = (country) => Object.keys(priceZones).find((key) => priceZones[key].includes(country)) ?? null;
|
|
247
256
|
var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
248
|
-
if (offerVariant
|
|
257
|
+
if (isPrintVariant(offerVariant)) {
|
|
249
258
|
return [...ALL_COUNTRY_CODES];
|
|
250
259
|
}
|
|
251
260
|
const zone = getZoneByCountry(offerCountry);
|
|
@@ -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[];
|