@economist/web-apple-pay 1.7.7 → 1.7.8
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 +7 -18
- package/dist/src/apple-pay-button.js +6 -18
- package/dist/src/apple-pay-button.stories.js +6 -18
- package/dist/src/apple-pay-modal.js +0 -1
- package/dist/src/apple-pay-modal.stories.js +6 -18
- package/dist/src/clients/payment-checkout/apple-session.js +2 -4
- package/dist/src/clients/payment-checkout/detects.js +1 -5
- package/dist/src/clients/payment-checkout/payment-handler.js +0 -1
- package/dist/src/constants.d.ts +2 -1
- package/dist/src/constants.js +1 -0
- package/dist/src/index.js +7 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -956,7 +956,6 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
|
|
|
956
956
|
cta.removeAttribute("aria-busy");
|
|
957
957
|
}
|
|
958
958
|
}).catch(() => {
|
|
959
|
-
console.error("[web-apple-pay] apple-pay-modal: failed to pre-fetch reCAPTCHA tokens; CTA remains disabled");
|
|
960
959
|
if (cta) {
|
|
961
960
|
cta.removeAttribute("aria-busy");
|
|
962
961
|
}
|
|
@@ -1142,15 +1141,11 @@ var isApplePayAvailable = async () => {
|
|
|
1142
1141
|
}
|
|
1143
1142
|
const merchantId = getApplePayConfig()?.merchantId;
|
|
1144
1143
|
if (!merchantId) {
|
|
1145
|
-
console.warn(
|
|
1146
|
-
"[web-apple-pay] Missing merchantId. Call configureApplePay({ merchantId, ... }) before rendering Apple Pay components."
|
|
1147
|
-
);
|
|
1148
1144
|
return false;
|
|
1149
1145
|
}
|
|
1150
1146
|
const hasActiveCard = await applePaySession.canMakePaymentsWithActiveCard(merchantId);
|
|
1151
1147
|
return hasActiveCard;
|
|
1152
|
-
} catch
|
|
1153
|
-
console.error("Error checking Apple Pay active card status:", error);
|
|
1148
|
+
} catch {
|
|
1154
1149
|
return false;
|
|
1155
1150
|
}
|
|
1156
1151
|
};
|
|
@@ -1397,8 +1392,7 @@ async function handleMerchantValidation(event, session, config) {
|
|
|
1397
1392
|
return;
|
|
1398
1393
|
}
|
|
1399
1394
|
session.completeMerchantValidation(response.merchantSession);
|
|
1400
|
-
} catch
|
|
1401
|
-
console.error("[web-apple-pay] onvalidatemerchant: error during validation", err);
|
|
1395
|
+
} catch {
|
|
1402
1396
|
session.abort();
|
|
1403
1397
|
redirectToFallbackCheckout(config);
|
|
1404
1398
|
}
|
|
@@ -1431,8 +1425,7 @@ function startApplePaySession(config) {
|
|
|
1431
1425
|
};
|
|
1432
1426
|
trackWalletPaymentSheetOpen(config.skuId);
|
|
1433
1427
|
session.begin();
|
|
1434
|
-
} catch
|
|
1435
|
-
console.error("[web-apple-pay] startApplePaySession: failed to create session", err);
|
|
1428
|
+
} catch {
|
|
1436
1429
|
redirectToFallbackCheckout(config);
|
|
1437
1430
|
}
|
|
1438
1431
|
}
|
|
@@ -1647,7 +1640,6 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1647
1640
|
failApplePaySession(session, err.errors);
|
|
1648
1641
|
return;
|
|
1649
1642
|
}
|
|
1650
|
-
console.error("[web-apple-pay] onpaymentauthorized error", { skuId, err });
|
|
1651
1643
|
const walletError = parseWalletApiError(err);
|
|
1652
1644
|
trackWalletPaymentFailure(skuId, walletError?.errorType ?? "UNKNOWN");
|
|
1653
1645
|
failApplePaySession(session);
|
|
@@ -1925,7 +1917,6 @@ var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
|
1925
1917
|
var TOTAL_LABEL = "The Economist";
|
|
1926
1918
|
var DEFAULT_CURRENCY = "USD";
|
|
1927
1919
|
var DEFAULT_TOTAL = "0.00";
|
|
1928
|
-
var ERROR_INITIATE = "Failed to initiate Apple Pay session:";
|
|
1929
1920
|
var SEL_CONTAINER = ".apple-pay-container";
|
|
1930
1921
|
var SEL_BUTTON = ".apple-pay-btn";
|
|
1931
1922
|
var APPLE_PAY_EXCLUDED_VARIANTS = [
|
|
@@ -2057,8 +2048,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2057
2048
|
this.#computeBillingCountries();
|
|
2058
2049
|
if (await this.#fetchAndCacheOptions()) return;
|
|
2059
2050
|
this.#finishLoading();
|
|
2060
|
-
} catch
|
|
2061
|
-
console.error("[web-apple-pay] #run: unexpected error, hiding button", err);
|
|
2051
|
+
} catch {
|
|
2062
2052
|
this.style.display = "none";
|
|
2063
2053
|
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2064
2054
|
} finally {
|
|
@@ -2197,8 +2187,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2197
2187
|
*/
|
|
2198
2188
|
#scheduleRecaptchaTokens() {
|
|
2199
2189
|
const attempt = getPurchaseRecaptchaTokens();
|
|
2200
|
-
attempt.catch((
|
|
2201
|
-
console.error("[web-apple-pay] reCAPTCHA token pre-fetch failed; will retry on modal open", err);
|
|
2190
|
+
attempt.catch(() => {
|
|
2202
2191
|
if (this.#recaptchaTokensPromise === attempt) {
|
|
2203
2192
|
this.#recaptchaTokensPromise = null;
|
|
2204
2193
|
}
|
|
@@ -2259,8 +2248,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2259
2248
|
recaptchaTokens
|
|
2260
2249
|
)
|
|
2261
2250
|
);
|
|
2262
|
-
} catch
|
|
2263
|
-
console.error(ERROR_INITIATE, error);
|
|
2251
|
+
} catch {
|
|
2264
2252
|
}
|
|
2265
2253
|
}
|
|
2266
2254
|
};
|
|
@@ -2269,6 +2257,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2269
2257
|
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
2270
2258
|
ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
|
|
2271
2259
|
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
2260
|
+
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
2272
2261
|
return ApplePayEntryPoint2;
|
|
2273
2262
|
})(ApplePayEntryPoint || {});
|
|
2274
2263
|
|
|
@@ -951,7 +951,6 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
|
|
|
951
951
|
cta.removeAttribute("aria-busy");
|
|
952
952
|
}
|
|
953
953
|
}).catch(() => {
|
|
954
|
-
console.error("[web-apple-pay] apple-pay-modal: failed to pre-fetch reCAPTCHA tokens; CTA remains disabled");
|
|
955
954
|
if (cta) {
|
|
956
955
|
cta.removeAttribute("aria-busy");
|
|
957
956
|
}
|
|
@@ -1137,15 +1136,11 @@ var isApplePayAvailable = async () => {
|
|
|
1137
1136
|
}
|
|
1138
1137
|
const merchantId = getApplePayConfig()?.merchantId;
|
|
1139
1138
|
if (!merchantId) {
|
|
1140
|
-
console.warn(
|
|
1141
|
-
"[web-apple-pay] Missing merchantId. Call configureApplePay({ merchantId, ... }) before rendering Apple Pay components."
|
|
1142
|
-
);
|
|
1143
1139
|
return false;
|
|
1144
1140
|
}
|
|
1145
1141
|
const hasActiveCard = await applePaySession.canMakePaymentsWithActiveCard(merchantId);
|
|
1146
1142
|
return hasActiveCard;
|
|
1147
|
-
} catch
|
|
1148
|
-
console.error("Error checking Apple Pay active card status:", error);
|
|
1143
|
+
} catch {
|
|
1149
1144
|
return false;
|
|
1150
1145
|
}
|
|
1151
1146
|
};
|
|
@@ -1392,8 +1387,7 @@ async function handleMerchantValidation(event, session, config) {
|
|
|
1392
1387
|
return;
|
|
1393
1388
|
}
|
|
1394
1389
|
session.completeMerchantValidation(response.merchantSession);
|
|
1395
|
-
} catch
|
|
1396
|
-
console.error("[web-apple-pay] onvalidatemerchant: error during validation", err);
|
|
1390
|
+
} catch {
|
|
1397
1391
|
session.abort();
|
|
1398
1392
|
redirectToFallbackCheckout(config);
|
|
1399
1393
|
}
|
|
@@ -1426,8 +1420,7 @@ function startApplePaySession(config) {
|
|
|
1426
1420
|
};
|
|
1427
1421
|
trackWalletPaymentSheetOpen(config.skuId);
|
|
1428
1422
|
session.begin();
|
|
1429
|
-
} catch
|
|
1430
|
-
console.error("[web-apple-pay] startApplePaySession: failed to create session", err);
|
|
1423
|
+
} catch {
|
|
1431
1424
|
redirectToFallbackCheckout(config);
|
|
1432
1425
|
}
|
|
1433
1426
|
}
|
|
@@ -1642,7 +1635,6 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1642
1635
|
failApplePaySession(session, err.errors);
|
|
1643
1636
|
return;
|
|
1644
1637
|
}
|
|
1645
|
-
console.error("[web-apple-pay] onpaymentauthorized error", { skuId, err });
|
|
1646
1638
|
const walletError = parseWalletApiError(err);
|
|
1647
1639
|
trackWalletPaymentFailure(skuId, walletError?.errorType ?? "UNKNOWN");
|
|
1648
1640
|
failApplePaySession(session);
|
|
@@ -1920,7 +1912,6 @@ var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
|
1920
1912
|
var TOTAL_LABEL = "The Economist";
|
|
1921
1913
|
var DEFAULT_CURRENCY = "USD";
|
|
1922
1914
|
var DEFAULT_TOTAL = "0.00";
|
|
1923
|
-
var ERROR_INITIATE = "Failed to initiate Apple Pay session:";
|
|
1924
1915
|
var SEL_CONTAINER = ".apple-pay-container";
|
|
1925
1916
|
var SEL_BUTTON = ".apple-pay-btn";
|
|
1926
1917
|
var APPLE_PAY_EXCLUDED_VARIANTS = [
|
|
@@ -2052,8 +2043,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2052
2043
|
this.#computeBillingCountries();
|
|
2053
2044
|
if (await this.#fetchAndCacheOptions()) return;
|
|
2054
2045
|
this.#finishLoading();
|
|
2055
|
-
} catch
|
|
2056
|
-
console.error("[web-apple-pay] #run: unexpected error, hiding button", err);
|
|
2046
|
+
} catch {
|
|
2057
2047
|
this.style.display = "none";
|
|
2058
2048
|
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2059
2049
|
} finally {
|
|
@@ -2192,8 +2182,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2192
2182
|
*/
|
|
2193
2183
|
#scheduleRecaptchaTokens() {
|
|
2194
2184
|
const attempt = getPurchaseRecaptchaTokens();
|
|
2195
|
-
attempt.catch((
|
|
2196
|
-
console.error("[web-apple-pay] reCAPTCHA token pre-fetch failed; will retry on modal open", err);
|
|
2185
|
+
attempt.catch(() => {
|
|
2197
2186
|
if (this.#recaptchaTokensPromise === attempt) {
|
|
2198
2187
|
this.#recaptchaTokensPromise = null;
|
|
2199
2188
|
}
|
|
@@ -2254,8 +2243,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2254
2243
|
recaptchaTokens
|
|
2255
2244
|
)
|
|
2256
2245
|
);
|
|
2257
|
-
} catch
|
|
2258
|
-
console.error(ERROR_INITIATE, error);
|
|
2246
|
+
} catch {
|
|
2259
2247
|
}
|
|
2260
2248
|
}
|
|
2261
2249
|
};
|
|
@@ -959,7 +959,6 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
|
|
|
959
959
|
cta.removeAttribute("aria-busy");
|
|
960
960
|
}
|
|
961
961
|
}).catch(() => {
|
|
962
|
-
console.error("[web-apple-pay] apple-pay-modal: failed to pre-fetch reCAPTCHA tokens; CTA remains disabled");
|
|
963
962
|
if (cta) {
|
|
964
963
|
cta.removeAttribute("aria-busy");
|
|
965
964
|
}
|
|
@@ -1145,15 +1144,11 @@ var isApplePayAvailable = async () => {
|
|
|
1145
1144
|
}
|
|
1146
1145
|
const merchantId = getApplePayConfig()?.merchantId;
|
|
1147
1146
|
if (!merchantId) {
|
|
1148
|
-
console.warn(
|
|
1149
|
-
"[web-apple-pay] Missing merchantId. Call configureApplePay({ merchantId, ... }) before rendering Apple Pay components."
|
|
1150
|
-
);
|
|
1151
1147
|
return false;
|
|
1152
1148
|
}
|
|
1153
1149
|
const hasActiveCard = await applePaySession.canMakePaymentsWithActiveCard(merchantId);
|
|
1154
1150
|
return hasActiveCard;
|
|
1155
|
-
} catch
|
|
1156
|
-
console.error("Error checking Apple Pay active card status:", error);
|
|
1151
|
+
} catch {
|
|
1157
1152
|
return false;
|
|
1158
1153
|
}
|
|
1159
1154
|
};
|
|
@@ -1400,8 +1395,7 @@ async function handleMerchantValidation(event, session, config) {
|
|
|
1400
1395
|
return;
|
|
1401
1396
|
}
|
|
1402
1397
|
session.completeMerchantValidation(response.merchantSession);
|
|
1403
|
-
} catch
|
|
1404
|
-
console.error("[web-apple-pay] onvalidatemerchant: error during validation", err);
|
|
1398
|
+
} catch {
|
|
1405
1399
|
session.abort();
|
|
1406
1400
|
redirectToFallbackCheckout(config);
|
|
1407
1401
|
}
|
|
@@ -1434,8 +1428,7 @@ function startApplePaySession(config) {
|
|
|
1434
1428
|
};
|
|
1435
1429
|
trackWalletPaymentSheetOpen(config.skuId);
|
|
1436
1430
|
session.begin();
|
|
1437
|
-
} catch
|
|
1438
|
-
console.error("[web-apple-pay] startApplePaySession: failed to create session", err);
|
|
1431
|
+
} catch {
|
|
1439
1432
|
redirectToFallbackCheckout(config);
|
|
1440
1433
|
}
|
|
1441
1434
|
}
|
|
@@ -1650,7 +1643,6 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1650
1643
|
failApplePaySession(session, err.errors);
|
|
1651
1644
|
return;
|
|
1652
1645
|
}
|
|
1653
|
-
console.error("[web-apple-pay] onpaymentauthorized error", { skuId, err });
|
|
1654
1646
|
const walletError = parseWalletApiError(err);
|
|
1655
1647
|
trackWalletPaymentFailure(skuId, walletError?.errorType ?? "UNKNOWN");
|
|
1656
1648
|
failApplePaySession(session);
|
|
@@ -1928,7 +1920,6 @@ var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
|
1928
1920
|
var TOTAL_LABEL = "The Economist";
|
|
1929
1921
|
var DEFAULT_CURRENCY = "USD";
|
|
1930
1922
|
var DEFAULT_TOTAL = "0.00";
|
|
1931
|
-
var ERROR_INITIATE = "Failed to initiate Apple Pay session:";
|
|
1932
1923
|
var SEL_CONTAINER = ".apple-pay-container";
|
|
1933
1924
|
var SEL_BUTTON = ".apple-pay-btn";
|
|
1934
1925
|
var APPLE_PAY_EXCLUDED_VARIANTS = [
|
|
@@ -2060,8 +2051,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2060
2051
|
this.#computeBillingCountries();
|
|
2061
2052
|
if (await this.#fetchAndCacheOptions()) return;
|
|
2062
2053
|
this.#finishLoading();
|
|
2063
|
-
} catch
|
|
2064
|
-
console.error("[web-apple-pay] #run: unexpected error, hiding button", err);
|
|
2054
|
+
} catch {
|
|
2065
2055
|
this.style.display = "none";
|
|
2066
2056
|
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2067
2057
|
} finally {
|
|
@@ -2200,8 +2190,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2200
2190
|
*/
|
|
2201
2191
|
#scheduleRecaptchaTokens() {
|
|
2202
2192
|
const attempt = getPurchaseRecaptchaTokens();
|
|
2203
|
-
attempt.catch((
|
|
2204
|
-
console.error("[web-apple-pay] reCAPTCHA token pre-fetch failed; will retry on modal open", err);
|
|
2193
|
+
attempt.catch(() => {
|
|
2205
2194
|
if (this.#recaptchaTokensPromise === attempt) {
|
|
2206
2195
|
this.#recaptchaTokensPromise = null;
|
|
2207
2196
|
}
|
|
@@ -2262,8 +2251,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2262
2251
|
recaptchaTokens
|
|
2263
2252
|
)
|
|
2264
2253
|
);
|
|
2265
|
-
} catch
|
|
2266
|
-
console.error(ERROR_INITIATE, error);
|
|
2254
|
+
} catch {
|
|
2267
2255
|
}
|
|
2268
2256
|
}
|
|
2269
2257
|
};
|
|
@@ -951,7 +951,6 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
|
|
|
951
951
|
cta.removeAttribute("aria-busy");
|
|
952
952
|
}
|
|
953
953
|
}).catch(() => {
|
|
954
|
-
console.error("[web-apple-pay] apple-pay-modal: failed to pre-fetch reCAPTCHA tokens; CTA remains disabled");
|
|
955
954
|
if (cta) {
|
|
956
955
|
cta.removeAttribute("aria-busy");
|
|
957
956
|
}
|
|
@@ -951,7 +951,6 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
|
|
|
951
951
|
cta.removeAttribute("aria-busy");
|
|
952
952
|
}
|
|
953
953
|
}).catch(() => {
|
|
954
|
-
console.error("[web-apple-pay] apple-pay-modal: failed to pre-fetch reCAPTCHA tokens; CTA remains disabled");
|
|
955
954
|
if (cta) {
|
|
956
955
|
cta.removeAttribute("aria-busy");
|
|
957
956
|
}
|
|
@@ -1137,15 +1136,11 @@ var isApplePayAvailable = async () => {
|
|
|
1137
1136
|
}
|
|
1138
1137
|
const merchantId = getApplePayConfig()?.merchantId;
|
|
1139
1138
|
if (!merchantId) {
|
|
1140
|
-
console.warn(
|
|
1141
|
-
"[web-apple-pay] Missing merchantId. Call configureApplePay({ merchantId, ... }) before rendering Apple Pay components."
|
|
1142
|
-
);
|
|
1143
1139
|
return false;
|
|
1144
1140
|
}
|
|
1145
1141
|
const hasActiveCard = await applePaySession.canMakePaymentsWithActiveCard(merchantId);
|
|
1146
1142
|
return hasActiveCard;
|
|
1147
|
-
} catch
|
|
1148
|
-
console.error("Error checking Apple Pay active card status:", error);
|
|
1143
|
+
} catch {
|
|
1149
1144
|
return false;
|
|
1150
1145
|
}
|
|
1151
1146
|
};
|
|
@@ -1392,8 +1387,7 @@ async function handleMerchantValidation(event, session, config) {
|
|
|
1392
1387
|
return;
|
|
1393
1388
|
}
|
|
1394
1389
|
session.completeMerchantValidation(response.merchantSession);
|
|
1395
|
-
} catch
|
|
1396
|
-
console.error("[web-apple-pay] onvalidatemerchant: error during validation", err);
|
|
1390
|
+
} catch {
|
|
1397
1391
|
session.abort();
|
|
1398
1392
|
redirectToFallbackCheckout(config);
|
|
1399
1393
|
}
|
|
@@ -1426,8 +1420,7 @@ function startApplePaySession(config) {
|
|
|
1426
1420
|
};
|
|
1427
1421
|
trackWalletPaymentSheetOpen(config.skuId);
|
|
1428
1422
|
session.begin();
|
|
1429
|
-
} catch
|
|
1430
|
-
console.error("[web-apple-pay] startApplePaySession: failed to create session", err);
|
|
1423
|
+
} catch {
|
|
1431
1424
|
redirectToFallbackCheckout(config);
|
|
1432
1425
|
}
|
|
1433
1426
|
}
|
|
@@ -1642,7 +1635,6 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1642
1635
|
failApplePaySession(session, err.errors);
|
|
1643
1636
|
return;
|
|
1644
1637
|
}
|
|
1645
|
-
console.error("[web-apple-pay] onpaymentauthorized error", { skuId, err });
|
|
1646
1638
|
const walletError = parseWalletApiError(err);
|
|
1647
1639
|
trackWalletPaymentFailure(skuId, walletError?.errorType ?? "UNKNOWN");
|
|
1648
1640
|
failApplePaySession(session);
|
|
@@ -1920,7 +1912,6 @@ var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
|
1920
1912
|
var TOTAL_LABEL = "The Economist";
|
|
1921
1913
|
var DEFAULT_CURRENCY = "USD";
|
|
1922
1914
|
var DEFAULT_TOTAL = "0.00";
|
|
1923
|
-
var ERROR_INITIATE = "Failed to initiate Apple Pay session:";
|
|
1924
1915
|
var SEL_CONTAINER = ".apple-pay-container";
|
|
1925
1916
|
var SEL_BUTTON = ".apple-pay-btn";
|
|
1926
1917
|
var APPLE_PAY_EXCLUDED_VARIANTS = [
|
|
@@ -2052,8 +2043,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2052
2043
|
this.#computeBillingCountries();
|
|
2053
2044
|
if (await this.#fetchAndCacheOptions()) return;
|
|
2054
2045
|
this.#finishLoading();
|
|
2055
|
-
} catch
|
|
2056
|
-
console.error("[web-apple-pay] #run: unexpected error, hiding button", err);
|
|
2046
|
+
} catch {
|
|
2057
2047
|
this.style.display = "none";
|
|
2058
2048
|
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2059
2049
|
} finally {
|
|
@@ -2192,8 +2182,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2192
2182
|
*/
|
|
2193
2183
|
#scheduleRecaptchaTokens() {
|
|
2194
2184
|
const attempt = getPurchaseRecaptchaTokens();
|
|
2195
|
-
attempt.catch((
|
|
2196
|
-
console.error("[web-apple-pay] reCAPTCHA token pre-fetch failed; will retry on modal open", err);
|
|
2185
|
+
attempt.catch(() => {
|
|
2197
2186
|
if (this.#recaptchaTokensPromise === attempt) {
|
|
2198
2187
|
this.#recaptchaTokensPromise = null;
|
|
2199
2188
|
}
|
|
@@ -2254,8 +2243,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2254
2243
|
recaptchaTokens
|
|
2255
2244
|
)
|
|
2256
2245
|
);
|
|
2257
|
-
} catch
|
|
2258
|
-
console.error(ERROR_INITIATE, error);
|
|
2246
|
+
} catch {
|
|
2259
2247
|
}
|
|
2260
2248
|
}
|
|
2261
2249
|
};
|
|
@@ -211,8 +211,7 @@ async function handleMerchantValidation(event, session, config) {
|
|
|
211
211
|
return;
|
|
212
212
|
}
|
|
213
213
|
session.completeMerchantValidation(response.merchantSession);
|
|
214
|
-
} catch
|
|
215
|
-
console.error("[web-apple-pay] onvalidatemerchant: error during validation", err);
|
|
214
|
+
} catch {
|
|
216
215
|
session.abort();
|
|
217
216
|
redirectToFallbackCheckout(config);
|
|
218
217
|
}
|
|
@@ -245,8 +244,7 @@ function startApplePaySession(config) {
|
|
|
245
244
|
};
|
|
246
245
|
trackWalletPaymentSheetOpen(config.skuId);
|
|
247
246
|
session.begin();
|
|
248
|
-
} catch
|
|
249
|
-
console.error("[web-apple-pay] startApplePaySession: failed to create session", err);
|
|
247
|
+
} catch {
|
|
250
248
|
redirectToFallbackCheckout(config);
|
|
251
249
|
}
|
|
252
250
|
}
|
|
@@ -29,15 +29,11 @@ var isApplePayAvailable = async () => {
|
|
|
29
29
|
}
|
|
30
30
|
const merchantId = getApplePayConfig()?.merchantId;
|
|
31
31
|
if (!merchantId) {
|
|
32
|
-
console.warn(
|
|
33
|
-
"[web-apple-pay] Missing merchantId. Call configureApplePay({ merchantId, ... }) before rendering Apple Pay components."
|
|
34
|
-
);
|
|
35
32
|
return false;
|
|
36
33
|
}
|
|
37
34
|
const hasActiveCard = await applePaySession.canMakePaymentsWithActiveCard(merchantId);
|
|
38
35
|
return hasActiveCard;
|
|
39
|
-
} catch
|
|
40
|
-
console.error("Error checking Apple Pay active card status:", error);
|
|
36
|
+
} catch {
|
|
41
37
|
return false;
|
|
42
38
|
}
|
|
43
39
|
};
|
|
@@ -378,7 +378,6 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
378
378
|
failApplePaySession(session, err.errors);
|
|
379
379
|
return;
|
|
380
380
|
}
|
|
381
|
-
console.error("[web-apple-pay] onpaymentauthorized error", { skuId, err });
|
|
382
381
|
const walletError = parseWalletApiError(err);
|
|
383
382
|
trackWalletPaymentFailure(skuId, walletError?.errorType ?? "UNKNOWN");
|
|
384
383
|
failApplePaySession(session);
|
package/dist/src/constants.d.ts
CHANGED
package/dist/src/constants.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
3
3
|
ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
|
|
4
4
|
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
5
|
+
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
5
6
|
return ApplePayEntryPoint2;
|
|
6
7
|
})(ApplePayEntryPoint || {});
|
|
7
8
|
export {
|
package/dist/src/index.js
CHANGED
|
@@ -956,7 +956,6 @@ var ApplePayModal = class _ApplePayModal extends HTMLElement {
|
|
|
956
956
|
cta.removeAttribute("aria-busy");
|
|
957
957
|
}
|
|
958
958
|
}).catch(() => {
|
|
959
|
-
console.error("[web-apple-pay] apple-pay-modal: failed to pre-fetch reCAPTCHA tokens; CTA remains disabled");
|
|
960
959
|
if (cta) {
|
|
961
960
|
cta.removeAttribute("aria-busy");
|
|
962
961
|
}
|
|
@@ -1142,15 +1141,11 @@ var isApplePayAvailable = async () => {
|
|
|
1142
1141
|
}
|
|
1143
1142
|
const merchantId = getApplePayConfig()?.merchantId;
|
|
1144
1143
|
if (!merchantId) {
|
|
1145
|
-
console.warn(
|
|
1146
|
-
"[web-apple-pay] Missing merchantId. Call configureApplePay({ merchantId, ... }) before rendering Apple Pay components."
|
|
1147
|
-
);
|
|
1148
1144
|
return false;
|
|
1149
1145
|
}
|
|
1150
1146
|
const hasActiveCard = await applePaySession.canMakePaymentsWithActiveCard(merchantId);
|
|
1151
1147
|
return hasActiveCard;
|
|
1152
|
-
} catch
|
|
1153
|
-
console.error("Error checking Apple Pay active card status:", error);
|
|
1148
|
+
} catch {
|
|
1154
1149
|
return false;
|
|
1155
1150
|
}
|
|
1156
1151
|
};
|
|
@@ -1397,8 +1392,7 @@ async function handleMerchantValidation(event, session, config) {
|
|
|
1397
1392
|
return;
|
|
1398
1393
|
}
|
|
1399
1394
|
session.completeMerchantValidation(response.merchantSession);
|
|
1400
|
-
} catch
|
|
1401
|
-
console.error("[web-apple-pay] onvalidatemerchant: error during validation", err);
|
|
1395
|
+
} catch {
|
|
1402
1396
|
session.abort();
|
|
1403
1397
|
redirectToFallbackCheckout(config);
|
|
1404
1398
|
}
|
|
@@ -1431,8 +1425,7 @@ function startApplePaySession(config) {
|
|
|
1431
1425
|
};
|
|
1432
1426
|
trackWalletPaymentSheetOpen(config.skuId);
|
|
1433
1427
|
session.begin();
|
|
1434
|
-
} catch
|
|
1435
|
-
console.error("[web-apple-pay] startApplePaySession: failed to create session", err);
|
|
1428
|
+
} catch {
|
|
1436
1429
|
redirectToFallbackCheckout(config);
|
|
1437
1430
|
}
|
|
1438
1431
|
}
|
|
@@ -1647,7 +1640,6 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1647
1640
|
failApplePaySession(session, err.errors);
|
|
1648
1641
|
return;
|
|
1649
1642
|
}
|
|
1650
|
-
console.error("[web-apple-pay] onpaymentauthorized error", { skuId, err });
|
|
1651
1643
|
const walletError = parseWalletApiError(err);
|
|
1652
1644
|
trackWalletPaymentFailure(skuId, walletError?.errorType ?? "UNKNOWN");
|
|
1653
1645
|
failApplePaySession(session);
|
|
@@ -1925,7 +1917,6 @@ var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
|
|
|
1925
1917
|
var TOTAL_LABEL = "The Economist";
|
|
1926
1918
|
var DEFAULT_CURRENCY = "USD";
|
|
1927
1919
|
var DEFAULT_TOTAL = "0.00";
|
|
1928
|
-
var ERROR_INITIATE = "Failed to initiate Apple Pay session:";
|
|
1929
1920
|
var SEL_CONTAINER = ".apple-pay-container";
|
|
1930
1921
|
var SEL_BUTTON = ".apple-pay-btn";
|
|
1931
1922
|
var APPLE_PAY_EXCLUDED_VARIANTS = [
|
|
@@ -2057,8 +2048,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2057
2048
|
this.#computeBillingCountries();
|
|
2058
2049
|
if (await this.#fetchAndCacheOptions()) return;
|
|
2059
2050
|
this.#finishLoading();
|
|
2060
|
-
} catch
|
|
2061
|
-
console.error("[web-apple-pay] #run: unexpected error, hiding button", err);
|
|
2051
|
+
} catch {
|
|
2062
2052
|
this.style.display = "none";
|
|
2063
2053
|
this.querySelector(SEL_CONTAINER)?.remove();
|
|
2064
2054
|
} finally {
|
|
@@ -2197,8 +2187,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2197
2187
|
*/
|
|
2198
2188
|
#scheduleRecaptchaTokens() {
|
|
2199
2189
|
const attempt = getPurchaseRecaptchaTokens();
|
|
2200
|
-
attempt.catch((
|
|
2201
|
-
console.error("[web-apple-pay] reCAPTCHA token pre-fetch failed; will retry on modal open", err);
|
|
2190
|
+
attempt.catch(() => {
|
|
2202
2191
|
if (this.#recaptchaTokensPromise === attempt) {
|
|
2203
2192
|
this.#recaptchaTokensPromise = null;
|
|
2204
2193
|
}
|
|
@@ -2259,8 +2248,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2259
2248
|
recaptchaTokens
|
|
2260
2249
|
)
|
|
2261
2250
|
);
|
|
2262
|
-
} catch
|
|
2263
|
-
console.error(ERROR_INITIATE, error);
|
|
2251
|
+
} catch {
|
|
2264
2252
|
}
|
|
2265
2253
|
}
|
|
2266
2254
|
};
|
|
@@ -2269,6 +2257,7 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2269
2257
|
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
2270
2258
|
ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
|
|
2271
2259
|
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
2260
|
+
ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
|
|
2272
2261
|
return ApplePayEntryPoint2;
|
|
2273
2262
|
})(ApplePayEntryPoint || {});
|
|
2274
2263
|
|