From 3c35d6b9fa14fd68d6c1821ce1b5cc857b5f5972 Mon Sep 17 00:00:00 2001 From: Arush Date: Wed, 29 May 2024 17:21:29 +0530 Subject: [PATCH] fix: fixed ApplePay Event Handler --- src/orca-loader/Elements.res | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/orca-loader/Elements.res b/src/orca-loader/Elements.res index f868ec559..217db77d9 100644 --- a/src/orca-loader/Elements.res +++ b/src/orca-loader/Elements.res @@ -752,7 +752,10 @@ let make = ( applePayPresent->Belt.Option.isSome ) { //do operations here - let processPayment = (payment: ApplePayTypes.paymentResult) => { + let processPayment = ( + payment: ApplePayTypes.paymentResult, + applePayEvent: Types.event, + ) => { //let body = PaymentBody.applePayBody(~token) let msg = [ @@ -760,11 +763,11 @@ let make = ( ("applePayBillingContact", payment.billingContact), ("applePayShippingContact", payment.shippingContact), ]->Dict.fromArray - event.source->Window.sendPostMessage(msg) + applePayEvent.source->Window.sendPostMessage(msg) } - let handleApplePayMessages = (event: Types.event) => { - let json = event.data->Identity.anyTypeToJson + let handleApplePayMessages = (applePayEvent: Types.event) => { + let json = applePayEvent.data->Identity.anyTypeToJson let dict = json->getDictFromJson switch ( dict->Dict.get("applePayButtonClicked"), @@ -817,7 +820,7 @@ let make = ( {"status": ssn.\"STATUS_SUCCESS"}->Identity.anyTypeToJson, ) applePaySessionRef := Nullable.null - processPayment(event.payment) + processPayment(event.payment, applePayEvent) let value = "Payment Data Filled: New Payment Method" logger.setLogInfo( ~value, @@ -829,7 +832,7 @@ let make = ( ssn.oncancel = _ev => { let msg = [("showApplePayButton", true->JSON.Encode.bool)]->Dict.fromArray - event.source->Window.sendPostMessage(msg) + applePayEvent.source->Window.sendPostMessage(msg) applePaySessionRef := Nullable.null logInfo(Console.log("Apple Pay Payment Cancelled")) logger.setLogInfo(