@paypal/checkout-components 5.0.426-alpha-ea5d1e6.0 → 5.0.427
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/button.js +1 -1
- package/dist/test/button.js +1 -1
- package/package.json +8 -8
- package/src/connect/component.jsx +1 -1
- package/src/connect/component.test.js +2 -2
- package/src/funding/card/config.jsx +3 -3
- package/src/funding/card/config.test.jsx +10 -10
- package/src/funding/funding.js +6 -6
- package/src/funding/funding.test.js +3 -3
- package/src/funding/paylater/config.jsx +2 -2
- package/src/funding/paypal/template.jsx +8 -8
- package/src/funding/util.js +2 -2
- package/src/funding/util.test.js +16 -16
- package/src/hosted-buttons/index.test.js +9 -9
- package/src/hosted-buttons/types.js +3 -3
- package/src/hosted-buttons/utils.js +8 -8
- package/src/hosted-buttons/utils.test.js +43 -43
- package/src/lib/api.js +2 -2
- package/src/lib/appSwitchResume.js +1 -1
- package/src/lib/perceived-latency-instrumentation.js +1 -1
- package/src/lib/security.js +1 -1
- package/src/marks/component.jsx +4 -4
- package/src/marks/templateRebrand.test.jsx +1 -1
- package/src/shopper-insights/shopperSession.js +13 -13
- package/src/shopper-insights/shopperSession.test.js +25 -25
- package/src/three-domain-secure/api.js +1 -1
- package/src/three-domain-secure/api.test.js +4 -4
- package/src/three-domain-secure/component.jsx +3 -3
- package/src/three-domain-secure/component.test.js +14 -14
- package/src/ui/buttons/buttons.jsx +2 -2
- package/src/ui/buttons/buttons.test.js +4 -4
- package/src/ui/buttons/config.js +1 -1
- package/src/ui/buttons/poweredBy.jsx +1 -1
- package/src/ui/buttons/props.bnpl.test.js +1 -1
- package/src/ui/buttons/props.js +43 -43
- package/src/ui/buttons/props.test.js +8 -8
- package/src/ui/buttons/script.jsx +10 -10
- package/src/ui/buttons/styles/button.js +2 -2
- package/src/ui/buttons/styles/disableMaxHeightConfig.test.js +1 -1
- package/src/ui/buttons/styles/labelContainerHeight.test.js +5 -5
- package/src/ui/buttons/styles/labels.js +7 -7
- package/src/ui/buttons/styles/page.js +1 -1
- package/src/ui/buttons/styles/responsive.js +137 -137
- package/src/ui/buttons/styles/styleUtils.js +14 -12
- package/src/ui/buttons/styles/styleUtils.test.constants.js +731 -0
- package/src/ui/buttons/styles/styleUtils.test.js +198 -610
- package/src/ui/buttons/util.js +4 -4
- package/src/ui/overlay/paypal-app-switch/style.jsx +1 -1
- package/src/ui/overlay/three-domain-secure/overlay.jsx +1 -1
- package/src/ui/overlay/three-domain-secure/style.jsx +1 -1
- package/src/ui/saved-payment-methods/template.jsx +1 -1
- package/src/ui/text/text.jsx +1 -1
- package/src/zoid/buttons/component.jsx +13 -13
- package/src/zoid/buttons/container.jsx +2 -2
- package/src/zoid/buttons/prerender.jsx +3 -3
- package/src/zoid/buttons/util.js +10 -10
- package/src/zoid/buttons/util.test.js +2 -2
- package/src/zoid/card-fields/component.jsx +8 -9
- package/src/zoid/card-form/component.js +3 -3
- package/src/zoid/checkout/component.jsx +2 -2
- package/src/zoid/payment-fields/component.jsx +1 -1
- package/src/zoid/qr-code/container.test.jsx +2 -2
- package/src/zoid/qr-code/prerender.test.jsx +1 -1
- package/src/zoid/saved-payment-methods/component.jsx +8 -8
- package/src/zoid/saved-payment-methods/util.js +2 -2
- package/src/zoid/saved-payment-methods/util.test.js +14 -14
- package/src/zoid/wallet/component.jsx +1 -1
|
@@ -139,7 +139,7 @@ describe("getHostedButtonDetails", () => {
|
|
|
139
139
|
// $FlowIssue
|
|
140
140
|
request.mockImplementationOnce(() =>
|
|
141
141
|
// eslint-disable-next-line compat/compat
|
|
142
|
-
Promise.resolve(getHostedButtonDetailsResponse.v1)
|
|
142
|
+
Promise.resolve(getHostedButtonDetailsResponse.v1),
|
|
143
143
|
);
|
|
144
144
|
await getHostedButtonDetails({
|
|
145
145
|
hostedButtonId,
|
|
@@ -161,7 +161,7 @@ describe("getHostedButtonDetails", () => {
|
|
|
161
161
|
// $FlowIssue
|
|
162
162
|
request.mockImplementationOnce(() =>
|
|
163
163
|
// eslint-disable-next-line compat/compat
|
|
164
|
-
Promise.resolve(getHostedButtonDetailsResponse.v2)
|
|
164
|
+
Promise.resolve(getHostedButtonDetailsResponse.v2),
|
|
165
165
|
);
|
|
166
166
|
await getHostedButtonDetails({
|
|
167
167
|
hostedButtonId,
|
|
@@ -184,7 +184,7 @@ describe("getHostedButtonDetails", () => {
|
|
|
184
184
|
// $FlowIssue
|
|
185
185
|
request.mockImplementationOnce(() =>
|
|
186
186
|
// eslint-disable-next-line compat/compat
|
|
187
|
-
Promise.resolve(getHostedButtonDetailsResponse.v2)
|
|
187
|
+
Promise.resolve(getHostedButtonDetailsResponse.v2),
|
|
188
188
|
);
|
|
189
189
|
await getHostedButtonDetails({
|
|
190
190
|
hostedButtonId,
|
|
@@ -203,7 +203,7 @@ describe("getHostedButtonDetails", () => {
|
|
|
203
203
|
// $FlowIssue
|
|
204
204
|
request.mockImplementationOnce(() =>
|
|
205
205
|
// eslint-disable-next-line compat/compat
|
|
206
|
-
Promise.resolve(getHostedButtonDetailsResponse.v2)
|
|
206
|
+
Promise.resolve(getHostedButtonDetailsResponse.v2),
|
|
207
207
|
);
|
|
208
208
|
await getHostedButtonDetails({
|
|
209
209
|
hostedButtonId,
|
|
@@ -238,7 +238,7 @@ describe("getHostedButtonDetails", () => {
|
|
|
238
238
|
],
|
|
239
239
|
},
|
|
240
240
|
},
|
|
241
|
-
})
|
|
241
|
+
}),
|
|
242
242
|
);
|
|
243
243
|
await getHostedButtonDetails({
|
|
244
244
|
hostedButtonId,
|
|
@@ -246,7 +246,7 @@ describe("getHostedButtonDetails", () => {
|
|
|
246
246
|
expect(style).toEqual(
|
|
247
247
|
expect.objectContaining({
|
|
248
248
|
tagline: false,
|
|
249
|
-
})
|
|
249
|
+
}),
|
|
250
250
|
);
|
|
251
251
|
});
|
|
252
252
|
|
|
@@ -273,7 +273,7 @@ describe("getHostedButtonDetails", () => {
|
|
|
273
273
|
},
|
|
274
274
|
version: "2",
|
|
275
275
|
},
|
|
276
|
-
})
|
|
276
|
+
}),
|
|
277
277
|
);
|
|
278
278
|
await getHostedButtonDetails({
|
|
279
279
|
hostedButtonId,
|
|
@@ -308,7 +308,7 @@ describe("getHostedButtonDetails", () => {
|
|
|
308
308
|
],
|
|
309
309
|
},
|
|
310
310
|
},
|
|
311
|
-
})
|
|
311
|
+
}),
|
|
312
312
|
);
|
|
313
313
|
await getHostedButtonDetails({
|
|
314
314
|
hostedButtonId,
|
|
@@ -316,7 +316,7 @@ describe("getHostedButtonDetails", () => {
|
|
|
316
316
|
expect(style).toEqual(
|
|
317
317
|
expect.objectContaining({
|
|
318
318
|
tagline: false,
|
|
319
|
-
})
|
|
319
|
+
}),
|
|
320
320
|
);
|
|
321
321
|
});
|
|
322
322
|
|
|
@@ -339,7 +339,7 @@ describe("getHostedButtonDetails", () => {
|
|
|
339
339
|
},
|
|
340
340
|
version: "2",
|
|
341
341
|
},
|
|
342
|
-
})
|
|
342
|
+
}),
|
|
343
343
|
);
|
|
344
344
|
await getHostedButtonDetails({
|
|
345
345
|
hostedButtonId,
|
|
@@ -367,7 +367,7 @@ describe("createAccessToken", () => {
|
|
|
367
367
|
headers: expect.objectContaining({
|
|
368
368
|
Authorization: expect.stringContaining("Basic "),
|
|
369
369
|
}),
|
|
370
|
-
})
|
|
370
|
+
}),
|
|
371
371
|
);
|
|
372
372
|
expect.assertions(1);
|
|
373
373
|
});
|
|
@@ -382,7 +382,7 @@ describe("createAccessToken", () => {
|
|
|
382
382
|
Authorization: expect.stringContaining("Basic "),
|
|
383
383
|
DPoP: expect.any(String),
|
|
384
384
|
}),
|
|
385
|
-
})
|
|
385
|
+
}),
|
|
386
386
|
);
|
|
387
387
|
expect.assertions(1);
|
|
388
388
|
});
|
|
@@ -399,7 +399,7 @@ describe("BuildRequestHeaders", () => {
|
|
|
399
399
|
Authorization: expect.stringContaining("Bearer"),
|
|
400
400
|
"Content-Type": "application/json",
|
|
401
401
|
"PayPal-Entry-Point": "SDK",
|
|
402
|
-
})
|
|
402
|
+
}),
|
|
403
403
|
);
|
|
404
404
|
expect.assertions(1);
|
|
405
405
|
});
|
|
@@ -418,7 +418,7 @@ describe("BuildRequestHeaders", () => {
|
|
|
418
418
|
"Content-Type": "application/json",
|
|
419
419
|
"PayPal-Entry-Point": "SDK",
|
|
420
420
|
DPoP: expect.any(String),
|
|
421
|
-
})
|
|
421
|
+
}),
|
|
422
422
|
);
|
|
423
423
|
expect.assertions(1);
|
|
424
424
|
});
|
|
@@ -436,7 +436,7 @@ test("buildHostedButtonCreateOrder", async () => {
|
|
|
436
436
|
context_id: orderID,
|
|
437
437
|
status: "CREATED",
|
|
438
438
|
},
|
|
439
|
-
})
|
|
439
|
+
}),
|
|
440
440
|
);
|
|
441
441
|
|
|
442
442
|
const createOrder = buildHostedButtonCreateOrder({
|
|
@@ -449,7 +449,7 @@ test("buildHostedButtonCreateOrder", async () => {
|
|
|
449
449
|
headers: expect.objectContaining({
|
|
450
450
|
Authorization: `Bearer ${accessToken}`,
|
|
451
451
|
}),
|
|
452
|
-
})
|
|
452
|
+
}),
|
|
453
453
|
);
|
|
454
454
|
expect(createdOrderID).toBe(orderID);
|
|
455
455
|
expect.assertions(2);
|
|
@@ -473,7 +473,7 @@ test("buildHostedButtonCreateOrder with DPoP enabled", async () => {
|
|
|
473
473
|
context_id: orderID,
|
|
474
474
|
status: "CREATED",
|
|
475
475
|
},
|
|
476
|
-
})
|
|
476
|
+
}),
|
|
477
477
|
);
|
|
478
478
|
await createOrder({ paymentSource: "paypal" });
|
|
479
479
|
expect(request).toHaveBeenCalledWith(
|
|
@@ -482,7 +482,7 @@ test("buildHostedButtonCreateOrder with DPoP enabled", async () => {
|
|
|
482
482
|
Authorization: `DPoP ${accessToken}`,
|
|
483
483
|
DPoP: expect.any(String),
|
|
484
484
|
}),
|
|
485
|
-
})
|
|
485
|
+
}),
|
|
486
486
|
);
|
|
487
487
|
expect.assertions(1);
|
|
488
488
|
});
|
|
@@ -500,7 +500,7 @@ test("buildHostedButtonCreateOrder error handling", async () => {
|
|
|
500
500
|
body: {
|
|
501
501
|
name: "RESOURCE_NOT_FOUND",
|
|
502
502
|
},
|
|
503
|
-
})
|
|
503
|
+
}),
|
|
504
504
|
);
|
|
505
505
|
|
|
506
506
|
const onError = vi.fn();
|
|
@@ -526,7 +526,7 @@ test("buildHostedButtonCreateOrder error handling with issue name", async () =>
|
|
|
526
526
|
body: {
|
|
527
527
|
details: [{ issue: "RESOURCE_NOT_FOUND" }],
|
|
528
528
|
},
|
|
529
|
-
})
|
|
529
|
+
}),
|
|
530
530
|
);
|
|
531
531
|
|
|
532
532
|
const onError = vi.fn();
|
|
@@ -551,7 +551,7 @@ describe("buildHostedButtonOnApprove", () => {
|
|
|
551
551
|
// eslint-disable-next-line compat/compat
|
|
552
552
|
Promise.resolve({
|
|
553
553
|
body: {},
|
|
554
|
-
})
|
|
554
|
+
}),
|
|
555
555
|
);
|
|
556
556
|
await onApprove({ orderID, paymentSource: "paypal" });
|
|
557
557
|
expect(request).toHaveBeenCalledWith(
|
|
@@ -561,7 +561,7 @@ describe("buildHostedButtonOnApprove", () => {
|
|
|
561
561
|
merchant_id: merchantId,
|
|
562
562
|
context_id: orderID,
|
|
563
563
|
}),
|
|
564
|
-
})
|
|
564
|
+
}),
|
|
565
565
|
);
|
|
566
566
|
expect.assertions(1);
|
|
567
567
|
});
|
|
@@ -579,7 +579,7 @@ describe("buildHostedButtonOnApprove", () => {
|
|
|
579
579
|
// eslint-disable-next-line compat/compat
|
|
580
580
|
Promise.resolve({
|
|
581
581
|
body: {},
|
|
582
|
-
})
|
|
582
|
+
}),
|
|
583
583
|
);
|
|
584
584
|
await onApprove({ orderID, paymentSource: "paypal" });
|
|
585
585
|
expect(request).toHaveBeenCalledWith(
|
|
@@ -588,7 +588,7 @@ describe("buildHostedButtonOnApprove", () => {
|
|
|
588
588
|
Authorization: `DPoP ${accessToken}`,
|
|
589
589
|
DPoP: expect.any(String),
|
|
590
590
|
}),
|
|
591
|
-
})
|
|
591
|
+
}),
|
|
592
592
|
);
|
|
593
593
|
expect.assertions(1);
|
|
594
594
|
});
|
|
@@ -603,14 +603,14 @@ describe("buildHostedButtonOnApprove", () => {
|
|
|
603
603
|
// eslint-disable-next-line compat/compat
|
|
604
604
|
Promise.resolve({
|
|
605
605
|
body: {},
|
|
606
|
-
})
|
|
606
|
+
}),
|
|
607
607
|
);
|
|
608
608
|
|
|
609
609
|
test("redirects from the merchant's site to a thank you page", async () => {
|
|
610
610
|
expect(window.location.href).toBe("http://localhost:3000/");
|
|
611
611
|
await onApprove({ orderID, paymentSource: "card" });
|
|
612
612
|
expect(window.location).toBe(
|
|
613
|
-
"https://example.com/ncp/payment/B1234567890/EC-1234567890"
|
|
613
|
+
"https://example.com/ncp/payment/B1234567890/EC-1234567890",
|
|
614
614
|
);
|
|
615
615
|
});
|
|
616
616
|
|
|
@@ -626,12 +626,12 @@ describe("buildHostedButtonOnApprove", () => {
|
|
|
626
626
|
},
|
|
627
627
|
],
|
|
628
628
|
},
|
|
629
|
-
})
|
|
629
|
+
}),
|
|
630
630
|
);
|
|
631
631
|
|
|
632
632
|
await onApprove({ orderID, paymentSource: "card" });
|
|
633
633
|
expect(window.location).toBe(
|
|
634
|
-
"https://example.com/ncp/payment/B1234567890/EC-1234567890?status=DUPLICATE_INVOICE_ID"
|
|
634
|
+
"https://example.com/ncp/payment/B1234567890/EC-1234567890?status=DUPLICATE_INVOICE_ID",
|
|
635
635
|
);
|
|
636
636
|
});
|
|
637
637
|
});
|
|
@@ -672,7 +672,7 @@ describe("buildHostedButtonOnShippingAddressChange", () => {
|
|
|
672
672
|
Promise.resolve({
|
|
673
673
|
body: {},
|
|
674
674
|
status: 200,
|
|
675
|
-
})
|
|
675
|
+
}),
|
|
676
676
|
);
|
|
677
677
|
// $FlowIssue
|
|
678
678
|
await onShippingAddressChange(data, actions);
|
|
@@ -687,7 +687,7 @@ describe("buildHostedButtonOnShippingAddressChange", () => {
|
|
|
687
687
|
postal_code: postalCode,
|
|
688
688
|
},
|
|
689
689
|
}),
|
|
690
|
-
})
|
|
690
|
+
}),
|
|
691
691
|
);
|
|
692
692
|
expect.assertions(1);
|
|
693
693
|
});
|
|
@@ -704,7 +704,7 @@ describe("buildHostedButtonOnShippingAddressChange", () => {
|
|
|
704
704
|
Promise.resolve({
|
|
705
705
|
body: {},
|
|
706
706
|
status: 500,
|
|
707
|
-
})
|
|
707
|
+
}),
|
|
708
708
|
);
|
|
709
709
|
|
|
710
710
|
const localActions = {
|
|
@@ -714,7 +714,7 @@ describe("buildHostedButtonOnShippingAddressChange", () => {
|
|
|
714
714
|
|
|
715
715
|
// $FlowIssueeslint-disable-next-line compat/compat
|
|
716
716
|
await expect(onShippingAddressChange(data, localActions)).rejects.toThrow(
|
|
717
|
-
errors.ADDRESS_ERROR
|
|
717
|
+
errors.ADDRESS_ERROR,
|
|
718
718
|
);
|
|
719
719
|
|
|
720
720
|
expect(localActions.reject).toHaveBeenCalledWith(errors.ADDRESS_ERROR);
|
|
@@ -762,7 +762,7 @@ describe("buildHostedButtonOnShippingOptionsChange", () => {
|
|
|
762
762
|
Promise.resolve({
|
|
763
763
|
body: {},
|
|
764
764
|
status: 200,
|
|
765
|
-
})
|
|
765
|
+
}),
|
|
766
766
|
);
|
|
767
767
|
// $FlowIssue
|
|
768
768
|
await onShippingOptionsChange(data, actions);
|
|
@@ -772,7 +772,7 @@ describe("buildHostedButtonOnShippingOptionsChange", () => {
|
|
|
772
772
|
context_id: orderID,
|
|
773
773
|
shipping_option_id: id,
|
|
774
774
|
}),
|
|
775
|
-
})
|
|
775
|
+
}),
|
|
776
776
|
);
|
|
777
777
|
expect.assertions(1);
|
|
778
778
|
});
|
|
@@ -789,7 +789,7 @@ describe("buildHostedButtonOnShippingOptionsChange", () => {
|
|
|
789
789
|
Promise.resolve({
|
|
790
790
|
body: {},
|
|
791
791
|
status: 500,
|
|
792
|
-
})
|
|
792
|
+
}),
|
|
793
793
|
);
|
|
794
794
|
// $FlowIssue
|
|
795
795
|
await onShippingOptionsChange(data, actions);
|
|
@@ -880,7 +880,7 @@ describe("getButtonColor", () => {
|
|
|
880
880
|
colors.forEach((color) => {
|
|
881
881
|
fundingSources.forEach((fundingSource) => {
|
|
882
882
|
expect(getButtonColor(color, fundingSource)).toBe(
|
|
883
|
-
colorMapLegacy[color][fundingSource]
|
|
883
|
+
colorMapLegacy[color][fundingSource],
|
|
884
884
|
);
|
|
885
885
|
});
|
|
886
886
|
});
|
|
@@ -890,7 +890,7 @@ describe("getButtonColor", () => {
|
|
|
890
890
|
colors.forEach((color) => {
|
|
891
891
|
fundingSources.forEach((fundingSource) => {
|
|
892
892
|
expect(getButtonColor(color, fundingSource, true)).toBe(
|
|
893
|
-
colorMapRebrand[color][fundingSource]
|
|
893
|
+
colorMapRebrand[color][fundingSource],
|
|
894
894
|
);
|
|
895
895
|
});
|
|
896
896
|
});
|
|
@@ -997,7 +997,7 @@ describe("applyContainerStyles", () => {
|
|
|
997
997
|
// Intentionally not setting up the button container to throw the error
|
|
998
998
|
const shouldThrowError = () => applyContainerStyles(params);
|
|
999
999
|
expect(shouldThrowError).toThrowError(
|
|
1000
|
-
`Element with id ${buttonContainerId} not found
|
|
1000
|
+
`Element with id ${buttonContainerId} not found.`,
|
|
1001
1001
|
);
|
|
1002
1002
|
});
|
|
1003
1003
|
});
|
|
@@ -1052,7 +1052,7 @@ describe("render buttons", () => {
|
|
|
1052
1052
|
expect(Buttons).toHaveBeenCalledWith(
|
|
1053
1053
|
expect.objectContaining({
|
|
1054
1054
|
fundingSource: "paypal",
|
|
1055
|
-
})
|
|
1055
|
+
}),
|
|
1056
1056
|
);
|
|
1057
1057
|
});
|
|
1058
1058
|
|
|
@@ -1072,7 +1072,7 @@ describe("render buttons", () => {
|
|
|
1072
1072
|
|
|
1073
1073
|
expect(renderMock).toHaveBeenCalledTimes(0);
|
|
1074
1074
|
expect(errorMock).toHaveBeenCalledWith(
|
|
1075
|
-
"ncps_standalone_venmo_ineligible"
|
|
1075
|
+
"ncps_standalone_venmo_ineligible",
|
|
1076
1076
|
);
|
|
1077
1077
|
});
|
|
1078
1078
|
});
|
|
@@ -1112,7 +1112,7 @@ describe("render buttons", () => {
|
|
|
1112
1112
|
|
|
1113
1113
|
expect(errorMock).toHaveBeenCalledTimes(1);
|
|
1114
1114
|
expect(errorMock).toHaveBeenCalledWith(
|
|
1115
|
-
"ncps_standalone_venmo_ineligible"
|
|
1115
|
+
"ncps_standalone_venmo_ineligible",
|
|
1116
1116
|
);
|
|
1117
1117
|
expect(renderMock).toHaveBeenCalledWith(expectedContainerId);
|
|
1118
1118
|
});
|
|
@@ -1133,10 +1133,10 @@ describe("render buttons", () => {
|
|
|
1133
1133
|
|
|
1134
1134
|
expect(errorMock).toHaveBeenCalledTimes(2);
|
|
1135
1135
|
expect(errorMock).toHaveBeenCalledWith(
|
|
1136
|
-
"ncps_standalone_venmo_ineligible"
|
|
1136
|
+
"ncps_standalone_venmo_ineligible",
|
|
1137
1137
|
);
|
|
1138
1138
|
expect(errorMock).toHaveBeenCalledWith(
|
|
1139
|
-
"ncps_standalone_paylater_ineligible"
|
|
1139
|
+
"ncps_standalone_paylater_ineligible",
|
|
1140
1140
|
);
|
|
1141
1141
|
expect(renderMock).toHaveBeenCalledTimes(0);
|
|
1142
1142
|
});
|
package/src/lib/api.js
CHANGED
|
@@ -40,7 +40,7 @@ export function callRestAPI({
|
|
|
40
40
|
}).then(({ status, body, headers: responseHeaders }) => {
|
|
41
41
|
if (status >= 300) {
|
|
42
42
|
const error = new Error(
|
|
43
|
-
`${url} returned status ${status}\n\n${JSON.stringify(body)}
|
|
43
|
+
`${url} returned status ${status}\n\n${JSON.stringify(body)}`,
|
|
44
44
|
);
|
|
45
45
|
|
|
46
46
|
// $FlowFixMe
|
|
@@ -62,6 +62,6 @@ export function callMemoizedRestAPI({
|
|
|
62
62
|
return inlineMemoize(
|
|
63
63
|
callMemoizedRestAPI,
|
|
64
64
|
() => callRestAPI({ accessToken, method, url, data }),
|
|
65
|
-
[accessToken, method, url, JSON.stringify(data)]
|
|
65
|
+
[accessToken, method, url, JSON.stringify(data)],
|
|
66
66
|
);
|
|
67
67
|
}
|
|
@@ -86,7 +86,7 @@ function getAppSwitchParamsWebFallback(): AppSwitchResumeParams | null {
|
|
|
86
86
|
try {
|
|
87
87
|
const searchParams = Object.fromEntries(
|
|
88
88
|
// eslint-disable-next-line compat/compat
|
|
89
|
-
new URLSearchParams(window.location.search)
|
|
89
|
+
new URLSearchParams(window.location.search),
|
|
90
90
|
);
|
|
91
91
|
|
|
92
92
|
// If no PayPal params found in query string, check if they are embedded
|
|
@@ -58,7 +58,7 @@ export const logLatencyInstrumentationPhase = ({
|
|
|
58
58
|
|
|
59
59
|
export const prepareInstrumentationPayload = (
|
|
60
60
|
buttonSessionID: string,
|
|
61
|
-
component: "buttons" | "saved-payment-methods"
|
|
61
|
+
component: "buttons" | "saved-payment-methods",
|
|
62
62
|
): InstrumentationPayload => {
|
|
63
63
|
const timeOrigin = getNavigationTimeOrigin();
|
|
64
64
|
const renderStartTime = getStartTimeFromMark({
|
package/src/lib/security.js
CHANGED
|
@@ -8,7 +8,7 @@ import { ENV } from "@paypal/sdk-constants/src";
|
|
|
8
8
|
export function allowIframe(): boolean {
|
|
9
9
|
if (!isPayPalDomain()) {
|
|
10
10
|
throw new Error(
|
|
11
|
-
`Can only determine if iframe rendering is allowed on paypal domain
|
|
11
|
+
`Can only determine if iframe rendering is allowed on paypal domain`,
|
|
12
12
|
);
|
|
13
13
|
}
|
|
14
14
|
|
package/src/marks/component.jsx
CHANGED
|
@@ -91,15 +91,15 @@ export const getMarksComponent: () => MarksComponent = memoize(() => {
|
|
|
91
91
|
const supportsVenmoPopup = supportsVenmoPopups(
|
|
92
92
|
experiment,
|
|
93
93
|
supportsPopups,
|
|
94
|
-
userAgent
|
|
94
|
+
userAgent,
|
|
95
95
|
);
|
|
96
96
|
const supportedNativeVenmoBrowser = isSupportedNativeVenmoBrowser(
|
|
97
97
|
experiment,
|
|
98
|
-
userAgent
|
|
98
|
+
userAgent,
|
|
99
99
|
);
|
|
100
100
|
|
|
101
101
|
const hasShippingCallback = Boolean(
|
|
102
|
-
onShippingChange || onShippingAddressChange || onShippingOptionsChange
|
|
102
|
+
onShippingChange || onShippingAddressChange || onShippingOptionsChange,
|
|
103
103
|
);
|
|
104
104
|
const fundingSources = determineEligibleFunding({
|
|
105
105
|
fundingSource,
|
|
@@ -184,7 +184,7 @@ export const getMarksComponent: () => MarksComponent = memoize(() => {
|
|
|
184
184
|
/>
|
|
185
185
|
)}
|
|
186
186
|
</div>
|
|
187
|
-
).render(dom({ doc: document }))
|
|
187
|
+
).render(dom({ doc: document })),
|
|
188
188
|
);
|
|
189
189
|
});
|
|
190
190
|
};
|
|
@@ -47,7 +47,7 @@ describe("templateRebrand Mark variation logic", () => {
|
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
const marksDiv = element.children.find(
|
|
50
|
-
(child) => child?.props?.class === "paypal-marks-rebrand"
|
|
50
|
+
(child) => child?.props?.class === "paypal-marks-rebrand",
|
|
51
51
|
);
|
|
52
52
|
|
|
53
53
|
return marksDiv?.children?.[0]?.props;
|
|
@@ -98,7 +98,7 @@ const parseEmail = (merchantPayload): ?{| email: string |} => {
|
|
|
98
98
|
|
|
99
99
|
if (!isValidEmail) {
|
|
100
100
|
throw new ValidationError(
|
|
101
|
-
`Expected shopper information to include a valid email format
|
|
101
|
+
`Expected shopper information to include a valid email format`,
|
|
102
102
|
);
|
|
103
103
|
}
|
|
104
104
|
|
|
@@ -108,7 +108,7 @@ const parseEmail = (merchantPayload): ?{| email: string |} => {
|
|
|
108
108
|
};
|
|
109
109
|
|
|
110
110
|
const parsePhone = (
|
|
111
|
-
merchantPayload
|
|
111
|
+
merchantPayload,
|
|
112
112
|
): ?{| phone: {| country_code: string, national_number: string |} |} => {
|
|
113
113
|
if (!merchantPayload.phone) {
|
|
114
114
|
return;
|
|
@@ -119,7 +119,7 @@ const parsePhone = (
|
|
|
119
119
|
!merchantPayload.phone.countryCode
|
|
120
120
|
) {
|
|
121
121
|
throw new ValidationError(
|
|
122
|
-
`Expected phone number for shopper insights to include nationalNumber and countryCode
|
|
122
|
+
`Expected phone number for shopper insights to include nationalNumber and countryCode`,
|
|
123
123
|
);
|
|
124
124
|
}
|
|
125
125
|
|
|
@@ -130,7 +130,7 @@ const parsePhone = (
|
|
|
130
130
|
|
|
131
131
|
if (!isValidPhone) {
|
|
132
132
|
throw new ValidationError(
|
|
133
|
-
`Expected shopper information to be a valid phone number format
|
|
133
|
+
`Expected shopper information to be a valid phone number format`,
|
|
134
134
|
);
|
|
135
135
|
}
|
|
136
136
|
|
|
@@ -193,7 +193,7 @@ const parseSdkConfig = ({
|
|
|
193
193
|
});
|
|
194
194
|
|
|
195
195
|
throw new ValidationError(
|
|
196
|
-
`script data attribute sdk-client-token is required but was not passed
|
|
196
|
+
`script data attribute sdk-client-token is required but was not passed`,
|
|
197
197
|
);
|
|
198
198
|
}
|
|
199
199
|
|
|
@@ -208,7 +208,7 @@ const parseSdkConfig = ({
|
|
|
208
208
|
});
|
|
209
209
|
|
|
210
210
|
throw new ValidationError(
|
|
211
|
-
`script data attribute page-type is required but was not passed
|
|
211
|
+
`script data attribute page-type is required but was not passed`,
|
|
212
212
|
);
|
|
213
213
|
}
|
|
214
214
|
|
|
@@ -217,7 +217,7 @@ const parseSdkConfig = ({
|
|
|
217
217
|
|
|
218
218
|
export interface ShopperInsightsInterface {
|
|
219
219
|
getRecommendedPaymentMethods: (
|
|
220
|
-
payload: MerchantPayloadData
|
|
220
|
+
payload: MerchantPayloadData,
|
|
221
221
|
) => Promise<RecommendedPaymentMethods>;
|
|
222
222
|
isEligibleInPayPalNetwork: (payload: MerchantPayloadData) => Promise<boolean>;
|
|
223
223
|
}
|
|
@@ -247,7 +247,7 @@ export class ShopperSession {
|
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
async isEligibleInPayPalNetwork(
|
|
250
|
-
merchantPayload: MerchantPayloadData
|
|
250
|
+
merchantPayload: MerchantPayloadData,
|
|
251
251
|
): Promise<boolean> {
|
|
252
252
|
const startTime = Date.now();
|
|
253
253
|
const data = parseMerchantPayload({
|
|
@@ -257,7 +257,7 @@ export class ShopperSession {
|
|
|
257
257
|
try {
|
|
258
258
|
const body = await this.request<
|
|
259
259
|
RecommendedPaymentMethodsRequestData,
|
|
260
|
-
RecommendedPaymentMethodsResponse
|
|
260
|
+
RecommendedPaymentMethodsResponse,
|
|
261
261
|
>({
|
|
262
262
|
method: "POST",
|
|
263
263
|
url: `${this.sdkConfig.paypalApiDomain}/${ELIGIBLE_PAYMENT_METHODS}`,
|
|
@@ -272,7 +272,7 @@ export class ShopperSession {
|
|
|
272
272
|
const eligibleMethods = body?.eligible_methods ?? {};
|
|
273
273
|
const eligibleInPaypalNetwork = Object.keys(eligibleMethods).some(
|
|
274
274
|
(paymentMethod) =>
|
|
275
|
-
eligibleMethods[paymentMethod]?.eligible_in_paypal_network
|
|
275
|
+
eligibleMethods[paymentMethod]?.eligible_in_paypal_network,
|
|
276
276
|
);
|
|
277
277
|
|
|
278
278
|
this.logger.track({
|
|
@@ -315,7 +315,7 @@ export class ShopperSession {
|
|
|
315
315
|
}
|
|
316
316
|
|
|
317
317
|
async getRecommendedPaymentMethods(
|
|
318
|
-
merchantPayload: MerchantPayloadData
|
|
318
|
+
merchantPayload: MerchantPayloadData,
|
|
319
319
|
): Promise<RecommendedPaymentMethods> {
|
|
320
320
|
const startTime = Date.now();
|
|
321
321
|
const data = parseMerchantPayload({
|
|
@@ -325,7 +325,7 @@ export class ShopperSession {
|
|
|
325
325
|
try {
|
|
326
326
|
const body = await this.request<
|
|
327
327
|
RecommendedPaymentMethodsRequestData,
|
|
328
|
-
RecommendedPaymentMethodsResponse
|
|
328
|
+
RecommendedPaymentMethodsResponse,
|
|
329
329
|
>({
|
|
330
330
|
method: "POST",
|
|
331
331
|
url: `${this.sdkConfig.paypalApiDomain}/${ELIGIBLE_PAYMENT_METHODS}`,
|
|
@@ -354,7 +354,7 @@ export class ShopperSession {
|
|
|
354
354
|
[FPTI_KEY.EVENT_NAME]: FPTI_TRANSITION.SHOPPER_INSIGHTS_API_SUCCESS,
|
|
355
355
|
[FPTI_KEY.RESPONSE_DURATION]: (Date.now() - startTime).toString(),
|
|
356
356
|
[FPTI_KEY.RECOMMENDED_PAYMENT]: JSON.stringify(
|
|
357
|
-
fptiRecommendedPaymentPayload
|
|
357
|
+
fptiRecommendedPaymentPayload,
|
|
358
358
|
),
|
|
359
359
|
});
|
|
360
360
|
|