@economist/web-apple-pay 0.1.3-beta.23 → 0.1.3-beta.24
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 +11 -23
- package/dist/src/apple-pay-button.js +11 -23
- package/dist/src/apple-pay-button.stories.js +11 -23
- package/dist/src/apple-pay-modal.stories.js +11 -23
- package/dist/src/clients/payment-checkout/apple-session.js +0 -7
- package/dist/src/clients/payment-checkout/index.js +0 -7
- package/dist/src/clients/payment-checkout/messages.d.ts +11 -14
- package/dist/src/clients/payment-checkout/messages.js +0 -4
- package/dist/src/clients/payment-checkout/payment-handler.js +11 -23
- package/dist/src/clients/payment-checkout/session.js +0 -7
- package/dist/src/index.js +11 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1156,18 +1156,11 @@ var apiFetch = async (path, options = {}) => {
|
|
|
1156
1156
|
});
|
|
1157
1157
|
if (!response.ok) {
|
|
1158
1158
|
const contentType = response.headers.get("content-type") || "";
|
|
1159
|
-
console.warn("[web-apple-pay] apiFetch: non-2xx response", {
|
|
1160
|
-
path,
|
|
1161
|
-
status: response.status,
|
|
1162
|
-
contentType
|
|
1163
|
-
});
|
|
1164
1159
|
if (contentType.includes("application/json")) {
|
|
1165
1160
|
const errorBody = await response.json();
|
|
1166
|
-
console.warn("[web-apple-pay] apiFetch: parsed JSON error body", { errorBody });
|
|
1167
1161
|
throw new ApiError(response.status, errorBody);
|
|
1168
1162
|
}
|
|
1169
1163
|
const errorText = await response.text();
|
|
1170
|
-
console.warn("[web-apple-pay] apiFetch: non-JSON error body", { errorText });
|
|
1171
1164
|
throw new Error(
|
|
1172
1165
|
`API request failed: ${response.status} ${response.statusText} - ${errorText}`
|
|
1173
1166
|
);
|
|
@@ -1341,8 +1334,6 @@ var MSG_EMAIL_WRONG_FORMAT = "That email doesn\u2019t look right. Please enter a
|
|
|
1341
1334
|
var MSG_EMAIL_TOO_LONG = "This field must be 80 characters or less.";
|
|
1342
1335
|
var MSG_UNSUPPORTED_BILLING_COUNTRY = "Billing country does not match offer price zone";
|
|
1343
1336
|
var MSG_PAYMENT_GENERIC_ERROR = "Something went wrong. Please check your payment and billing details and try again or contact us.";
|
|
1344
|
-
var MSG_RECAPTCHA_VALIDATION_FAILED = "Security check failed. Please try again.";
|
|
1345
|
-
var MSG_EMAIL_COLLISION = "This email address is already linked to an account. Please log in, or try a different email address.";
|
|
1346
1337
|
var MSG_CONTACT_VALIDATION_INTERNAL = "Could not validate Apple Pay contact";
|
|
1347
1338
|
|
|
1348
1339
|
// src/clients/payment-checkout/apple-session.ts
|
|
@@ -1531,8 +1522,6 @@ var shippingContactDetails = (shippingContact) => {
|
|
|
1531
1522
|
};
|
|
1532
1523
|
|
|
1533
1524
|
// src/clients/payment-checkout/payment-handler.ts
|
|
1534
|
-
var MSG_ELIGIBILITY = "Something went wrong, please try again";
|
|
1535
|
-
var MSG_REGISTRATION = "We couldn't create your account. Please enter your email or try a different login method.";
|
|
1536
1525
|
var failApplePaySession = (session, errors = []) => {
|
|
1537
1526
|
session.completePayment({
|
|
1538
1527
|
status: ApplePaySession.STATUS_FAILURE,
|
|
@@ -1572,22 +1561,21 @@ function redirectFallback(skuId, returnUrl, country, options) {
|
|
|
1572
1561
|
});
|
|
1573
1562
|
}
|
|
1574
1563
|
var ERROR_HANDLERS = {
|
|
1575
|
-
|
|
1576
|
-
|
|
1564
|
+
// emailError flows as an inline field error on the email input.
|
|
1565
|
+
// email pre-populates the input so the user doesn't have to retype it.
|
|
1566
|
+
EMAIL_COLLISION: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
1567
|
+
emailError: walletError.message,
|
|
1577
1568
|
email: validatedEmail
|
|
1578
1569
|
}),
|
|
1579
|
-
PAYMENT_DECLINED: ({ skuId, returnUrl, country }) => (
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
),
|
|
1583
|
-
|
|
1584
|
-
REGISTRATION_FAILED: ({ skuId, returnUrl, country }) => redirectFallback(skuId, returnUrl, country, { inlineError: MSG_REGISTRATION }),
|
|
1585
|
-
ACCOUNT_CREATION_FAILED: ({ skuId, returnUrl, country, validatedEmail }) => redirectFallback(skuId, returnUrl, country, {
|
|
1586
|
-
emailError: MSG_REGISTRATION,
|
|
1570
|
+
PAYMENT_DECLINED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1571
|
+
ELIGIBILITY_REJECTED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1572
|
+
REGISTRATION_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1573
|
+
ACCOUNT_CREATION_FAILED: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
1574
|
+
emailError: walletError.message,
|
|
1587
1575
|
email: validatedEmail
|
|
1588
1576
|
}),
|
|
1589
|
-
VALIDATION_ERROR: ({ skuId, returnUrl, country }) => redirectFallback(skuId, returnUrl, country, { inlineError:
|
|
1590
|
-
RECAPTCHA_FAILED: ({ skuId, returnUrl, country }) => redirectFallback(skuId, returnUrl, country, { inlineError:
|
|
1577
|
+
VALIDATION_ERROR: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1578
|
+
RECAPTCHA_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message })
|
|
1591
1579
|
};
|
|
1592
1580
|
function handleStructuredError(ctx) {
|
|
1593
1581
|
const handler = ERROR_HANDLERS[ctx.walletError.errorType];
|
|
@@ -1151,18 +1151,11 @@ var apiFetch = async (path, options = {}) => {
|
|
|
1151
1151
|
});
|
|
1152
1152
|
if (!response.ok) {
|
|
1153
1153
|
const contentType = response.headers.get("content-type") || "";
|
|
1154
|
-
console.warn("[web-apple-pay] apiFetch: non-2xx response", {
|
|
1155
|
-
path,
|
|
1156
|
-
status: response.status,
|
|
1157
|
-
contentType
|
|
1158
|
-
});
|
|
1159
1154
|
if (contentType.includes("application/json")) {
|
|
1160
1155
|
const errorBody = await response.json();
|
|
1161
|
-
console.warn("[web-apple-pay] apiFetch: parsed JSON error body", { errorBody });
|
|
1162
1156
|
throw new ApiError(response.status, errorBody);
|
|
1163
1157
|
}
|
|
1164
1158
|
const errorText = await response.text();
|
|
1165
|
-
console.warn("[web-apple-pay] apiFetch: non-JSON error body", { errorText });
|
|
1166
1159
|
throw new Error(
|
|
1167
1160
|
`API request failed: ${response.status} ${response.statusText} - ${errorText}`
|
|
1168
1161
|
);
|
|
@@ -1336,8 +1329,6 @@ var MSG_EMAIL_WRONG_FORMAT = "That email doesn\u2019t look right. Please enter a
|
|
|
1336
1329
|
var MSG_EMAIL_TOO_LONG = "This field must be 80 characters or less.";
|
|
1337
1330
|
var MSG_UNSUPPORTED_BILLING_COUNTRY = "Billing country does not match offer price zone";
|
|
1338
1331
|
var MSG_PAYMENT_GENERIC_ERROR = "Something went wrong. Please check your payment and billing details and try again or contact us.";
|
|
1339
|
-
var MSG_RECAPTCHA_VALIDATION_FAILED = "Security check failed. Please try again.";
|
|
1340
|
-
var MSG_EMAIL_COLLISION = "This email address is already linked to an account. Please log in, or try a different email address.";
|
|
1341
1332
|
var MSG_CONTACT_VALIDATION_INTERNAL = "Could not validate Apple Pay contact";
|
|
1342
1333
|
|
|
1343
1334
|
// src/clients/payment-checkout/apple-session.ts
|
|
@@ -1526,8 +1517,6 @@ var shippingContactDetails = (shippingContact) => {
|
|
|
1526
1517
|
};
|
|
1527
1518
|
|
|
1528
1519
|
// src/clients/payment-checkout/payment-handler.ts
|
|
1529
|
-
var MSG_ELIGIBILITY = "Something went wrong, please try again";
|
|
1530
|
-
var MSG_REGISTRATION = "We couldn't create your account. Please enter your email or try a different login method.";
|
|
1531
1520
|
var failApplePaySession = (session, errors = []) => {
|
|
1532
1521
|
session.completePayment({
|
|
1533
1522
|
status: ApplePaySession.STATUS_FAILURE,
|
|
@@ -1567,22 +1556,21 @@ function redirectFallback(skuId, returnUrl, country, options) {
|
|
|
1567
1556
|
});
|
|
1568
1557
|
}
|
|
1569
1558
|
var ERROR_HANDLERS = {
|
|
1570
|
-
|
|
1571
|
-
|
|
1559
|
+
// emailError flows as an inline field error on the email input.
|
|
1560
|
+
// email pre-populates the input so the user doesn't have to retype it.
|
|
1561
|
+
EMAIL_COLLISION: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
1562
|
+
emailError: walletError.message,
|
|
1572
1563
|
email: validatedEmail
|
|
1573
1564
|
}),
|
|
1574
|
-
PAYMENT_DECLINED: ({ skuId, returnUrl, country }) => (
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
),
|
|
1578
|
-
|
|
1579
|
-
REGISTRATION_FAILED: ({ skuId, returnUrl, country }) => redirectFallback(skuId, returnUrl, country, { inlineError: MSG_REGISTRATION }),
|
|
1580
|
-
ACCOUNT_CREATION_FAILED: ({ skuId, returnUrl, country, validatedEmail }) => redirectFallback(skuId, returnUrl, country, {
|
|
1581
|
-
emailError: MSG_REGISTRATION,
|
|
1565
|
+
PAYMENT_DECLINED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1566
|
+
ELIGIBILITY_REJECTED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1567
|
+
REGISTRATION_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1568
|
+
ACCOUNT_CREATION_FAILED: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
1569
|
+
emailError: walletError.message,
|
|
1582
1570
|
email: validatedEmail
|
|
1583
1571
|
}),
|
|
1584
|
-
VALIDATION_ERROR: ({ skuId, returnUrl, country }) => redirectFallback(skuId, returnUrl, country, { inlineError:
|
|
1585
|
-
RECAPTCHA_FAILED: ({ skuId, returnUrl, country }) => redirectFallback(skuId, returnUrl, country, { inlineError:
|
|
1572
|
+
VALIDATION_ERROR: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1573
|
+
RECAPTCHA_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message })
|
|
1586
1574
|
};
|
|
1587
1575
|
function handleStructuredError(ctx) {
|
|
1588
1576
|
const handler = ERROR_HANDLERS[ctx.walletError.errorType];
|
|
@@ -1159,18 +1159,11 @@ var apiFetch = async (path, options = {}) => {
|
|
|
1159
1159
|
});
|
|
1160
1160
|
if (!response.ok) {
|
|
1161
1161
|
const contentType = response.headers.get("content-type") || "";
|
|
1162
|
-
console.warn("[web-apple-pay] apiFetch: non-2xx response", {
|
|
1163
|
-
path,
|
|
1164
|
-
status: response.status,
|
|
1165
|
-
contentType
|
|
1166
|
-
});
|
|
1167
1162
|
if (contentType.includes("application/json")) {
|
|
1168
1163
|
const errorBody = await response.json();
|
|
1169
|
-
console.warn("[web-apple-pay] apiFetch: parsed JSON error body", { errorBody });
|
|
1170
1164
|
throw new ApiError(response.status, errorBody);
|
|
1171
1165
|
}
|
|
1172
1166
|
const errorText = await response.text();
|
|
1173
|
-
console.warn("[web-apple-pay] apiFetch: non-JSON error body", { errorText });
|
|
1174
1167
|
throw new Error(
|
|
1175
1168
|
`API request failed: ${response.status} ${response.statusText} - ${errorText}`
|
|
1176
1169
|
);
|
|
@@ -1344,8 +1337,6 @@ var MSG_EMAIL_WRONG_FORMAT = "That email doesn\u2019t look right. Please enter a
|
|
|
1344
1337
|
var MSG_EMAIL_TOO_LONG = "This field must be 80 characters or less.";
|
|
1345
1338
|
var MSG_UNSUPPORTED_BILLING_COUNTRY = "Billing country does not match offer price zone";
|
|
1346
1339
|
var MSG_PAYMENT_GENERIC_ERROR = "Something went wrong. Please check your payment and billing details and try again or contact us.";
|
|
1347
|
-
var MSG_RECAPTCHA_VALIDATION_FAILED = "Security check failed. Please try again.";
|
|
1348
|
-
var MSG_EMAIL_COLLISION = "This email address is already linked to an account. Please log in, or try a different email address.";
|
|
1349
1340
|
var MSG_CONTACT_VALIDATION_INTERNAL = "Could not validate Apple Pay contact";
|
|
1350
1341
|
|
|
1351
1342
|
// src/clients/payment-checkout/apple-session.ts
|
|
@@ -1534,8 +1525,6 @@ var shippingContactDetails = (shippingContact) => {
|
|
|
1534
1525
|
};
|
|
1535
1526
|
|
|
1536
1527
|
// src/clients/payment-checkout/payment-handler.ts
|
|
1537
|
-
var MSG_ELIGIBILITY = "Something went wrong, please try again";
|
|
1538
|
-
var MSG_REGISTRATION = "We couldn't create your account. Please enter your email or try a different login method.";
|
|
1539
1528
|
var failApplePaySession = (session, errors = []) => {
|
|
1540
1529
|
session.completePayment({
|
|
1541
1530
|
status: ApplePaySession.STATUS_FAILURE,
|
|
@@ -1575,22 +1564,21 @@ function redirectFallback(skuId, returnUrl, country, options) {
|
|
|
1575
1564
|
});
|
|
1576
1565
|
}
|
|
1577
1566
|
var ERROR_HANDLERS = {
|
|
1578
|
-
|
|
1579
|
-
|
|
1567
|
+
// emailError flows as an inline field error on the email input.
|
|
1568
|
+
// email pre-populates the input so the user doesn't have to retype it.
|
|
1569
|
+
EMAIL_COLLISION: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
1570
|
+
emailError: walletError.message,
|
|
1580
1571
|
email: validatedEmail
|
|
1581
1572
|
}),
|
|
1582
|
-
PAYMENT_DECLINED: ({ skuId, returnUrl, country }) => (
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
),
|
|
1586
|
-
|
|
1587
|
-
REGISTRATION_FAILED: ({ skuId, returnUrl, country }) => redirectFallback(skuId, returnUrl, country, { inlineError: MSG_REGISTRATION }),
|
|
1588
|
-
ACCOUNT_CREATION_FAILED: ({ skuId, returnUrl, country, validatedEmail }) => redirectFallback(skuId, returnUrl, country, {
|
|
1589
|
-
emailError: MSG_REGISTRATION,
|
|
1573
|
+
PAYMENT_DECLINED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1574
|
+
ELIGIBILITY_REJECTED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1575
|
+
REGISTRATION_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1576
|
+
ACCOUNT_CREATION_FAILED: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
1577
|
+
emailError: walletError.message,
|
|
1590
1578
|
email: validatedEmail
|
|
1591
1579
|
}),
|
|
1592
|
-
VALIDATION_ERROR: ({ skuId, returnUrl, country }) => redirectFallback(skuId, returnUrl, country, { inlineError:
|
|
1593
|
-
RECAPTCHA_FAILED: ({ skuId, returnUrl, country }) => redirectFallback(skuId, returnUrl, country, { inlineError:
|
|
1580
|
+
VALIDATION_ERROR: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1581
|
+
RECAPTCHA_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message })
|
|
1594
1582
|
};
|
|
1595
1583
|
function handleStructuredError(ctx) {
|
|
1596
1584
|
const handler = ERROR_HANDLERS[ctx.walletError.errorType];
|
|
@@ -1151,18 +1151,11 @@ var apiFetch = async (path, options = {}) => {
|
|
|
1151
1151
|
});
|
|
1152
1152
|
if (!response.ok) {
|
|
1153
1153
|
const contentType = response.headers.get("content-type") || "";
|
|
1154
|
-
console.warn("[web-apple-pay] apiFetch: non-2xx response", {
|
|
1155
|
-
path,
|
|
1156
|
-
status: response.status,
|
|
1157
|
-
contentType
|
|
1158
|
-
});
|
|
1159
1154
|
if (contentType.includes("application/json")) {
|
|
1160
1155
|
const errorBody = await response.json();
|
|
1161
|
-
console.warn("[web-apple-pay] apiFetch: parsed JSON error body", { errorBody });
|
|
1162
1156
|
throw new ApiError(response.status, errorBody);
|
|
1163
1157
|
}
|
|
1164
1158
|
const errorText = await response.text();
|
|
1165
|
-
console.warn("[web-apple-pay] apiFetch: non-JSON error body", { errorText });
|
|
1166
1159
|
throw new Error(
|
|
1167
1160
|
`API request failed: ${response.status} ${response.statusText} - ${errorText}`
|
|
1168
1161
|
);
|
|
@@ -1336,8 +1329,6 @@ var MSG_EMAIL_WRONG_FORMAT = "That email doesn\u2019t look right. Please enter a
|
|
|
1336
1329
|
var MSG_EMAIL_TOO_LONG = "This field must be 80 characters or less.";
|
|
1337
1330
|
var MSG_UNSUPPORTED_BILLING_COUNTRY = "Billing country does not match offer price zone";
|
|
1338
1331
|
var MSG_PAYMENT_GENERIC_ERROR = "Something went wrong. Please check your payment and billing details and try again or contact us.";
|
|
1339
|
-
var MSG_RECAPTCHA_VALIDATION_FAILED = "Security check failed. Please try again.";
|
|
1340
|
-
var MSG_EMAIL_COLLISION = "This email address is already linked to an account. Please log in, or try a different email address.";
|
|
1341
1332
|
var MSG_CONTACT_VALIDATION_INTERNAL = "Could not validate Apple Pay contact";
|
|
1342
1333
|
|
|
1343
1334
|
// src/clients/payment-checkout/apple-session.ts
|
|
@@ -1526,8 +1517,6 @@ var shippingContactDetails = (shippingContact) => {
|
|
|
1526
1517
|
};
|
|
1527
1518
|
|
|
1528
1519
|
// src/clients/payment-checkout/payment-handler.ts
|
|
1529
|
-
var MSG_ELIGIBILITY = "Something went wrong, please try again";
|
|
1530
|
-
var MSG_REGISTRATION = "We couldn't create your account. Please enter your email or try a different login method.";
|
|
1531
1520
|
var failApplePaySession = (session, errors = []) => {
|
|
1532
1521
|
session.completePayment({
|
|
1533
1522
|
status: ApplePaySession.STATUS_FAILURE,
|
|
@@ -1567,22 +1556,21 @@ function redirectFallback(skuId, returnUrl, country, options) {
|
|
|
1567
1556
|
});
|
|
1568
1557
|
}
|
|
1569
1558
|
var ERROR_HANDLERS = {
|
|
1570
|
-
|
|
1571
|
-
|
|
1559
|
+
// emailError flows as an inline field error on the email input.
|
|
1560
|
+
// email pre-populates the input so the user doesn't have to retype it.
|
|
1561
|
+
EMAIL_COLLISION: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
1562
|
+
emailError: walletError.message,
|
|
1572
1563
|
email: validatedEmail
|
|
1573
1564
|
}),
|
|
1574
|
-
PAYMENT_DECLINED: ({ skuId, returnUrl, country }) => (
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
),
|
|
1578
|
-
|
|
1579
|
-
REGISTRATION_FAILED: ({ skuId, returnUrl, country }) => redirectFallback(skuId, returnUrl, country, { inlineError: MSG_REGISTRATION }),
|
|
1580
|
-
ACCOUNT_CREATION_FAILED: ({ skuId, returnUrl, country, validatedEmail }) => redirectFallback(skuId, returnUrl, country, {
|
|
1581
|
-
emailError: MSG_REGISTRATION,
|
|
1565
|
+
PAYMENT_DECLINED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1566
|
+
ELIGIBILITY_REJECTED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1567
|
+
REGISTRATION_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1568
|
+
ACCOUNT_CREATION_FAILED: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
1569
|
+
emailError: walletError.message,
|
|
1582
1570
|
email: validatedEmail
|
|
1583
1571
|
}),
|
|
1584
|
-
VALIDATION_ERROR: ({ skuId, returnUrl, country }) => redirectFallback(skuId, returnUrl, country, { inlineError:
|
|
1585
|
-
RECAPTCHA_FAILED: ({ skuId, returnUrl, country }) => redirectFallback(skuId, returnUrl, country, { inlineError:
|
|
1572
|
+
VALIDATION_ERROR: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1573
|
+
RECAPTCHA_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message })
|
|
1586
1574
|
};
|
|
1587
1575
|
function handleStructuredError(ctx) {
|
|
1588
1576
|
const handler = ERROR_HANDLERS[ctx.walletError.errorType];
|
|
@@ -43,18 +43,11 @@ var apiFetch = async (path, options = {}) => {
|
|
|
43
43
|
});
|
|
44
44
|
if (!response.ok) {
|
|
45
45
|
const contentType = response.headers.get("content-type") || "";
|
|
46
|
-
console.warn("[web-apple-pay] apiFetch: non-2xx response", {
|
|
47
|
-
path,
|
|
48
|
-
status: response.status,
|
|
49
|
-
contentType
|
|
50
|
-
});
|
|
51
46
|
if (contentType.includes("application/json")) {
|
|
52
47
|
const errorBody = await response.json();
|
|
53
|
-
console.warn("[web-apple-pay] apiFetch: parsed JSON error body", { errorBody });
|
|
54
48
|
throw new ApiError(response.status, errorBody);
|
|
55
49
|
}
|
|
56
50
|
const errorText = await response.text();
|
|
57
|
-
console.warn("[web-apple-pay] apiFetch: non-JSON error body", { errorText });
|
|
58
51
|
throw new Error(
|
|
59
52
|
`API request failed: ${response.status} ${response.statusText} - ${errorText}`
|
|
60
53
|
);
|
|
@@ -43,18 +43,11 @@ var apiFetch = async (path, options = {}) => {
|
|
|
43
43
|
});
|
|
44
44
|
if (!response.ok) {
|
|
45
45
|
const contentType = response.headers.get("content-type") || "";
|
|
46
|
-
console.warn("[web-apple-pay] apiFetch: non-2xx response", {
|
|
47
|
-
path,
|
|
48
|
-
status: response.status,
|
|
49
|
-
contentType
|
|
50
|
-
});
|
|
51
46
|
if (contentType.includes("application/json")) {
|
|
52
47
|
const errorBody = await response.json();
|
|
53
|
-
console.warn("[web-apple-pay] apiFetch: parsed JSON error body", { errorBody });
|
|
54
48
|
throw new ApiError(response.status, errorBody);
|
|
55
49
|
}
|
|
56
50
|
const errorText = await response.text();
|
|
57
|
-
console.warn("[web-apple-pay] apiFetch: non-JSON error body", { errorText });
|
|
58
51
|
throw new Error(
|
|
59
52
|
`API request failed: ${response.status} ${response.statusText} - ${errorText}`
|
|
60
53
|
);
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Canonical user-facing
|
|
2
|
+
* Canonical user-facing strings for the Apple Pay Express Checkout flow.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* These constants cover two categories:
|
|
5
|
+
* 1. Local contact/field validation — fired before any BFF call, no API
|
|
6
|
+
* message is available.
|
|
7
|
+
* 2. Pre-purchase fallbacks — merchant validation failures and unstructured
|
|
8
|
+
* network errors where no BFF WalletApiError is present.
|
|
9
|
+
*
|
|
10
|
+
* Structured BFF errors (EMAIL_COLLISION, PAYMENT_DECLINED, RECAPTCHA_FAILED,
|
|
11
|
+
* etc.) are NOT represented here — their user-facing copy comes directly from
|
|
12
|
+
* walletError.message in the API response, so copy changes on the BFF side
|
|
13
|
+
* take effect without a frontend deploy.
|
|
7
14
|
*/
|
|
8
15
|
/** Shown when a required Apple Pay contact field is absent. */
|
|
9
16
|
export declare const MSG_MISSING_REQUIRED_FIELD = "Missing required field";
|
|
@@ -19,15 +26,5 @@ export declare const MSG_UNSUPPORTED_BILLING_COUNTRY = "Billing country does not
|
|
|
19
26
|
* Matches sma-checkout GENERIC_ERROR_MSG pattern.
|
|
20
27
|
*/
|
|
21
28
|
export declare const MSG_PAYMENT_GENERIC_ERROR = "Something went wrong. Please check your payment and billing details and try again or contact us.";
|
|
22
|
-
/**
|
|
23
|
-
* Shown when a reCAPTCHA security check fails.
|
|
24
|
-
* Matches sma-checkout reference: handlers/create-on-payment-authorized-handler/subscribe.
|
|
25
|
-
*/
|
|
26
|
-
export declare const MSG_RECAPTCHA_VALIDATION_FAILED = "Security check failed. Please try again.";
|
|
27
|
-
/**
|
|
28
|
-
* Shown when the BFF returns an EMAIL_COLLISION error (account already exists).
|
|
29
|
-
* Matches sma-checkout L103-104.
|
|
30
|
-
*/
|
|
31
|
-
export declare const MSG_EMAIL_COLLISION = "This email address is already linked to an account. Please log in, or try a different email address.";
|
|
32
29
|
/** Internal ContactValidationError message — not shown to the user directly. */
|
|
33
30
|
export declare const MSG_CONTACT_VALIDATION_INTERNAL = "Could not validate Apple Pay contact";
|
|
@@ -4,16 +4,12 @@ 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 MSG_PAYMENT_GENERIC_ERROR = "Something went wrong. Please check your payment and billing details and try again or contact us.";
|
|
7
|
-
var MSG_RECAPTCHA_VALIDATION_FAILED = "Security check failed. Please try again.";
|
|
8
|
-
var MSG_EMAIL_COLLISION = "This email address is already linked to an account. Please log in, or try a different email address.";
|
|
9
7
|
var MSG_CONTACT_VALIDATION_INTERNAL = "Could not validate Apple Pay contact";
|
|
10
8
|
export {
|
|
11
9
|
MSG_CONTACT_VALIDATION_INTERNAL,
|
|
12
|
-
MSG_EMAIL_COLLISION,
|
|
13
10
|
MSG_EMAIL_TOO_LONG,
|
|
14
11
|
MSG_EMAIL_WRONG_FORMAT,
|
|
15
12
|
MSG_MISSING_REQUIRED_FIELD,
|
|
16
13
|
MSG_PAYMENT_GENERIC_ERROR,
|
|
17
|
-
MSG_RECAPTCHA_VALIDATION_FAILED,
|
|
18
14
|
MSG_UNSUPPORTED_BILLING_COUNTRY
|
|
19
15
|
};
|
|
@@ -43,18 +43,11 @@ var apiFetch = async (path, options = {}) => {
|
|
|
43
43
|
});
|
|
44
44
|
if (!response.ok) {
|
|
45
45
|
const contentType = response.headers.get("content-type") || "";
|
|
46
|
-
console.warn("[web-apple-pay] apiFetch: non-2xx response", {
|
|
47
|
-
path,
|
|
48
|
-
status: response.status,
|
|
49
|
-
contentType
|
|
50
|
-
});
|
|
51
46
|
if (contentType.includes("application/json")) {
|
|
52
47
|
const errorBody = await response.json();
|
|
53
|
-
console.warn("[web-apple-pay] apiFetch: parsed JSON error body", { errorBody });
|
|
54
48
|
throw new ApiError(response.status, errorBody);
|
|
55
49
|
}
|
|
56
50
|
const errorText = await response.text();
|
|
57
|
-
console.warn("[web-apple-pay] apiFetch: non-JSON error body", { errorText });
|
|
58
51
|
throw new Error(
|
|
59
52
|
`API request failed: ${response.status} ${response.statusText} - ${errorText}`
|
|
60
53
|
);
|
|
@@ -125,8 +118,6 @@ var MSG_EMAIL_WRONG_FORMAT = "That email doesn\u2019t look right. Please enter a
|
|
|
125
118
|
var MSG_EMAIL_TOO_LONG = "This field must be 80 characters or less.";
|
|
126
119
|
var MSG_UNSUPPORTED_BILLING_COUNTRY = "Billing country does not match offer price zone";
|
|
127
120
|
var MSG_PAYMENT_GENERIC_ERROR = "Something went wrong. Please check your payment and billing details and try again or contact us.";
|
|
128
|
-
var MSG_RECAPTCHA_VALIDATION_FAILED = "Security check failed. Please try again.";
|
|
129
|
-
var MSG_EMAIL_COLLISION = "This email address is already linked to an account. Please log in, or try a different email address.";
|
|
130
121
|
var MSG_CONTACT_VALIDATION_INTERNAL = "Could not validate Apple Pay contact";
|
|
131
122
|
|
|
132
123
|
// src/clients/payment-checkout/contact-validation.ts
|
|
@@ -296,8 +287,6 @@ var redirectToCheckoutFallback = (params) => {
|
|
|
296
287
|
};
|
|
297
288
|
|
|
298
289
|
// src/clients/payment-checkout/payment-handler.ts
|
|
299
|
-
var MSG_ELIGIBILITY = "Something went wrong, please try again";
|
|
300
|
-
var MSG_REGISTRATION = "We couldn't create your account. Please enter your email or try a different login method.";
|
|
301
290
|
var failApplePaySession = (session, errors = []) => {
|
|
302
291
|
session.completePayment({
|
|
303
292
|
status: ApplePaySession.STATUS_FAILURE,
|
|
@@ -337,22 +326,21 @@ function redirectFallback(skuId, returnUrl, country, options) {
|
|
|
337
326
|
});
|
|
338
327
|
}
|
|
339
328
|
var ERROR_HANDLERS = {
|
|
340
|
-
|
|
341
|
-
|
|
329
|
+
// emailError flows as an inline field error on the email input.
|
|
330
|
+
// email pre-populates the input so the user doesn't have to retype it.
|
|
331
|
+
EMAIL_COLLISION: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
332
|
+
emailError: walletError.message,
|
|
342
333
|
email: validatedEmail
|
|
343
334
|
}),
|
|
344
|
-
PAYMENT_DECLINED: ({ skuId, returnUrl, country }) => (
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
),
|
|
348
|
-
|
|
349
|
-
REGISTRATION_FAILED: ({ skuId, returnUrl, country }) => redirectFallback(skuId, returnUrl, country, { inlineError: MSG_REGISTRATION }),
|
|
350
|
-
ACCOUNT_CREATION_FAILED: ({ skuId, returnUrl, country, validatedEmail }) => redirectFallback(skuId, returnUrl, country, {
|
|
351
|
-
emailError: MSG_REGISTRATION,
|
|
335
|
+
PAYMENT_DECLINED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
336
|
+
ELIGIBILITY_REJECTED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
337
|
+
REGISTRATION_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
338
|
+
ACCOUNT_CREATION_FAILED: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
339
|
+
emailError: walletError.message,
|
|
352
340
|
email: validatedEmail
|
|
353
341
|
}),
|
|
354
|
-
VALIDATION_ERROR: ({ skuId, returnUrl, country }) => redirectFallback(skuId, returnUrl, country, { inlineError:
|
|
355
|
-
RECAPTCHA_FAILED: ({ skuId, returnUrl, country }) => redirectFallback(skuId, returnUrl, country, { inlineError:
|
|
342
|
+
VALIDATION_ERROR: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
343
|
+
RECAPTCHA_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message })
|
|
356
344
|
};
|
|
357
345
|
function handleStructuredError(ctx) {
|
|
358
346
|
const handler = ERROR_HANDLERS[ctx.walletError.errorType];
|
|
@@ -43,18 +43,11 @@ var apiFetch = async (path, options = {}) => {
|
|
|
43
43
|
});
|
|
44
44
|
if (!response.ok) {
|
|
45
45
|
const contentType = response.headers.get("content-type") || "";
|
|
46
|
-
console.warn("[web-apple-pay] apiFetch: non-2xx response", {
|
|
47
|
-
path,
|
|
48
|
-
status: response.status,
|
|
49
|
-
contentType
|
|
50
|
-
});
|
|
51
46
|
if (contentType.includes("application/json")) {
|
|
52
47
|
const errorBody = await response.json();
|
|
53
|
-
console.warn("[web-apple-pay] apiFetch: parsed JSON error body", { errorBody });
|
|
54
48
|
throw new ApiError(response.status, errorBody);
|
|
55
49
|
}
|
|
56
50
|
const errorText = await response.text();
|
|
57
|
-
console.warn("[web-apple-pay] apiFetch: non-JSON error body", { errorText });
|
|
58
51
|
throw new Error(
|
|
59
52
|
`API request failed: ${response.status} ${response.statusText} - ${errorText}`
|
|
60
53
|
);
|
package/dist/src/index.js
CHANGED
|
@@ -1156,18 +1156,11 @@ var apiFetch = async (path, options = {}) => {
|
|
|
1156
1156
|
});
|
|
1157
1157
|
if (!response.ok) {
|
|
1158
1158
|
const contentType = response.headers.get("content-type") || "";
|
|
1159
|
-
console.warn("[web-apple-pay] apiFetch: non-2xx response", {
|
|
1160
|
-
path,
|
|
1161
|
-
status: response.status,
|
|
1162
|
-
contentType
|
|
1163
|
-
});
|
|
1164
1159
|
if (contentType.includes("application/json")) {
|
|
1165
1160
|
const errorBody = await response.json();
|
|
1166
|
-
console.warn("[web-apple-pay] apiFetch: parsed JSON error body", { errorBody });
|
|
1167
1161
|
throw new ApiError(response.status, errorBody);
|
|
1168
1162
|
}
|
|
1169
1163
|
const errorText = await response.text();
|
|
1170
|
-
console.warn("[web-apple-pay] apiFetch: non-JSON error body", { errorText });
|
|
1171
1164
|
throw new Error(
|
|
1172
1165
|
`API request failed: ${response.status} ${response.statusText} - ${errorText}`
|
|
1173
1166
|
);
|
|
@@ -1341,8 +1334,6 @@ var MSG_EMAIL_WRONG_FORMAT = "That email doesn\u2019t look right. Please enter a
|
|
|
1341
1334
|
var MSG_EMAIL_TOO_LONG = "This field must be 80 characters or less.";
|
|
1342
1335
|
var MSG_UNSUPPORTED_BILLING_COUNTRY = "Billing country does not match offer price zone";
|
|
1343
1336
|
var MSG_PAYMENT_GENERIC_ERROR = "Something went wrong. Please check your payment and billing details and try again or contact us.";
|
|
1344
|
-
var MSG_RECAPTCHA_VALIDATION_FAILED = "Security check failed. Please try again.";
|
|
1345
|
-
var MSG_EMAIL_COLLISION = "This email address is already linked to an account. Please log in, or try a different email address.";
|
|
1346
1337
|
var MSG_CONTACT_VALIDATION_INTERNAL = "Could not validate Apple Pay contact";
|
|
1347
1338
|
|
|
1348
1339
|
// src/clients/payment-checkout/apple-session.ts
|
|
@@ -1531,8 +1522,6 @@ var shippingContactDetails = (shippingContact) => {
|
|
|
1531
1522
|
};
|
|
1532
1523
|
|
|
1533
1524
|
// src/clients/payment-checkout/payment-handler.ts
|
|
1534
|
-
var MSG_ELIGIBILITY = "Something went wrong, please try again";
|
|
1535
|
-
var MSG_REGISTRATION = "We couldn't create your account. Please enter your email or try a different login method.";
|
|
1536
1525
|
var failApplePaySession = (session, errors = []) => {
|
|
1537
1526
|
session.completePayment({
|
|
1538
1527
|
status: ApplePaySession.STATUS_FAILURE,
|
|
@@ -1572,22 +1561,21 @@ function redirectFallback(skuId, returnUrl, country, options) {
|
|
|
1572
1561
|
});
|
|
1573
1562
|
}
|
|
1574
1563
|
var ERROR_HANDLERS = {
|
|
1575
|
-
|
|
1576
|
-
|
|
1564
|
+
// emailError flows as an inline field error on the email input.
|
|
1565
|
+
// email pre-populates the input so the user doesn't have to retype it.
|
|
1566
|
+
EMAIL_COLLISION: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
1567
|
+
emailError: walletError.message,
|
|
1577
1568
|
email: validatedEmail
|
|
1578
1569
|
}),
|
|
1579
|
-
PAYMENT_DECLINED: ({ skuId, returnUrl, country }) => (
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
),
|
|
1583
|
-
|
|
1584
|
-
REGISTRATION_FAILED: ({ skuId, returnUrl, country }) => redirectFallback(skuId, returnUrl, country, { inlineError: MSG_REGISTRATION }),
|
|
1585
|
-
ACCOUNT_CREATION_FAILED: ({ skuId, returnUrl, country, validatedEmail }) => redirectFallback(skuId, returnUrl, country, {
|
|
1586
|
-
emailError: MSG_REGISTRATION,
|
|
1570
|
+
PAYMENT_DECLINED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1571
|
+
ELIGIBILITY_REJECTED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1572
|
+
REGISTRATION_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1573
|
+
ACCOUNT_CREATION_FAILED: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
1574
|
+
emailError: walletError.message,
|
|
1587
1575
|
email: validatedEmail
|
|
1588
1576
|
}),
|
|
1589
|
-
VALIDATION_ERROR: ({ skuId, returnUrl, country }) => redirectFallback(skuId, returnUrl, country, { inlineError:
|
|
1590
|
-
RECAPTCHA_FAILED: ({ skuId, returnUrl, country }) => redirectFallback(skuId, returnUrl, country, { inlineError:
|
|
1577
|
+
VALIDATION_ERROR: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1578
|
+
RECAPTCHA_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message })
|
|
1591
1579
|
};
|
|
1592
1580
|
function handleStructuredError(ctx) {
|
|
1593
1581
|
const handler = ERROR_HANDLERS[ctx.walletError.errorType];
|
package/package.json
CHANGED