@economist/web-apple-pay 0.1.3-beta.26 → 0.1.3-beta.28
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 -3
- package/dist/src/apple-pay-button.js +7 -3
- package/dist/src/apple-pay-button.stories.js +7 -3
- package/dist/src/apple-pay-modal.stories.js +7 -3
- package/dist/src/clients/payment-checkout/index.js +1 -1
- package/dist/src/clients/payment-checkout/payment-handler.js +7 -3
- package/dist/src/clients/payment-checkout/types.d.ts +5 -1
- package/dist/src/index.js +7 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1207,7 +1207,7 @@ var validateAppleMerchant = (data) => {
|
|
|
1207
1207
|
});
|
|
1208
1208
|
};
|
|
1209
1209
|
var performPurchase = (data) => {
|
|
1210
|
-
console.log("[web-apple-pay] /v1/wallet/purchase payload", data);
|
|
1210
|
+
console.log("[web-apple-pay] /v1/wallet/purchase payload", JSON.stringify(data, null, 2));
|
|
1211
1211
|
return apiFetch("/v1/wallet/purchase", {
|
|
1212
1212
|
method: "POST",
|
|
1213
1213
|
body: JSON.stringify(data),
|
|
@@ -1620,13 +1620,17 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1620
1620
|
sessionData,
|
|
1621
1621
|
config.supportedBillingCountries
|
|
1622
1622
|
);
|
|
1623
|
+
const resolvedShippingContact = sessionData.loggedIn ? {
|
|
1624
|
+
...event.payment.shippingContact ?? {},
|
|
1625
|
+
emailAddress: sessionData.emailAddress
|
|
1626
|
+
} : event.payment.shippingContact;
|
|
1623
1627
|
const result = await performPurchase({
|
|
1624
1628
|
applePayToken: event.payment.token,
|
|
1625
1629
|
skuId: config.skuId,
|
|
1626
1630
|
currency: config.currency,
|
|
1627
1631
|
billingContact: event.payment.billingContact,
|
|
1628
|
-
...
|
|
1629
|
-
shippingContact:
|
|
1632
|
+
...resolvedShippingContact && {
|
|
1633
|
+
shippingContact: resolvedShippingContact
|
|
1630
1634
|
},
|
|
1631
1635
|
recaptchaTokens: config.recaptchaTokens
|
|
1632
1636
|
});
|
|
@@ -1202,7 +1202,7 @@ var validateAppleMerchant = (data) => {
|
|
|
1202
1202
|
});
|
|
1203
1203
|
};
|
|
1204
1204
|
var performPurchase = (data) => {
|
|
1205
|
-
console.log("[web-apple-pay] /v1/wallet/purchase payload", data);
|
|
1205
|
+
console.log("[web-apple-pay] /v1/wallet/purchase payload", JSON.stringify(data, null, 2));
|
|
1206
1206
|
return apiFetch("/v1/wallet/purchase", {
|
|
1207
1207
|
method: "POST",
|
|
1208
1208
|
body: JSON.stringify(data),
|
|
@@ -1615,13 +1615,17 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1615
1615
|
sessionData,
|
|
1616
1616
|
config.supportedBillingCountries
|
|
1617
1617
|
);
|
|
1618
|
+
const resolvedShippingContact = sessionData.loggedIn ? {
|
|
1619
|
+
...event.payment.shippingContact ?? {},
|
|
1620
|
+
emailAddress: sessionData.emailAddress
|
|
1621
|
+
} : event.payment.shippingContact;
|
|
1618
1622
|
const result = await performPurchase({
|
|
1619
1623
|
applePayToken: event.payment.token,
|
|
1620
1624
|
skuId: config.skuId,
|
|
1621
1625
|
currency: config.currency,
|
|
1622
1626
|
billingContact: event.payment.billingContact,
|
|
1623
|
-
...
|
|
1624
|
-
shippingContact:
|
|
1627
|
+
...resolvedShippingContact && {
|
|
1628
|
+
shippingContact: resolvedShippingContact
|
|
1625
1629
|
},
|
|
1626
1630
|
recaptchaTokens: config.recaptchaTokens
|
|
1627
1631
|
});
|
|
@@ -1210,7 +1210,7 @@ var validateAppleMerchant = (data) => {
|
|
|
1210
1210
|
});
|
|
1211
1211
|
};
|
|
1212
1212
|
var performPurchase = (data) => {
|
|
1213
|
-
console.log("[web-apple-pay] /v1/wallet/purchase payload", data);
|
|
1213
|
+
console.log("[web-apple-pay] /v1/wallet/purchase payload", JSON.stringify(data, null, 2));
|
|
1214
1214
|
return apiFetch("/v1/wallet/purchase", {
|
|
1215
1215
|
method: "POST",
|
|
1216
1216
|
body: JSON.stringify(data),
|
|
@@ -1623,13 +1623,17 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1623
1623
|
sessionData,
|
|
1624
1624
|
config.supportedBillingCountries
|
|
1625
1625
|
);
|
|
1626
|
+
const resolvedShippingContact = sessionData.loggedIn ? {
|
|
1627
|
+
...event.payment.shippingContact ?? {},
|
|
1628
|
+
emailAddress: sessionData.emailAddress
|
|
1629
|
+
} : event.payment.shippingContact;
|
|
1626
1630
|
const result = await performPurchase({
|
|
1627
1631
|
applePayToken: event.payment.token,
|
|
1628
1632
|
skuId: config.skuId,
|
|
1629
1633
|
currency: config.currency,
|
|
1630
1634
|
billingContact: event.payment.billingContact,
|
|
1631
|
-
...
|
|
1632
|
-
shippingContact:
|
|
1635
|
+
...resolvedShippingContact && {
|
|
1636
|
+
shippingContact: resolvedShippingContact
|
|
1633
1637
|
},
|
|
1634
1638
|
recaptchaTokens: config.recaptchaTokens
|
|
1635
1639
|
});
|
|
@@ -1202,7 +1202,7 @@ var validateAppleMerchant = (data) => {
|
|
|
1202
1202
|
});
|
|
1203
1203
|
};
|
|
1204
1204
|
var performPurchase = (data) => {
|
|
1205
|
-
console.log("[web-apple-pay] /v1/wallet/purchase payload", data);
|
|
1205
|
+
console.log("[web-apple-pay] /v1/wallet/purchase payload", JSON.stringify(data, null, 2));
|
|
1206
1206
|
return apiFetch("/v1/wallet/purchase", {
|
|
1207
1207
|
method: "POST",
|
|
1208
1208
|
body: JSON.stringify(data),
|
|
@@ -1615,13 +1615,17 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1615
1615
|
sessionData,
|
|
1616
1616
|
config.supportedBillingCountries
|
|
1617
1617
|
);
|
|
1618
|
+
const resolvedShippingContact = sessionData.loggedIn ? {
|
|
1619
|
+
...event.payment.shippingContact ?? {},
|
|
1620
|
+
emailAddress: sessionData.emailAddress
|
|
1621
|
+
} : event.payment.shippingContact;
|
|
1618
1622
|
const result = await performPurchase({
|
|
1619
1623
|
applePayToken: event.payment.token,
|
|
1620
1624
|
skuId: config.skuId,
|
|
1621
1625
|
currency: config.currency,
|
|
1622
1626
|
billingContact: event.payment.billingContact,
|
|
1623
|
-
...
|
|
1624
|
-
shippingContact:
|
|
1627
|
+
...resolvedShippingContact && {
|
|
1628
|
+
shippingContact: resolvedShippingContact
|
|
1625
1629
|
},
|
|
1626
1630
|
recaptchaTokens: config.recaptchaTokens
|
|
1627
1631
|
});
|
|
@@ -69,7 +69,7 @@ var validateAppleMerchant = (data) => {
|
|
|
69
69
|
});
|
|
70
70
|
};
|
|
71
71
|
var performPurchase = (data) => {
|
|
72
|
-
console.log("[web-apple-pay] /v1/wallet/purchase payload", data);
|
|
72
|
+
console.log("[web-apple-pay] /v1/wallet/purchase payload", JSON.stringify(data, null, 2));
|
|
73
73
|
return apiFetch("/v1/wallet/purchase", {
|
|
74
74
|
method: "POST",
|
|
75
75
|
body: JSON.stringify(data),
|
|
@@ -55,7 +55,7 @@ var apiFetch = async (path, options = {}) => {
|
|
|
55
55
|
return response.json();
|
|
56
56
|
};
|
|
57
57
|
var performPurchase = (data) => {
|
|
58
|
-
console.log("[web-apple-pay] /v1/wallet/purchase payload", data);
|
|
58
|
+
console.log("[web-apple-pay] /v1/wallet/purchase payload", JSON.stringify(data, null, 2));
|
|
59
59
|
return apiFetch("/v1/wallet/purchase", {
|
|
60
60
|
method: "POST",
|
|
61
61
|
body: JSON.stringify(data),
|
|
@@ -360,13 +360,17 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
360
360
|
sessionData,
|
|
361
361
|
config.supportedBillingCountries
|
|
362
362
|
);
|
|
363
|
+
const resolvedShippingContact = sessionData.loggedIn ? {
|
|
364
|
+
...event.payment.shippingContact ?? {},
|
|
365
|
+
emailAddress: sessionData.emailAddress
|
|
366
|
+
} : event.payment.shippingContact;
|
|
363
367
|
const result = await performPurchase({
|
|
364
368
|
applePayToken: event.payment.token,
|
|
365
369
|
skuId: config.skuId,
|
|
366
370
|
currency: config.currency,
|
|
367
371
|
billingContact: event.payment.billingContact,
|
|
368
|
-
...
|
|
369
|
-
shippingContact:
|
|
372
|
+
...resolvedShippingContact && {
|
|
373
|
+
shippingContact: resolvedShippingContact
|
|
370
374
|
},
|
|
371
375
|
recaptchaTokens: config.recaptchaTokens
|
|
372
376
|
});
|
|
@@ -89,7 +89,11 @@ export type PurchaseRequest = {
|
|
|
89
89
|
skuId: string;
|
|
90
90
|
currency: string;
|
|
91
91
|
billingContact: ApplePayPaymentContact;
|
|
92
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* Contains an emailAddress for /purchase. For anonymous users this is sourced
|
|
94
|
+
* from Apple Pay shipping contact; for logged-in users it may be filled from
|
|
95
|
+
* authenticated session data when Apple Pay does not return shipping fields.
|
|
96
|
+
*/
|
|
93
97
|
shippingContact?: ApplePayPaymentContact;
|
|
94
98
|
recaptchaTokens: {
|
|
95
99
|
checkEligibility: string;
|
package/dist/src/index.js
CHANGED
|
@@ -1207,7 +1207,7 @@ var validateAppleMerchant = (data) => {
|
|
|
1207
1207
|
});
|
|
1208
1208
|
};
|
|
1209
1209
|
var performPurchase = (data) => {
|
|
1210
|
-
console.log("[web-apple-pay] /v1/wallet/purchase payload", data);
|
|
1210
|
+
console.log("[web-apple-pay] /v1/wallet/purchase payload", JSON.stringify(data, null, 2));
|
|
1211
1211
|
return apiFetch("/v1/wallet/purchase", {
|
|
1212
1212
|
method: "POST",
|
|
1213
1213
|
body: JSON.stringify(data),
|
|
@@ -1620,13 +1620,17 @@ async function handlePaymentAuthorized(event, session, sessionData, config) {
|
|
|
1620
1620
|
sessionData,
|
|
1621
1621
|
config.supportedBillingCountries
|
|
1622
1622
|
);
|
|
1623
|
+
const resolvedShippingContact = sessionData.loggedIn ? {
|
|
1624
|
+
...event.payment.shippingContact ?? {},
|
|
1625
|
+
emailAddress: sessionData.emailAddress
|
|
1626
|
+
} : event.payment.shippingContact;
|
|
1623
1627
|
const result = await performPurchase({
|
|
1624
1628
|
applePayToken: event.payment.token,
|
|
1625
1629
|
skuId: config.skuId,
|
|
1626
1630
|
currency: config.currency,
|
|
1627
1631
|
billingContact: event.payment.billingContact,
|
|
1628
|
-
...
|
|
1629
|
-
shippingContact:
|
|
1632
|
+
...resolvedShippingContact && {
|
|
1633
|
+
shippingContact: resolvedShippingContact
|
|
1630
1634
|
},
|
|
1631
1635
|
recaptchaTokens: config.recaptchaTokens
|
|
1632
1636
|
});
|
package/package.json
CHANGED