@economist/web-apple-pay 0.1.3-beta.50 → 0.1.3-beta.52
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 +8 -5
- package/dist/src/apple-pay-button.js +8 -5
- package/dist/src/apple-pay-button.stories.js +8 -5
- package/dist/src/apple-pay-modal.stories.js +8 -5
- package/dist/src/clients/payment-checkout/messages.d.ts +5 -0
- package/dist/src/clients/payment-checkout/messages.js +7 -3
- package/dist/src/clients/payment-checkout/payment-handler.js +8 -5
- package/dist/src/index.js +8 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1383,12 +1383,15 @@ var MSG_EMAIL_WRONG_FORMAT = "That email doesn\u2019t look right. Please enter a
|
|
|
1383
1383
|
var MSG_EMAIL_TOO_LONG = "This field must be 80 characters or less.";
|
|
1384
1384
|
var MSG_UNSUPPORTED_BILLING_COUNTRY = "Billing country does not match offer price zone";
|
|
1385
1385
|
var BILLING_COUNTRY_MISMATCH_FALLBACK = "Country not supported for this purchase";
|
|
1386
|
+
var MSG_BILLING_COUNTRY_MISMATCH_REDIRECT = "This country isn\u2019t supported for this purchase. Try updating your billing address.";
|
|
1386
1387
|
var buildCountryMismatchMessage = (countryCode) => {
|
|
1387
1388
|
if (!countryCode) return BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
1388
1389
|
try {
|
|
1389
|
-
const regionNames = new Intl.DisplayNames(["en"], { type: "region" });
|
|
1390
|
-
const
|
|
1391
|
-
|
|
1390
|
+
const regionNames = new Intl.DisplayNames(["en"], { type: "region", fallback: "none" });
|
|
1391
|
+
const upper = countryCode.toUpperCase();
|
|
1392
|
+
const countryName = regionNames.of(upper);
|
|
1393
|
+
const isResolved = countryName && countryName !== upper && countryName !== "Unknown Region";
|
|
1394
|
+
return isResolved ? `${countryName} address required` : BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
1392
1395
|
} catch {
|
|
1393
1396
|
return BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
1394
1397
|
}
|
|
@@ -1674,7 +1677,7 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1674
1677
|
} catch (err) {
|
|
1675
1678
|
if (err instanceof ContactValidationError) {
|
|
1676
1679
|
const isBillingCountryMismatch = err.errors.some(
|
|
1677
|
-
(e) => e.
|
|
1680
|
+
(e) => e.contactField === "countryCode"
|
|
1678
1681
|
);
|
|
1679
1682
|
if (isBillingCountryMismatch) {
|
|
1680
1683
|
const countryCode = event.payment.billingContact?.countryCode;
|
|
@@ -1682,7 +1685,7 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1682
1685
|
failApplePaySession(session, [
|
|
1683
1686
|
new ApplePayError("billingContactInvalid", "countryCode", userMessage)
|
|
1684
1687
|
]);
|
|
1685
|
-
redirectFallback(skuId, returnUrl, country, { inlineError:
|
|
1688
|
+
redirectFallback(skuId, returnUrl, country, { inlineError: MSG_BILLING_COUNTRY_MISMATCH_REDIRECT });
|
|
1686
1689
|
} else {
|
|
1687
1690
|
failApplePaySession(session, err.errors);
|
|
1688
1691
|
}
|
|
@@ -1378,12 +1378,15 @@ var MSG_EMAIL_WRONG_FORMAT = "That email doesn\u2019t look right. Please enter a
|
|
|
1378
1378
|
var MSG_EMAIL_TOO_LONG = "This field must be 80 characters or less.";
|
|
1379
1379
|
var MSG_UNSUPPORTED_BILLING_COUNTRY = "Billing country does not match offer price zone";
|
|
1380
1380
|
var BILLING_COUNTRY_MISMATCH_FALLBACK = "Country not supported for this purchase";
|
|
1381
|
+
var MSG_BILLING_COUNTRY_MISMATCH_REDIRECT = "This country isn\u2019t supported for this purchase. Try updating your billing address.";
|
|
1381
1382
|
var buildCountryMismatchMessage = (countryCode) => {
|
|
1382
1383
|
if (!countryCode) return BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
1383
1384
|
try {
|
|
1384
|
-
const regionNames = new Intl.DisplayNames(["en"], { type: "region" });
|
|
1385
|
-
const
|
|
1386
|
-
|
|
1385
|
+
const regionNames = new Intl.DisplayNames(["en"], { type: "region", fallback: "none" });
|
|
1386
|
+
const upper = countryCode.toUpperCase();
|
|
1387
|
+
const countryName = regionNames.of(upper);
|
|
1388
|
+
const isResolved = countryName && countryName !== upper && countryName !== "Unknown Region";
|
|
1389
|
+
return isResolved ? `${countryName} address required` : BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
1387
1390
|
} catch {
|
|
1388
1391
|
return BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
1389
1392
|
}
|
|
@@ -1669,7 +1672,7 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1669
1672
|
} catch (err) {
|
|
1670
1673
|
if (err instanceof ContactValidationError) {
|
|
1671
1674
|
const isBillingCountryMismatch = err.errors.some(
|
|
1672
|
-
(e) => e.
|
|
1675
|
+
(e) => e.contactField === "countryCode"
|
|
1673
1676
|
);
|
|
1674
1677
|
if (isBillingCountryMismatch) {
|
|
1675
1678
|
const countryCode = event.payment.billingContact?.countryCode;
|
|
@@ -1677,7 +1680,7 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1677
1680
|
failApplePaySession(session, [
|
|
1678
1681
|
new ApplePayError("billingContactInvalid", "countryCode", userMessage)
|
|
1679
1682
|
]);
|
|
1680
|
-
redirectFallback(skuId, returnUrl, country, { inlineError:
|
|
1683
|
+
redirectFallback(skuId, returnUrl, country, { inlineError: MSG_BILLING_COUNTRY_MISMATCH_REDIRECT });
|
|
1681
1684
|
} else {
|
|
1682
1685
|
failApplePaySession(session, err.errors);
|
|
1683
1686
|
}
|
|
@@ -1386,12 +1386,15 @@ var MSG_EMAIL_WRONG_FORMAT = "That email doesn\u2019t look right. Please enter a
|
|
|
1386
1386
|
var MSG_EMAIL_TOO_LONG = "This field must be 80 characters or less.";
|
|
1387
1387
|
var MSG_UNSUPPORTED_BILLING_COUNTRY = "Billing country does not match offer price zone";
|
|
1388
1388
|
var BILLING_COUNTRY_MISMATCH_FALLBACK = "Country not supported for this purchase";
|
|
1389
|
+
var MSG_BILLING_COUNTRY_MISMATCH_REDIRECT = "This country isn\u2019t supported for this purchase. Try updating your billing address.";
|
|
1389
1390
|
var buildCountryMismatchMessage = (countryCode) => {
|
|
1390
1391
|
if (!countryCode) return BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
1391
1392
|
try {
|
|
1392
|
-
const regionNames = new Intl.DisplayNames(["en"], { type: "region" });
|
|
1393
|
-
const
|
|
1394
|
-
|
|
1393
|
+
const regionNames = new Intl.DisplayNames(["en"], { type: "region", fallback: "none" });
|
|
1394
|
+
const upper = countryCode.toUpperCase();
|
|
1395
|
+
const countryName = regionNames.of(upper);
|
|
1396
|
+
const isResolved = countryName && countryName !== upper && countryName !== "Unknown Region";
|
|
1397
|
+
return isResolved ? `${countryName} address required` : BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
1395
1398
|
} catch {
|
|
1396
1399
|
return BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
1397
1400
|
}
|
|
@@ -1677,7 +1680,7 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1677
1680
|
} catch (err) {
|
|
1678
1681
|
if (err instanceof ContactValidationError) {
|
|
1679
1682
|
const isBillingCountryMismatch = err.errors.some(
|
|
1680
|
-
(e) => e.
|
|
1683
|
+
(e) => e.contactField === "countryCode"
|
|
1681
1684
|
);
|
|
1682
1685
|
if (isBillingCountryMismatch) {
|
|
1683
1686
|
const countryCode = event.payment.billingContact?.countryCode;
|
|
@@ -1685,7 +1688,7 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1685
1688
|
failApplePaySession(session, [
|
|
1686
1689
|
new ApplePayError("billingContactInvalid", "countryCode", userMessage)
|
|
1687
1690
|
]);
|
|
1688
|
-
redirectFallback(skuId, returnUrl, country, { inlineError:
|
|
1691
|
+
redirectFallback(skuId, returnUrl, country, { inlineError: MSG_BILLING_COUNTRY_MISMATCH_REDIRECT });
|
|
1689
1692
|
} else {
|
|
1690
1693
|
failApplePaySession(session, err.errors);
|
|
1691
1694
|
}
|
|
@@ -1378,12 +1378,15 @@ var MSG_EMAIL_WRONG_FORMAT = "That email doesn\u2019t look right. Please enter a
|
|
|
1378
1378
|
var MSG_EMAIL_TOO_LONG = "This field must be 80 characters or less.";
|
|
1379
1379
|
var MSG_UNSUPPORTED_BILLING_COUNTRY = "Billing country does not match offer price zone";
|
|
1380
1380
|
var BILLING_COUNTRY_MISMATCH_FALLBACK = "Country not supported for this purchase";
|
|
1381
|
+
var MSG_BILLING_COUNTRY_MISMATCH_REDIRECT = "This country isn\u2019t supported for this purchase. Try updating your billing address.";
|
|
1381
1382
|
var buildCountryMismatchMessage = (countryCode) => {
|
|
1382
1383
|
if (!countryCode) return BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
1383
1384
|
try {
|
|
1384
|
-
const regionNames = new Intl.DisplayNames(["en"], { type: "region" });
|
|
1385
|
-
const
|
|
1386
|
-
|
|
1385
|
+
const regionNames = new Intl.DisplayNames(["en"], { type: "region", fallback: "none" });
|
|
1386
|
+
const upper = countryCode.toUpperCase();
|
|
1387
|
+
const countryName = regionNames.of(upper);
|
|
1388
|
+
const isResolved = countryName && countryName !== upper && countryName !== "Unknown Region";
|
|
1389
|
+
return isResolved ? `${countryName} address required` : BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
1387
1390
|
} catch {
|
|
1388
1391
|
return BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
1389
1392
|
}
|
|
@@ -1669,7 +1672,7 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1669
1672
|
} catch (err) {
|
|
1670
1673
|
if (err instanceof ContactValidationError) {
|
|
1671
1674
|
const isBillingCountryMismatch = err.errors.some(
|
|
1672
|
-
(e) => e.
|
|
1675
|
+
(e) => e.contactField === "countryCode"
|
|
1673
1676
|
);
|
|
1674
1677
|
if (isBillingCountryMismatch) {
|
|
1675
1678
|
const countryCode = event.payment.billingContact?.countryCode;
|
|
@@ -1677,7 +1680,7 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1677
1680
|
failApplePaySession(session, [
|
|
1678
1681
|
new ApplePayError("billingContactInvalid", "countryCode", userMessage)
|
|
1679
1682
|
]);
|
|
1680
|
-
redirectFallback(skuId, returnUrl, country, { inlineError:
|
|
1683
|
+
redirectFallback(skuId, returnUrl, country, { inlineError: MSG_BILLING_COUNTRY_MISMATCH_REDIRECT });
|
|
1681
1684
|
} else {
|
|
1682
1685
|
failApplePaySession(session, err.errors);
|
|
1683
1686
|
}
|
|
@@ -27,6 +27,11 @@ export declare const MSG_UNSUPPORTED_BILLING_COUNTRY = "Billing country does not
|
|
|
27
27
|
* name cannot be resolved from the country code.
|
|
28
28
|
*/
|
|
29
29
|
export declare const BILLING_COUNTRY_MISMATCH_FALLBACK = "Country not supported for this purchase";
|
|
30
|
+
/**
|
|
31
|
+
* User-facing message shown as an inlineError on the checkout redirect page
|
|
32
|
+
* when the billing country does not match the offer price zone.
|
|
33
|
+
*/
|
|
34
|
+
export declare const MSG_BILLING_COUNTRY_MISMATCH_REDIRECT = "This country isn\u2019t supported for this purchase. Try updating your billing address.";
|
|
30
35
|
/**
|
|
31
36
|
* Builds a short, user-facing message for a billing country mismatch, suitable
|
|
32
37
|
* for Apple's native payment sheet (~50 char limit).
|
|
@@ -4,12 +4,15 @@ var MSG_EMAIL_WRONG_FORMAT = "That email doesn\u2019t look right. Please enter a
|
|
|
4
4
|
var MSG_EMAIL_TOO_LONG = "This field must be 80 characters or less.";
|
|
5
5
|
var MSG_UNSUPPORTED_BILLING_COUNTRY = "Billing country does not match offer price zone";
|
|
6
6
|
var BILLING_COUNTRY_MISMATCH_FALLBACK = "Country not supported for this purchase";
|
|
7
|
+
var MSG_BILLING_COUNTRY_MISMATCH_REDIRECT = "This country isn\u2019t supported for this purchase. Try updating your billing address.";
|
|
7
8
|
var buildCountryMismatchMessage = (countryCode) => {
|
|
8
9
|
if (!countryCode) return BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
9
10
|
try {
|
|
10
|
-
const regionNames = new Intl.DisplayNames(["en"], { type: "region" });
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
const regionNames = new Intl.DisplayNames(["en"], { type: "region", fallback: "none" });
|
|
12
|
+
const upper = countryCode.toUpperCase();
|
|
13
|
+
const countryName = regionNames.of(upper);
|
|
14
|
+
const isResolved = countryName && countryName !== upper && countryName !== "Unknown Region";
|
|
15
|
+
return isResolved ? `${countryName} address required` : BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
13
16
|
} catch {
|
|
14
17
|
return BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
15
18
|
}
|
|
@@ -18,6 +21,7 @@ var MSG_PAYMENT_GENERIC_ERROR = "Something went wrong. Please check your payment
|
|
|
18
21
|
var MSG_CONTACT_VALIDATION_INTERNAL = "Could not validate Apple Pay contact";
|
|
19
22
|
export {
|
|
20
23
|
BILLING_COUNTRY_MISMATCH_FALLBACK,
|
|
24
|
+
MSG_BILLING_COUNTRY_MISMATCH_REDIRECT,
|
|
21
25
|
MSG_CONTACT_VALIDATION_INTERNAL,
|
|
22
26
|
MSG_EMAIL_TOO_LONG,
|
|
23
27
|
MSG_EMAIL_WRONG_FORMAT,
|
|
@@ -118,12 +118,15 @@ var MSG_EMAIL_WRONG_FORMAT = "That email doesn\u2019t look right. Please enter a
|
|
|
118
118
|
var MSG_EMAIL_TOO_LONG = "This field must be 80 characters or less.";
|
|
119
119
|
var MSG_UNSUPPORTED_BILLING_COUNTRY = "Billing country does not match offer price zone";
|
|
120
120
|
var BILLING_COUNTRY_MISMATCH_FALLBACK = "Country not supported for this purchase";
|
|
121
|
+
var MSG_BILLING_COUNTRY_MISMATCH_REDIRECT = "This country isn\u2019t supported for this purchase. Try updating your billing address.";
|
|
121
122
|
var buildCountryMismatchMessage = (countryCode) => {
|
|
122
123
|
if (!countryCode) return BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
123
124
|
try {
|
|
124
|
-
const regionNames = new Intl.DisplayNames(["en"], { type: "region" });
|
|
125
|
-
const
|
|
126
|
-
|
|
125
|
+
const regionNames = new Intl.DisplayNames(["en"], { type: "region", fallback: "none" });
|
|
126
|
+
const upper = countryCode.toUpperCase();
|
|
127
|
+
const countryName = regionNames.of(upper);
|
|
128
|
+
const isResolved = countryName && countryName !== upper && countryName !== "Unknown Region";
|
|
129
|
+
return isResolved ? `${countryName} address required` : BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
127
130
|
} catch {
|
|
128
131
|
return BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
129
132
|
}
|
|
@@ -387,7 +390,7 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
387
390
|
} catch (err) {
|
|
388
391
|
if (err instanceof ContactValidationError) {
|
|
389
392
|
const isBillingCountryMismatch = err.errors.some(
|
|
390
|
-
(e) => e.
|
|
393
|
+
(e) => e.contactField === "countryCode"
|
|
391
394
|
);
|
|
392
395
|
if (isBillingCountryMismatch) {
|
|
393
396
|
const countryCode = event.payment.billingContact?.countryCode;
|
|
@@ -395,7 +398,7 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
395
398
|
failApplePaySession(session, [
|
|
396
399
|
new ApplePayError("billingContactInvalid", "countryCode", userMessage)
|
|
397
400
|
]);
|
|
398
|
-
redirectFallback(skuId, returnUrl, country, { inlineError:
|
|
401
|
+
redirectFallback(skuId, returnUrl, country, { inlineError: MSG_BILLING_COUNTRY_MISMATCH_REDIRECT });
|
|
399
402
|
} else {
|
|
400
403
|
failApplePaySession(session, err.errors);
|
|
401
404
|
}
|
package/dist/src/index.js
CHANGED
|
@@ -1383,12 +1383,15 @@ var MSG_EMAIL_WRONG_FORMAT = "That email doesn\u2019t look right. Please enter a
|
|
|
1383
1383
|
var MSG_EMAIL_TOO_LONG = "This field must be 80 characters or less.";
|
|
1384
1384
|
var MSG_UNSUPPORTED_BILLING_COUNTRY = "Billing country does not match offer price zone";
|
|
1385
1385
|
var BILLING_COUNTRY_MISMATCH_FALLBACK = "Country not supported for this purchase";
|
|
1386
|
+
var MSG_BILLING_COUNTRY_MISMATCH_REDIRECT = "This country isn\u2019t supported for this purchase. Try updating your billing address.";
|
|
1386
1387
|
var buildCountryMismatchMessage = (countryCode) => {
|
|
1387
1388
|
if (!countryCode) return BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
1388
1389
|
try {
|
|
1389
|
-
const regionNames = new Intl.DisplayNames(["en"], { type: "region" });
|
|
1390
|
-
const
|
|
1391
|
-
|
|
1390
|
+
const regionNames = new Intl.DisplayNames(["en"], { type: "region", fallback: "none" });
|
|
1391
|
+
const upper = countryCode.toUpperCase();
|
|
1392
|
+
const countryName = regionNames.of(upper);
|
|
1393
|
+
const isResolved = countryName && countryName !== upper && countryName !== "Unknown Region";
|
|
1394
|
+
return isResolved ? `${countryName} address required` : BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
1392
1395
|
} catch {
|
|
1393
1396
|
return BILLING_COUNTRY_MISMATCH_FALLBACK;
|
|
1394
1397
|
}
|
|
@@ -1674,7 +1677,7 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1674
1677
|
} catch (err) {
|
|
1675
1678
|
if (err instanceof ContactValidationError) {
|
|
1676
1679
|
const isBillingCountryMismatch = err.errors.some(
|
|
1677
|
-
(e) => e.
|
|
1680
|
+
(e) => e.contactField === "countryCode"
|
|
1678
1681
|
);
|
|
1679
1682
|
if (isBillingCountryMismatch) {
|
|
1680
1683
|
const countryCode = event.payment.billingContact?.countryCode;
|
|
@@ -1682,7 +1685,7 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1682
1685
|
failApplePaySession(session, [
|
|
1683
1686
|
new ApplePayError("billingContactInvalid", "countryCode", userMessage)
|
|
1684
1687
|
]);
|
|
1685
|
-
redirectFallback(skuId, returnUrl, country, { inlineError:
|
|
1688
|
+
redirectFallback(skuId, returnUrl, country, { inlineError: MSG_BILLING_COUNTRY_MISMATCH_REDIRECT });
|
|
1686
1689
|
} else {
|
|
1687
1690
|
failApplePaySession(session, err.errors);
|
|
1688
1691
|
}
|
package/package.json
CHANGED