diff --git a/CHANGELOG.md b/CHANGELOG.md
index 554c76ec8..83947fb0a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,45 @@
+## [0.70.7](https://github.com/juspay/hyperswitch-web/compare/v0.70.6...v0.70.7) (2024-06-25)
+
+
+### Bug Fixes
+
+* google Pay Fix ([#458](https://github.com/juspay/hyperswitch-web/issues/458)) ([1bcd585](https://github.com/juspay/hyperswitch-web/commit/1bcd585f09f9eb5c151614e29827127d4d6dc4e0))
+
+## [0.70.6](https://github.com/juspay/hyperswitch-web/compare/v0.70.5...v0.70.6) (2024-06-25)
+
+
+### Bug Fixes
+
+* fixed handling of empty string in requiredString and warningString ([#450](https://github.com/juspay/hyperswitch-web/issues/450)) ([a1c75fb](https://github.com/juspay/hyperswitch-web/commit/a1c75fbaea004b2abd274544b90e40a9b1a74cea))
+
+## [0.70.5](https://github.com/juspay/hyperswitch-web/compare/v0.70.4...v0.70.5) (2024-06-25)
+
+
+### Bug Fixes
+
+* headers update & warnings removed ([#457](https://github.com/juspay/hyperswitch-web/issues/457)) ([a4b653b](https://github.com/juspay/hyperswitch-web/commit/a4b653b79b0056bfc1966f6dcab5a02c272c2c47))
+
+## [0.70.4](https://github.com/juspay/hyperswitch-web/compare/v0.70.3...v0.70.4) (2024-06-25)
+
+
+### Bug Fixes
+
+* handle requires_customer_action and processing status for pix pa… ([#456](https://github.com/juspay/hyperswitch-web/issues/456)) ([a680e71](https://github.com/juspay/hyperswitch-web/commit/a680e71a73a31eef89d66fd1d35666da53294a51))
+
+## [0.70.3](https://github.com/juspay/hyperswitch-web/compare/v0.70.2...v0.70.3) (2024-06-24)
+
+
+### Bug Fixes
+
+* fixed Saved Methods ApplePay and GooglePay Handler ([#455](https://github.com/juspay/hyperswitch-web/issues/455)) ([bce8bea](https://github.com/juspay/hyperswitch-web/commit/bce8bea6045acbae2df1016b93623709715a8277))
+
+## [0.70.2](https://github.com/juspay/hyperswitch-web/compare/v0.70.1...v0.70.2) (2024-06-24)
+
+
+### Bug Fixes
+
+* package update ([0d01ff2](https://github.com/juspay/hyperswitch-web/commit/0d01ff290e0d22e17bf294d939d500c6c9a927a5))
+
# [0.69.0](https://github.com/juspay/hyperswitch-web/compare/v0.68.0...v0.69.0) (2024-06-20)
diff --git a/package-lock.json b/package-lock.json
index 7f0017ce1..a6a9a53e6 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "orca-payment-page",
- "version": "0.69.0",
+ "version": "0.70.7",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "orca-payment-page",
- "version": "0.69.0",
+ "version": "0.70.7",
"hasInstallScript": true,
"dependencies": {
"@aws-sdk/client-cloudfront": "^3.414.0",
diff --git a/package.json b/package.json
index 731bf62ef..ff7368c6e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "orca-payment-page",
- "version": "0.69.0",
+ "version": "0.70.7",
"main": "index.js",
"private": true,
"dependencies": {
diff --git a/src/Components/SavedMethods.res b/src/Components/SavedMethods.res
index ab0ff5f3c..817482fa9 100644
--- a/src/Components/SavedMethods.res
+++ b/src/Components/SavedMethods.res
@@ -33,8 +33,10 @@ let make = (
let dict = sessions->Utils.getDictFromJson
let sessionObj = React.useMemo(() => SessionsType.itemToObjMapper(dict, Others), [dict])
- let isApplePayReady = Recoil.useRecoilValueFromAtom(RecoilAtoms.isApplePayReady)
- let isGPayReady = Recoil.useRecoilValueFromAtom(RecoilAtoms.isGooglePayReady)
+ let gPayToken = SessionsType.getPaymentSessionObj(sessionObj.sessionsToken, Gpay)
+
+ let applePaySessionObj = SessionsType.itemToObjMapper(dict, ApplePayObject)
+ let applePayToken = SessionsType.getPaymentSessionObj(applePaySessionObj.sessionsToken, ApplePay)
let intent = PaymentHelpers.usePaymentIntent(Some(loggerState), Card)
let savedCardlength = savedMethods->Array.length
@@ -59,13 +61,6 @@ let make = (
let bottomElement = {
savedMethods
- ->Array.filter(savedMethod => {
- switch savedMethod.paymentMethodType {
- | Some("apple_pay") => isApplePayReady
- | Some("google_pay") => isGPayReady
- | _ => true
- }
- })
->Array.mapWithIndex((obj, i) => {
let brandIcon = switch obj.paymentMethod {
| "wallet" => getWalletBrandIcon(obj)
@@ -121,9 +116,9 @@ let make = (
useHandlePostMessages(~complete, ~empty, ~paymentType, ~savedMethod=true)
- GooglePayHelpers.useHandleGooglePayResponse(~connectors=[], ~intent)
+ GooglePayHelpers.useHandleGooglePayResponse(~connectors=[], ~intent, ~isSavedMethodsFlow=true)
- ApplePayHelpers.useHandleApplePayResponse(~connectors=[], ~intent)
+ ApplePayHelpers.useHandleApplePayResponse(~connectors=[], ~intent, ~isSavedMethodsFlow=true)
let submitCallback = React.useCallback((ev: Window.event) => {
let json = ev.data->JSON.parseExn
@@ -162,52 +157,44 @@ let make = (
confirm.confirmTimestamp >= confirm.readyTimestamp
) {
switch customerMethod.paymentMethodType {
- | Some("google_pay") => {
- let gPayToken = SessionsType.getPaymentSessionObj(sessionObj.sessionsToken, Gpay)
- switch gPayToken {
- | OtherTokenOptional(optToken) =>
- GooglePayHelpers.handleGooglePayClicked(
- ~sessionObj=optToken,
- ~componentName,
- ~iframeId,
- ~readOnly,
- )
- | _ =>
- // TODO - To be replaced with proper error message
- intent(
- ~bodyArr=savedPaymentMethodBody
- ->getJsonFromArrayOfJson
- ->flattenObject(true)
- ->mergeTwoFlattenedJsonDicts(requiredFieldsBody)
- ->getArrayOfTupleFromDict,
- ~confirmParam=confirm.confirmParams,
- ~handleUserError=false,
- (),
- )
- }
+ | Some("google_pay") =>
+ switch gPayToken {
+ | OtherTokenOptional(optToken) =>
+ GooglePayHelpers.handleGooglePayClicked(
+ ~sessionObj=optToken,
+ ~componentName,
+ ~iframeId,
+ ~readOnly,
+ )
+ | _ =>
+ // TODO - To be replaced with proper error message
+ intent(
+ ~bodyArr=savedPaymentMethodBody
+ ->getJsonFromArrayOfJson
+ ->flattenObject(true)
+ ->mergeTwoFlattenedJsonDicts(requiredFieldsBody)
+ ->getArrayOfTupleFromDict,
+ ~confirmParam=confirm.confirmParams,
+ ~handleUserError=false,
+ (),
+ )
}
- | Some("apple_pay") => {
- let applePaySessionObj = SessionsType.itemToObjMapper(dict, ApplePayObject)
- let applePayToken = SessionsType.getPaymentSessionObj(
- applePaySessionObj.sessionsToken,
- ApplePay,
+ | Some("apple_pay") =>
+ switch applePayToken {
+ | ApplePayTokenOptional(optToken) =>
+ ApplePayHelpers.handleApplePayButtonClicked(~sessionObj=optToken, ~componentName)
+ | _ =>
+ // TODO - To be replaced with proper error message
+ intent(
+ ~bodyArr=savedPaymentMethodBody
+ ->getJsonFromArrayOfJson
+ ->flattenObject(true)
+ ->mergeTwoFlattenedJsonDicts(requiredFieldsBody)
+ ->getArrayOfTupleFromDict,
+ ~confirmParam=confirm.confirmParams,
+ ~handleUserError=false,
+ (),
)
- switch applePayToken {
- | ApplePayTokenOptional(optToken) =>
- ApplePayHelpers.handleApplePayButtonClicked(~sessionObj=optToken, ~componentName)
- | _ =>
- // TODO - To be replaced with proper error message
- intent(
- ~bodyArr=savedPaymentMethodBody
- ->getJsonFromArrayOfJson
- ->flattenObject(true)
- ->mergeTwoFlattenedJsonDicts(requiredFieldsBody)
- ->getArrayOfTupleFromDict,
- ~confirmParam=confirm.confirmParams,
- ~handleUserError=false,
- (),
- )
- }
}
| _ =>
intent(
@@ -244,6 +231,8 @@ let make = (
complete,
customerMethod,
isCustomerAcceptanceRequired,
+ applePayToken,
+ gPayToken,
))
useSubmitPaymentData(submitCallback)
diff --git a/src/PaymentElement.res b/src/PaymentElement.res
index 648932116..f46bed6b4 100644
--- a/src/PaymentElement.res
+++ b/src/PaymentElement.res
@@ -26,6 +26,9 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod
let (walletOptions, setWalletOptions) = React.useState(_ => [])
let {sdkHandleConfirmPayment} = Recoil.useRecoilValueFromAtom(optionAtom)
+ let isApplePayReady = Recoil.useRecoilValueFromAtom(RecoilAtoms.isApplePayReady)
+ let isGPayReady = Recoil.useRecoilValueFromAtom(RecoilAtoms.isGooglePayReady)
+
let (paymentMethodListValue, setPaymentMethodListValue) = Recoil.useRecoilState(
PaymentUtils.paymentMethodListValue,
)
@@ -72,7 +75,16 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod
}
}
- let finalSavedPaymentMethods = savedPaymentMethods->Array.copy
+ let finalSavedPaymentMethods =
+ savedPaymentMethods
+ ->Array.copy
+ ->Array.filter(savedMethod => {
+ switch savedMethod.paymentMethodType {
+ | Some("apple_pay") => isApplePayReady
+ | Some("google_pay") => isGPayReady
+ | _ => true
+ }
+ })
finalSavedPaymentMethods->Array.sort(sortSavedPaymentMethods)
let paymentOrder = paymentMethodOrder->getOptionalArr->removeDuplicate
@@ -98,7 +110,13 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod
}
None
- }, (customerPaymentMethods, displaySavedPaymentMethods, optionAtomValue))
+ }, (
+ customerPaymentMethods,
+ displaySavedPaymentMethods,
+ optionAtomValue,
+ isApplePayReady,
+ isGPayReady,
+ ))
React.useEffect(() => {
let defaultSelectedPaymentMethod = optionAtomValue.displayDefaultSavedPaymentIcon
@@ -344,7 +362,9 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod
-
+
Array.length > 0 || walletOptions->Array.length > 0) &&
diff --git a/src/Payments/GPay.res b/src/Payments/GPay.res
index cd33c5557..6a1671a0f 100644
--- a/src/Payments/GPay.res
+++ b/src/Payments/GPay.res
@@ -27,8 +27,6 @@ let make = (~sessionObj: option, ~thirdPartySessionObj: opti
let areOneClickWalletsRendered = Recoil.useSetRecoilState(RecoilAtoms.areOneClickWalletsRendered)
- let isGuestCustomer = UtilityHooks.useIsGuestCustomer()
-
let googlePayPaymentMethodType = switch PaymentMethodsRecord.getPaymentMethodTypeFromList(
~paymentMethodListValue,
~paymentMethod="wallet",
diff --git a/src/Payments/QRCodeDisplay.res b/src/Payments/QRCodeDisplay.res
index 8dd6eb9fc..c91ddd1b0 100644
--- a/src/Payments/QRCodeDisplay.res
+++ b/src/Payments/QRCodeDisplay.res
@@ -94,7 +94,9 @@ let make = () => {
let dict = json->JSON.Decode.object->Option.getOr(Dict.make())
let status = dict->getString("status", "")
- if status === "succeeded" {
+ if (
+ status === "succeeded" || status === "requires_customer_action" || status === "processing"
+ ) {
postSubmitResponse(~jsonData=json, ~url=return_url)
} else if status === "failed" {
postFailedSubmitResponse(
diff --git a/src/Utilities/ApplePayHelpers.res b/src/Utilities/ApplePayHelpers.res
index 24f482439..e3a0dc0b7 100644
--- a/src/Utilities/ApplePayHelpers.res
+++ b/src/Utilities/ApplePayHelpers.res
@@ -138,6 +138,7 @@ let useHandleApplePayResponse = (
~setApplePayClicked=_ => (),
~syncPayment=() => (),
~isInvokeSDKFlow=true,
+ ~isSavedMethodsFlow=false,
) => {
let options = Recoil.useRecoilValueFromAtom(RecoilAtoms.optionAtom)
let {publishableKey} = Recoil.useRecoilValueFromAtom(RecoilAtoms.keys)
@@ -191,6 +192,9 @@ let useHandleApplePayResponse = (
)
} else if dict->Dict.get("showApplePayButton")->Option.isSome {
setApplePayClicked(_ => false)
+ if isSavedMethodsFlow {
+ postFailedSubmitResponse(~errortype="server_error", ~message="Something went wrong")
+ }
} else if dict->Dict.get("applePaySyncPayment")->Option.isSome {
syncPayment()
}
diff --git a/src/Utilities/GooglePayHelpers.res b/src/Utilities/GooglePayHelpers.res
index 64b3c24da..b2519d690 100644
--- a/src/Utilities/GooglePayHelpers.res
+++ b/src/Utilities/GooglePayHelpers.res
@@ -78,7 +78,7 @@ let processPayment = (
)
}
-let useHandleGooglePayResponse = (~connectors, ~intent) => {
+let useHandleGooglePayResponse = (~connectors, ~intent, ~isSavedMethodsFlow=false) => {
let options = Recoil.useRecoilValueFromAtom(RecoilAtoms.optionAtom)
let {publishableKey} = Recoil.useRecoilValueFromAtom(RecoilAtoms.keys)
@@ -123,6 +123,9 @@ let useHandleGooglePayResponse = (~connectors, ~intent) => {
}
if dict->Dict.get("gpayError")->Option.isSome {
handlePostMessage([("fullscreen", false->JSON.Encode.bool)])
+ if isSavedMethodsFlow {
+ postFailedSubmitResponse(~errortype="server_error", ~message="Something went wrong")
+ }
}
}
Window.addEventListener("message", handle)
diff --git a/src/Utilities/PaymentHelpers.res b/src/Utilities/PaymentHelpers.res
index 861a753a3..cd9cc7f1a 100644
--- a/src/Utilities/PaymentHelpers.res
+++ b/src/Utilities/PaymentHelpers.res
@@ -558,6 +558,7 @@ let rec intentCall = (
| (Applepay, false)
| (Paypal, false) =>
if !isPaymentSession {
+ closePaymentLoaderIfAny()
postSubmitResponse(~jsonData=data, ~url=url.href)
} else if confirmParam.redirect === Some("always") {
handleOpenUrl(url.href)
@@ -1714,4 +1715,3 @@ let paymentIntentForPaymentSession = (
(),
)
}
-
diff --git a/src/Utilities/Utils.res b/src/Utilities/Utils.res
index a49dcf0a3..281802612 100644
--- a/src/Utilities/Utils.res
+++ b/src/Utilities/Utils.res
@@ -110,14 +110,12 @@ let getDecodedBoolFromJson = (json, callbackFunc, defaultValue) => {
let getRequiredString = (dict, key, default, ~logger) => {
let optionalStr = getOptionString(dict, key)
switch optionalStr {
- | Some(val) => {
- val == "" ? manageErrorWarning(REQUIRED_PARAMETER, ~dynamicStr=key, ~logger, ()) : ()
- val
- }
- | None => {
+ | None
+ | Some("") => {
manageErrorWarning(REQUIRED_PARAMETER, ~dynamicStr=key, ~logger, ())
optionalStr->Option.getOr(default)
}
+ | Some(val) => val
}
}
@@ -125,10 +123,11 @@ let getWarningString = (dict, key, default, ~logger) => {
switch dict->Dict.get(key) {
| Some(val) =>
switch val->JSON.Decode.string {
- | Some(val) => val
- | None =>
+ | None
+ | Some("") =>
manageErrorWarning(TYPE_STRING_ERROR, ~dynamicStr=key, ~logger, ())
default
+ | Some(val) => val
}
| None => default
}
@@ -804,6 +803,9 @@ let getHeaders = (~uri=?, ~token=?, ~headers=Dict.make(), ()) => {
("Content-Type", "application/json"),
("X-Client-Version", Window.version),
("X-Payment-Confirm-Source", "sdk"),
+ ("X-Browser-Name", OrcaLogger.arrayOfNameAndVersion->Array.get(0)->Option.getOr("Others")),
+ ("X-Browser-Version", OrcaLogger.arrayOfNameAndVersion->Array.get(1)->Option.getOr("0")),
+ ("X-Client-Platform", "web"),
]->Dict.fromArray
switch (token, uri) {
@@ -1331,4 +1333,3 @@ let handleFailureResponse = (~message, ~errorType) =>
]->getJsonFromArrayOfJson,
),
]->getJsonFromArrayOfJson
-
diff --git a/src/orca-loader/PaymentSessionMethods.res b/src/orca-loader/PaymentSessionMethods.res
index 828484ba6..a0e920454 100644
--- a/src/orca-loader/PaymentSessionMethods.res
+++ b/src/orca-loader/PaymentSessionMethods.res
@@ -12,12 +12,6 @@ let getCustomerSavedPaymentMethods = (
open GooglePayType
let applePaySessionRef = ref(Nullable.null)
- let gPayClient = google(
- {
- "environment": publishableKey->String.startsWith("pk_prd_") ? "PRODUCTION" : "TEST",
- }->Identity.anyTypeToJson,
- )
-
PaymentHelpers.fetchCustomerPaymentMethodList(
~clientSecret,
~publishableKey,
@@ -27,6 +21,12 @@ let getCustomerSavedPaymentMethods = (
~isPaymentSession=true,
)
->then(customerDetails => {
+ let gPayClient = google(
+ {
+ "environment": publishableKey->String.startsWith("pk_prd_") ? "PRODUCTION" : "TEST",
+ }->Identity.anyTypeToJson,
+ )
+
let customerDetailsDict = customerDetails->JSON.Decode.object->Option.getOr(Dict.make())
let (customerPaymentMethods, isGuestCustomer) =
customerDetailsDict->PaymentType.itemToCustomerObjMapper
@@ -168,7 +168,12 @@ let getCustomerSavedPaymentMethods = (
PaymentUtils.getStateJson()
->then(stateJson => {
- logger.setLogInfo(~value="States Loaded", ~eventName=APPLE_PAY_FLOW, ~paymentMethod="APPLE_PAY", ())
+ logger.setLogInfo(
+ ~value="States Loaded",
+ ~eventName=APPLE_PAY_FLOW,
+ ~paymentMethod="APPLE_PAY",
+ (),
+ )
stateJson->completeApplePayPayment
})
->catch(err => {
@@ -226,7 +231,12 @@ let getCustomerSavedPaymentMethods = (
PaymentUtils.getStateJson()
->then(
stateJson => {
- logger.setLogInfo(~value="States Loaded", ~eventName=GOOGLE_PAY_FLOW, ~paymentMethod="GOOGLE_PAY", ())
+ logger.setLogInfo(
+ ~value="States Loaded",
+ ~eventName=GOOGLE_PAY_FLOW,
+ ~paymentMethod="GOOGLE_PAY",
+ (),
+ )
stateJson->completeGooglePayPayment
},
)
@@ -423,7 +433,7 @@ let getCustomerSavedPaymentMethods = (
->Identity.anyTypeToJson
->resolve
})
- ->catch(err => {
+ ->catch(_ => {
updateCustomerPaymentMethodsRef(~isFilterApplePay=true, ~isFilterGooglePay=true)
{