diff --git a/src/Types/ApplePayTypes.res b/src/Types/ApplePayTypes.res index 29b00e88..998f42fc 100644 --- a/src/Types/ApplePayTypes.res +++ b/src/Types/ApplePayTypes.res @@ -74,6 +74,16 @@ type paymentRequestData = { @optional merchantIdentifier: string, } +type headlessApplePayToken = { + paymentRequestData: JSON.t, + sessionTokenData: option, +} + +let defaultHeadlessApplePayToken: headlessApplePayToken = { + paymentRequestData: JSON.Encode.null, + sessionTokenData: None, +} + let jsonToPaymentRequestDataType: Dict.t => paymentRequestData = jsonDict => { let clientTimeZone = CardUtils.dateTimeFormat().resolvedOptions().timeZone let clientCountry = getClientCountry(clientTimeZone) diff --git a/src/orca-loader/PaymentSessionMethods.res b/src/orca-loader/PaymentSessionMethods.res index 0130a64d..60e54b84 100644 --- a/src/orca-loader/PaymentSessionMethods.res +++ b/src/orca-loader/PaymentSessionMethods.res @@ -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 = @@ -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, @@ -425,7 +425,10 @@ let getCustomerSavedPaymentMethods = ( ~sessionObj=optToken, ~componentName, ) - applePayTokenRef := paymentRequest + applePayTokenRef := { + paymentRequestData: paymentRequest, + sessionTokenData: optToken, + } } | _ => updateCustomerPaymentMethodsRef(~isFilterApplePay=true) }