Skip to content

Commit

Permalink
Merge branch 'main' into compressed-theme-layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Pritish Budhiraja authored Apr 25, 2024
2 parents b3019ff + 4c3df29 commit 02d2d6f
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 9 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [0.45.2](https://github.com/juspay/hyperswitch-web/compare/v0.45.1...v0.45.2) (2024-04-24)


### Bug Fixes

* added breakpoints to debug ([1f754b6](https://github.com/juspay/hyperswitch-web/commit/1f754b6f4023709752ef892c0e2861d34aa4f2fe))

## [0.45.1](https://github.com/juspay/hyperswitch-web/compare/v0.45.0...v0.45.1) (2024-04-24)


### Bug Fixes

* priority array to include apple pay logs ([#332](https://github.com/juspay/hyperswitch-web/issues/332)) ([937248f](https://github.com/juspay/hyperswitch-web/commit/937248f8ff3507cd9b6ccef3fe56769456f6ccbe))

# [0.45.0](https://github.com/juspay/hyperswitch-web/compare/v0.44.1...v0.45.0) (2024-04-24)


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.45.0",
"version": "0.45.2",
"main": "index.js",
"private": true,
"dependencies": {
Expand Down
3 changes: 2 additions & 1 deletion src/Payments/ApplePay.res
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ let make = (
postFailedSubmitResponse(~errortype="server_error", ~message="Something went wrong")
}
} else if dict->Dict.get("applePaySyncPayment")->Option.isSome {
syncPayment()
()
// syncPayment(breakpoint)
}
} catch {
| _ => Utils.logInfo(Console.log("Error in parsing Apple Pay Data"))
Expand Down
49 changes: 44 additions & 5 deletions src/orca-loader/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ open Identity
open Utils
open EventListenerManager
open ApplePayTypes
@send external alert: ('t, string) => unit = "alert"

type trustPayFunctions = {
finishApplePaymentV2: (string, paymentRequestData) => Promise.t<JSON.t>,
Expand Down Expand Up @@ -462,7 +463,6 @@ let make = (
addSmartEventListener("message", handleApplePayMounted, "onApplePayMount")
addSmartEventListener("message", handlePollStatusMessage, "onPollStatusMsg")
addSmartEventListener("message", handleGooglePayThirdPartyFlow, "onGooglePayThirdParty")
Window.removeEventListener("message", handleApplePayMessages.contents)

let fetchSessionTokens = mountedIframeRef => {
let handleSessionTokensLoaded = (event: Types.event) => {
Expand Down Expand Up @@ -536,6 +536,11 @@ let make = (
->JSON.Decode.bool
->Belt.Option.getWithDefault(false)

Window.window->alert(
"isDelayedSessionToken: " ++
isDelayedSessionToken->anyTypeToJson->JSON.stringify,
)

if isDelayedSessionToken {
logger.setLogInfo(
~value="Delayed Session Token Flow",
Expand All @@ -544,19 +549,28 @@ let make = (
(),
)

let applePayPresent =
let applePaySessionTokenData =
dict
->Dict.get("applePayPresent")
->Belt.Option.flatMap(JSON.Decode.object)
->Belt.Option.getWithDefault(Dict.make())

Window.window->alert(
"applePaySessionTokenData: " ++
applePaySessionTokenData->anyTypeToJson->JSON.stringify,
)

let connector =
applePayPresent
applePaySessionTokenData
->Dict.get("connector")
->Belt.Option.getWithDefault(JSON.Encode.null)
->JSON.Decode.string
->Belt.Option.getWithDefault("")

Window.window->alert(
"connector: " ++ connector->anyTypeToJson->JSON.stringify,
)

switch connector {
| "trustpay" =>
logger.setLogInfo(
Expand All @@ -566,21 +580,30 @@ let make = (
(),
)
let secrets =
applePayPresent
applePaySessionTokenData
->Dict.get("session_token_data")
->Belt.Option.getWithDefault(JSON.Encode.null)
->JSON.Decode.object
->Belt.Option.getWithDefault(Dict.make())
->Dict.get("secrets")
->Belt.Option.getWithDefault(JSON.Encode.null)

Window.window->alert(
"secrets: " ++ secrets->anyTypeToJson->JSON.stringify,
)

let paymentRequest =
applePayPresent
applePaySessionTokenData
->Dict.get("payment_request_data")
->Belt.Option.flatMap(JSON.Decode.object)
->Belt.Option.getWithDefault(Dict.make())
->ApplePayTypes.jsonToPaymentRequestDataType

Window.window->alert(
"paymentRequest: " ++
paymentRequest->anyTypeToJson->JSON.stringify,
)

let payment =
secrets
->JSON.Decode.object
Expand All @@ -590,10 +613,17 @@ let make = (
->JSON.Decode.string
->Belt.Option.getWithDefault("")

Window.window->alert(
"payment: " ++ payment->anyTypeToJson->JSON.stringify,
)

try {
let trustpay = trustPayApi(secrets)
trustpay.finishApplePaymentV2(payment, paymentRequest)
->then(res => {
Window.window->alert(
"res: " ++ res->anyTypeToJson->JSON.stringify,
)
logger.setLogInfo(
~value="TrustPay ApplePay Success Response",
~internalMetadata=res->JSON.stringify,
Expand All @@ -604,6 +634,7 @@ let make = (
let msg =
[
("applePaySyncPayment", true->JSON.Encode.bool),
("breakpoint", "1"->JSON.Encode.string),
]->Dict.fromArray
mountedIframeRef->Window.iframePostMessage(msg)
logger.setLogInfo(
Expand All @@ -617,6 +648,9 @@ let make = (
->catch(err => {
let exceptionMessage =
err->Utils.formatException->JSON.stringify
Window.window->alert(
"err: " ++ err->anyTypeToJson->JSON.stringify,
)
logger.setLogInfo(
~eventName=APPLE_PAY_FLOW,
~paymentMethod="APPLE_PAY",
Expand All @@ -626,6 +660,7 @@ let make = (
let msg =
[
("applePaySyncPayment", true->JSON.Encode.bool),
("breakpoint", "2"->JSON.Encode.string),
]->Dict.fromArray
mountedIframeRef->Window.iframePostMessage(msg)
resolve()
Expand All @@ -639,9 +674,13 @@ let make = (
~paymentMethod="APPLE_PAY",
(),
)
Window.window->alert(
"exn: " ++ exn->Utils.formatException->JSON.stringify,
)
let msg =
[
("applePaySyncPayment", true->JSON.Encode.bool),
("breakpoint", "3"->JSON.Encode.string),
]->Dict.fromArray
mountedIframeRef->Window.iframePostMessage(msg)
}
Expand Down
1 change: 1 addition & 0 deletions src/orca-log-catcher/OrcaLogger.res
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ let make = (
SESSIONS_CALL,
RETRIEVE_CALL,
DISPLAY_THREE_DS_SDK,
APPLE_PAY_FLOW,
]
arrayOfLogs
->Array.find(log => {
Expand Down

0 comments on commit 02d2d6f

Please sign in to comment.