Skip to content

Commit

Permalink
fix: fixed ApplePay Event Handler
Browse files Browse the repository at this point in the history
  • Loading branch information
ArushKapoorJuspay committed May 29, 2024
1 parent 52b02a5 commit 3c35d6b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/orca-loader/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -752,19 +752,22 @@ 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 =
[
("applePayProcessPayment", payment.token),
("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"),
Expand Down Expand Up @@ -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,
Expand All @@ -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(
Expand Down

0 comments on commit 3c35d6b

Please sign in to comment.