Skip to content

Commit

Permalink
update logic to remove hardcoding of paymentType from app switch flows
Browse files Browse the repository at this point in the history
  • Loading branch information
jaxdesmarais committed Jul 30, 2024
1 parent 4e46ba8 commit c15d3aa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Sources/BraintreePayPal/BTPayPalClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,12 @@ import BraintreeDataCollector

switch returnURL.state {
case .succeeded, .canceled:
handleReturn(url, paymentType: .vault, completion: appSwitchCompletion)
guard let payPalRequest else {
notifyFailure(with: BTPayPalError.missingPayPalRequest, completion: appSwitchCompletion)
return
}

handleReturn(url, paymentType: payPalRequest.paymentType, completion: appSwitchCompletion)
case .unknownPath:
notifyFailure(with: BTPayPalError.appSwitchReturnURLPathInvalid, completion: appSwitchCompletion)
}
Expand Down Expand Up @@ -443,6 +448,7 @@ import BraintreeDataCollector
notifyFailure(with: BTPayPalError.missingPayPalRequest, completion: appSwitchCompletion)
return
}

handleReturn(url, paymentType: payPalRequest.paymentType, completion: completion)
case .unknownPath:
notifyFailure(with: BTPayPalError.asWebAuthenticationSessionURLInvalid(url.absoluteString), completion: completion)
Expand Down

0 comments on commit c15d3aa

Please sign in to comment.