Skip to content

Commit

Permalink
refactor: added some condition for paypal
Browse files Browse the repository at this point in the history
  • Loading branch information
sakksham7 committed Nov 20, 2024
1 parent f8ec2d3 commit 96d01aa
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/Utilities/PaymentUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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")
}

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 96d01aa

Please sign in to comment.