{walletOptions
@@ -113,12 +107,12 @@ let make = (~sessions, ~walletOptions, ~paymentType) => {
| OtherTokenOptional(optToken) =>
switch (optToken, isPaypalSDKFlow, isPaypalRedirectFlow) {
| (Some(token), true, _) =>
- | (_, _, true) =>
+ | (_, _, true) =>
| _ => React.null
}
| _ =>
-
+
}}
diff --git a/src/Types/PaymentModeType.res b/src/Types/PaymentModeType.res
index 14d29b39..074f872f 100644
--- a/src/Types/PaymentModeType.res
+++ b/src/Types/PaymentModeType.res
@@ -19,6 +19,7 @@ type payment =
| GooglePay
| ApplePay
| Boleto
+ | PayPal
| NONE
let paymentMode = str => {
@@ -43,6 +44,7 @@ let paymentMode = str => {
| "google_pay" => GooglePay
| "apple_pay" => ApplePay
| "boleto" => Boleto
+ | "paypal" => PayPal
| _ => NONE
}
}
diff --git a/src/Utilities/DynamicFieldsUtils.res b/src/Utilities/DynamicFieldsUtils.res
index 0f3c5685..203c836a 100644
--- a/src/Utilities/DynamicFieldsUtils.res
+++ b/src/Utilities/DynamicFieldsUtils.res
@@ -25,6 +25,7 @@ let dynamicFieldsEnabledPaymentMethods = [
"bacs",
"pay_bright",
"multibanco_transfer",
+ "paypal",
]
let getName = (item: PaymentMethodsRecord.required_fields, field: RecoilAtomTypes.field) => {
diff --git a/src/Utilities/PaymentUtils.res b/src/Utilities/PaymentUtils.res
index b1c071b6..4a4c8a92 100644
--- a/src/Utilities/PaymentUtils.res
+++ b/src/Utilities/PaymentUtils.res
@@ -10,6 +10,7 @@ let paymentListLookupNew = (
~areAllGooglePayRequiredFieldsPrefilled,
~isGooglePayReady,
~shouldDisplayApplePayInTabs,
+ ~shouldDisplayPayPalInTabs,
) => {
let pmList = list->PaymentMethodsRecord.buildFromPaymentList
let walletsList = []
@@ -36,6 +37,10 @@ let paymentListLookupNew = (
walletToBeDisplayedInTabs->Array.push("apple_pay")
}
+ if shouldDisplayPayPalInTabs {
+ walletToBeDisplayedInTabs->Array.push("paypal")
+ }
+
if (
!paymentMethodListValue.collect_billing_details_from_wallets &&
!areAllGooglePayRequiredFieldsPrefilled &&
@@ -305,6 +310,32 @@ let getIsKlarnaSDKFlow = sessions => {
}
}
+let usePaypalFlowStatus = (~sessions, ~paymentMethodListValue) => {
+ open Utils
+
+ let sessionObj =
+ sessions
+ ->getDictFromJson
+ ->SessionsType.itemToObjMapper(Others)
+
+ let {
+ paypalToken,
+ isPaypalSDKFlow,
+ isPaypalRedirectFlow,
+ } = PayPalHelpers.usePaymentMethodExperience(~paymentMethodListValue, ~sessionObj)
+
+ let isPaypalTokenExist = switch paypalToken {
+ | OtherTokenOptional(optToken) =>
+ switch optToken {
+ | Some(_) => true
+ | _ => false
+ }
+ | _ => false
+ }
+
+ (isPaypalSDKFlow, isPaypalRedirectFlow, isPaypalTokenExist)
+}
+
let useGetPaymentMethodList = (~paymentOptions, ~paymentType, ~sessions) => {
open Utils
let methodslist = Recoil.useRecoilValueFromAtom(RecoilAtoms.paymentMethodList)
@@ -332,9 +363,20 @@ let useGetPaymentMethodList = (~paymentOptions, ~paymentType, ~sessions) => {
~paymentMethodType="google_pay",
)
+ let areAllPaypalRequiredFieldsPreFilled = useAreAllRequiredFieldsPrefilled(
+ ~paymentMethodListValue,
+ ~paymentMethod="wallet",
+ ~paymentMethodType="paypal",
+ )
+
let isApplePayReady = Recoil.useRecoilValueFromAtom(RecoilAtoms.isApplePayReady)
let isGooglePayReady = Recoil.useRecoilValueFromAtom(RecoilAtoms.isGooglePayReady)
+ let (isPaypalSDKFlow, isPaypalRedirectFlow, isPaypalTokenExist) = usePaypalFlowStatus(
+ ~sessions,
+ ~paymentMethodListValue,
+ )
+
React.useMemo(() => {
switch methodslist {
| Loaded(paymentlist) =>
@@ -347,16 +389,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,
~isGooglePayReady,
~shouldDisplayApplePayInTabs,
+ ~shouldDisplayPayPalInTabs,
)
let klarnaPaymentMethodExperience = PaymentMethodsRecord.getPaymentExperienceTypeFromPML(