From 6790429442ebb47561f8170dc800f82b32a6d573 Mon Sep 17 00:00:00 2001 From: rosman Date: Tue, 30 Apr 2024 20:57:22 -0400 Subject: [PATCH 01/13] pass merchant id from cpnw callback, flush logger --- src/zoid/buttons/component.jsx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/zoid/buttons/component.jsx b/src/zoid/buttons/component.jsx index 34e860d91..d0e65f58b 100644 --- a/src/zoid/buttons/component.jsx +++ b/src/zoid/buttons/component.jsx @@ -716,9 +716,9 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { messageType, offerCountryCode, creditProductIdentifier, + merchantID, }) => { - const { message, clientID, merchantID, currency, buttonSessionID } = - props; + const { message, clientID, currency, buttonSessionID } = props; const amount = message?.amount; getLogger() @@ -730,7 +730,7 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { [FPTI_KEY.CONTEXT_ID]: buttonSessionID, [FPTI_KEY.CONTEXT_TYPE]: "button_session_id", [FPTI_KEY.EVENT_NAME]: "message_click", - [FPTI_KEY.SELLER_ID]: merchantID?.join(","), + [FPTI_KEY.SELLER_ID]: merchantID, [FPTI_KEY.BUTTON_MESSAGE_OFFER_TYPE]: offerType, [FPTI_KEY.BUTTON_MESSAGE_CREDIT_PRODUCT_IDENTIFIER]: creditProductIdentifier, @@ -741,7 +741,8 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { [FPTI_KEY.BUTTON_MESSAGE_OFFER_COUNTRY]: offerCountryCode, [FPTI_KEY.BUTTON_MESSAGE_CURRENCY]: currency, [FPTI_KEY.BUTTON_MESSAGE_AMOUNT]: amount, - }); + }) + .flush(); const modalInstance = await getModal(clientID, merchantID); return modalInstance?.show({ @@ -757,11 +758,11 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { type: "function", required: false, value: ({ props }) => { - return () => { + return ({ merchantID }) => { // offerType, messageType, offerCountryCode, and creditProductIdentifier are passed in and may be used in an upcoming message hover logging feature // lazy loads the modal, to be memoized and executed onMessageClick - const { clientID, merchantID } = props; + const { clientID } = props; return getModal(clientID, merchantID); }; }, @@ -776,8 +777,9 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { messageType, offerCountryCode, creditProductIdentifier, + merchantID, }) => { - const { message, buttonSessionID, currency, merchantID } = props; + const { message, buttonSessionID, currency } = props; getLogger() .info("button_message_render") @@ -788,7 +790,7 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { [FPTI_KEY.CONTEXT_ID]: buttonSessionID, [FPTI_KEY.CONTEXT_TYPE]: "button_session_id", [FPTI_KEY.EVENT_NAME]: "message_render", - [FPTI_KEY.SELLER_ID]: merchantID?.join(","), + [FPTI_KEY.SELLER_ID]: merchantID, [FPTI_KEY.BUTTON_MESSAGE_OFFER_TYPE]: offerType, [FPTI_KEY.BUTTON_MESSAGE_CREDIT_PRODUCT_IDENTIFIER]: creditProductIdentifier, @@ -799,7 +801,8 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { [FPTI_KEY.BUTTON_MESSAGE_CURRENCY]: currency, [FPTI_KEY.BUTTON_MESSAGE_OFFER_COUNTRY]: offerCountryCode, [FPTI_KEY.BUTTON_MESSAGE_AMOUNT]: message?.amount, - }); + }) + .flush(); }; }, }, From 97d26c3ca79050784e775494f2a0f124db271fce Mon Sep 17 00:00:00 2001 From: rosman Date: Thu, 2 May 2024 16:32:33 -0400 Subject: [PATCH 02/13] fix issue with modal and merchantID --- src/zoid/buttons/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zoid/buttons/util.js b/src/zoid/buttons/util.js index 52346bd62..9efb7cec4 100644 --- a/src/zoid/buttons/util.js +++ b/src/zoid/buttons/util.js @@ -396,7 +396,7 @@ export const getModal: ( return window[namespace].MessagesModal({ account: `client-id:${clientID}`, - merchantId: merchantID?.join(",") || undefined, + merchantId: merchantID, }); } catch (err) { // $FlowFixMe flow doesn't seem to understand that the reset function property exists on the function object itself From 9ba81f0a3296c792feb7aa986bc81763528c40d6 Mon Sep 17 00:00:00 2001 From: rosman Date: Mon, 6 May 2024 11:44:54 -0400 Subject: [PATCH 03/13] add override before tracking --- src/zoid/buttons/component.jsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/zoid/buttons/component.jsx b/src/zoid/buttons/component.jsx index d0e65f58b..156be17fd 100644 --- a/src/zoid/buttons/component.jsx +++ b/src/zoid/buttons/component.jsx @@ -721,6 +721,12 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { const { message, clientID, currency, buttonSessionID } = props; const amount = message?.amount; + // since we are adding our own merchantID + // this should override the default coming from sdk client + logger.addTrackingBuilder(() => ({ + [FPTI_KEY.SELLER_ID]: merchantID, + })); + getLogger() .info("button_message_click") .track({ @@ -781,6 +787,11 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { }) => { const { message, buttonSessionID, currency } = props; + // since we are adding our own merchantID + // this should override the default coming from sdk client + logger.addTrackingBuilder(() => ({ + [FPTI_KEY.SELLER_ID]: merchantID, + })); getLogger() .info("button_message_render") .track({ From fdbcf07a5ad41ce6ecfe1f255ef9a23bf030c9d0 Mon Sep 17 00:00:00 2001 From: rosman Date: Tue, 7 May 2024 14:05:31 -0400 Subject: [PATCH 04/13] rename to getLogger --- src/zoid/buttons/component.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zoid/buttons/component.jsx b/src/zoid/buttons/component.jsx index 156be17fd..cfb8057aa 100644 --- a/src/zoid/buttons/component.jsx +++ b/src/zoid/buttons/component.jsx @@ -723,7 +723,7 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { // since we are adding our own merchantID // this should override the default coming from sdk client - logger.addTrackingBuilder(() => ({ + getLogger().addTrackingBuilder(() => ({ [FPTI_KEY.SELLER_ID]: merchantID, })); @@ -789,7 +789,7 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { // since we are adding our own merchantID // this should override the default coming from sdk client - logger.addTrackingBuilder(() => ({ + getLogger().addTrackingBuilder(() => ({ [FPTI_KEY.SELLER_ID]: merchantID, })); getLogger() From daf370ca0afe6aa9a62f5fb304c6f3e31ded7964 Mon Sep 17 00:00:00 2001 From: rosman Date: Wed, 8 May 2024 12:37:45 -0400 Subject: [PATCH 05/13] add conditionals to check for partner id if it exists --- src/zoid/buttons/component.jsx | 52 +++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/src/zoid/buttons/component.jsx b/src/zoid/buttons/component.jsx index cfb8057aa..cb6613866 100644 --- a/src/zoid/buttons/component.jsx +++ b/src/zoid/buttons/component.jsx @@ -716,16 +716,20 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { messageType, offerCountryCode, creditProductIdentifier, - merchantID, + merchantID: serverMerchantId, }) => { - const { message, clientID, currency, buttonSessionID } = props; + const { + message, + clientID, + currency, + buttonSessionID, + merchantID: partnerMerchantId, + } = props; const amount = message?.amount; - - // since we are adding our own merchantID - // this should override the default coming from sdk client - getLogger().addTrackingBuilder(() => ({ - [FPTI_KEY.SELLER_ID]: merchantID, - })); + const merchantID = + partnerMerchantId === "" || !partnerMerchantId + ? serverMerchantId + : partnerMerchantId.join(); getLogger() .info("button_message_click") @@ -764,11 +768,16 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { type: "function", required: false, value: ({ props }) => { - return ({ merchantID }) => { + return ({ merchantID: serverMerchantId }) => { + const { clientID, merchantID: partnerMerchantId } = props; + // merchantID that comes from props is an array + const merchantID = + partnerMerchantId === "" || !partnerMerchantId + ? serverMerchantId + : partnerMerchantId.join(); // offerType, messageType, offerCountryCode, and creditProductIdentifier are passed in and may be used in an upcoming message hover logging feature // lazy loads the modal, to be memoized and executed onMessageClick - const { clientID } = props; return getModal(clientID, merchantID); }; }, @@ -783,15 +792,27 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { messageType, offerCountryCode, creditProductIdentifier, - merchantID, + merchantID: serverMerchantId, }) => { - const { message, buttonSessionID, currency } = props; - - // since we are adding our own merchantID - // this should override the default coming from sdk client + // merchantID that comes from props is an array + const { + message, + buttonSessionID, + currency, + merchantID: partnerMerchantId, + } = props; + // check to see if a partner merchant id integration exists + // if not grab the server merchant id + const merchantID = + partnerMerchantId === "" || !partnerMerchantId + ? serverMerchantId + : partnerMerchantId.join(); + + // override with server id if partner does not exist getLogger().addTrackingBuilder(() => ({ [FPTI_KEY.SELLER_ID]: merchantID, })); + getLogger() .info("button_message_render") .track({ @@ -801,7 +822,6 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { [FPTI_KEY.CONTEXT_ID]: buttonSessionID, [FPTI_KEY.CONTEXT_TYPE]: "button_session_id", [FPTI_KEY.EVENT_NAME]: "message_render", - [FPTI_KEY.SELLER_ID]: merchantID, [FPTI_KEY.BUTTON_MESSAGE_OFFER_TYPE]: offerType, [FPTI_KEY.BUTTON_MESSAGE_CREDIT_PRODUCT_IDENTIFIER]: creditProductIdentifier, From 3c52aeb470f3e9c7ad69efe0dd3758409a0b509c Mon Sep 17 00:00:00 2001 From: rosman Date: Thu, 16 May 2024 21:22:22 -0400 Subject: [PATCH 06/13] fix tests --- test/integration/tests/button/message.js | 12 ++++++------ test/integration/windows/button/index.jsx | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/integration/tests/button/message.js b/test/integration/tests/button/message.js index 3365d6e78..25fe7625a 100644 --- a/test/integration/tests/button/message.js +++ b/test/integration/tests/button/message.js @@ -458,7 +458,7 @@ describe(`paypal button message`, () => { message: {}, test: { onRender({ hoverMessage }) { - hoverMessage() + hoverMessage({ merchantID: "123" }) .then(() => { assert.equal(getNamespace(), window.namespace); done(); @@ -475,7 +475,7 @@ describe(`paypal button message`, () => { message: {}, test: { onRender({ hoverMessage }) { - hoverMessage() + hoverMessage({ merchantID: "123" }) .then(() => { assert.ok( Object.keys(window.paypal.MessagesModal.mock.calledWith) @@ -487,7 +487,7 @@ describe(`paypal button message`, () => { ); assert.ok( typeof window.paypal.MessagesModal.mock.calledWith - .merchantId === "undefined" + .merchantId === "string" ); done(); }) @@ -506,7 +506,7 @@ describe(`paypal button message`, () => { }, test: { onRender({ clickMessage, hoverMessage }) { - hoverMessage() + hoverMessage({ merchantID: "123" }) .then(() => { return clickMessage(props).then(() => { assert.equal( @@ -539,10 +539,10 @@ describe(`paypal button message`, () => { }, test: { onRender({ clickMessage, hoverMessage }) { - hoverMessage() + hoverMessage({ merchantID: "123" }) .then(() => { return clickMessage(props).then(() => { - return hoverMessage().then(() => { + return hoverMessage({ merchantID: "123" }).then(() => { return clickMessage(props).then(() => { assert.equal(window.paypal.MessagesModal.mock.calls, 1); done(); diff --git a/test/integration/windows/button/index.jsx b/test/integration/windows/button/index.jsx index e702f8022..119da324b 100644 --- a/test/integration/windows/button/index.jsx +++ b/test/integration/windows/button/index.jsx @@ -236,8 +236,8 @@ if (onRender) { click() { getElement(".paypal-button", document).click(); }, - hoverMessage(): ZalgoPromise | void { - return window.xprops.onMessageHover(); + hoverMessage({ merchantID }): ZalgoPromise | void { + return window.xprops.onMessageHover({ merchantID }); }, clickMessage({ offerType, messageType }): ZalgoPromise | void { return window.xprops.onMessageClick({ offerType, messageType }); From bbb08aeeae9cd38f27e52b8e1b2e09a07c6878e7 Mon Sep 17 00:00:00 2001 From: rosman Date: Thu, 16 May 2024 21:55:22 -0400 Subject: [PATCH 07/13] fix typecheck errors --- src/zoid/buttons/component.jsx | 12 ++++++------ src/zoid/buttons/util.js | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/zoid/buttons/component.jsx b/src/zoid/buttons/component.jsx index cb6613866..491d32c13 100644 --- a/src/zoid/buttons/component.jsx +++ b/src/zoid/buttons/component.jsx @@ -727,9 +727,9 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { } = props; const amount = message?.amount; const merchantID = - partnerMerchantId === "" || !partnerMerchantId + partnerMerchantId && partnerMerchantId[0] === "" ? serverMerchantId - : partnerMerchantId.join(); + : partnerMerchantId?.join(); getLogger() .info("button_message_click") @@ -772,9 +772,9 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { const { clientID, merchantID: partnerMerchantId } = props; // merchantID that comes from props is an array const merchantID = - partnerMerchantId === "" || !partnerMerchantId + partnerMerchantId && partnerMerchantId[0] === "" ? serverMerchantId - : partnerMerchantId.join(); + : partnerMerchantId?.join(); // offerType, messageType, offerCountryCode, and creditProductIdentifier are passed in and may be used in an upcoming message hover logging feature // lazy loads the modal, to be memoized and executed onMessageClick @@ -804,9 +804,9 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { // check to see if a partner merchant id integration exists // if not grab the server merchant id const merchantID = - partnerMerchantId === "" || !partnerMerchantId + partnerMerchantId && partnerMerchantId[0] === "" ? serverMerchantId - : partnerMerchantId.join(); + : partnerMerchantId?.join(); // override with server id if partner does not exist getLogger().addTrackingBuilder(() => ({ diff --git a/src/zoid/buttons/util.js b/src/zoid/buttons/util.js index 9efb7cec4..bc7ce3209 100644 --- a/src/zoid/buttons/util.js +++ b/src/zoid/buttons/util.js @@ -373,7 +373,7 @@ function buildModalBundleUrl(): string { export const getModal: ( clientID: string, - merchantID: $ReadOnlyArray | void + merchantID?: string | void ) => Object = memoize(async (clientID, merchantID) => { try { const namespace = getNamespace(); @@ -396,7 +396,7 @@ export const getModal: ( return window[namespace].MessagesModal({ account: `client-id:${clientID}`, - merchantId: merchantID, + merchantId: merchantID || undefined, }); } catch (err) { // $FlowFixMe flow doesn't seem to understand that the reset function property exists on the function object itself From b97e02879cf381ea91ea53a1ae180c0506e4aa97 Mon Sep 17 00:00:00 2001 From: rosman Date: Thu, 16 May 2024 22:09:39 -0400 Subject: [PATCH 08/13] fix tests --- test/integration/tests/button/message.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/tests/button/message.js b/test/integration/tests/button/message.js index 25fe7625a..6414d81bf 100644 --- a/test/integration/tests/button/message.js +++ b/test/integration/tests/button/message.js @@ -487,7 +487,7 @@ describe(`paypal button message`, () => { ); assert.ok( typeof window.paypal.MessagesModal.mock.calledWith - .merchantId === "string" + .merchantId === "undefined" ); done(); }) From 26bb4d8046a7bde6d51364bdaaec5c4d70e89ea2 Mon Sep 17 00:00:00 2001 From: rosman Date: Thu, 16 May 2024 23:34:44 -0400 Subject: [PATCH 09/13] fix issues with merchantID being undefined --- src/zoid/buttons/component.jsx | 38 ++++++++++++++++-------- test/integration/tests/button/message.js | 2 +- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/zoid/buttons/component.jsx b/src/zoid/buttons/component.jsx index 491d32c13..a946ed88d 100644 --- a/src/zoid/buttons/component.jsx +++ b/src/zoid/buttons/component.jsx @@ -726,10 +726,15 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { merchantID: partnerMerchantId, } = props; const amount = message?.amount; - const merchantID = - partnerMerchantId && partnerMerchantId[0] === "" - ? serverMerchantId - : partnerMerchantId?.join(); + const isPartnerMerchantIdEmpty = + !partnerMerchantId || + partnerMerchantId.length === 0 || + partnerMerchantId[0] === ""; + // check to see if a partner merchant id integration exists + // if not grab the server merchant id + const merchantID = isPartnerMerchantIdEmpty + ? serverMerchantId + : partnerMerchantId?.join(); getLogger() .info("button_message_click") @@ -770,11 +775,15 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { value: ({ props }) => { return ({ merchantID: serverMerchantId }) => { const { clientID, merchantID: partnerMerchantId } = props; - // merchantID that comes from props is an array - const merchantID = - partnerMerchantId && partnerMerchantId[0] === "" - ? serverMerchantId - : partnerMerchantId?.join(); + const isPartnerMerchantIdEmpty = + !partnerMerchantId || + partnerMerchantId.length === 0 || + partnerMerchantId[0] === ""; + // check to see if a partner merchant id integration exists + // if not grab the server merchant id + const merchantID = isPartnerMerchantIdEmpty + ? serverMerchantId + : partnerMerchantId?.join(); // offerType, messageType, offerCountryCode, and creditProductIdentifier are passed in and may be used in an upcoming message hover logging feature // lazy loads the modal, to be memoized and executed onMessageClick @@ -801,12 +810,15 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { currency, merchantID: partnerMerchantId, } = props; + const isPartnerMerchantIdEmpty = + !partnerMerchantId || + partnerMerchantId.length === 0 || + partnerMerchantId[0] === ""; // check to see if a partner merchant id integration exists // if not grab the server merchant id - const merchantID = - partnerMerchantId && partnerMerchantId[0] === "" - ? serverMerchantId - : partnerMerchantId?.join(); + const merchantID = isPartnerMerchantIdEmpty + ? serverMerchantId + : partnerMerchantId?.join(); // override with server id if partner does not exist getLogger().addTrackingBuilder(() => ({ diff --git a/test/integration/tests/button/message.js b/test/integration/tests/button/message.js index 6414d81bf..25fe7625a 100644 --- a/test/integration/tests/button/message.js +++ b/test/integration/tests/button/message.js @@ -487,7 +487,7 @@ describe(`paypal button message`, () => { ); assert.ok( typeof window.paypal.MessagesModal.mock.calledWith - .merchantId === "undefined" + .merchantId === "string" ); done(); }) From 7683357519f658a150278dd62c30b10b730a7f52 Mon Sep 17 00:00:00 2001 From: rosman Date: Mon, 20 May 2024 15:25:36 -0400 Subject: [PATCH 10/13] address comments --- src/zoid/buttons/component.jsx | 51 +++--------------------- src/zoid/buttons/util.js | 4 +- test/integration/tests/button/message.js | 2 +- 3 files changed, 9 insertions(+), 48 deletions(-) diff --git a/src/zoid/buttons/component.jsx b/src/zoid/buttons/component.jsx index a946ed88d..42506537a 100644 --- a/src/zoid/buttons/component.jsx +++ b/src/zoid/buttons/component.jsx @@ -716,25 +716,10 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { messageType, offerCountryCode, creditProductIdentifier, - merchantID: serverMerchantId, }) => { - const { - message, - clientID, - currency, - buttonSessionID, - merchantID: partnerMerchantId, - } = props; + const { message, clientID, currency, buttonSessionID, merchantID } = + props; const amount = message?.amount; - const isPartnerMerchantIdEmpty = - !partnerMerchantId || - partnerMerchantId.length === 0 || - partnerMerchantId[0] === ""; - // check to see if a partner merchant id integration exists - // if not grab the server merchant id - const merchantID = isPartnerMerchantIdEmpty - ? serverMerchantId - : partnerMerchantId?.join(); getLogger() .info("button_message_click") @@ -745,7 +730,6 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { [FPTI_KEY.CONTEXT_ID]: buttonSessionID, [FPTI_KEY.CONTEXT_TYPE]: "button_session_id", [FPTI_KEY.EVENT_NAME]: "message_click", - [FPTI_KEY.SELLER_ID]: merchantID, [FPTI_KEY.BUTTON_MESSAGE_OFFER_TYPE]: offerType, [FPTI_KEY.BUTTON_MESSAGE_CREDIT_PRODUCT_IDENTIFIER]: creditProductIdentifier, @@ -773,17 +757,8 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { type: "function", required: false, value: ({ props }) => { - return ({ merchantID: serverMerchantId }) => { - const { clientID, merchantID: partnerMerchantId } = props; - const isPartnerMerchantIdEmpty = - !partnerMerchantId || - partnerMerchantId.length === 0 || - partnerMerchantId[0] === ""; - // check to see if a partner merchant id integration exists - // if not grab the server merchant id - const merchantID = isPartnerMerchantIdEmpty - ? serverMerchantId - : partnerMerchantId?.join(); + return () => { + const { clientID, merchantID } = props; // offerType, messageType, offerCountryCode, and creditProductIdentifier are passed in and may be used in an upcoming message hover logging feature // lazy loads the modal, to be memoized and executed onMessageClick @@ -804,25 +779,11 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { merchantID: serverMerchantId, }) => { // merchantID that comes from props is an array - const { - message, - buttonSessionID, - currency, - merchantID: partnerMerchantId, - } = props; - const isPartnerMerchantIdEmpty = - !partnerMerchantId || - partnerMerchantId.length === 0 || - partnerMerchantId[0] === ""; - // check to see if a partner merchant id integration exists - // if not grab the server merchant id - const merchantID = isPartnerMerchantIdEmpty - ? serverMerchantId - : partnerMerchantId?.join(); + const { message, buttonSessionID, currency, merchantID } = props; // override with server id if partner does not exist getLogger().addTrackingBuilder(() => ({ - [FPTI_KEY.SELLER_ID]: merchantID, + [FPTI_KEY.SELLER_ID]: merchantID.toString() || serverMerchantId, })); getLogger() diff --git a/src/zoid/buttons/util.js b/src/zoid/buttons/util.js index bc7ce3209..1c2386ce4 100644 --- a/src/zoid/buttons/util.js +++ b/src/zoid/buttons/util.js @@ -373,7 +373,7 @@ function buildModalBundleUrl(): string { export const getModal: ( clientID: string, - merchantID?: string | void + merchantID?: $ReadOnlyArray | void ) => Object = memoize(async (clientID, merchantID) => { try { const namespace = getNamespace(); @@ -396,7 +396,7 @@ export const getModal: ( return window[namespace].MessagesModal({ account: `client-id:${clientID}`, - merchantId: merchantID || undefined, + merchantId: merchantID?.join() || undefined, }); } catch (err) { // $FlowFixMe flow doesn't seem to understand that the reset function property exists on the function object itself diff --git a/test/integration/tests/button/message.js b/test/integration/tests/button/message.js index 25fe7625a..6414d81bf 100644 --- a/test/integration/tests/button/message.js +++ b/test/integration/tests/button/message.js @@ -487,7 +487,7 @@ describe(`paypal button message`, () => { ); assert.ok( typeof window.paypal.MessagesModal.mock.calledWith - .merchantId === "string" + .merchantId === "undefined" ); done(); }) From 38249f78f2fa95de586282c85482003857921cd9 Mon Sep 17 00:00:00 2001 From: rosman Date: Mon, 20 May 2024 15:26:09 -0400 Subject: [PATCH 11/13] check --- src/zoid/buttons/component.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zoid/buttons/component.jsx b/src/zoid/buttons/component.jsx index 42506537a..cf8fb7be4 100644 --- a/src/zoid/buttons/component.jsx +++ b/src/zoid/buttons/component.jsx @@ -783,7 +783,7 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { // override with server id if partner does not exist getLogger().addTrackingBuilder(() => ({ - [FPTI_KEY.SELLER_ID]: merchantID.toString() || serverMerchantId, + [FPTI_KEY.SELLER_ID]: merchantID?.toString() || serverMerchantId, })); getLogger() From f677e0241a3a846c5784591a0c5f0b2926fc0592 Mon Sep 17 00:00:00 2001 From: rosman Date: Tue, 21 May 2024 14:10:56 -0400 Subject: [PATCH 12/13] remove merchantID from hover tests --- test/integration/tests/button/message.js | 10 +++++----- test/integration/windows/button/index.jsx | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/integration/tests/button/message.js b/test/integration/tests/button/message.js index 6414d81bf..3365d6e78 100644 --- a/test/integration/tests/button/message.js +++ b/test/integration/tests/button/message.js @@ -458,7 +458,7 @@ describe(`paypal button message`, () => { message: {}, test: { onRender({ hoverMessage }) { - hoverMessage({ merchantID: "123" }) + hoverMessage() .then(() => { assert.equal(getNamespace(), window.namespace); done(); @@ -475,7 +475,7 @@ describe(`paypal button message`, () => { message: {}, test: { onRender({ hoverMessage }) { - hoverMessage({ merchantID: "123" }) + hoverMessage() .then(() => { assert.ok( Object.keys(window.paypal.MessagesModal.mock.calledWith) @@ -506,7 +506,7 @@ describe(`paypal button message`, () => { }, test: { onRender({ clickMessage, hoverMessage }) { - hoverMessage({ merchantID: "123" }) + hoverMessage() .then(() => { return clickMessage(props).then(() => { assert.equal( @@ -539,10 +539,10 @@ describe(`paypal button message`, () => { }, test: { onRender({ clickMessage, hoverMessage }) { - hoverMessage({ merchantID: "123" }) + hoverMessage() .then(() => { return clickMessage(props).then(() => { - return hoverMessage({ merchantID: "123" }).then(() => { + return hoverMessage().then(() => { return clickMessage(props).then(() => { assert.equal(window.paypal.MessagesModal.mock.calls, 1); done(); diff --git a/test/integration/windows/button/index.jsx b/test/integration/windows/button/index.jsx index 119da324b..e702f8022 100644 --- a/test/integration/windows/button/index.jsx +++ b/test/integration/windows/button/index.jsx @@ -236,8 +236,8 @@ if (onRender) { click() { getElement(".paypal-button", document).click(); }, - hoverMessage({ merchantID }): ZalgoPromise | void { - return window.xprops.onMessageHover({ merchantID }); + hoverMessage(): ZalgoPromise | void { + return window.xprops.onMessageHover(); }, clickMessage({ offerType, messageType }): ZalgoPromise | void { return window.xprops.onMessageClick({ offerType, messageType }); From 8770f670f65ec3bd1c705ba3597ddbebbfbdcb4d Mon Sep 17 00:00:00 2001 From: rosman Date: Tue, 11 Jun 2024 12:17:08 -0400 Subject: [PATCH 13/13] address comments --- src/zoid/buttons/component.jsx | 10 ++++++---- src/zoid/buttons/util.js | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/zoid/buttons/component.jsx b/src/zoid/buttons/component.jsx index cf8fb7be4..271c3f66a 100644 --- a/src/zoid/buttons/component.jsx +++ b/src/zoid/buttons/component.jsx @@ -779,12 +779,14 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => { merchantID: serverMerchantId, }) => { // merchantID that comes from props is an array - const { message, buttonSessionID, currency, merchantID } = props; + const { message, buttonSessionID, currency } = props; // override with server id if partner does not exist - getLogger().addTrackingBuilder(() => ({ - [FPTI_KEY.SELLER_ID]: merchantID?.toString() || serverMerchantId, - })); + if (serverMerchantId) { + getLogger().addTrackingBuilder(() => ({ + [FPTI_KEY.SELLER_ID]: serverMerchantId, + })); + } getLogger() .info("button_message_render") diff --git a/src/zoid/buttons/util.js b/src/zoid/buttons/util.js index 1c2386ce4..b5576f134 100644 --- a/src/zoid/buttons/util.js +++ b/src/zoid/buttons/util.js @@ -396,7 +396,7 @@ export const getModal: ( return window[namespace].MessagesModal({ account: `client-id:${clientID}`, - merchantId: merchantID?.join() || undefined, + merchantId: merchantID?.join(",") || undefined, }); } catch (err) { // $FlowFixMe flow doesn't seem to understand that the reset function property exists on the function object itself