Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: third party confirm url #342

Merged
merged 8 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/Payments/ApplePay.res
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ let make = (

let isGuestCustomer = UtilityHooks.useIsGuestCustomer()

let processPayment = bodyArr => {
let processPayment = (bodyArr, isThirdPartyFlow) => {
prafulkoppalkar marked this conversation as resolved.
Show resolved Hide resolved
let requestBody = PaymentUtils.appendedCustomerAcceptance(
~isGuestCustomer,
~paymentType=list.payment_type,
Expand All @@ -69,6 +69,7 @@ let make = (
publishableKey,
},
~handleUserError=true,
~isThirdPartyFlow,
(),
)
} else {
Expand All @@ -86,6 +87,7 @@ let make = (
publishableKey,
},
~handleUserError=true,
~isThirdPartyFlow,
(),
)
}
Expand Down Expand Up @@ -264,14 +266,14 @@ let make = (
if isDelayedSessionToken {
setShowApplePayLoader(_ => true)
let bodyDict = PaymentBody.applePayThirdPartySdkBody(~connectors)
processPayment(bodyDict)
processPayment(bodyDict, true)
} else {
let message = [("applePayButtonClicked", true->JSON.Encode.bool)]
Utils.handlePostMessage(message)
}
} else {
let bodyDict = PaymentBody.applePayRedirectBody(~connectors)
processPayment(bodyDict)
processPayment(bodyDict, false)
}
} else {
setApplePayClicked(_ => false)
Expand All @@ -295,7 +297,7 @@ let make = (
let token =
dict->Dict.get("applePayProcessPayment")->Option.getOr(Dict.make()->JSON.Encode.object)
let bodyDict = PaymentBody.applePayBody(~token, ~connectors)
processPayment(bodyDict)
processPayment(bodyDict, false)
} else if dict->Dict.get("showApplePayButton")->Option.isSome {
setApplePayClicked(_ => false)
if !isWallet {
Expand Down
9 changes: 5 additions & 4 deletions src/Payments/GPay.res
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ let make = (
->Option.getOr(false)
}, [thirdPartySessionObj])

let processPayment = (body: array<(string, JSON.t)>) => {
let processPayment = (body: array<(string, JSON.t)>, isThirdPartyFlow) => {
intent(
~bodyArr=body,
~confirmParam={
return_url: options.wallets.walletReturnUrl,
publishableKey,
},
~handleUserError=true,
~isThirdPartyFlow,
(),
)
}
Expand Down Expand Up @@ -103,7 +104,7 @@ let make = (
->mergeTwoFlattenedJsonDicts(requiredFieldsBody)
->getArrayOfTupleFromDict
}
processPayment(body)
processPayment(body, false)
}
if dict->Dict.get("gpayError")->Option.isSome {
Utils.handlePostMessage([("fullscreen", false->JSON.Encode.bool)])
Expand Down Expand Up @@ -157,7 +158,7 @@ let make = (
("iframeId", iframeId->JSON.Encode.string),
])
let bodyDict = PaymentBody.gPayThirdPartySdkBody(~connectors)
processPayment(bodyDict)
processPayment(bodyDict, true)
} else {
handlePostMessage([
("fullscreen", true->JSON.Encode.bool),
Expand All @@ -168,7 +169,7 @@ let make = (
}
} else {
let bodyDict = PaymentBody.gpayRedirectBody(~connectors)
processPayment(bodyDict)
processPayment(bodyDict, false)
}
}
resolve()
Expand Down
3 changes: 2 additions & 1 deletion src/Utilities/PaymentHelpers.res
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,7 @@ let usePaymentIntent = (optLogger, paymentType) => {
~bodyArr: array<(string, JSON.t)>,
~confirmParam: ConfirmType.confirmParams,
~iframeId=keys.iframeId,
~isThirdPartyFlow=false,
(),
) => {
switch keys.clientSecret {
Expand All @@ -925,7 +926,7 @@ let usePaymentIntent = (optLogger, paymentType) => {
])
let endpoint = ApiEndpoint.getApiEndPoint(
~publishableKey=confirmParam.publishableKey,
~isConfirmCall=true,
~isConfirmCall=!isThirdPartyFlow,
(),
)
let uri = `${endpoint}/payments/${paymentIntentID}/confirm`
Expand Down
5 changes: 0 additions & 5 deletions src/orca-loader/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ type trustPayFunctions = {
executeGooglePayment: (string, GooglePayType.paymentDataRequest) => Promise.t<JSON.t>,
}
@new external trustPayApi: JSON.t => trustPayFunctions = "TrustPayApi"
@val @scope("window")
external alert: 't => unit = "alert"

let make = (
options,
Expand Down Expand Up @@ -454,9 +452,6 @@ let make = (
switch dict->Dict.get("applePayButtonClicked") {
| Some(val) =>
if val->JSON.Decode.bool->Belt.Option.getWithDefault(false) {
alert(event)
alert("event.isTrusted handleApplePayThirdPartyFlow")
alert(event.isTrusted)
let applePaySessionTokenData =
dict
->Dict.get("applePayPresent")
Expand Down
2 changes: 1 addition & 1 deletion src/orca-loader/Types.res
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type eventData = {
confirmTriggered: bool,
oneClickConfirmTriggered: bool,
}
type event = {key: string, data: eventData, isTrusted: bool}
type event = {key: string, data: eventData}
type eventParam = Event(event) | EventData(eventData) | Empty
type eventHandler = option<JSON.t> => unit
@send external onload: (Dom.element, unit => Promise.t<'a>) => Promise.t<'a> = "onload"
Expand Down
Loading