From 96d01aafe386a90e9c5482274f0a4ebcbc0a5aa4 Mon Sep 17 00:00:00 2001 From: Saksham Sharma Date: Wed, 20 Nov 2024 14:46:36 +0530 Subject: [PATCH] refactor: added some condition for paypal --- src/Utilities/PaymentUtils.res | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/Utilities/PaymentUtils.res b/src/Utilities/PaymentUtils.res index 6fe6cd5e..eb49e2aa 100644 --- a/src/Utilities/PaymentUtils.res +++ b/src/Utilities/PaymentUtils.res @@ -8,12 +8,9 @@ let paymentListLookupNew = ( ~isKlarnaSDKFlow, ~paymentMethodListValue: PaymentMethodsRecord.paymentMethodList, ~areAllGooglePayRequiredFieldsPrefilled, - ~areAllPaypalRequiredFieldsPreFilled, ~isGooglePayReady, ~shouldDisplayApplePayInTabs, - ~isPaypalSDKFlow, - ~isPaypalRedirectFlow, - ~isPaypalTokenExist, + ~shouldDisplayPayPalInTabs, ) => { let pmList = list->PaymentMethodsRecord.buildFromPaymentList let walletsList = [] @@ -40,12 +37,7 @@ let paymentListLookupNew = ( walletToBeDisplayedInTabs->Array.push("apple_pay") } - if ( - !paymentMethodListValue.collect_billing_details_from_wallets && - !areAllPaypalRequiredFieldsPreFilled && - isPaypalRedirectFlow && - (!isPaypalSDKFlow || !isPaypalTokenExist) - ) { + if shouldDisplayPayPalInTabs { walletToBeDisplayedInTabs->Array.push("paypal") } @@ -407,20 +399,26 @@ let useGetPaymentMethodList = (~paymentOptions, ~paymentType, ~sessions) => { !areAllApplePayRequiredFieldsPrefilled && isApplePayReady + let isShowPaypal = optionAtomValue.wallets.payPal === Auto + + let shouldDisplayPayPalInTabs = + isShowPaypal && + !paymentMethodListValue.collect_billing_details_from_wallets && + !areAllPaypalRequiredFieldsPreFilled && + isPaypalRedirectFlow && + (!isPaypalSDKFlow || !isPaypalTokenExist) + let (wallets, otherOptions) = plist->paymentListLookupNew( ~order=paymentOrder, - ~isShowPaypal=optionAtomValue.wallets.payPal === Auto, + ~isShowPaypal, ~isShowKlarnaOneClick=optionAtomValue.wallets.klarna === Auto, ~isKlarnaSDKFlow, ~paymentMethodListValue=plist, ~areAllGooglePayRequiredFieldsPrefilled, - ~areAllPaypalRequiredFieldsPreFilled, ~isGooglePayReady, ~shouldDisplayApplePayInTabs, - ~isPaypalSDKFlow, - ~isPaypalRedirectFlow, - ~isPaypalTokenExist, + ~shouldDisplayPayPalInTabs, ) let klarnaPaymentMethodExperience = PaymentMethodsRecord.getPaymentExperienceTypeFromPML(