{
let paymentMethodListValue = Recoil.useRecoilValueFromAtom(PaymentUtils.paymentMethodListValue)
let sessionObj = React.useMemo(() => itemToObjMapper(dict, Others), [dict])
- let paypalToken = React.useMemo(
- () => getPaymentSessionObj(sessionObj.sessionsToken, Paypal),
- [sessionObj],
- )
- let paypalPaymentMethodExperience = React.useMemo(() => {
- PaymentMethodsRecord.getPaymentExperienceTypeFromPML(
- ~paymentMethodList=paymentMethodListValue,
- ~paymentMethodName="wallet",
- ~paymentMethodType="paypal",
- )
- }, [paymentMethodListValue])
+
+ let {
+ paypalToken,
+ isPaypalSDKFlow,
+ isPaypalRedirectFlow,
+ } = PayPalHelpers.usePaymentMethodExperience(~paymentMethodListValue, ~sessionObj)
+
let gPayToken = getPaymentSessionObj(sessionObj.sessionsToken, Gpay)
let applePaySessionObj = itemToObjMapper(dict, ApplePayObject)
let applePayToken = getPaymentSessionObj(applePaySessionObj.sessionsToken, ApplePay)
@@ -70,8 +66,6 @@ let make = (~sessions, ~walletOptions, ~paymentType) => {
let {clientSecret} = Recoil.useRecoilValueFromAtom(RecoilAtoms.keys)
let options = Recoil.useRecoilValueFromAtom(RecoilAtoms.optionAtom)
- let isPaypalSDKFlow = paypalPaymentMethodExperience->Array.includes(InvokeSDK)
- let isPaypalRedirectFlow = paypalPaymentMethodExperience->Array.includes(RedirectToURL)
{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/Payments/PazeTypes.res b/src/Payments/PazeTypes.res
index 1452ee62..133f1748 100644
--- a/src/Payments/PazeTypes.res
+++ b/src/Payments/PazeTypes.res
@@ -36,8 +36,9 @@ type complete = {
transactionValue: transactionValue,
}
+type canCheckoutReturnType = {consumerPresent: bool}
type digitalWalletSdk = {
- canCheckout: canCheckout => promise
,
+ canCheckout: canCheckout => promise,
checkout: checkout => promise,
complete: complete => promise,
initialize: initialize => promise,
diff --git a/src/Payments/PazeWallet.res b/src/Payments/PazeWallet.res
index 9008954d..6f70bce8 100644
--- a/src/Payments/PazeWallet.res
+++ b/src/Payments/PazeWallet.res
@@ -41,12 +41,12 @@ let make = () => {
Console.log2("PAZE --- init completed", val)
- let consumerPresent = await digitalWalletSdk.canCheckout({
+ let canCheckout = await digitalWalletSdk.canCheckout({
emailAddress: emailAddress,
})
Console.log("PAZE --- canCheckout completed")
- Console.log2("PAZE --- consumerPresent: ", consumerPresent)
+ Console.log2("PAZE --- canCheckout: ", canCheckout.consumerPresent)
let transactionValue = {
transactionAmount,
@@ -59,16 +59,16 @@ let make = () => {
payloadTypeIndicator: "PAYMENT",
}
- let checkoutResponse = await digitalWalletSdk.checkout({
+ let _ = await digitalWalletSdk.checkout({
acceptedPaymentCardNetworks: ["VISA", "MASTERCARD"],
- emailAddress,
+ emailAddress: canCheckout.consumerPresent ? emailAddress : "",
sessionId,
actionCode: "START_FLOW",
transactionValue,
shippingPreference: "ALL",
})
- Console.log2("PAZE --- Checkout Response Object: ", checkoutResponse)
+ Console.log("PAZE --- digitalWalletSdk.checkout completed")
let completeObj = {
transactionOptions,
@@ -80,7 +80,7 @@ let make = () => {
let completeResponse = await digitalWalletSdk.complete(completeObj)
- Console.log2("PAZE --- Complete Response Object: ", completeResponse)
+ Console.log("PAZE --- digitalWalletSdk.complete completed")
messageParentWindow([
("fullscreen", false->JSON.Encode.bool),
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..8714428c 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) => {
@@ -289,6 +290,7 @@ let useRequiredFieldsEmptyAndValid = (
cardExpiry,
cvcNumber,
bankAccountNumber,
+ cryptoCurrencyNetworks,
))
}
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(
diff --git a/src/Utilities/RecoilAtoms.res b/src/Utilities/RecoilAtoms.res
index 6ecce38e..5281dc20 100644
--- a/src/Utilities/RecoilAtoms.res
+++ b/src/Utilities/RecoilAtoms.res
@@ -50,6 +50,7 @@ let userPhoneNumber = Recoil.atom(
countryCode: "",
},
)
+let userCardNickName = Recoil.atom("userCardNickName", defaultFieldValues)
let isGooglePayReady = Recoil.atom("isGooglePayReady", false)
let isApplePayReady = Recoil.atom("isApplePayReady", false)
let userCountry = Recoil.atom("userCountry", "")
diff --git a/src/Utilities/Utils.res b/src/Utilities/Utils.res
index c5e82b2d..745478b0 100644
--- a/src/Utilities/Utils.res
+++ b/src/Utilities/Utils.res
@@ -1451,3 +1451,10 @@ let handleIframePostMessageForWallets = (msg, componentName, mountedIframeRef) =
mountedIframeRef->Window.iframePostMessage(msg)
}
}
+
+let isDigitLimitExceeded = (val, ~digit) => {
+ switch val->String.match(%re("/\d/g")) {
+ | Some(matches) => matches->Array.length > digit
+ | None => false
+ }
+}
diff --git a/webpack.common.js b/webpack.common.js
index c3cea6c8..18a9015f 100644
--- a/webpack.common.js
+++ b/webpack.common.js
@@ -50,7 +50,6 @@ const getEnvironmentDomain = (prodDomain, integDomain, defaultDomain) => {
const backendDomain = getEnvironmentDomain("checkout", "dev", "beta");
const confirmDomain = getEnvironmentDomain("api", "integ-api", "sandbox");
-const logDomain = getEnvironmentDomain("api", "integ-api", "sandbox");
const backendEndPoint =
envBackendUrl || `https://${backendDomain}.hyperswitch.io/api`;
@@ -58,8 +57,7 @@ const backendEndPoint =
const confirmEndPoint =
envBackendUrl || `https://${confirmDomain}.hyperswitch.io`;
-const logEndpoint =
- envLoggingUrl || `https://${logDomain}.hyperswitch.io/logs/sdk`;
+const logEndpoint = envLoggingUrl;
const loggingLevel = "DEBUG";
const maxLogsPushedPerEventName = 100;