@economist/web-apple-pay 1.8.2 → 1.9.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/dist/index.js +38 -10
- package/dist/src/apple-pay-button.d.ts +17 -1
- package/dist/src/apple-pay-button.js +32 -2
- package/dist/src/apple-pay-button.stories.js +32 -2
- package/dist/src/apple-pay-modal.stories.js +32 -2
- package/dist/src/constants.d.ts +20 -0
- package/dist/src/constants.js +7 -0
- package/dist/src/index.js +38 -10
- package/dist/src/types/experiment-integration.d.js +0 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1937,6 +1937,19 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1937
1937
|
return [...zoneCountries];
|
|
1938
1938
|
};
|
|
1939
1939
|
|
|
1940
|
+
// src/constants.ts
|
|
1941
|
+
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint3) => {
|
|
1942
|
+
ApplePayEntryPoint3["PAYWALL"] = "article_paywall";
|
|
1943
|
+
ApplePayEntryPoint3["REGWALL"] = "article_regwall";
|
|
1944
|
+
ApplePayEntryPoint3["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
1945
|
+
return ApplePayEntryPoint3;
|
|
1946
|
+
})(ApplePayEntryPoint || {});
|
|
1947
|
+
var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-feature-flag-placeholder";
|
|
1948
|
+
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
1949
|
+
CONTROL: "control",
|
|
1950
|
+
TREATMENT: "treatment"
|
|
1951
|
+
};
|
|
1952
|
+
|
|
1940
1953
|
// src/apple-pay-button.ts
|
|
1941
1954
|
var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
1942
1955
|
var TOTAL_LABEL = "The Economist";
|
|
@@ -1954,7 +1967,23 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
1954
1967
|
define(_ApplePayButton.tag, _ApplePayButton);
|
|
1955
1968
|
}
|
|
1956
1969
|
/**
|
|
1957
|
-
* Creates and configures an ApplePayButton
|
|
1970
|
+
* Creates and configures an ApplePayButton when the Amplitude experiment is enabled.
|
|
1971
|
+
*
|
|
1972
|
+
* Reads the experiment variant from `window.experimentIntegration.getVariant` using
|
|
1973
|
+
* {@link APPLE_PAY_EXPRESS_EXPERIMENT_KEY}. The host page is responsible
|
|
1974
|
+
* for setting up `window.experimentIntegration` before calling this method.
|
|
1975
|
+
*
|
|
1976
|
+
* - `treatment` → button created and returned
|
|
1977
|
+
* - `control` / missing / anything else → returns null (button suppressed)
|
|
1978
|
+
*
|
|
1979
|
+
* **Transition period:** the legacy `FEATURE_APPLE_PAY_EXPRESS_CHECKOUT` URL param
|
|
1980
|
+
* gate is also evaluated as a fallback until all host apps have integrated
|
|
1981
|
+
* `window.experimentIntegration`. Once all consumers are migrated, the URL param
|
|
1982
|
+
* fallback will be removed.
|
|
1983
|
+
*
|
|
1984
|
+
* @param offer - The offer to display in the Apple Pay flow.
|
|
1985
|
+
* @param country - The user's country code.
|
|
1986
|
+
* @param entryPoint - Where the button is being rendered (e.g. paywall, banner).
|
|
1958
1987
|
*/
|
|
1959
1988
|
static createIfEnabled(offer, country, entryPoint) {
|
|
1960
1989
|
if (!offer) {
|
|
@@ -1963,7 +1992,14 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
1963
1992
|
if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
|
|
1964
1993
|
return null;
|
|
1965
1994
|
}
|
|
1966
|
-
|
|
1995
|
+
const experimentValue = window.experimentIntegration?.getVariant?.(
|
|
1996
|
+
APPLE_PAY_EXPRESS_EXPERIMENT_KEY
|
|
1997
|
+
);
|
|
1998
|
+
const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
1999
|
+
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2000
|
+
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
2001
|
+
);
|
|
2002
|
+
if (!isTreatment && !hasUrlParamFlag) {
|
|
1967
2003
|
return null;
|
|
1968
2004
|
}
|
|
1969
2005
|
_ApplePayButton.define();
|
|
@@ -2271,14 +2307,6 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2271
2307
|
}
|
|
2272
2308
|
};
|
|
2273
2309
|
|
|
2274
|
-
// src/constants.ts
|
|
2275
|
-
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
2276
|
-
ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
|
|
2277
|
-
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
2278
|
-
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
2279
|
-
return ApplePayEntryPoint2;
|
|
2280
|
-
})(ApplePayEntryPoint || {});
|
|
2281
|
-
|
|
2282
2310
|
// src/index.ts
|
|
2283
2311
|
function defineApplePayElements() {
|
|
2284
2312
|
ApplePayButton.define();
|
|
@@ -6,7 +6,23 @@ export declare class ApplePayButton extends HTMLElement {
|
|
|
6
6
|
static readonly tag = "teg-apple-pay-button";
|
|
7
7
|
static define(): void;
|
|
8
8
|
/**
|
|
9
|
-
* Creates and configures an ApplePayButton
|
|
9
|
+
* Creates and configures an ApplePayButton when the Amplitude experiment is enabled.
|
|
10
|
+
*
|
|
11
|
+
* Reads the experiment variant from `window.experimentIntegration.getVariant` using
|
|
12
|
+
* {@link APPLE_PAY_EXPRESS_EXPERIMENT_KEY}. The host page is responsible
|
|
13
|
+
* for setting up `window.experimentIntegration` before calling this method.
|
|
14
|
+
*
|
|
15
|
+
* - `treatment` → button created and returned
|
|
16
|
+
* - `control` / missing / anything else → returns null (button suppressed)
|
|
17
|
+
*
|
|
18
|
+
* **Transition period:** the legacy `FEATURE_APPLE_PAY_EXPRESS_CHECKOUT` URL param
|
|
19
|
+
* gate is also evaluated as a fallback until all host apps have integrated
|
|
20
|
+
* `window.experimentIntegration`. Once all consumers are migrated, the URL param
|
|
21
|
+
* fallback will be removed.
|
|
22
|
+
*
|
|
23
|
+
* @param offer - The offer to display in the Apple Pay flow.
|
|
24
|
+
* @param country - The user's country code.
|
|
25
|
+
* @param entryPoint - Where the button is being rendered (e.g. paywall, banner).
|
|
10
26
|
*/
|
|
11
27
|
static createIfEnabled(offer: Offer | undefined, country: string, entryPoint?: ApplePayEntryPoint): ApplePayButton | null;
|
|
12
28
|
get offer(): Offer | null;
|
|
@@ -1932,6 +1932,13 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1932
1932
|
return [...zoneCountries];
|
|
1933
1933
|
};
|
|
1934
1934
|
|
|
1935
|
+
// src/constants.ts
|
|
1936
|
+
var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-feature-flag-placeholder";
|
|
1937
|
+
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
1938
|
+
CONTROL: "control",
|
|
1939
|
+
TREATMENT: "treatment"
|
|
1940
|
+
};
|
|
1941
|
+
|
|
1935
1942
|
// src/apple-pay-button.ts
|
|
1936
1943
|
var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
1937
1944
|
var TOTAL_LABEL = "The Economist";
|
|
@@ -1949,7 +1956,23 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
1949
1956
|
define(_ApplePayButton.tag, _ApplePayButton);
|
|
1950
1957
|
}
|
|
1951
1958
|
/**
|
|
1952
|
-
* Creates and configures an ApplePayButton
|
|
1959
|
+
* Creates and configures an ApplePayButton when the Amplitude experiment is enabled.
|
|
1960
|
+
*
|
|
1961
|
+
* Reads the experiment variant from `window.experimentIntegration.getVariant` using
|
|
1962
|
+
* {@link APPLE_PAY_EXPRESS_EXPERIMENT_KEY}. The host page is responsible
|
|
1963
|
+
* for setting up `window.experimentIntegration` before calling this method.
|
|
1964
|
+
*
|
|
1965
|
+
* - `treatment` → button created and returned
|
|
1966
|
+
* - `control` / missing / anything else → returns null (button suppressed)
|
|
1967
|
+
*
|
|
1968
|
+
* **Transition period:** the legacy `FEATURE_APPLE_PAY_EXPRESS_CHECKOUT` URL param
|
|
1969
|
+
* gate is also evaluated as a fallback until all host apps have integrated
|
|
1970
|
+
* `window.experimentIntegration`. Once all consumers are migrated, the URL param
|
|
1971
|
+
* fallback will be removed.
|
|
1972
|
+
*
|
|
1973
|
+
* @param offer - The offer to display in the Apple Pay flow.
|
|
1974
|
+
* @param country - The user's country code.
|
|
1975
|
+
* @param entryPoint - Where the button is being rendered (e.g. paywall, banner).
|
|
1953
1976
|
*/
|
|
1954
1977
|
static createIfEnabled(offer, country, entryPoint) {
|
|
1955
1978
|
if (!offer) {
|
|
@@ -1958,7 +1981,14 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
1958
1981
|
if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
|
|
1959
1982
|
return null;
|
|
1960
1983
|
}
|
|
1961
|
-
|
|
1984
|
+
const experimentValue = window.experimentIntegration?.getVariant?.(
|
|
1985
|
+
APPLE_PAY_EXPRESS_EXPERIMENT_KEY
|
|
1986
|
+
);
|
|
1987
|
+
const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
1988
|
+
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
1989
|
+
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
1990
|
+
);
|
|
1991
|
+
if (!isTreatment && !hasUrlParamFlag) {
|
|
1962
1992
|
return null;
|
|
1963
1993
|
}
|
|
1964
1994
|
_ApplePayButton.define();
|
|
@@ -1940,6 +1940,13 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1940
1940
|
return [...zoneCountries];
|
|
1941
1941
|
};
|
|
1942
1942
|
|
|
1943
|
+
// src/constants.ts
|
|
1944
|
+
var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-feature-flag-placeholder";
|
|
1945
|
+
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
1946
|
+
CONTROL: "control",
|
|
1947
|
+
TREATMENT: "treatment"
|
|
1948
|
+
};
|
|
1949
|
+
|
|
1943
1950
|
// src/apple-pay-button.ts
|
|
1944
1951
|
var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
1945
1952
|
var TOTAL_LABEL = "The Economist";
|
|
@@ -1957,7 +1964,23 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
1957
1964
|
define(_ApplePayButton.tag, _ApplePayButton);
|
|
1958
1965
|
}
|
|
1959
1966
|
/**
|
|
1960
|
-
* Creates and configures an ApplePayButton
|
|
1967
|
+
* Creates and configures an ApplePayButton when the Amplitude experiment is enabled.
|
|
1968
|
+
*
|
|
1969
|
+
* Reads the experiment variant from `window.experimentIntegration.getVariant` using
|
|
1970
|
+
* {@link APPLE_PAY_EXPRESS_EXPERIMENT_KEY}. The host page is responsible
|
|
1971
|
+
* for setting up `window.experimentIntegration` before calling this method.
|
|
1972
|
+
*
|
|
1973
|
+
* - `treatment` → button created and returned
|
|
1974
|
+
* - `control` / missing / anything else → returns null (button suppressed)
|
|
1975
|
+
*
|
|
1976
|
+
* **Transition period:** the legacy `FEATURE_APPLE_PAY_EXPRESS_CHECKOUT` URL param
|
|
1977
|
+
* gate is also evaluated as a fallback until all host apps have integrated
|
|
1978
|
+
* `window.experimentIntegration`. Once all consumers are migrated, the URL param
|
|
1979
|
+
* fallback will be removed.
|
|
1980
|
+
*
|
|
1981
|
+
* @param offer - The offer to display in the Apple Pay flow.
|
|
1982
|
+
* @param country - The user's country code.
|
|
1983
|
+
* @param entryPoint - Where the button is being rendered (e.g. paywall, banner).
|
|
1961
1984
|
*/
|
|
1962
1985
|
static createIfEnabled(offer, country, entryPoint) {
|
|
1963
1986
|
if (!offer) {
|
|
@@ -1966,7 +1989,14 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
1966
1989
|
if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
|
|
1967
1990
|
return null;
|
|
1968
1991
|
}
|
|
1969
|
-
|
|
1992
|
+
const experimentValue = window.experimentIntegration?.getVariant?.(
|
|
1993
|
+
APPLE_PAY_EXPRESS_EXPERIMENT_KEY
|
|
1994
|
+
);
|
|
1995
|
+
const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
1996
|
+
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
1997
|
+
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
1998
|
+
);
|
|
1999
|
+
if (!isTreatment && !hasUrlParamFlag) {
|
|
1970
2000
|
return null;
|
|
1971
2001
|
}
|
|
1972
2002
|
_ApplePayButton.define();
|
|
@@ -1932,6 +1932,13 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1932
1932
|
return [...zoneCountries];
|
|
1933
1933
|
};
|
|
1934
1934
|
|
|
1935
|
+
// src/constants.ts
|
|
1936
|
+
var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-feature-flag-placeholder";
|
|
1937
|
+
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
1938
|
+
CONTROL: "control",
|
|
1939
|
+
TREATMENT: "treatment"
|
|
1940
|
+
};
|
|
1941
|
+
|
|
1935
1942
|
// src/apple-pay-button.ts
|
|
1936
1943
|
var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
1937
1944
|
var TOTAL_LABEL = "The Economist";
|
|
@@ -1949,7 +1956,23 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
1949
1956
|
define(_ApplePayButton.tag, _ApplePayButton);
|
|
1950
1957
|
}
|
|
1951
1958
|
/**
|
|
1952
|
-
* Creates and configures an ApplePayButton
|
|
1959
|
+
* Creates and configures an ApplePayButton when the Amplitude experiment is enabled.
|
|
1960
|
+
*
|
|
1961
|
+
* Reads the experiment variant from `window.experimentIntegration.getVariant` using
|
|
1962
|
+
* {@link APPLE_PAY_EXPRESS_EXPERIMENT_KEY}. The host page is responsible
|
|
1963
|
+
* for setting up `window.experimentIntegration` before calling this method.
|
|
1964
|
+
*
|
|
1965
|
+
* - `treatment` → button created and returned
|
|
1966
|
+
* - `control` / missing / anything else → returns null (button suppressed)
|
|
1967
|
+
*
|
|
1968
|
+
* **Transition period:** the legacy `FEATURE_APPLE_PAY_EXPRESS_CHECKOUT` URL param
|
|
1969
|
+
* gate is also evaluated as a fallback until all host apps have integrated
|
|
1970
|
+
* `window.experimentIntegration`. Once all consumers are migrated, the URL param
|
|
1971
|
+
* fallback will be removed.
|
|
1972
|
+
*
|
|
1973
|
+
* @param offer - The offer to display in the Apple Pay flow.
|
|
1974
|
+
* @param country - The user's country code.
|
|
1975
|
+
* @param entryPoint - Where the button is being rendered (e.g. paywall, banner).
|
|
1953
1976
|
*/
|
|
1954
1977
|
static createIfEnabled(offer, country, entryPoint) {
|
|
1955
1978
|
if (!offer) {
|
|
@@ -1958,7 +1981,14 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
1958
1981
|
if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
|
|
1959
1982
|
return null;
|
|
1960
1983
|
}
|
|
1961
|
-
|
|
1984
|
+
const experimentValue = window.experimentIntegration?.getVariant?.(
|
|
1985
|
+
APPLE_PAY_EXPRESS_EXPERIMENT_KEY
|
|
1986
|
+
);
|
|
1987
|
+
const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
1988
|
+
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
1989
|
+
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
1990
|
+
);
|
|
1991
|
+
if (!isTreatment && !hasUrlParamFlag) {
|
|
1962
1992
|
return null;
|
|
1963
1993
|
}
|
|
1964
1994
|
_ApplePayButton.define();
|
package/dist/src/constants.d.ts
CHANGED
|
@@ -3,3 +3,23 @@ export declare enum ApplePayEntryPoint {
|
|
|
3
3
|
REGWALL = "article_regwall",
|
|
4
4
|
DUAL_OFFER_BANNER = "dual_offer_banner"
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Amplitude experiment key for Apple Pay Express Checkout.
|
|
8
|
+
* This package reads the variant for this key internally via
|
|
9
|
+
* `window.experimentIntegration.getVariant()` — set up by the host page
|
|
10
|
+
* before `createIfEnabled` is called. Gates all entry points (paywall, regwall, banner).
|
|
11
|
+
*
|
|
12
|
+
* TODO: Replace with the confirmed Amplitude experiment key once available.
|
|
13
|
+
* The current value is a placeholder and must be verified against the
|
|
14
|
+
* Amplitude experiment dashboard before going to production.
|
|
15
|
+
*/
|
|
16
|
+
export declare const APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-feature-flag-placeholder";
|
|
17
|
+
/**
|
|
18
|
+
* Amplitude variant values for the Apple Pay Express Checkout experiment.
|
|
19
|
+
* CONTROL → button hidden (baseline)
|
|
20
|
+
* TREATMENT → button shown
|
|
21
|
+
*/
|
|
22
|
+
export declare const APPLE_PAY_EXPRESS_VARIANTS: {
|
|
23
|
+
readonly CONTROL: "control";
|
|
24
|
+
readonly TREATMENT: "treatment";
|
|
25
|
+
};
|
package/dist/src/constants.js
CHANGED
|
@@ -5,6 +5,13 @@ var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
|
5
5
|
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
6
6
|
return ApplePayEntryPoint2;
|
|
7
7
|
})(ApplePayEntryPoint || {});
|
|
8
|
+
var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-feature-flag-placeholder";
|
|
9
|
+
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
10
|
+
CONTROL: "control",
|
|
11
|
+
TREATMENT: "treatment"
|
|
12
|
+
};
|
|
8
13
|
export {
|
|
14
|
+
APPLE_PAY_EXPRESS_EXPERIMENT_KEY,
|
|
15
|
+
APPLE_PAY_EXPRESS_VARIANTS,
|
|
9
16
|
ApplePayEntryPoint
|
|
10
17
|
};
|
package/dist/src/index.js
CHANGED
|
@@ -1937,6 +1937,19 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
|
|
|
1937
1937
|
return [...zoneCountries];
|
|
1938
1938
|
};
|
|
1939
1939
|
|
|
1940
|
+
// src/constants.ts
|
|
1941
|
+
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint3) => {
|
|
1942
|
+
ApplePayEntryPoint3["PAYWALL"] = "article_paywall";
|
|
1943
|
+
ApplePayEntryPoint3["REGWALL"] = "article_regwall";
|
|
1944
|
+
ApplePayEntryPoint3["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
1945
|
+
return ApplePayEntryPoint3;
|
|
1946
|
+
})(ApplePayEntryPoint || {});
|
|
1947
|
+
var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-feature-flag-placeholder";
|
|
1948
|
+
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
1949
|
+
CONTROL: "control",
|
|
1950
|
+
TREATMENT: "treatment"
|
|
1951
|
+
};
|
|
1952
|
+
|
|
1940
1953
|
// src/apple-pay-button.ts
|
|
1941
1954
|
var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
1942
1955
|
var TOTAL_LABEL = "The Economist";
|
|
@@ -1954,7 +1967,23 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
1954
1967
|
define(_ApplePayButton.tag, _ApplePayButton);
|
|
1955
1968
|
}
|
|
1956
1969
|
/**
|
|
1957
|
-
* Creates and configures an ApplePayButton
|
|
1970
|
+
* Creates and configures an ApplePayButton when the Amplitude experiment is enabled.
|
|
1971
|
+
*
|
|
1972
|
+
* Reads the experiment variant from `window.experimentIntegration.getVariant` using
|
|
1973
|
+
* {@link APPLE_PAY_EXPRESS_EXPERIMENT_KEY}. The host page is responsible
|
|
1974
|
+
* for setting up `window.experimentIntegration` before calling this method.
|
|
1975
|
+
*
|
|
1976
|
+
* - `treatment` → button created and returned
|
|
1977
|
+
* - `control` / missing / anything else → returns null (button suppressed)
|
|
1978
|
+
*
|
|
1979
|
+
* **Transition period:** the legacy `FEATURE_APPLE_PAY_EXPRESS_CHECKOUT` URL param
|
|
1980
|
+
* gate is also evaluated as a fallback until all host apps have integrated
|
|
1981
|
+
* `window.experimentIntegration`. Once all consumers are migrated, the URL param
|
|
1982
|
+
* fallback will be removed.
|
|
1983
|
+
*
|
|
1984
|
+
* @param offer - The offer to display in the Apple Pay flow.
|
|
1985
|
+
* @param country - The user's country code.
|
|
1986
|
+
* @param entryPoint - Where the button is being rendered (e.g. paywall, banner).
|
|
1958
1987
|
*/
|
|
1959
1988
|
static createIfEnabled(offer, country, entryPoint) {
|
|
1960
1989
|
if (!offer) {
|
|
@@ -1963,7 +1992,14 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
1963
1992
|
if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
|
|
1964
1993
|
return null;
|
|
1965
1994
|
}
|
|
1966
|
-
|
|
1995
|
+
const experimentValue = window.experimentIntegration?.getVariant?.(
|
|
1996
|
+
APPLE_PAY_EXPRESS_EXPERIMENT_KEY
|
|
1997
|
+
);
|
|
1998
|
+
const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
1999
|
+
const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
|
|
2000
|
+
FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
|
|
2001
|
+
);
|
|
2002
|
+
if (!isTreatment && !hasUrlParamFlag) {
|
|
1967
2003
|
return null;
|
|
1968
2004
|
}
|
|
1969
2005
|
_ApplePayButton.define();
|
|
@@ -2271,14 +2307,6 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2271
2307
|
}
|
|
2272
2308
|
};
|
|
2273
2309
|
|
|
2274
|
-
// src/constants.ts
|
|
2275
|
-
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
2276
|
-
ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
|
|
2277
|
-
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
2278
|
-
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
2279
|
-
return ApplePayEntryPoint2;
|
|
2280
|
-
})(ApplePayEntryPoint || {});
|
|
2281
|
-
|
|
2282
2310
|
// src/index.ts
|
|
2283
2311
|
function defineApplePayElements() {
|
|
2284
2312
|
ApplePayButton.define();
|
|
File without changes
|