From 3a124c6a6a521e61a8e22d11667696bd49615be4 Mon Sep 17 00:00:00 2001 From: Maria Chin Date: Fri, 6 Dec 2024 13:41:57 -0800 Subject: [PATCH 1/9] Limit eligible button to Paypal when new createSubscription is used --- src/ui/buttons/buttons.jsx | 22 ++-- src/ui/buttons/buttons.test.js | 194 +++++++++++++++++++++++++++++++++ src/zoid/buttons/component.jsx | 17 +++ 3 files changed, 225 insertions(+), 8 deletions(-) create mode 100644 src/ui/buttons/buttons.test.js diff --git a/src/ui/buttons/buttons.jsx b/src/ui/buttons/buttons.jsx index f7281f86ac..28d7a2bc65 100644 --- a/src/ui/buttons/buttons.jsx +++ b/src/ui/buttons/buttons.jsx @@ -134,7 +134,7 @@ export function validateButtonProps(props: ButtonPropsInputs) { } export function Buttons(props: ButtonsProps): ElementNode { - const { onClick = noop } = props; + const { onClick = noop, isFsSubscription } = props; const { applePaySupport, buyerCountry, @@ -190,7 +190,6 @@ export function Buttons(props: ButtonsProps): ElementNode { experiment, displayOnly, }); - const multiple = fundingSources.length > 1; if (!fundingSources.length) { throw new ValidationError( @@ -209,13 +208,20 @@ export function Buttons(props: ButtonsProps): ElementNode { ]; } - const isAPM = fundingSources.some((src) => { + // Set the value of the FINAL fundingSource we want to use + const finalFundingSources = isFsSubscription + ? fundingSources.filter((src) => src === FUNDING.PAYPAL) + : fundingSources; + + const multiple = finalFundingSources.length > 1; + + const isAPM = finalFundingSources.some((src) => { return APM_LIST.includes(src); }); const instruments = getWalletInstruments({ wallet, - fundingSources, + fundingSources: finalFundingSources, layout, hasShippingCallback, }); @@ -234,7 +240,7 @@ export function Buttons(props: ButtonsProps): ElementNode { !fundingSource && !message; - const showPoweredBy = calculateShowPoweredBy(layout, fundingSources); + const showPoweredBy = calculateShowPoweredBy(layout, finalFundingSources); return (
) : null} - {fundingSources.map((source, i) => ( + {finalFundingSources.map((source, i) => (