Skip to content

Commit

Permalink
Take IBP incentive eligibility from return URL
Browse files Browse the repository at this point in the history
  • Loading branch information
tillh-stripe committed Jan 20, 2025
1 parent dbcf05a commit 642c6da
Showing 1 changed file with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,9 @@ extension FinancialConnectionsWebFlowViewController {
case .success(.success(let returnUrl)):
if manifest.isProductInstantDebits {
if let paymentMethod = returnUrl.extractLinkBankPaymentMethod() {
let instantDebitsLinkedBank = InstantDebitsLinkedBank(
paymentMethod: paymentMethod,
bankName: returnUrl.extractValue(forKey: "bank_name")?
// backend can return "+" instead of a more-common encoding of "%20" for spaces
.replacingOccurrences(of: "+", with: " "),
last4: returnUrl.extractValue(forKey: "last4"),
linkMode: elementsSessionContext?.linkMode,
// TODO: Parse this from the return URL
incentiveEligible: false
let instantDebitsLinkedBank = createInstantDebitsLinkedBank(
from: returnUrl,
with: paymentMethod
)
self.notifyDelegateOfSuccess(result: .instantDebits(instantDebitsLinkedBank))
} else {
Expand Down Expand Up @@ -212,6 +206,21 @@ extension FinancialConnectionsWebFlowViewController {
self.authSessionManager = nil
})
}

private func createInstantDebitsLinkedBank(
from url: URL,
with paymentMethod: LinkBankPaymentMethod
) -> InstantDebitsLinkedBank {
return InstantDebitsLinkedBank(
paymentMethod: paymentMethod,
bankName: url.extractValue(forKey: "bank_name")?
// backend can return "+" instead of a more-common encoding of "%20" for spaces
.replacingOccurrences(of: "+", with: " "),
last4: url.extractValue(forKey: "last4"),
linkMode: elementsSessionContext?.linkMode,
incentiveEligible: url.extractValue(forKey: "incentive_eligible").flatMap { Bool($0) } ?? false
)
}

private func redirect(to url: URL) {
DispatchQueue.main.async {
Expand Down

0 comments on commit 642c6da

Please sign in to comment.