@paypal/checkout-components 5.0.330 → 5.0.331
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/package.json
CHANGED
package/src/ui/buttons/props.js
CHANGED
|
@@ -433,7 +433,7 @@ export type ApplePaySessionConfigRequest = (
|
|
|
433
433
|
|
|
434
434
|
export type ButtonMessage = {|
|
|
435
435
|
amount?: number,
|
|
436
|
-
offer?:
|
|
436
|
+
offer?: string,
|
|
437
437
|
color: $Values<typeof MESSAGE_COLOR>,
|
|
438
438
|
position: $Values<typeof MESSAGE_POSITION>,
|
|
439
439
|
align: $Values<typeof MESSAGE_ALIGN>,
|
|
@@ -782,12 +782,11 @@ export function normalizeButtonMessage(
|
|
|
782
782
|
): ButtonMessage {
|
|
783
783
|
const {
|
|
784
784
|
amount,
|
|
785
|
-
offer,
|
|
786
785
|
color = MESSAGE_COLOR.BLACK,
|
|
787
786
|
position,
|
|
788
787
|
align = MESSAGE_ALIGN.CENTER,
|
|
789
788
|
} = message;
|
|
790
|
-
|
|
789
|
+
let offer = message.offer;
|
|
791
790
|
if (typeof amount !== "undefined") {
|
|
792
791
|
if (typeof amount !== "number") {
|
|
793
792
|
throw new TypeError(
|
|
@@ -802,6 +801,9 @@ export function normalizeButtonMessage(
|
|
|
802
801
|
}
|
|
803
802
|
|
|
804
803
|
if (typeof offer !== "undefined") {
|
|
804
|
+
if (typeof offer === "string") {
|
|
805
|
+
offer = offer.split(",");
|
|
806
|
+
}
|
|
805
807
|
if (!Array.isArray(offer)) {
|
|
806
808
|
throw new TypeError(
|
|
807
809
|
`Expected message.offer to be an array of strings, got: ${String(
|
|
@@ -815,6 +817,7 @@ export function normalizeButtonMessage(
|
|
|
815
817
|
if (invalidOffers.length > 0) {
|
|
816
818
|
throw new Error(`Invalid offer(s): ${invalidOffers.join(",")}`);
|
|
817
819
|
}
|
|
820
|
+
offer = offer.join(",");
|
|
818
821
|
}
|
|
819
822
|
|
|
820
823
|
if (typeof color !== "undefined" && !values(MESSAGE_COLOR).includes(color)) {
|
package/src/ui/buttons/util.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { COUNTRY, FUNDING } from "@paypal/sdk-constants/src";
|
|
3
3
|
|
|
4
4
|
import { BUTTON_LABEL, BUTTON_LAYOUT, MESSAGE_POSITION } from "../../constants";
|
|
5
|
-
import { ValidationError } from "../../lib";
|
|
6
5
|
|
|
7
6
|
export function isBorderRadiusNumber(borderRadius?: number): boolean {
|
|
8
7
|
return typeof borderRadius === "number";
|
|
@@ -25,8 +24,9 @@ export function calculateMessagePosition(
|
|
|
25
24
|
const showPoweredBy = calculateShowPoweredBy(layout, fundingSources);
|
|
26
25
|
|
|
27
26
|
if (showPoweredBy && position === MESSAGE_POSITION.BOTTOM) {
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
// eslint-disable-next-line no-console
|
|
28
|
+
console.warn(
|
|
29
|
+
"PayPal Button Message cannot be positioned at bottom when displaying the Debit or Credit Card button."
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -743,7 +743,11 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
|
|
|
743
743
|
})
|
|
744
744
|
.flush();
|
|
745
745
|
|
|
746
|
-
const modalInstance = await getModal(
|
|
746
|
+
const modalInstance = await getModal(
|
|
747
|
+
clientID,
|
|
748
|
+
merchantID,
|
|
749
|
+
buttonSessionID
|
|
750
|
+
);
|
|
747
751
|
return modalInstance?.show({
|
|
748
752
|
amount,
|
|
749
753
|
offer: offerType,
|
|
@@ -758,11 +762,10 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
|
|
|
758
762
|
required: false,
|
|
759
763
|
value: ({ props }) => {
|
|
760
764
|
return () => {
|
|
761
|
-
const { clientID, merchantID } = props;
|
|
762
765
|
// offerType, messageType, offerCountryCode, and creditProductIdentifier are passed in and may be used in an upcoming message hover logging feature
|
|
763
|
-
|
|
764
766
|
// lazy loads the modal, to be memoized and executed onMessageClick
|
|
765
|
-
|
|
767
|
+
const { buttonSessionID, clientID, merchantID } = props;
|
|
768
|
+
return getModal(clientID, merchantID, buttonSessionID);
|
|
766
769
|
};
|
|
767
770
|
},
|
|
768
771
|
},
|
package/src/zoid/buttons/util.js
CHANGED
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
once,
|
|
15
15
|
memoize,
|
|
16
16
|
} from "@krakenjs/belter/src";
|
|
17
|
-
import { FUNDING } from "@paypal/sdk-constants/src";
|
|
18
17
|
import {
|
|
19
18
|
getEnableFunding,
|
|
20
19
|
getLogger,
|
|
@@ -25,6 +24,7 @@ import {
|
|
|
25
24
|
getEnv,
|
|
26
25
|
getNamespace,
|
|
27
26
|
} from "@paypal/sdk-client/src";
|
|
27
|
+
import { FUNDING, FPTI_KEY } from "@paypal/sdk-constants/src";
|
|
28
28
|
import { getRefinedFundingEligibility } from "@paypal/funding-components/src";
|
|
29
29
|
|
|
30
30
|
import type { Experiment as EligibilityExperiment } from "../../types";
|
|
@@ -371,8 +371,9 @@ function buildModalBundleUrl(): string {
|
|
|
371
371
|
|
|
372
372
|
export const getModal: (
|
|
373
373
|
clientID: string,
|
|
374
|
-
merchantID
|
|
375
|
-
|
|
374
|
+
merchantID: $ReadOnlyArray<string> | void,
|
|
375
|
+
buttonSessionID: string
|
|
376
|
+
) => Object = memoize(async (clientID, merchantID, buttonSessionID) => {
|
|
376
377
|
try {
|
|
377
378
|
const namespace = getNamespace();
|
|
378
379
|
if (!window[namespace].MessagesModal) {
|
|
@@ -393,6 +394,19 @@ export const getModal: (
|
|
|
393
394
|
}
|
|
394
395
|
|
|
395
396
|
return window[namespace].MessagesModal({
|
|
397
|
+
buttonSessionId: buttonSessionID,
|
|
398
|
+
onApply: () =>
|
|
399
|
+
getLogger()
|
|
400
|
+
.info("button_message_modal_apply")
|
|
401
|
+
.track({
|
|
402
|
+
[FPTI_KEY.TRANSITION]: "button_message_modal_apply",
|
|
403
|
+
[FPTI_KEY.STATE]: "BUTTON_MESSAGE",
|
|
404
|
+
[FPTI_KEY.BUTTON_SESSION_UID]: buttonSessionID,
|
|
405
|
+
[FPTI_KEY.CONTEXT_ID]: buttonSessionID,
|
|
406
|
+
[FPTI_KEY.CONTEXT_TYPE]: "button_session_id",
|
|
407
|
+
[FPTI_KEY.EVENT_NAME]: "modal_apply",
|
|
408
|
+
})
|
|
409
|
+
.flush(),
|
|
396
410
|
account: `client-id:${clientID}`,
|
|
397
411
|
merchantId: merchantID?.join(",") || undefined,
|
|
398
412
|
});
|
|
@@ -295,6 +295,12 @@ export function getVenmoCheckoutComponent(): VenmoCheckoutComponent {
|
|
|
295
295
|
queryParam: true,
|
|
296
296
|
required: false,
|
|
297
297
|
},
|
|
298
|
+
|
|
299
|
+
venmoVaultEnabled: {
|
|
300
|
+
type: "boolean",
|
|
301
|
+
queryParam: true,
|
|
302
|
+
required: false,
|
|
303
|
+
},
|
|
298
304
|
},
|
|
299
305
|
|
|
300
306
|
dimensions: ({ props }) => {
|