Skip to content

Commit

Permalink
Merge branch 'main' into feature/add-bubblegum-theme
Browse files Browse the repository at this point in the history
  • Loading branch information
PritishBudhiraja authored Oct 10, 2024
2 parents 80f560e + 6e513a3 commit 3f71527
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 10 additions & 0 deletions src/Types/ApplePayTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ type paymentRequestData = {
@optional merchantIdentifier: string,
}

type headlessApplePayToken = {
paymentRequestData: JSON.t,
sessionTokenData: option<JSON.t>,
}

let defaultHeadlessApplePayToken: headlessApplePayToken = {
paymentRequestData: JSON.Encode.null,
sessionTokenData: None,
}

let jsonToPaymentRequestDataType: Dict.t<JSON.t> => paymentRequestData = jsonDict => {
let clientTimeZone = CardUtils.dateTimeFormat().resolvedOptions().timeZone
let clientCountry = getClientCountry(clientTimeZone)
Expand Down
11 changes: 7 additions & 4 deletions src/orca-loader/PaymentSessionMethods.res
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ let getCustomerSavedPaymentMethods = (
customerPaymentMethods->Array.sort((a, b) => compareLogic(a.lastUsedAt, b.lastUsedAt))

let customerPaymentMethodsRef = ref(customerPaymentMethods)
let applePayTokenRef = ref(JSON.Encode.null)
let applePayTokenRef = ref(defaultHeadlessApplePayToken)
let googlePayTokenRef = ref(JSON.Encode.null)

let isApplePayPresent =
Expand Down Expand Up @@ -187,9 +187,9 @@ let getCustomerSavedPaymentMethods = (
}

ApplePayHelpers.startApplePaySession(
~paymentRequest=applePayTokenRef.contents,
~paymentRequest=applePayTokenRef.contents.paymentRequestData,
~applePaySessionRef,
~applePayPresent=Some(applePayTokenRef.contents),
~applePayPresent=applePayTokenRef.contents.sessionTokenData,
~logger,
~callBackFunc=processPayment,
~clientSecret,
Expand Down Expand Up @@ -425,7 +425,10 @@ let getCustomerSavedPaymentMethods = (
~sessionObj=optToken,
~componentName,
)
applePayTokenRef := paymentRequest
applePayTokenRef := {
paymentRequestData: paymentRequest,
sessionTokenData: optToken,
}
}
| _ => updateCustomerPaymentMethodsRef(~isFilterApplePay=true)
}
Expand Down

0 comments on commit 3f71527

Please sign in to comment.