Skip to content

Commit

Permalink
Merge branch 'main' into paze-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
PritishBudhiraja authored Oct 16, 2024
2 parents 756ee62 + 85bc6df commit b96e5fa
Show file tree
Hide file tree
Showing 19 changed files with 508 additions and 81 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
## [0.94.2](https://github.com/juspay/hyperswitch-web/compare/v0.94.1...v0.94.2) (2024-10-15)

## [0.94.1](https://github.com/juspay/hyperswitch-web/compare/v0.94.0...v0.94.1) (2024-10-15)


### Bug Fixes

* callback fix ([5b7e78b](https://github.com/juspay/hyperswitch-web/commit/5b7e78b49fe4ce7e05fafb4e259dfa6a3f71919e))

# [0.94.0](https://github.com/juspay/hyperswitch-web/compare/v0.93.0...v0.94.0) (2024-10-15)


### Features

* added click handler ([#732](https://github.com/juspay/hyperswitch-web/issues/732)) ([9c09ff2](https://github.com/juspay/hyperswitch-web/commit/9c09ff2d90ece78583c897c9cb29f2f45f346f90))

# [0.93.0](https://github.com/juspay/hyperswitch-web/compare/v0.92.1...v0.93.0) (2024-10-15)


### Features

* added confirm handler ([#731](https://github.com/juspay/hyperswitch-web/issues/731)) ([4f65ecb](https://github.com/juspay/hyperswitch-web/commit/4f65ecbeb48022dbe9da507d98344e43c308b691))

## [0.92.1](https://github.com/juspay/hyperswitch-web/compare/v0.92.0...v0.92.1) (2024-10-10)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orca-payment-page",
"version": "0.92.1",
"version": "0.94.2",
"main": "index.js",
"private": true,
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/Components/SavedPaymentManagement.res
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let make = (~savedMethods: array<PaymentType.customerMethods>, ~setSavedMethods)
let logger = Recoil.useRecoilValueFromAtom(RecoilAtoms.loggerAtom)

let removeSavedMethod = (
savedMethods: array<OrcaPaymentPage.PaymentType.customerMethods>,
savedMethods: array<PaymentType.customerMethods>,
paymentMethodId,
) => {
savedMethods->Array.filter(savedMethod => {
Expand Down
15 changes: 15 additions & 0 deletions src/LoaderController.res
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
let setUserAddressState = Recoil.useLoggedSetRecoilState(userAddressState, "state", logger)
let setUserAddressCountry = Recoil.useLoggedSetRecoilState(userAddressCountry, "country", logger)
let (_country, setCountry) = Recoil.useRecoilState(userCountry)
let (isCompleteCallbackUsed, setIsCompleteCallbackUsed) = Recoil.useRecoilState(
isCompleteCallbackUsed,
)
let (isPaymentButtonHandlerProvided, setIsPaymentButtonHandlerProvided) = Recoil.useRecoilState(
isPaymentButtonHandlerProvidedAtom,
)

let optionsCallback = (optionsPayment: PaymentType.options) => {
[
Expand Down Expand Up @@ -245,6 +251,15 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
let metadata = dict->getJsonObjectFromDict("analyticsMetadata")
logger.setMetadata(metadata)
}

if dict->getDictIsSome("onCompleteDoThisUsed") {
let isCallbackUsedVal = dict->Utils.getBool("onCompleteDoThisUsed", false)
setIsCompleteCallbackUsed(_ => isCallbackUsedVal)
}
if dict->getDictIsSome("isPaymentButtonHandlerProvided") {
let isSDKClick = dict->Utils.getBool("isPaymentButtonHandlerProvided", false)
setIsPaymentButtonHandlerProvided(_ => isSDKClick)
}
if dict->getDictIsSome("paymentOptions") {
let paymentOptions = dict->getDictFromObj("paymentOptions")

Expand Down
13 changes: 9 additions & 4 deletions src/Payments/ApplePay.res
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ let make = (~sessionObj: option<JSON.t>, ~walletOptions, ~paymentType: CardTheme
let url = RescriptReactRouter.useUrl()
let componentName = CardUtils.getQueryParamsDictforKey(url.search, "componentName")
let loggerState = Recoil.useRecoilValueFromAtom(RecoilAtoms.loggerAtom)
let {publishableKey, sdkHandleOneClickConfirmPayment} = Recoil.useRecoilValueFromAtom(
RecoilAtoms.keys,
let sdkHandleIsThere = Recoil.useRecoilValueFromAtom(
RecoilAtoms.isPaymentButtonHandlerProvidedAtom,
)
let {publishableKey} = Recoil.useRecoilValueFromAtom(RecoilAtoms.keys)
let isApplePayReady = Recoil.useRecoilValueFromAtom(RecoilAtoms.isApplePayReady)
let setIsShowOrPayUsing = Recoil.useSetRecoilState(RecoilAtoms.isShowOrPayUsing)
let (showApplePay, setShowApplePay) = React.useState(() => false)
Expand Down Expand Up @@ -212,7 +213,7 @@ let make = (~sessionObj: option<JSON.t>, ~walletOptions, ~paymentType: CardTheme
~paymentMethod="APPLE_PAY",
)
setApplePayClicked(_ => true)
makeOneClickHandlerPromise(sdkHandleOneClickConfirmPayment)
makeOneClickHandlerPromise(sdkHandleIsThere)
->then(result => {
let result = result->JSON.Decode.bool->Option.getOr(false)
if result {
Expand Down Expand Up @@ -241,7 +242,11 @@ let make = (~sessionObj: option<JSON.t>, ~walletOptions, ~paymentType: CardTheme
~isManualRetryEnabled,
)
} else {
ApplePayHelpers.handleApplePayButtonClicked(~sessionObj, ~componentName, ~paymentMethodListValue)
ApplePayHelpers.handleApplePayButtonClicked(
~sessionObj,
~componentName,
~paymentMethodListValue,
)
}
} else {
let bodyDict = PaymentBody.applePayRedirectBody(~connectors)
Expand Down
5 changes: 3 additions & 2 deletions src/Payments/GPay.res
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ let make = (
let componentName = CardUtils.getQueryParamsDictforKey(url.search, "componentName")
let loggerState = Recoil.useRecoilValueFromAtom(loggerAtom)
let {iframeId} = Recoil.useRecoilValueFromAtom(keys)
let {publishableKey, sdkHandleOneClickConfirmPayment} = Recoil.useRecoilValueFromAtom(keys)
let isSDKHandleClick = Recoil.useRecoilValueFromAtom(isPaymentButtonHandlerProvidedAtom)
let {publishableKey} = Recoil.useRecoilValueFromAtom(keys)
let options = Recoil.useRecoilValueFromAtom(optionAtom)
let intent = PaymentHelpers.usePaymentIntent(Some(loggerState), Gpay)
let isManualRetryEnabled = Recoil.useRecoilValueFromAtom(RecoilAtoms.isManualRetryEnabled)
Expand Down Expand Up @@ -103,7 +104,7 @@ let make = (
~eventName=GOOGLE_PAY_FLOW,
~paymentMethod="GOOGLE_PAY",
)
makeOneClickHandlerPromise(sdkHandleOneClickConfirmPayment)->then(result => {
makeOneClickHandlerPromise(isSDKHandleClick)->then(result => {
let result = result->JSON.Decode.bool->Option.getOr(false)
if result {
if isInvokeSDKFlow {
Expand Down
11 changes: 6 additions & 5 deletions src/Payments/KlarnaSDK.res
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ open KlarnaSDKTypes
let make = (~sessionObj: SessionsType.token) => {
let url = RescriptReactRouter.useUrl()
let componentName = CardUtils.getQueryParamsDictforKey(url.search, "componentName")
let loggerState = Recoil.useRecoilValueFromAtom(RecoilAtoms.loggerAtom)
let setIsShowOrPayUsing = Recoil.useSetRecoilState(RecoilAtoms.isShowOrPayUsing)
let {publishableKey, sdkHandleOneClickConfirmPayment} = Recoil.useRecoilValueFromAtom(keys)
let loggerState = Recoil.useRecoilValueFromAtom(loggerAtom)
let setIsShowOrPayUsing = Recoil.useSetRecoilState(isShowOrPayUsing)
let sdkHandleIsThere = Recoil.useRecoilValueFromAtom(isPaymentButtonHandlerProvidedAtom)
let {publishableKey} = Recoil.useRecoilValueFromAtom(keys)
let options = Recoil.useRecoilValueFromAtom(optionAtom)
let isManualRetryEnabled = Recoil.useRecoilValueFromAtom(RecoilAtoms.isManualRetryEnabled)
let isManualRetryEnabled = Recoil.useRecoilValueFromAtom(isManualRetryEnabled)
let intent = PaymentHelpers.usePaymentIntent(Some(loggerState), Other)
let {iframeId} = Recoil.useRecoilValueFromAtom(keys)
let status = CommonHooks.useScript("https://x.klarnacdn.net/kp/lib/v1/api.js") // Klarna SDK script
Expand Down Expand Up @@ -65,7 +66,7 @@ let make = (~sessionObj: SessionsType.token) => {
theme: options.wallets.style.theme == Dark ? "default" : "outlined",
shape: "default",
on_click: authorize => {
makeOneClickHandlerPromise(sdkHandleOneClickConfirmPayment)->then(
makeOneClickHandlerPromise(sdkHandleIsThere)->then(
result => {
let result = result->JSON.Decode.bool->Option.getOr(false)
if result {
Expand Down
5 changes: 3 additions & 2 deletions src/Payments/PayPal.res
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ let payPalIcon = <Icon size=35 width=90 name="paypal" />
let make = () => {
let loggerState = Recoil.useRecoilValueFromAtom(loggerAtom)
let (paypalClicked, setPaypalClicked) = React.useState(_ => false)
let {publishableKey, sdkHandleOneClickConfirmPayment} = Recoil.useRecoilValueFromAtom(keys)
let sdkHandleIsThere = Recoil.useRecoilValueFromAtom(isPaymentButtonHandlerProvidedAtom)
let {publishableKey} = Recoil.useRecoilValueFromAtom(keys)
let options = Recoil.useRecoilValueFromAtom(optionAtom)
let areOneClickWalletsRendered = Recoil.useSetRecoilState(areOneClickWalletsRendered)
let paymentMethodListValue = Recoil.useRecoilValueFromAtom(PaymentUtils.paymentMethodListValue)
Expand Down Expand Up @@ -48,7 +49,7 @@ let make = () => {
)
setPaypalClicked(_ => true)
open Promise
Utils.makeOneClickHandlerPromise(sdkHandleOneClickConfirmPayment)
Utils.makeOneClickHandlerPromise(sdkHandleIsThere)
->then(result => {
let result = result->JSON.Decode.bool->Option.getOr(false)
if result {
Expand Down
16 changes: 13 additions & 3 deletions src/Payments/PaypalSDK.res
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@ let make = (~sessionObj: SessionsType.token, ~paymentType: CardThemeType.mode) =
let {iframeId, publishableKey, sdkHandleOneClickConfirmPayment} = Recoil.useRecoilValueFromAtom(
RecoilAtoms.keys,
)
let sdkHandleIsThere = Recoil.useRecoilValueFromAtom(
RecoilAtoms.isPaymentButtonHandlerProvidedAtom,
)
let (loggerState, _setLoggerState) = Recoil.useRecoilState(RecoilAtoms.loggerAtom)
let areOneClickWalletsRendered = Recoil.useSetRecoilState(RecoilAtoms.areOneClickWalletsRendered)
let paymentMethodListValue = Recoil.useRecoilValueFromAtom(PaymentUtils.paymentMethodListValue)
let (isCompleted, setIsCompleted) = React.useState(_ => false)
let isCallbackUsedVal = Recoil.useRecoilValueFromAtom(RecoilAtoms.isCompleteCallbackUsed)

let token = sessionObj.token
let orderDetails = sessionObj.orderDetails->getOrderDetails(paymentType)
let intent = PaymentHelpers.usePaymentIntent(Some(loggerState), Paypal)
let isManualRetryEnabled = Recoil.useRecoilValueFromAtom(RecoilAtoms.isManualRetryEnabled)
let intent = PaymentHelpers.usePostSessionTokens(Some(loggerState), Paypal, Wallet)
let confirm = PaymentHelpers.usePaymentIntent(Some(loggerState), Paypal)
let sessions = Recoil.useRecoilValueFromAtom(RecoilAtoms.sessions)
let completeAuthorize = PaymentHelpers.useCompleteAuthorize(Some(loggerState), Paypal)
let isManualRetryEnabled = Recoil.useRecoilValueFromAtom(RecoilAtoms.isManualRetryEnabled)
let checkoutScript =
Window.document(Window.window)->Window.getElementById("braintree-checkout")->Nullable.toOption
let clientScript =
Expand Down Expand Up @@ -80,16 +86,20 @@ let make = (~sessionObj: SessionsType.token, ~paymentType: CardThemeType.mode) =
~iframeId,
~paymentMethodListValue,
~isGuestCustomer,
~intent,
~postSessionTokens=intent,
~isManualRetryEnabled,
~options,
~publishableKey,
~paymentMethodTypes,
~stateJson,
~confirm,
~completeAuthorize,
~handleCloseLoader,
~areOneClickWalletsRendered,
~setIsCompleted,
~isCallbackUsedVal,
~sdkHandleIsThere,
~sessions,
)
})
Window.body->Window.appendChild(paypalScript)
Expand Down
Loading

0 comments on commit b96e5fa

Please sign in to comment.