Skip to content

Commit

Permalink
fix: added alert on trustpayapi init, log onload of script
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrishab Srivatsa committed Apr 25, 2024
1 parent 35d17a8 commit 07a7495
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/orca-loader/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,21 @@ let make = (
Window.querySelectorAll(`script[src="https://test-tpgw.trustpay.eu/js/v1.js"]`)->Array.length === 0
) {
let trustPayScriptURL =
publishableKey->String.startsWith("pk_prd_")
publishableKey->String.startsWith("pk_prd_")->not
? "https://tpgw.trustpay.eu/js/v1.js"
: "https://test-tpgw.trustpay.eu/js/v1.js"
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)
logger.setLogInfo(~value="TrustPay Script Loaded", ~eventName=TRUSTPAY_SCRIPT, ())
Promise.resolve()
})
->ignore
Expand Down Expand Up @@ -634,6 +637,9 @@ let make = (

try {
let trustpay = trustPayApi(secrets)
Window.window->alert(
"trustpay: " ++ trustpay->anyTypeToJson->JSON.stringify,
)
trustpay.finishApplePaymentV2(payment, paymentRequest)
->then(res => {
Window.window->alert(
Expand Down

0 comments on commit 07a7495

Please sign in to comment.