@economist/web-apple-pay 0.1.3-beta.23 → 0.1.3-beta.26
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 +73 -49
- package/dist/src/apple-pay-button.d.ts +4 -3
- package/dist/src/apple-pay-button.js +65 -49
- package/dist/src/apple-pay-button.stories.js +65 -49
- package/dist/src/apple-pay-modal.js +28 -12
- package/dist/src/apple-pay-modal.stories.js +65 -49
- package/dist/src/clients/payment-checkout/apple-session.js +0 -7
- package/dist/src/clients/payment-checkout/index.js +1 -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 +12 -23
- package/dist/src/clients/payment-checkout/session.js +0 -7
- package/dist/src/constants.d.ts +4 -0
- package/dist/src/constants.js +9 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +73 -49
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -320,28 +320,41 @@ var apple_pay_modal_template_default = `<style>
|
|
|
320
320
|
cursor: not-allowed;
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
-
.apm__cta
|
|
324
|
-
|
|
323
|
+
.apm__cta-content {
|
|
324
|
+
display: flex;
|
|
325
|
+
align-items: center;
|
|
326
|
+
gap: 0.375rem;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.apm__cta-label {
|
|
330
|
+
display: inline-flex;
|
|
331
|
+
align-items: center;
|
|
332
|
+
gap: 0.375rem;
|
|
325
333
|
}
|
|
326
334
|
|
|
327
|
-
.apm__cta
|
|
335
|
+
.apm__cta-loading {
|
|
336
|
+
display: none;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.apm__cta[aria-busy="true"]::before {
|
|
328
340
|
content: '';
|
|
329
341
|
position: absolute;
|
|
330
|
-
left: 50%;
|
|
331
342
|
top: 50%;
|
|
332
|
-
|
|
333
|
-
margin-top: -0.625rem;
|
|
343
|
+
left: 50%;
|
|
334
344
|
width: 1.25rem;
|
|
335
345
|
height: 1.25rem;
|
|
336
|
-
border: 2px solid rgba(255, 255, 255, 0.
|
|
346
|
+
border: 2px solid rgba(255, 255, 255, 0.25);
|
|
337
347
|
border-top-color: #fff;
|
|
338
348
|
border-radius: 50%;
|
|
339
349
|
animation: apm-cta-spinner 0.8s linear infinite;
|
|
340
350
|
}
|
|
341
351
|
|
|
342
352
|
@keyframes apm-cta-spinner {
|
|
353
|
+
from {
|
|
354
|
+
transform: translate(-50%, -50%) rotate(0deg);
|
|
355
|
+
}
|
|
343
356
|
to {
|
|
344
|
-
transform: rotate(360deg);
|
|
357
|
+
transform: translate(-50%, -50%) rotate(360deg);
|
|
345
358
|
}
|
|
346
359
|
}
|
|
347
360
|
|
|
@@ -518,11 +531,14 @@ var apple_pay_modal_template_default = `<style>
|
|
|
518
531
|
</div>
|
|
519
532
|
<button class="apm__cta" id="apple-pay-modal-cta" aria-label="Continue with Apple Pay">
|
|
520
533
|
<span class="apm__cta-content">
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
<
|
|
524
|
-
|
|
534
|
+
<span class="apm__cta-label">
|
|
535
|
+
Continue with
|
|
536
|
+
<svg width="51" height="22" aria-hidden="true" role="img">
|
|
537
|
+
<use href="#apple-pay-logo" />
|
|
538
|
+
</svg>
|
|
539
|
+
</span>
|
|
525
540
|
</span>
|
|
541
|
+
<span class="apm__cta-loading" aria-hidden="true">Loading...</span>
|
|
526
542
|
</button>
|
|
527
543
|
</div>
|
|
528
544
|
</div>
|
|
@@ -1035,28 +1051,34 @@ var apple_pay_button_template_default = `<style>
|
|
|
1035
1051
|
cursor: default;
|
|
1036
1052
|
}
|
|
1037
1053
|
|
|
1038
|
-
teg-apple-pay-button .apple-pay-btn.wap-loading
|
|
1039
|
-
visibility: hidden;
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
teg-apple-pay-button .apple-pay-btn.wap-loading::after {
|
|
1054
|
+
teg-apple-pay-button .apple-pay-btn.wap-loading::before {
|
|
1043
1055
|
content: '';
|
|
1044
1056
|
position: absolute;
|
|
1045
|
-
left: 50%;
|
|
1046
1057
|
top: 50%;
|
|
1047
|
-
|
|
1048
|
-
margin-top: -0.625rem;
|
|
1058
|
+
left: 50%;
|
|
1049
1059
|
width: 1.25rem;
|
|
1050
1060
|
height: 1.25rem;
|
|
1051
|
-
border: 2px solid rgba(255, 255, 255, 0.
|
|
1061
|
+
border: 2px solid rgba(255, 255, 255, 0.25);
|
|
1052
1062
|
border-top-color: #fff;
|
|
1053
1063
|
border-radius: 50%;
|
|
1054
1064
|
animation: wap-button-spinner 0.8s linear infinite;
|
|
1055
1065
|
}
|
|
1056
1066
|
|
|
1067
|
+
teg-apple-pay-button .apple-pay-btn__logo {
|
|
1068
|
+
display: inline-flex;
|
|
1069
|
+
align-items: center;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
teg-apple-pay-button .apple-pay-btn__loading {
|
|
1073
|
+
display: none;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1057
1076
|
@keyframes wap-button-spinner {
|
|
1077
|
+
from {
|
|
1078
|
+
transform: translate(-50%, -50%) rotate(0deg);
|
|
1079
|
+
}
|
|
1058
1080
|
to {
|
|
1059
|
-
transform: rotate(360deg);
|
|
1081
|
+
transform: translate(-50%, -50%) rotate(360deg);
|
|
1060
1082
|
}
|
|
1061
1083
|
}
|
|
1062
1084
|
</style>
|
|
@@ -1068,9 +1090,12 @@ var apple_pay_button_template_default = `<style>
|
|
|
1068
1090
|
aria-label="Pay with Apple Pay"
|
|
1069
1091
|
data-analytics="paywall:apple-pay-checkout"
|
|
1070
1092
|
>
|
|
1071
|
-
<
|
|
1072
|
-
<
|
|
1073
|
-
|
|
1093
|
+
<span class="apple-pay-btn__logo">
|
|
1094
|
+
<svg width="51" height="22" aria-label="Apple Pay" role="img">
|
|
1095
|
+
<use href="#apple-pay-logo" />
|
|
1096
|
+
</svg>
|
|
1097
|
+
</span>
|
|
1098
|
+
<span class="apple-pay-btn__loading" aria-hidden="true">Loading...</span>
|
|
1074
1099
|
</button>
|
|
1075
1100
|
</div>
|
|
1076
1101
|
`;
|
|
@@ -1156,18 +1181,11 @@ var apiFetch = async (path, options = {}) => {
|
|
|
1156
1181
|
});
|
|
1157
1182
|
if (!response.ok) {
|
|
1158
1183
|
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
1184
|
if (contentType.includes("application/json")) {
|
|
1165
1185
|
const errorBody = await response.json();
|
|
1166
|
-
console.warn("[web-apple-pay] apiFetch: parsed JSON error body", { errorBody });
|
|
1167
1186
|
throw new ApiError(response.status, errorBody);
|
|
1168
1187
|
}
|
|
1169
1188
|
const errorText = await response.text();
|
|
1170
|
-
console.warn("[web-apple-pay] apiFetch: non-JSON error body", { errorText });
|
|
1171
1189
|
throw new Error(
|
|
1172
1190
|
`API request failed: ${response.status} ${response.statusText} - ${errorText}`
|
|
1173
1191
|
);
|
|
@@ -1189,6 +1207,7 @@ var validateAppleMerchant = (data) => {
|
|
|
1189
1207
|
});
|
|
1190
1208
|
};
|
|
1191
1209
|
var performPurchase = (data) => {
|
|
1210
|
+
console.log("[web-apple-pay] /v1/wallet/purchase payload", data);
|
|
1192
1211
|
return apiFetch("/v1/wallet/purchase", {
|
|
1193
1212
|
method: "POST",
|
|
1194
1213
|
body: JSON.stringify(data),
|
|
@@ -1341,8 +1360,6 @@ var MSG_EMAIL_WRONG_FORMAT = "That email doesn\u2019t look right. Please enter a
|
|
|
1341
1360
|
var MSG_EMAIL_TOO_LONG = "This field must be 80 characters or less.";
|
|
1342
1361
|
var MSG_UNSUPPORTED_BILLING_COUNTRY = "Billing country does not match offer price zone";
|
|
1343
1362
|
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
1363
|
var MSG_CONTACT_VALIDATION_INTERNAL = "Could not validate Apple Pay contact";
|
|
1347
1364
|
|
|
1348
1365
|
// src/clients/payment-checkout/apple-session.ts
|
|
@@ -1531,8 +1548,6 @@ var shippingContactDetails = (shippingContact) => {
|
|
|
1531
1548
|
};
|
|
1532
1549
|
|
|
1533
1550
|
// 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
1551
|
var failApplePaySession = (session, errors = []) => {
|
|
1537
1552
|
session.completePayment({
|
|
1538
1553
|
status: ApplePaySession.STATUS_FAILURE,
|
|
@@ -1572,22 +1587,21 @@ function redirectFallback(skuId, returnUrl, country, options) {
|
|
|
1572
1587
|
});
|
|
1573
1588
|
}
|
|
1574
1589
|
var ERROR_HANDLERS = {
|
|
1575
|
-
|
|
1576
|
-
|
|
1590
|
+
// emailError flows as an inline field error on the email input.
|
|
1591
|
+
// email pre-populates the input so the user doesn't have to retype it.
|
|
1592
|
+
EMAIL_COLLISION: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
1593
|
+
emailError: walletError.message,
|
|
1577
1594
|
email: validatedEmail
|
|
1578
1595
|
}),
|
|
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,
|
|
1596
|
+
PAYMENT_DECLINED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1597
|
+
ELIGIBILITY_REJECTED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1598
|
+
REGISTRATION_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1599
|
+
ACCOUNT_CREATION_FAILED: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
1600
|
+
emailError: walletError.message,
|
|
1587
1601
|
email: validatedEmail
|
|
1588
1602
|
}),
|
|
1589
|
-
VALIDATION_ERROR: ({ skuId, returnUrl, country }) => redirectFallback(skuId, returnUrl, country, { inlineError:
|
|
1590
|
-
RECAPTCHA_FAILED: ({ skuId, returnUrl, country }) => redirectFallback(skuId, returnUrl, country, { inlineError:
|
|
1603
|
+
VALIDATION_ERROR: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1604
|
+
RECAPTCHA_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message })
|
|
1591
1605
|
};
|
|
1592
1606
|
function handleStructuredError(ctx) {
|
|
1593
1607
|
const handler = ERROR_HANDLERS[ctx.walletError.errorType];
|
|
@@ -1941,7 +1955,9 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
1941
1955
|
const button = document.createElement(_ApplePayButton.tag);
|
|
1942
1956
|
button.offer = offer;
|
|
1943
1957
|
button.country = country;
|
|
1944
|
-
|
|
1958
|
+
if (entryPoint) {
|
|
1959
|
+
button.entryPoint = entryPoint;
|
|
1960
|
+
}
|
|
1945
1961
|
return button;
|
|
1946
1962
|
}
|
|
1947
1963
|
/**
|
|
@@ -2251,6 +2267,13 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
2251
2267
|
}
|
|
2252
2268
|
};
|
|
2253
2269
|
|
|
2270
|
+
// src/constants.ts
|
|
2271
|
+
var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
|
|
2272
|
+
ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
|
|
2273
|
+
ApplePayEntryPoint2["REGWALL"] = "article_regwall";
|
|
2274
|
+
return ApplePayEntryPoint2;
|
|
2275
|
+
})(ApplePayEntryPoint || {});
|
|
2276
|
+
|
|
2254
2277
|
// src/index.ts
|
|
2255
2278
|
function defineApplePayElements() {
|
|
2256
2279
|
ApplePayButton.define();
|
|
@@ -2259,6 +2282,7 @@ function defineApplePayElements() {
|
|
|
2259
2282
|
export {
|
|
2260
2283
|
APPLE_PAY_EXCLUDED_VARIANTS,
|
|
2261
2284
|
ApplePayButton,
|
|
2285
|
+
ApplePayEntryPoint,
|
|
2262
2286
|
ApplePayModal,
|
|
2263
2287
|
configureApplePay,
|
|
2264
2288
|
defineApplePayElements,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Offer, ProductVariant } from './types/offer.types';
|
|
2
|
+
import { ApplePayEntryPoint } from './constants';
|
|
2
3
|
export declare const APPLE_PAY_EXCLUDED_VARIANTS: readonly ProductVariant[];
|
|
3
4
|
export declare class ApplePayButton extends HTMLElement {
|
|
4
5
|
#private;
|
|
@@ -7,13 +8,13 @@ export declare class ApplePayButton extends HTMLElement {
|
|
|
7
8
|
/**
|
|
8
9
|
* Creates and configures an ApplePayButton if the feature flag is present.
|
|
9
10
|
*/
|
|
10
|
-
static createIfEnabled(offer: Offer | undefined, country: string, entryPoint
|
|
11
|
+
static createIfEnabled(offer: Offer | undefined, country: string, entryPoint?: ApplePayEntryPoint): ApplePayButton | null;
|
|
11
12
|
get offer(): Offer | null;
|
|
12
13
|
set offer(value: Offer | null);
|
|
13
14
|
get country(): string;
|
|
14
15
|
set country(value: string);
|
|
15
|
-
get entryPoint():
|
|
16
|
-
set entryPoint(value:
|
|
16
|
+
get entryPoint(): ApplePayEntryPoint | '';
|
|
17
|
+
set entryPoint(value: ApplePayEntryPoint);
|
|
17
18
|
/**
|
|
18
19
|
* Awaitable contract for the component's current render lifecycle.
|
|
19
20
|
*
|
|
@@ -320,28 +320,41 @@ var apple_pay_modal_template_default = `<style>
|
|
|
320
320
|
cursor: not-allowed;
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
-
.apm__cta
|
|
324
|
-
|
|
323
|
+
.apm__cta-content {
|
|
324
|
+
display: flex;
|
|
325
|
+
align-items: center;
|
|
326
|
+
gap: 0.375rem;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.apm__cta-label {
|
|
330
|
+
display: inline-flex;
|
|
331
|
+
align-items: center;
|
|
332
|
+
gap: 0.375rem;
|
|
325
333
|
}
|
|
326
334
|
|
|
327
|
-
.apm__cta
|
|
335
|
+
.apm__cta-loading {
|
|
336
|
+
display: none;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.apm__cta[aria-busy="true"]::before {
|
|
328
340
|
content: '';
|
|
329
341
|
position: absolute;
|
|
330
|
-
left: 50%;
|
|
331
342
|
top: 50%;
|
|
332
|
-
|
|
333
|
-
margin-top: -0.625rem;
|
|
343
|
+
left: 50%;
|
|
334
344
|
width: 1.25rem;
|
|
335
345
|
height: 1.25rem;
|
|
336
|
-
border: 2px solid rgba(255, 255, 255, 0.
|
|
346
|
+
border: 2px solid rgba(255, 255, 255, 0.25);
|
|
337
347
|
border-top-color: #fff;
|
|
338
348
|
border-radius: 50%;
|
|
339
349
|
animation: apm-cta-spinner 0.8s linear infinite;
|
|
340
350
|
}
|
|
341
351
|
|
|
342
352
|
@keyframes apm-cta-spinner {
|
|
353
|
+
from {
|
|
354
|
+
transform: translate(-50%, -50%) rotate(0deg);
|
|
355
|
+
}
|
|
343
356
|
to {
|
|
344
|
-
transform: rotate(360deg);
|
|
357
|
+
transform: translate(-50%, -50%) rotate(360deg);
|
|
345
358
|
}
|
|
346
359
|
}
|
|
347
360
|
|
|
@@ -518,11 +531,14 @@ var apple_pay_modal_template_default = `<style>
|
|
|
518
531
|
</div>
|
|
519
532
|
<button class="apm__cta" id="apple-pay-modal-cta" aria-label="Continue with Apple Pay">
|
|
520
533
|
<span class="apm__cta-content">
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
<
|
|
524
|
-
|
|
534
|
+
<span class="apm__cta-label">
|
|
535
|
+
Continue with
|
|
536
|
+
<svg width="51" height="22" aria-hidden="true" role="img">
|
|
537
|
+
<use href="#apple-pay-logo" />
|
|
538
|
+
</svg>
|
|
539
|
+
</span>
|
|
525
540
|
</span>
|
|
541
|
+
<span class="apm__cta-loading" aria-hidden="true">Loading...</span>
|
|
526
542
|
</button>
|
|
527
543
|
</div>
|
|
528
544
|
</div>
|
|
@@ -1030,28 +1046,34 @@ var apple_pay_button_template_default = `<style>
|
|
|
1030
1046
|
cursor: default;
|
|
1031
1047
|
}
|
|
1032
1048
|
|
|
1033
|
-
teg-apple-pay-button .apple-pay-btn.wap-loading
|
|
1034
|
-
visibility: hidden;
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
teg-apple-pay-button .apple-pay-btn.wap-loading::after {
|
|
1049
|
+
teg-apple-pay-button .apple-pay-btn.wap-loading::before {
|
|
1038
1050
|
content: '';
|
|
1039
1051
|
position: absolute;
|
|
1040
|
-
left: 50%;
|
|
1041
1052
|
top: 50%;
|
|
1042
|
-
|
|
1043
|
-
margin-top: -0.625rem;
|
|
1053
|
+
left: 50%;
|
|
1044
1054
|
width: 1.25rem;
|
|
1045
1055
|
height: 1.25rem;
|
|
1046
|
-
border: 2px solid rgba(255, 255, 255, 0.
|
|
1056
|
+
border: 2px solid rgba(255, 255, 255, 0.25);
|
|
1047
1057
|
border-top-color: #fff;
|
|
1048
1058
|
border-radius: 50%;
|
|
1049
1059
|
animation: wap-button-spinner 0.8s linear infinite;
|
|
1050
1060
|
}
|
|
1051
1061
|
|
|
1062
|
+
teg-apple-pay-button .apple-pay-btn__logo {
|
|
1063
|
+
display: inline-flex;
|
|
1064
|
+
align-items: center;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
teg-apple-pay-button .apple-pay-btn__loading {
|
|
1068
|
+
display: none;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1052
1071
|
@keyframes wap-button-spinner {
|
|
1072
|
+
from {
|
|
1073
|
+
transform: translate(-50%, -50%) rotate(0deg);
|
|
1074
|
+
}
|
|
1053
1075
|
to {
|
|
1054
|
-
transform: rotate(360deg);
|
|
1076
|
+
transform: translate(-50%, -50%) rotate(360deg);
|
|
1055
1077
|
}
|
|
1056
1078
|
}
|
|
1057
1079
|
</style>
|
|
@@ -1063,9 +1085,12 @@ var apple_pay_button_template_default = `<style>
|
|
|
1063
1085
|
aria-label="Pay with Apple Pay"
|
|
1064
1086
|
data-analytics="paywall:apple-pay-checkout"
|
|
1065
1087
|
>
|
|
1066
|
-
<
|
|
1067
|
-
<
|
|
1068
|
-
|
|
1088
|
+
<span class="apple-pay-btn__logo">
|
|
1089
|
+
<svg width="51" height="22" aria-label="Apple Pay" role="img">
|
|
1090
|
+
<use href="#apple-pay-logo" />
|
|
1091
|
+
</svg>
|
|
1092
|
+
</span>
|
|
1093
|
+
<span class="apple-pay-btn__loading" aria-hidden="true">Loading...</span>
|
|
1069
1094
|
</button>
|
|
1070
1095
|
</div>
|
|
1071
1096
|
`;
|
|
@@ -1151,18 +1176,11 @@ var apiFetch = async (path, options = {}) => {
|
|
|
1151
1176
|
});
|
|
1152
1177
|
if (!response.ok) {
|
|
1153
1178
|
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
1179
|
if (contentType.includes("application/json")) {
|
|
1160
1180
|
const errorBody = await response.json();
|
|
1161
|
-
console.warn("[web-apple-pay] apiFetch: parsed JSON error body", { errorBody });
|
|
1162
1181
|
throw new ApiError(response.status, errorBody);
|
|
1163
1182
|
}
|
|
1164
1183
|
const errorText = await response.text();
|
|
1165
|
-
console.warn("[web-apple-pay] apiFetch: non-JSON error body", { errorText });
|
|
1166
1184
|
throw new Error(
|
|
1167
1185
|
`API request failed: ${response.status} ${response.statusText} - ${errorText}`
|
|
1168
1186
|
);
|
|
@@ -1184,6 +1202,7 @@ var validateAppleMerchant = (data) => {
|
|
|
1184
1202
|
});
|
|
1185
1203
|
};
|
|
1186
1204
|
var performPurchase = (data) => {
|
|
1205
|
+
console.log("[web-apple-pay] /v1/wallet/purchase payload", data);
|
|
1187
1206
|
return apiFetch("/v1/wallet/purchase", {
|
|
1188
1207
|
method: "POST",
|
|
1189
1208
|
body: JSON.stringify(data),
|
|
@@ -1336,8 +1355,6 @@ var MSG_EMAIL_WRONG_FORMAT = "That email doesn\u2019t look right. Please enter a
|
|
|
1336
1355
|
var MSG_EMAIL_TOO_LONG = "This field must be 80 characters or less.";
|
|
1337
1356
|
var MSG_UNSUPPORTED_BILLING_COUNTRY = "Billing country does not match offer price zone";
|
|
1338
1357
|
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
1358
|
var MSG_CONTACT_VALIDATION_INTERNAL = "Could not validate Apple Pay contact";
|
|
1342
1359
|
|
|
1343
1360
|
// src/clients/payment-checkout/apple-session.ts
|
|
@@ -1526,8 +1543,6 @@ var shippingContactDetails = (shippingContact) => {
|
|
|
1526
1543
|
};
|
|
1527
1544
|
|
|
1528
1545
|
// 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
1546
|
var failApplePaySession = (session, errors = []) => {
|
|
1532
1547
|
session.completePayment({
|
|
1533
1548
|
status: ApplePaySession.STATUS_FAILURE,
|
|
@@ -1567,22 +1582,21 @@ function redirectFallback(skuId, returnUrl, country, options) {
|
|
|
1567
1582
|
});
|
|
1568
1583
|
}
|
|
1569
1584
|
var ERROR_HANDLERS = {
|
|
1570
|
-
|
|
1571
|
-
|
|
1585
|
+
// emailError flows as an inline field error on the email input.
|
|
1586
|
+
// email pre-populates the input so the user doesn't have to retype it.
|
|
1587
|
+
EMAIL_COLLISION: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
1588
|
+
emailError: walletError.message,
|
|
1572
1589
|
email: validatedEmail
|
|
1573
1590
|
}),
|
|
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,
|
|
1591
|
+
PAYMENT_DECLINED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1592
|
+
ELIGIBILITY_REJECTED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1593
|
+
REGISTRATION_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1594
|
+
ACCOUNT_CREATION_FAILED: ({ skuId, returnUrl, country, validatedEmail, walletError }) => redirectFallback(skuId, returnUrl, country, {
|
|
1595
|
+
emailError: walletError.message,
|
|
1582
1596
|
email: validatedEmail
|
|
1583
1597
|
}),
|
|
1584
|
-
VALIDATION_ERROR: ({ skuId, returnUrl, country }) => redirectFallback(skuId, returnUrl, country, { inlineError:
|
|
1585
|
-
RECAPTCHA_FAILED: ({ skuId, returnUrl, country }) => redirectFallback(skuId, returnUrl, country, { inlineError:
|
|
1598
|
+
VALIDATION_ERROR: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message }),
|
|
1599
|
+
RECAPTCHA_FAILED: ({ skuId, returnUrl, country, walletError }) => redirectFallback(skuId, returnUrl, country, { inlineError: walletError.message })
|
|
1586
1600
|
};
|
|
1587
1601
|
function handleStructuredError(ctx) {
|
|
1588
1602
|
const handler = ERROR_HANDLERS[ctx.walletError.errorType];
|
|
@@ -1936,7 +1950,9 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
|
|
|
1936
1950
|
const button = document.createElement(_ApplePayButton.tag);
|
|
1937
1951
|
button.offer = offer;
|
|
1938
1952
|
button.country = country;
|
|
1939
|
-
|
|
1953
|
+
if (entryPoint) {
|
|
1954
|
+
button.entryPoint = entryPoint;
|
|
1955
|
+
}
|
|
1940
1956
|
return button;
|
|
1941
1957
|
}
|
|
1942
1958
|
/**
|