From 9754371acc850b27b98e7062ee8a9874d6afb241 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja Date: Tue, 3 Sep 2024 12:00:01 +0530 Subject: [PATCH] fix: merge conflcts --- CHANGELOG.md | 23 ++++ package-lock.json | 112 +++++++++++++++++- package.json | 4 +- src/App.res | 2 + src/BrutalTheme.res | 1 + src/CharcoalTheme.res | 1 + src/Components/Accordion.res | 1 - src/Components/AccordionContainer.res | 1 - src/Components/SavedPaymentManagement.res | 4 +- src/DefaultTheme.res | 1 + src/Index.res | 2 +- src/LoaderController.res | 4 +- src/MidnightTheme.res | 1 + src/PaymentElement.res | 47 ++++---- src/PaymentMethodCollectElement.res | 13 +- src/Payments/PaymentRequestButtonElement.res | 11 +- src/Payments/PlaidSDKIframe.res | 2 +- src/Payments/PreMountLoader.res | 26 ++-- src/Payments/QRCodeDisplay.res | 6 +- src/RenderPaymentMethods.res | 27 +++-- src/SoftTheme.res | 1 + src/Utilities/ApiEndpoint.res | 15 +-- src/Utilities/PaymentHelpers.res | 95 ++++++--------- src/Utilities/RecoilAtoms.res | 2 +- src/WalletElement.res | 5 +- src/orca-loader/Elements.res | 26 ++-- .../PaymentMethodsManagementElements.res | 11 +- src/orca-loader/PaymentSession.res | 13 +- src/orca-loader/PaymentSessionMethods.res | 16 ++- src/orca-log-catcher/ErrorBoundary.res | 21 +++- src/orca-log-catcher/OrcaLogger.res | 11 +- .../ReusableReactSuspense.res | 8 ++ webpack.common.js | 13 +- 33 files changed, 354 insertions(+), 172 deletions(-) create mode 100644 src/orca-log-catcher/ReusableReactSuspense.res diff --git a/CHANGELOG.md b/CHANGELOG.md index 9460d090c..7528d527d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,26 @@ +## [0.84.9](https://github.com/juspay/hyperswitch-web/compare/v0.84.8...v0.84.9) (2024-09-03) + + +### Bug Fixes + +* added loader for netecetera when openurl_if_required is sent post otp submission ([#589](https://github.com/juspay/hyperswitch-web/issues/589)) ([bf04562](https://github.com/juspay/hyperswitch-web/commit/bf0456234bb6746a4e8c44fd7f9cd364c914e665)) + +## [0.84.8](https://github.com/juspay/hyperswitch-web/compare/v0.84.7...v0.84.8) (2024-09-02) + + +### Bug Fixes + +* added customization for padding inside accordion item rule ([#595](https://github.com/juspay/hyperswitch-web/issues/595)) ([a251de5](https://github.com/juspay/hyperswitch-web/commit/a251de52d70b0389bc5b0e789bcc1982cf343344)) + +## [0.84.7](https://github.com/juspay/hyperswitch-web/compare/v0.84.6...v0.84.7) (2024-09-02) + +## [0.84.6](https://github.com/juspay/hyperswitch-web/compare/v0.84.5...v0.84.6) (2024-08-30) + + +### Bug Fixes + +* added support for customPodUri instead of switchToCustomPod ([#591](https://github.com/juspay/hyperswitch-web/issues/591)) ([f9fed51](https://github.com/juspay/hyperswitch-web/commit/f9fed5117e74c63f813117d5eceafc4a000e17dc)) + ## [0.84.5](https://github.com/juspay/hyperswitch-web/compare/v0.84.4...v0.84.5) (2024-08-26) ## [0.84.4](https://github.com/juspay/hyperswitch-web/compare/v0.84.3...v0.84.4) (2024-08-23) diff --git a/package-lock.json b/package-lock.json index 42a0726fe..0812e6668 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "orca-payment-page", - "version": "0.84.5", + "version": "0.84.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "orca-payment-page", - "version": "0.84.5", + "version": "0.84.9", "hasInstallScript": true, "dependencies": { "@glennsl/rescript-fetch": "^0.2.0", @@ -23,6 +23,7 @@ "devDependencies": { "@babel/core": "^7.25.2", "@babel/preset-env": "^7.25.3", + "@babel/preset-react": "^7.24.7", "@commitlint/cli": "^17.0.3", "@commitlint/config-conventional": "^17.0.3", "@semantic-release/changelog": "^6.0.3", @@ -32,6 +33,7 @@ "@semantic-release/release-notes-generator": "^14.0.1", "autoprefixer": "^10.4.8", "babel-loader": "^9.1.3", + "babel-plugin-add-react-displayname": "^0.0.5", "copy-webpack-plugin": "^11.0.0", "css-loader": "^6.7.1", "cz-conventional-changelog": "^3.3.0", @@ -739,6 +741,21 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-syntax-jsx": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.24.7.tgz", + "integrity": "sha512-6ddciUPe/mpMnOKv/U+RSd2vvVy+Yw/JfBB0ZHYjEZt9NLHmCUylNYlsbqCCS1Bffjlb0fCwC9Vqz+sBz6PsiQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/plugin-syntax-logical-assignment-operators": { "version": "7.10.4", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", @@ -1472,6 +1489,71 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-transform-react-display-name": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-display-name/-/plugin-transform-react-display-name-7.24.7.tgz", + "integrity": "sha512-H/Snz9PFxKsS1JLI4dJLtnJgCJRoo0AUm3chP6NYr+9En1JMKloheEiLIhlp5MDVznWo+H3AAC1Mc8lmUEpsgg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx": { + "version": "7.25.2", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.25.2.tgz", + "integrity": "sha512-KQsqEAVBpU82NM/B/N9j9WOdphom1SZH3R+2V7INrQUH+V9EBFwZsEJl8eBIVeQE62FxJCc70jzEZwqU7RcVqA==", + "dev": true, + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.24.7", + "@babel/helper-module-imports": "^7.24.7", + "@babel/helper-plugin-utils": "^7.24.8", + "@babel/plugin-syntax-jsx": "^7.24.7", + "@babel/types": "^7.25.2" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx-development": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-development/-/plugin-transform-react-jsx-development-7.24.7.tgz", + "integrity": "sha512-QG9EnzoGn+Qar7rxuW+ZOsbWOt56FvvI93xInqsZDC5fsekx1AlIO4KIJ5M+D0p0SqSH156EpmZyXq630B8OlQ==", + "dev": true, + "dependencies": { + "@babel/plugin-transform-react-jsx": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-react-pure-annotations": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-pure-annotations/-/plugin-transform-react-pure-annotations-7.24.7.tgz", + "integrity": "sha512-PLgBVk3fzbmEjBJ/u8kFzOqS9tUeDjiaWud/rRym/yjCo/M9cASPlnrd2ZmmZpQT40fOOrvR8jh+n8jikrOhNA==", + "dev": true, + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.24.7", + "@babel/helper-plugin-utils": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/plugin-transform-regenerator": { "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.24.7.tgz", @@ -1762,6 +1844,26 @@ "@babel/core": "^7.0.0-0 || ^8.0.0-0 <8.0.0" } }, + "node_modules/@babel/preset-react": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/preset-react/-/preset-react-7.24.7.tgz", + "integrity": "sha512-AAH4lEkpmzFWrGVlHaxJB7RLH21uPQ9+He+eFLWHmF9IuFQVugz8eAsamaW0DXRrTfco5zj1wWtpdcXJUOfsag==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.24.7", + "@babel/helper-validator-option": "^7.24.7", + "@babel/plugin-transform-react-display-name": "^7.24.7", + "@babel/plugin-transform-react-jsx": "^7.24.7", + "@babel/plugin-transform-react-jsx-development": "^7.24.7", + "@babel/plugin-transform-react-pure-annotations": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/regjsgen": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/@babel/regjsgen/-/regjsgen-0.8.0.tgz", @@ -4509,6 +4611,12 @@ "webpack": ">=5" } }, + "node_modules/babel-plugin-add-react-displayname": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/babel-plugin-add-react-displayname/-/babel-plugin-add-react-displayname-0.0.5.tgz", + "integrity": "sha512-LY3+Y0XVDYcShHHorshrDbt4KFWL4bSeniCtl4SYZbask+Syngk1uMPCeN9+nSiZo6zX5s0RTq/J9Pnaaf/KHw==", + "dev": true + }, "node_modules/babel-plugin-polyfill-corejs2": { "version": "0.4.11", "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.4.11.tgz", diff --git a/package.json b/package.json index d6398445c..93e651e02 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "orca-payment-page", - "version": "0.84.5", + "version": "0.84.9", "main": "index.js", "private": true, "dependencies": { @@ -56,6 +56,7 @@ "devDependencies": { "@babel/core": "^7.25.2", "@babel/preset-env": "^7.25.3", + "@babel/preset-react": "^7.24.7", "@commitlint/cli": "^17.0.3", "@commitlint/config-conventional": "^17.0.3", "@semantic-release/changelog": "^6.0.3", @@ -65,6 +66,7 @@ "@semantic-release/release-notes-generator": "^14.0.1", "autoprefixer": "^10.4.8", "babel-loader": "^9.1.3", + "babel-plugin-add-react-displayname": "^0.0.5", "copy-webpack-plugin": "^11.0.0", "css-loader": "^6.7.1", "cz-conventional-changelog": "^3.3.0", diff --git a/src/App.res b/src/App.res index 04b239690..020d9cd9a 100644 --- a/src/App.res +++ b/src/App.res @@ -45,6 +45,7 @@ let make = () => { "hyperComponentName", )->Types.getHyperComponentNameFromStr let merchantHostname = CardUtils.getQueryParamsDictforKey(url.search, "merchantHostname") + let customPodUri = CardUtils.getQueryParamsDictforKey(url.search, "customPodUri") { ephemeralKey hyperComponentName merchantHostname + customPodUri /> } | "achBankTransfer" diff --git a/src/BrutalTheme.res b/src/BrutalTheme.res index 7bb4125da..ceb18a16e 100644 --- a/src/BrutalTheme.res +++ b/src/BrutalTheme.res @@ -138,6 +138,7 @@ let brutalRules = (theme: CardThemeType.themeClass) => "color": theme.colorBackgroundText, "transition": "height 1s ease", "borderColor": `#000000 !important`, + "padding": "20px", }, ".AccordionMore": { "backgroundColor": theme.colorBackground, diff --git a/src/CharcoalTheme.res b/src/CharcoalTheme.res index 8c8da2f64..6709840f7 100644 --- a/src/CharcoalTheme.res +++ b/src/CharcoalTheme.res @@ -137,6 +137,7 @@ let charcoalRules = theme => "backgroundColor": theme.colorBackground, "color": theme.colorTextSecondary, "transition": "height 1s ease", + "padding": "20px", }, ".AccordionMore": { "backgroundColor": theme.colorBackground, diff --git a/src/Components/Accordion.res b/src/Components/Accordion.res index b9f540c64..5d6250064 100644 --- a/src/Components/Accordion.res +++ b/src/Components/Accordion.res @@ -39,7 +39,6 @@ let make = ( style={ minHeight: "60px", width: "-webkit-fill-available", - padding: "20px", cursor: "pointer", marginBottom: layoutClass.spacedAccordionItems ? themeObj.spacingAccordionItem : "", border: `1px solid ${themeObj.borderColor}`, diff --git a/src/Components/AccordionContainer.res b/src/Components/AccordionContainer.res index 9f99ecb2e..56f4b2d3f 100644 --- a/src/Components/AccordionContainer.res +++ b/src/Components/AccordionContainer.res @@ -34,7 +34,6 @@ module Loader = { }, borderTopStyle: {i == 0 && !layoutClass.spacedAccordionItems ? "hidden" : "solid"}, width: "100%", - paddingLeft: "25px", marginBottom: layoutClass.spacedAccordionItems ? themeObj.spacingAccordionItem : "", cursor: "pointer", }> diff --git a/src/Components/SavedPaymentManagement.res b/src/Components/SavedPaymentManagement.res index 05fc9f16b..f492b4b24 100644 --- a/src/Components/SavedPaymentManagement.res +++ b/src/Components/SavedPaymentManagement.res @@ -5,7 +5,7 @@ let make = (~savedMethods: array, ~setSavedMethods) let {iframeId} = Recoil.useRecoilValueFromAtom(RecoilAtoms.keys) let {config} = Recoil.useRecoilValueFromAtom(RecoilAtoms.configAtom) - let switchToCustomPod = Recoil.useRecoilValueFromAtom(RecoilAtoms.switchToCustomPod) + let customPodUri = Recoil.useRecoilValueFromAtom(RecoilAtoms.customPodUri) let logger = Recoil.useRecoilValueFromAtom(RecoilAtoms.loggerAtom) let removeSavedMethod = ( @@ -28,7 +28,7 @@ let make = (~savedMethods: array, ~setSavedMethods) ~ephemeralKey=config.ephemeralKey, ~paymentMethodId=paymentItem.paymentMethodId, ~logger, - ~switchToCustomPod, + ~customPodUri, ) ->then(res => { let dict = res->getDictFromJson diff --git a/src/DefaultTheme.res b/src/DefaultTheme.res index 51e414300..738ed839e 100644 --- a/src/DefaultTheme.res +++ b/src/DefaultTheme.res @@ -147,6 +147,7 @@ let defaultRules = theme => "color": theme.colorTextSecondary, "transition": "height 1s ease", "boxShadow": "0px 1px 1px rgb(0 0 0 / 3%), 0px 3px 6px rgb(0 0 0 / 2%)", + "padding": "20px", }, ".AccordionMore": { "backgroundColor": theme.colorBackground, diff --git a/src/Index.res b/src/Index.res index a254531ff..34fb585d3 100644 --- a/src/Index.res +++ b/src/Index.res @@ -9,7 +9,7 @@ let app = switch ReactDOM.querySelector("#app") {
- + diff --git a/src/LoaderController.res b/src/LoaderController.res index af25ede5c..d81b6457b 100644 --- a/src/LoaderController.res +++ b/src/LoaderController.res @@ -11,7 +11,7 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime let (optionsPayment, setOptionsPayment) = Recoil.useRecoilState(optionAtom) let setSessionId = Recoil.useSetRecoilState(sessionId) let setBlockConfirm = Recoil.useSetRecoilState(isConfirmBlocked) - let setSwitchToCustomPod = Recoil.useSetRecoilState(switchToCustomPod) + let setCustomPodUri = Recoil.useSetRecoilState(customPodUri) let setIsGooglePayReady = Recoil.useSetRecoilState(isGooglePayReady) let setIsApplePayReady = Recoil.useSetRecoilState(isApplePayReady) let (divH, setDivH) = React.useState(_ => 0.0) @@ -231,8 +231,8 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime logger.setSessionId(sdkSessionId) if Window.isInteg { setBlockConfirm(_ => dict->getBool("blockConfirm", false)) - setSwitchToCustomPod(_ => dict->getBool("switchToCustomPod", false)) } + setCustomPodUri(_ => dict->getString("customPodUri", "")) updateOptions(dict) setSessionId(_ => { sdkSessionId diff --git a/src/MidnightTheme.res b/src/MidnightTheme.res index eced1032a..49b194977 100644 --- a/src/MidnightTheme.res +++ b/src/MidnightTheme.res @@ -154,6 +154,7 @@ let midnightRules = theme => "transition": "height 1s ease", "color": "#e0e0e0", "boxShadow": "0px 2px 4px rgb(0 0 0 / 50%), 0px 1px 6px rgb(0 0 0 / 25%)", + "padding": "20px", }, ".AccordionItem:hover": { "color": theme.colorTextSecondary, diff --git a/src/PaymentElement.res b/src/PaymentElement.res index afa3e8b4a..8d8e045b0 100644 --- a/src/PaymentElement.res +++ b/src/PaymentElement.res @@ -284,47 +284,47 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod } let checkoutEle = { - + {switch selectedOption->PaymentModeType.paymentMode { | Card => | Klarna => - + - + | ACHTransfer => - + - + | SepaTransfer => - + - + | BacsTransfer => - + - + | ACHBankDebit => - + - + | SepaBankDebit => - + - + | BacsBankDebit => - + - + | BanContactCard => | BecsBankDebit => - + - + | Boleto => - + - + | ApplePay => switch applePayToken { | ApplePayTokenOptional(optToken) => @@ -350,9 +350,9 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod }} | _ => - + - + }} } @@ -402,7 +402,10 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod condition={(paymentOptions->Array.length > 0 || walletOptions->Array.length > 0) && showFields}>
- + { ~clientSecret=keys.clientSecret->Option.getOr(""), ~publishableKey=keys.publishableKey, ~logger, - ~switchToCustomPod=false, + ~customPodUri="", ~uri, ~body=pmdBody, ) @@ -171,7 +171,7 @@ let make = (~integrateError, ~logger) => { ~clientSecret=keys.clientSecret->Option.getOr(""), ~publishableKey=keys.publishableKey, ~logger, - ~switchToCustomPod=false, + ~customPodUri="", ~endpoint=ApiEndpoint.getApiEndPoint(), ~body=pmdBody, ) @@ -296,8 +296,13 @@ let make = (~integrateError, ~logger) => { className="font-bold text-5xl mt-5 lg:mt-0 lg:text-3xl flex justify-center items-center">

{React.string(`${options.currency} ${options.amount}`)}

-
- O +
+ O
diff --git a/src/Payments/PaymentRequestButtonElement.res b/src/Payments/PaymentRequestButtonElement.res index f78578493..34e4ad5ef 100644 --- a/src/Payments/PaymentRequestButtonElement.res +++ b/src/Payments/PaymentRequestButtonElement.res @@ -65,8 +65,13 @@ let make = (~sessions, ~walletOptions, ~paymentType) => { {walletOptions ->Array.mapWithIndex((item, i) => { Int.toString}-request-button`}> - } key={i->Int.toString}> + level={ErrorBoundary.RequestButton} + key={`${item}-${i->Int.toString}-request-button`} + componentName="PaymentRequestButtonElement"> + } + componentName="PaymentRequestButtonElement" + key={i->Int.toString}> {switch clientSecret { | Some(_) => switch item->paymentMode { @@ -123,7 +128,7 @@ let make = (~sessions, ~walletOptions, ~paymentType) => { } | None => React.null }} - + }) ->React.array} diff --git a/src/Payments/PlaidSDKIframe.res b/src/Payments/PlaidSDKIframe.res index 4e2d68cc4..e3716d663 100644 --- a/src/Payments/PlaidSDKIframe.res +++ b/src/Payments/PlaidSDKIframe.res @@ -57,7 +57,7 @@ let make = () => { clientSecret, headers, ~optLogger=Some(logger), - ~switchToCustomPod=false, + ~customPodUri="", ~isForceSync=true, ) ->then(json => { diff --git a/src/Payments/PreMountLoader.res b/src/Payments/PreMountLoader.res index c1f680ea8..276531539 100644 --- a/src/Payments/PreMountLoader.res +++ b/src/Payments/PreMountLoader.res @@ -29,13 +29,20 @@ let useMessageHandler = getPromisesAndMessageHandler => { module PreMountLoaderForElements = { @react.component - let make = (~logger, ~publishableKey, ~clientSecret, ~endpoint, ~merchantHostname) => { + let make = ( + ~logger, + ~publishableKey, + ~clientSecret, + ~merchantHostname, + ~endpoint, + ~customPodUri, + ) => { useMessageHandler(() => { let paymentMethodsPromise = PaymentHelpers.fetchPaymentMethodList( ~clientSecret, ~publishableKey, ~logger, - ~switchToCustomPod=false, + ~customPodUri, ~endpoint, ) @@ -43,17 +50,17 @@ module PreMountLoaderForElements = { ~clientSecret, ~publishableKey, ~optLogger=Some(logger), - ~switchToCustomPod=false, ~endpoint, + ~customPodUri, ) let sessionTokensPromise = PaymentHelpers.fetchSessions( ~clientSecret, ~publishableKey, ~optLogger=Some(logger), - ~switchToCustomPod=false, ~endpoint, ~merchantHostname, + ~customPodUri, ) let messageHandler = (ev: Window.event) => { @@ -78,13 +85,13 @@ module PreMountLoaderForElements = { module PreMountLoaderForPMMElements = { @react.component - let make = (~logger, ~endpoint, ~ephemeralKey) => { + let make = (~logger, ~endpoint, ~ephemeralKey, ~customPodUri) => { useMessageHandler(() => { let savedPaymentMethodsPromise = PaymentHelpers.fetchSavedPaymentMethodList( ~ephemeralKey, ~optLogger=Some(logger), - ~switchToCustomPod=false, ~endpoint, + ~customPodUri, ) let messageHandler = (ev: Window.event) => { @@ -112,6 +119,7 @@ let make = ( ~ephemeralKey, ~hyperComponentName: Types.hyperComponentName, ~merchantHostname, + ~customPodUri, ) => { let logger = OrcaLogger.make( ~sessionId, @@ -122,8 +130,10 @@ let make = ( switch hyperComponentName { | Elements => - + | PaymentMethodsManagementElements => - + } } diff --git a/src/Payments/QRCodeDisplay.res b/src/Payments/QRCodeDisplay.res index c73727eff..7507f1f01 100644 --- a/src/Payments/QRCodeDisplay.res +++ b/src/Payments/QRCodeDisplay.res @@ -16,7 +16,7 @@ let make = () => { let (clientSecret, setClientSecret) = React.useState(_ => "") let (headers, setHeaders) = React.useState(_ => []) let logger = Recoil.useRecoilValueFromAtom(RecoilAtoms.loggerAtom) - let switchToCustomPod = Recoil.useRecoilValueFromAtom(RecoilAtoms.switchToCustomPod) + let customPodUri = Recoil.useRecoilValueFromAtom(RecoilAtoms.customPodUri) React.useEffect0(() => { messageParentWindow([("iframeMountedCallback", true->JSON.Encode.bool)]) @@ -55,7 +55,7 @@ let make = () => { paymentIntentId, headers->Dict.toArray, ~optLogger=Some(logger), - ~switchToCustomPod, + ~customPodUri, ) ->then(res => { Modal.close(setOpenModal) @@ -88,7 +88,7 @@ let make = () => { clientSecret, headers, ~optLogger=Some(logger), - ~switchToCustomPod, + ~customPodUri, ) ->then(json => { let dict = json->getDictFromJson diff --git a/src/RenderPaymentMethods.res b/src/RenderPaymentMethods.res index 8f0ab28d1..d2def612a 100644 --- a/src/RenderPaymentMethods.res +++ b/src/RenderPaymentMethods.res @@ -72,28 +72,30 @@ let make = (
{switch paymentType { | Card => - + - }> + } + componentName="SingleLineCardPaymentLazy"> - + | GooglePayElement | PayPalElement | ApplePayElement | KlarnaElement | ExpressCheckoutElement | Payment => - + {paymentType->Utils.getIsWalletElementPaymentType ? : } - }> + } + componentName="PaymentElementRendererLazy"> - + | CardNumberElement => | PaymentMethodsManagement => - + - }> + } + componentName="PaymentManagementLazy"> - + | PaymentMethodCollectElement | NONE => React.null }} diff --git a/src/SoftTheme.res b/src/SoftTheme.res index 41b28ae98..4177b13ba 100644 --- a/src/SoftTheme.res +++ b/src/SoftTheme.res @@ -136,6 +136,7 @@ let softRules = theme => "color": theme.colorTextSecondary, "transition": "background .15s ease, border .15s ease, box-shadow .15s ease", "boxShadow": `4px 4px 5px #353637, -4px -4px 5px #434445`, + "padding": "20px", }, ".AccordionItem--selected": { "color": theme.colorPrimary, diff --git a/src/Utilities/ApiEndpoint.res b/src/Utilities/ApiEndpoint.res index d8d032be3..9e0fefd51 100644 --- a/src/Utilities/ApiEndpoint.res +++ b/src/Utilities/ApiEndpoint.res @@ -18,14 +18,11 @@ let getApiEndPoint = (~publishableKey="", ~isConfirmCall=false) => { } } -let addCustomPodHeader = (arr: array<(string, string)>, ~switchToCustomPod=?) => { - let customPod = switch switchToCustomPod { - | Some(val) => val - | None => false - } - if customPod { - arr->Array.concat([("x-feature", "router-custom-dbd")])->Dict.fromArray - } else { - arr->Dict.fromArray +let addCustomPodHeader = (arr: array<(string, string)>, ~customPodUri=?) => { + switch customPodUri { + | Some("") + | None => () + | Some(customPodVal) => arr->Array.push(("x-feature", customPodVal)) } + arr->Dict.fromArray } diff --git a/src/Utilities/PaymentHelpers.res b/src/Utilities/PaymentHelpers.res index 36e85ad34..e0c1e47fd 100644 --- a/src/Utilities/PaymentHelpers.res +++ b/src/Utilities/PaymentHelpers.res @@ -44,7 +44,7 @@ let retrievePaymentIntent = ( clientSecret, headers, ~optLogger, - ~switchToCustomPod, + ~customPodUri, ~isForceSync=false, ) => { open Promise @@ -61,7 +61,7 @@ let retrievePaymentIntent = ( ~logType=INFO, ~logCategory=API, ) - fetchApi(uri, ~method=#GET, ~headers=headers->ApiEndpoint.addCustomPodHeader(~switchToCustomPod)) + fetchApi(uri, ~method=#GET, ~headers=headers->ApiEndpoint.addCustomPodHeader(~customPodUri)) ->then(res => { let statusCode = res->Fetch.Response.status->Int.toString if statusCode->String.charAt(0) !== "2" { @@ -170,11 +170,11 @@ let rec pollRetrievePaymentIntent = ( clientSecret, headers, ~optLogger, - ~switchToCustomPod, + ~customPodUri, ~isForceSync=false, ) => { open Promise - retrievePaymentIntent(clientSecret, headers, ~optLogger, ~switchToCustomPod, ~isForceSync) + retrievePaymentIntent(clientSecret, headers, ~optLogger, ~customPodUri, ~isForceSync) ->then(json => { let dict = json->getDictFromJson let status = dict->getString("status", "") @@ -183,23 +183,17 @@ let rec pollRetrievePaymentIntent = ( resolve(json) } else { delay(2000)->then(_val => { - pollRetrievePaymentIntent( - clientSecret, - headers, - ~optLogger, - ~switchToCustomPod, - ~isForceSync, - ) + pollRetrievePaymentIntent(clientSecret, headers, ~optLogger, ~customPodUri, ~isForceSync) }) } }) ->catch(e => { Console.log2("Unable to retrieve payment due to following error", e) - pollRetrievePaymentIntent(clientSecret, headers, ~optLogger, ~switchToCustomPod, ~isForceSync) + pollRetrievePaymentIntent(clientSecret, headers, ~optLogger, ~customPodUri, ~isForceSync) }) } -let retrieveStatus = (~headers, ~switchToCustomPod, pollID, logger) => { +let retrieveStatus = (~headers, ~customPodUri, pollID, logger) => { open Promise let endpoint = ApiEndpoint.getApiEndPoint() let uri = `${endpoint}/poll/status/${pollID}` @@ -211,7 +205,7 @@ let retrieveStatus = (~headers, ~switchToCustomPod, pollID, logger) => { ~logType=INFO, ~logCategory=API, ) - fetchApi(uri, ~method=#GET, ~headers=headers->ApiEndpoint.addCustomPodHeader(~switchToCustomPod)) + fetchApi(uri, ~method=#GET, ~headers=headers->ApiEndpoint.addCustomPodHeader(~customPodUri)) ->then(res => { let statusCode = res->Fetch.Response.status->Int.toString if statusCode->String.charAt(0) !== "2" { @@ -249,17 +243,9 @@ let retrieveStatus = (~headers, ~switchToCustomPod, pollID, logger) => { }) } -let rec pollStatus = ( - ~headers, - ~switchToCustomPod, - ~pollId, - ~interval, - ~count, - ~returnUrl, - ~logger, -) => { +let rec pollStatus = (~headers, ~customPodUri, ~pollId, ~interval, ~count, ~returnUrl, ~logger) => { open Promise - retrieveStatus(~headers, ~switchToCustomPod, pollId, logger) + retrieveStatus(~headers, ~customPodUri, pollId, logger) ->then(json => { let dict = json->getDictFromJson let status = dict->getString("status", "") @@ -275,7 +261,7 @@ let rec pollStatus = ( _ => { pollStatus( ~headers, - ~switchToCustomPod, + ~customPodUri, ~pollId, ~interval, ~count=count - 1, @@ -297,7 +283,7 @@ let rec pollStatus = ( Console.log2("Unable to retrieve payment due to following error", e) pollStatus( ~headers, - ~switchToCustomPod, + ~customPodUri, ~pollId, ~interval, ~count=count - 1, @@ -325,7 +311,7 @@ let rec intentCall = ( ~iframeId, ~fetchMethod, ~setIsManualRetryEnabled, - ~switchToCustomPod, + ~customPodUri, ~sdkHandleOneClickConfirmPayment, ~counter, ~isPaymentSession=false, @@ -360,7 +346,7 @@ let rec intentCall = ( fetchApi( uri, ~method=fetchMethod, - ~headers=headers->ApiEndpoint.addCustomPodHeader(~switchToCustomPod), + ~headers=headers->ApiEndpoint.addCustomPodHeader(~customPodUri), ~bodyStr, ) ->then(res => { @@ -474,7 +460,7 @@ let rec intentCall = ( ~iframeId, ~fetchMethod=#GET, ~setIsManualRetryEnabled, - ~switchToCustomPod, + ~customPodUri, ~sdkHandleOneClickConfirmPayment, ~counter=counter + 1, ) @@ -872,7 +858,7 @@ let rec intentCall = ( ~iframeId, ~fetchMethod=#GET, ~setIsManualRetryEnabled, - ~switchToCustomPod, + ~customPodUri, ~sdkHandleOneClickConfirmPayment, ~counter=counter + 1, ~isPaymentSession, @@ -904,7 +890,7 @@ let usePaymentSync = (optLogger: option, paymentType: pay open RecoilAtoms let paymentMethodList = Recoil.useRecoilValueFromAtom(paymentMethodList) let keys = Recoil.useRecoilValueFromAtom(keys) - let switchToCustomPod = Recoil.useRecoilValueFromAtom(switchToCustomPod) + let customPodUri = Recoil.useRecoilValueFromAtom(customPodUri) let setIsManualRetryEnabled = Recoil.useSetRecoilState(isManualRetryEnabled) (~handleUserError=false, ~confirmParam: ConfirmType.confirmParams, ~iframeId="") => { switch keys.clientSecret { @@ -928,7 +914,7 @@ let usePaymentSync = (optLogger: option, paymentType: pay ~iframeId, ~fetchMethod=#GET, ~setIsManualRetryEnabled, - ~switchToCustomPod, + ~customPodUri, ~sdkHandleOneClickConfirmPayment=keys.sdkHandleOneClickConfirmPayment, ~counter=0, )->ignore @@ -974,7 +960,7 @@ let usePaymentIntent = (optLogger, paymentType) => { let paymentTypeFromUrl = CardUtils.getQueryParamsDictforKey(url.search, "componentName")->CardThemeType.getPaymentMode let blockConfirm = Recoil.useRecoilValueFromAtom(isConfirmBlocked) - let switchToCustomPod = Recoil.useRecoilValueFromAtom(switchToCustomPod) + let customPodUri = Recoil.useRecoilValueFromAtom(customPodUri) let paymentMethodList = Recoil.useRecoilValueFromAtom(paymentMethodList) let keys = Recoil.useRecoilValueFromAtom(keys) @@ -1067,7 +1053,7 @@ let usePaymentIntent = (optLogger, paymentType) => { ~iframeId, ~fetchMethod=#POST, ~setIsManualRetryEnabled, - ~switchToCustomPod, + ~customPodUri, ~sdkHandleOneClickConfirmPayment=keys.sdkHandleOneClickConfirmPayment, ~counter=0, ) @@ -1151,7 +1137,7 @@ let useCompleteAuthorize = (optLogger: option, paymentTyp open RecoilAtoms let paymentMethodList = Recoil.useRecoilValueFromAtom(paymentMethodList) let keys = Recoil.useRecoilValueFromAtom(keys) - let switchToCustomPod = Recoil.useRecoilValueFromAtom(switchToCustomPod) + let customPodUri = Recoil.useRecoilValueFromAtom(customPodUri) let setIsManualRetryEnabled = Recoil.useSetRecoilState(isManualRetryEnabled) let url = RescriptReactRouter.useUrl() let paymentTypeFromUrl = @@ -1194,7 +1180,7 @@ let useCompleteAuthorize = (optLogger: option, paymentTyp ~iframeId, ~fetchMethod=#POST, ~setIsManualRetryEnabled, - ~switchToCustomPod, + ~customPodUri, ~sdkHandleOneClickConfirmPayment=keys.sdkHandleOneClickConfirmPayment, ~counter=0, )->ignore @@ -1218,7 +1204,7 @@ let fetchSessions = ( ~wallets=[], ~isDelayedSessionToken=false, ~optLogger, - ~switchToCustomPod, + ~customPodUri, ~endpoint, ~isPaymentSession=false, ~merchantHostname=Window.Location.hostname, @@ -1251,7 +1237,7 @@ let fetchSessions = ( uri, ~method=#POST, ~bodyStr=body->JSON.stringify, - ~headers=headers->ApiEndpoint.addCustomPodHeader(~switchToCustomPod), + ~headers=headers->ApiEndpoint.addCustomPodHeader(~customPodUri), ) ->then(resp => { let statusCode = resp->Fetch.Response.status->Int.toString @@ -1302,7 +1288,7 @@ let fetchSessions = ( }) } -let confirmPayout = (~clientSecret, ~publishableKey, ~logger, ~switchToCustomPod, ~uri, ~body) => { +let confirmPayout = (~clientSecret, ~publishableKey, ~logger, ~customPodUri, ~uri, ~body) => { open Promise let headers = [("Content-Type", "application/json"), ("api-key", publishableKey)] logApi( @@ -1322,7 +1308,7 @@ let confirmPayout = (~clientSecret, ~publishableKey, ~logger, ~switchToCustomPod uri, ~method=#POST, ~bodyStr=body->JSON.stringify, - ~headers=headers->ApiEndpoint.addCustomPodHeader(~switchToCustomPod), + ~headers=headers->ApiEndpoint.addCustomPodHeader(~customPodUri), ) ->then(resp => { let statusCode = resp->Fetch.Response.status->Int.toString @@ -1374,7 +1360,7 @@ let createPaymentMethod = ( ~clientSecret, ~publishableKey, ~logger, - ~switchToCustomPod, + ~customPodUri, ~endpoint, ~body, ) => { @@ -1398,7 +1384,7 @@ let createPaymentMethod = ( uri, ~method=#POST, ~bodyStr=body->JSON.stringify, - ~headers=headers->ApiEndpoint.addCustomPodHeader(~switchToCustomPod), + ~headers=headers->ApiEndpoint.addCustomPodHeader(~customPodUri), ) ->then(resp => { let statusCode = resp->Fetch.Response.status->Int.toString @@ -1450,7 +1436,7 @@ let fetchPaymentMethodList = ( ~clientSecret, ~publishableKey, ~logger, - ~switchToCustomPod, + ~customPodUri, ~endpoint, ) => { open Promise @@ -1464,7 +1450,7 @@ let fetchPaymentMethodList = ( ~logType=INFO, ~logCategory=API, ) - fetchApi(uri, ~method=#GET, ~headers=headers->ApiEndpoint.addCustomPodHeader(~switchToCustomPod)) + fetchApi(uri, ~method=#GET, ~headers=headers->ApiEndpoint.addCustomPodHeader(~customPodUri)) ->then(resp => { let statusCode = resp->Fetch.Response.status->Int.toString if statusCode->String.charAt(0) !== "2" { @@ -1516,7 +1502,7 @@ let fetchCustomerPaymentMethodList = ( ~publishableKey, ~endpoint, ~optLogger, - ~switchToCustomPod, + ~customPodUri, ~isPaymentSession=false, ) => { open Promise @@ -1531,7 +1517,7 @@ let fetchCustomerPaymentMethodList = ( ~logCategory=API, ~isPaymentSession, ) - fetchApi(uri, ~method=#GET, ~headers=headers->ApiEndpoint.addCustomPodHeader(~switchToCustomPod)) + fetchApi(uri, ~method=#GET, ~headers=headers->ApiEndpoint.addCustomPodHeader(~customPodUri)) ->then(res => { let statusCode = res->Fetch.Response.status->Int.toString if statusCode->String.charAt(0) !== "2" { @@ -1588,6 +1574,7 @@ let paymentIntentForPaymentSession = ( ~publishableKey, ~clientSecret, ~logger, + ~customPodUri, ) => { let confirmParams = payload @@ -1640,7 +1627,7 @@ let paymentIntentForPaymentSession = ( ~iframeId="", ~fetchMethod=#POST, ~setIsManualRetryEnabled={_ => ()}, - ~switchToCustomPod=false, + ~customPodUri, ~sdkHandleOneClickConfirmPayment=false, ~counter=0, ~isPaymentSession=true, @@ -1817,7 +1804,7 @@ let callAuthExchange = ( ~clientSecret=clientSecret->Option.getOr(""), ~publishableKey, ~optLogger=Some(logger), - ~switchToCustomPod=false, + ~customPodUri="", ~endpoint, ) ->then(customerListResponse => { @@ -1861,7 +1848,7 @@ let fetchSavedPaymentMethodList = ( ~ephemeralKey, ~endpoint, ~optLogger, - ~switchToCustomPod, + ~customPodUri, ~isPaymentSession=false, ) => { open Promise @@ -1876,7 +1863,7 @@ let fetchSavedPaymentMethodList = ( ~logCategory=API, ~isPaymentSession, ) - fetchApi(uri, ~method=#GET, ~headers=headers->ApiEndpoint.addCustomPodHeader(~switchToCustomPod)) + fetchApi(uri, ~method=#GET, ~headers=headers->ApiEndpoint.addCustomPodHeader(~customPodUri)) ->then(res => { let statusCode = res->Fetch.Response.status->Int.toString if statusCode->String.charAt(0) !== "2" { @@ -1926,7 +1913,7 @@ let fetchSavedPaymentMethodList = ( }) } -let deletePaymentMethod = (~ephemeralKey, ~paymentMethodId, ~logger, ~switchToCustomPod) => { +let deletePaymentMethod = (~ephemeralKey, ~paymentMethodId, ~logger, ~customPodUri) => { open Promise let endpoint = ApiEndpoint.getApiEndPoint() let headers = [("Content-Type", "application/json"), ("api-key", ephemeralKey)] @@ -1939,11 +1926,7 @@ let deletePaymentMethod = (~ephemeralKey, ~paymentMethodId, ~logger, ~switchToCu ~logType=INFO, ~logCategory=API, ) - fetchApi( - uri, - ~method=#DELETE, - ~headers=headers->ApiEndpoint.addCustomPodHeader(~switchToCustomPod), - ) + fetchApi(uri, ~method=#DELETE, ~headers=headers->ApiEndpoint.addCustomPodHeader(~customPodUri)) ->then(resp => { let statusCode = resp->Fetch.Response.status->Int.toString if statusCode->String.charAt(0) !== "2" { diff --git a/src/Utilities/RecoilAtoms.res b/src/Utilities/RecoilAtoms.res index 46438cf75..96f3be110 100644 --- a/src/Utilities/RecoilAtoms.res +++ b/src/Utilities/RecoilAtoms.res @@ -10,7 +10,7 @@ let paymentMethodList = Recoil.atom("paymentMethodList", PaymentType.Loading) let loggerAtom = Recoil.atom("component", OrcaLogger.defaultLoggerConfig) let sessionId = Recoil.atom("sessionId", "") let isConfirmBlocked = Recoil.atom("isConfirmBlocked", false) -let switchToCustomPod = Recoil.atom("switchToCustomPod", false) +let customPodUri = Recoil.atom("customPodUri", "") let selectedOptionAtom = Recoil.atom("selectedOption", "") let paymentTokenAtom = Recoil.atom( "paymentToken", diff --git a/src/WalletElement.res b/src/WalletElement.res index 897286d7e..27fb89e34 100644 --- a/src/WalletElement.res +++ b/src/WalletElement.res @@ -33,7 +33,10 @@ let make = (~paymentType) => { Array.length > 0}>
- +
diff --git a/src/orca-loader/Elements.res b/src/orca-loader/Elements.res index 9723d7d8e..96bb201cd 100644 --- a/src/orca-loader/Elements.res +++ b/src/orca-loader/Elements.res @@ -49,13 +49,12 @@ let make = ( ->Option.flatMap(x => x->Dict.get("blockConfirm")) ->Option.flatMap(JSON.Decode.bool) ->Option.getOr(false) - let switchToCustomPod = - GlobalVars.isInteg && + let customPodUri = options ->JSON.Decode.object - ->Option.flatMap(x => x->Dict.get("switchToCustomPod")) - ->Option.flatMap(JSON.Decode.bool) - ->Option.getOr(false) + ->Option.flatMap(x => x->Dict.get("customPodUri")) + ->Option.flatMap(JSON.Decode.string) + ->Option.getOr("") let merchantHostname = Window.Location.hostname @@ -72,7 +71,7 @@ let make = ( @@ -313,7 +312,7 @@ let make = ( ("endpoint", endpoint->JSON.Encode.string), ("sdkSessionId", sdkSessionId->JSON.Encode.string), ("blockConfirm", blockConfirm->JSON.Encode.bool), - ("switchToCustomPod", switchToCustomPod->JSON.Encode.bool), + ("customPodUri", customPodUri->JSON.Encode.string), ("sdkHandleOneClickConfirmPayment", sdkHandleOneClickConfirmPayment->JSON.Encode.bool), ("parentURL", "*"->JSON.Encode.string), ("analyticsMetadata", analyticsMetadata), @@ -418,7 +417,7 @@ let make = ( clientSecret, headers, ~optLogger=Some(logger), - ~switchToCustomPod, + ~customPodUri, ~isForceSync=true, ) ) @@ -626,7 +625,7 @@ let make = ( let url = dict->getString("return_url_with_query_params", "") PaymentHelpers.pollStatus( ~headers, - ~switchToCustomPod, + ~customPodUri, ~pollId, ~interval, ~count, @@ -638,7 +637,7 @@ let make = ( clientSecret, headers, ~optLogger=Some(logger), - ~switchToCustomPod, + ~customPodUri, ~isForceSync=true, ) ->then(json => { @@ -680,6 +679,11 @@ let make = ( switch eventDataObject->getOptionalJsonFromJson("openurl_if_required") { | Some(val) => + messageParentWindow([ + ("fullscreen", true->JSON.Encode.bool), + ("param", "paymentloader"->JSON.Encode.string), + ("iframeId", selectorString->JSON.Encode.string), + ]) if redirect.contents === "always" { Window.Location.replace(val->JSON.Decode.string->Option.getOr("")) resolve(JSON.Encode.null) @@ -688,7 +692,7 @@ let make = ( clientSecret, headers, ~optLogger=Some(logger), - ~switchToCustomPod, + ~customPodUri, ~isForceSync=true, ) ->then(json => { diff --git a/src/orca-loader/PaymentMethodsManagementElements.res b/src/orca-loader/PaymentMethodsManagementElements.res index 85dd27b17..720a2cf69 100644 --- a/src/orca-loader/PaymentMethodsManagementElements.res +++ b/src/orca-loader/PaymentMethodsManagementElements.res @@ -33,13 +33,12 @@ let make = ( ->Option.getOr([]) ->JSON.Encode.array - let switchToCustomPod = - GlobalVars.isInteg && + let customPodUri = options ->JSON.Decode.object - ->Option.flatMap(x => x->Dict.get("switchToCustomPod")) - ->Option.flatMap(JSON.Decode.bool) - ->Option.getOr(false) + ->Option.flatMap(x => x->Dict.get("customPodUri")) + ->Option.flatMap(JSON.Decode.string) + ->Option.getOr("") let localSelectorString = "hyper-preMountLoader-iframe" let mountPreMountLoaderIframe = () => { @@ -190,7 +189,7 @@ let make = ( ("publishableKey", publishableKey->JSON.Encode.string), ("endpoint", endpoint->JSON.Encode.string), ("sdkSessionId", sdkSessionId->JSON.Encode.string), - ("switchToCustomPod", switchToCustomPod->JSON.Encode.bool), + ("customPodUri", customPodUri->JSON.Encode.string), ("parentURL", "*"->JSON.Encode.string), ("analyticsMetadata", analyticsMetadata), ("launchTime", launchTime->JSON.Encode.float), diff --git a/src/orca-loader/PaymentSession.res b/src/orca-loader/PaymentSession.res index c1e32280e..751ebc0bb 100644 --- a/src/orca-loader/PaymentSession.res +++ b/src/orca-loader/PaymentSession.res @@ -8,13 +8,12 @@ let make = ( ~ephemeralKey, ) => { let logger = logger->Option.getOr(OrcaLogger.defaultLoggerConfig) - let switchToCustomPod = - GlobalVars.isInteg && + let customPodUri = options ->JSON.Decode.object - ->Option.flatMap(x => x->Dict.get("switchToCustomPod")) - ->Option.flatMap(JSON.Decode.bool) - ->Option.getOr(false) + ->Option.flatMap(x => x->Dict.get("customPodUri")) + ->Option.flatMap(JSON.Decode.string) + ->Option.getOr("") let endpoint = ApiEndpoint.getApiEndPoint(~publishableKey) let defaultInitPaymentSession = { @@ -24,13 +23,13 @@ let make = ( ~publishableKey, ~endpoint, ~logger, - ~switchToCustomPod, + ~customPodUri, ), getPaymentManagementMethods: _ => PaymentSessionMethods.getPaymentManagementMethods( ~ephemeralKey, ~logger, - ~switchToCustomPod, + ~customPodUri, ~endpoint, ), } diff --git a/src/orca-loader/PaymentSessionMethods.res b/src/orca-loader/PaymentSessionMethods.res index ccceb1e7a..39633ef0d 100644 --- a/src/orca-loader/PaymentSessionMethods.res +++ b/src/orca-loader/PaymentSessionMethods.res @@ -7,7 +7,7 @@ let getCustomerSavedPaymentMethods = ( ~publishableKey, ~endpoint, ~logger, - ~switchToCustomPod, + ~customPodUri, ) => { open ApplePayTypes open GooglePayType @@ -17,7 +17,7 @@ let getCustomerSavedPaymentMethods = ( ~clientSecret, ~publishableKey, ~endpoint, - ~switchToCustomPod, + ~customPodUri, ~optLogger=Some(logger), ~isPaymentSession=true, ) @@ -114,6 +114,7 @@ let getCustomerSavedPaymentMethods = ( ~publishableKey, ~clientSecret, ~logger, + ~customPodUri, ) } | None => @@ -161,6 +162,7 @@ let getCustomerSavedPaymentMethods = ( ~publishableKey, ~clientSecret, ~logger, + ~customPodUri, )->then(val => { val->resolvePromise resolve() @@ -225,6 +227,7 @@ let getCustomerSavedPaymentMethods = ( ~publishableKey, ~clientSecret, ~logger, + ~customPodUri, ) } @@ -298,6 +301,7 @@ let getCustomerSavedPaymentMethods = ( ~publishableKey, ~clientSecret, ~logger, + ~customPodUri, ) } | None => @@ -331,7 +335,7 @@ let getCustomerSavedPaymentMethods = ( ~clientSecret, ~publishableKey, ~optLogger=Some(logger), - ~switchToCustomPod=false, + ~customPodUri, ~endpoint, ) ->then(sessionDetails => { @@ -464,12 +468,12 @@ let getCustomerSavedPaymentMethods = ( }) } -let getPaymentManagementMethods = (~ephemeralKey, ~logger, ~switchToCustomPod, ~endpoint) => { +let getPaymentManagementMethods = (~ephemeralKey, ~logger, ~customPodUri, ~endpoint) => { let getSavedPaymentManagementMethodsList = _ => { PaymentHelpers.fetchSavedPaymentMethodList( ~ephemeralKey, ~optLogger=Some(logger), - ~switchToCustomPod=false, + ~customPodUri, ~endpoint, ) ->then(response => { @@ -486,7 +490,7 @@ let getPaymentManagementMethods = (~ephemeralKey, ~logger, ~switchToCustomPod, ~ ~ephemeralKey, ~paymentMethodId={paymentMethodId->JSON.Decode.string->Option.getOr("")}, ~logger, - ~switchToCustomPod, + ~customPodUri, ) ->then(response => { response->resolve diff --git a/src/orca-log-catcher/ErrorBoundary.res b/src/orca-log-catcher/ErrorBoundary.res index b05080046..4f95da757 100644 --- a/src/orca-log-catcher/ErrorBoundary.res +++ b/src/orca-log-catcher/ErrorBoundary.res @@ -123,7 +123,7 @@ module ErrorTextAndImage = { module ErrorCard = { @react.component - let make = (~error: Sentry.ErrorBoundary.fallbackArg, ~level) => { + let make = (~error: Sentry.ErrorBoundary.fallbackArg, ~level, ~componentName) => { let beaconApiCall = data => { if data->Array.length > 0 { let logData = data->Array.map(OrcaLogger.logFileToObj)->JSON.Encode.array->JSON.stringify @@ -135,13 +135,20 @@ module ErrorCard = { let loggingLevel = GlobalVars.loggingLevelStr let enableLogging = GlobalVars.enableLogging if enableLogging && ["DEBUG", "INFO", "WARN", "ERROR"]->Array.includes(loggingLevel) { + let errorDict = + error + ->Identity.anyTypeToJson + ->Utils.getDictFromJson + + errorDict->Dict.set("componentName", componentName->JSON.Encode.string) + let errorLog: OrcaLogger.logFile = { logType: ERROR, timestamp: Date.now()->Float.toString, sessionId: "", source: "orca-elements", version: GlobalVars.repoVersion, - value: error->Identity.anyTypeToJson->JSON.stringify, + value: errorDict->JSON.Encode.object->JSON.stringify, internalMetadata: "", category: USER_ERROR, paymentId: "", @@ -200,10 +207,12 @@ module ErrorCard = { } } -let defaultFallback = (e, level) => { - +let defaultFallback = (e, level, componentName) => { + } @react.component -let make = (~children, ~renderFallback=defaultFallback, ~level=PaymentMethod) => { - renderFallback(e, level)}> children +let make = (~children, ~renderFallback=defaultFallback, ~level=PaymentMethod, ~componentName) => { + renderFallback(e, level, componentName)}> + children + } diff --git a/src/orca-log-catcher/OrcaLogger.res b/src/orca-log-catcher/OrcaLogger.res index c73c14a04..fa0ca071b 100644 --- a/src/orca-log-catcher/OrcaLogger.res +++ b/src/orca-log-catcher/OrcaLogger.res @@ -539,14 +539,17 @@ let make = ( let counter = eventName->calculateAndUpdateCounterHook if GlobalVars.enableLogging && counter <= maxLogsPushedPerEventName { switch loggingLevel { - | DEBUG => log->Array.push(mainLogFile, _)->ignore + | DEBUG => log->(Array.push(mainLogFile, _))->ignore | INFO => [INFO, WARNING, ERROR]->Array.includes(log.logType) - ? log->Array.push(mainLogFile, _)->ignore + ? log->(Array.push(mainLogFile, _))->ignore : () | WARNING => - [WARNING, ERROR]->Array.includes(log.logType) ? log->Array.push(mainLogFile, _)->ignore : () - | ERROR => [ERROR]->Array.includes(log.logType) ? log->Array.push(mainLogFile, _)->ignore : () + [WARNING, ERROR]->Array.includes(log.logType) + ? log->(Array.push(mainLogFile, _))->ignore + : () + | ERROR => + [ERROR]->Array.includes(log.logType) ? log->(Array.push(mainLogFile, _))->ignore : () | SILENT => () } } diff --git a/src/orca-log-catcher/ReusableReactSuspense.res b/src/orca-log-catcher/ReusableReactSuspense.res new file mode 100644 index 000000000..8827d9218 --- /dev/null +++ b/src/orca-log-catcher/ReusableReactSuspense.res @@ -0,0 +1,8 @@ +@react.component +let make = (~children, ~loaderComponent, ~componentName) => { + Console.log2("-- componentName -- ", componentName) + + + {children} + +} diff --git a/webpack.common.js b/webpack.common.js index 9ab14dfbc..a2b8c40ff 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -8,6 +8,7 @@ const HtmlWebpackPlugin = require("html-webpack-plugin"); const TerserPlugin = require("terser-webpack-plugin"); const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); const { sentryWebpackPlugin } = require("@sentry/webpack-plugin"); +const AddReactDisplayNamePlugin = require("babel-plugin-add-react-displayname"); const getEnvVariable = (variable, defaultValue) => process.env[variable] ?? defaultValue; @@ -138,6 +139,10 @@ module.exports = (publicPath = "auto") => { compress: { drop_console: false, }, + mangle: { + keep_fnames: true, // Prevent function names from being mangled + keep_classnames: true, // Prevent class names from being mangled + }, }, }), ], @@ -161,17 +166,21 @@ module.exports = (publicPath = "auto") => { ], }, { - test: /\.js$/, + test: /\.jsx?$/, // Matches both .js and .jsx files exclude: /node_modules/, use: { loader: "babel-loader", options: { - presets: ["@babel/preset-env"], + presets: ["@babel/preset-env", "@babel/preset-react"], + plugins: [AddReactDisplayNamePlugin], }, }, }, ], }, entry: entries, + resolve: { + extensions: [".js", ".jsx"], + }, }; };