Skip to content

Commit

Permalink
Merge branch 'main' into phone-number-validations
Browse files Browse the repository at this point in the history
  • Loading branch information
Pritish Budhiraja authored Apr 26, 2024
2 parents bc992df + 43ccd89 commit d47b822
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 53 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.4](https://github.com/juspay/hyperswitch-web/compare/v0.45.3...v0.45.4) (2024-04-25)


### Bug Fixes

* apple pay debug ([34d4828](https://github.com/juspay/hyperswitch-web/commit/34d4828894c284c514dc869c6c75c4af59e873cd))

## [0.45.3](https://github.com/juspay/hyperswitch-web/compare/v0.45.2...v0.45.3) (2024-04-25)


### Bug Fixes

* apple pay debugging ([#333](https://github.com/juspay/hyperswitch-web/issues/333)) ([ca96770](https://github.com/juspay/hyperswitch-web/commit/ca96770a46c0e273da77ae3f4d1fa154c6f8a87f))

## [0.45.2](https://github.com/juspay/hyperswitch-web/compare/v0.45.1...v0.45.2) (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.2",
"version": "0.45.4",
"main": "index.js",
"private": true,
"dependencies": {
Expand Down
127 changes: 77 additions & 50 deletions src/orca-loader/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ let make = (
) => {
let handleApplePayMessages = ref(_ => ())
let applePaySessionRef = ref(Nullable.null)
let isReadyToLoadTrustpayPromise = Promise.make((resolve, _) => {
let handleOnReady = (event: Types.event) => {
let json = event.data->anyTypeToJson
let dict = json->getDictFromJson
if dict->Dict.get("preMountLoaderIframeUnMount")->Belt.Option.isSome {
resolve()
}
}
addSmartEventListener("message", handleOnReady, "handleOnReadyToLoadTrustpayScript")
})

try {
let iframeRef = []
Expand Down Expand Up @@ -144,13 +154,21 @@ let make = (
publishableKey->String.startsWith("pk_prd_")
? "https://tpgw.trustpay.eu/js/v1.js"
: "https://test-tpgw.trustpay.eu/js/v1.js"
let trustPayScript = Window.createElement("script")
trustPayScript->Window.elementSrc(trustPayScriptURL)
trustPayScript->Window.elementOnerror(err => {
Utils.logInfo(Console.log2("ERROR DURING LOADING TRUSTPAY APPLE PAY", err))
isReadyToLoadTrustpayPromise
->Promise.then(_ => {
let trustPayScript = Window.createElement("script")
logger.setLogInfo(~value="TrustPay Script Loading", ~eventName=TRUSTPAY_SCRIPT, ())
trustPayScript->Window.elementSrc(trustPayScriptURL)
trustPayScript->Window.elementOnerror(err => {
Utils.logInfo(Console.log2("ERROR DURING LOADING TRUSTPAY APPLE PAY", err))
})
trustPayScript->Window.elementOnload(_ => {
logger.setLogInfo(~value="TrustPay Script Loaded", ~eventName=TRUSTPAY_SCRIPT, ())
})
Window.body->Window.appendChild(trustPayScript)
Promise.resolve()
})
Window.body->Window.appendChild(trustPayScript)
logger.setLogInfo(~value="TrustPay Script Loaded", ~eventName=TRUSTPAY_SCRIPT, ())
->ignore
}
}
let msg = [("paymentMethodList", json)]->Dict.fromArray
Expand Down Expand Up @@ -618,54 +636,63 @@ let make = (
)

try {
let trustpay = trustPayApi(secrets)
trustpay.finishApplePaymentV2(payment, paymentRequest)
->then(res => {
setTimeout(() => {
let trustpay = trustPayApi(secrets)
Window.window->alert(
"res: " ++ res->anyTypeToJson->JSON.stringify,
"trustpay: " ++ trustpay->anyTypeToJson->JSON.stringify,
)
logger.setLogInfo(
~value="TrustPay ApplePay Success Response",
~internalMetadata=res->JSON.stringify,
~eventName=APPLE_PAY_FLOW,
~paymentMethod="APPLE_PAY",
(),
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,
~eventName=APPLE_PAY_FLOW,
~paymentMethod="APPLE_PAY",
(),
)
let msg =
[
("applePaySyncPayment", true->JSON.Encode.bool),
("breakpoint", "1"->JSON.Encode.string),
]->Dict.fromArray
mountedIframeRef->Window.iframePostMessage(msg)
logger.setLogInfo(
~value="",
~eventName=PAYMENT_DATA_FILLED,
~paymentMethod="APPLE_PAY",
(),
)
resolve()
},
)
let msg =
[
("applePaySyncPayment", true->JSON.Encode.bool),
("breakpoint", "1"->JSON.Encode.string),
]->Dict.fromArray
mountedIframeRef->Window.iframePostMessage(msg)
logger.setLogInfo(
~value="",
~eventName=PAYMENT_DATA_FILLED,
~paymentMethod="APPLE_PAY",
(),
)
resolve()
})
->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",
~value=exceptionMessage,
(),
->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",
~value=exceptionMessage,
(),
)
let msg =
[
("applePaySyncPayment", true->JSON.Encode.bool),
("breakpoint", "2"->JSON.Encode.string),
]->Dict.fromArray
mountedIframeRef->Window.iframePostMessage(msg)
resolve()
},
)
let msg =
[
("applePaySyncPayment", true->JSON.Encode.bool),
("breakpoint", "2"->JSON.Encode.string),
]->Dict.fromArray
mountedIframeRef->Window.iframePostMessage(msg)
resolve()
})
->ignore
->ignore
}, 0)->ignore
} catch {
| exn => {
logger.setLogInfo(
Expand Down

0 comments on commit d47b822

Please sign in to comment.