taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

KYCauth.swift (2226B)


      1 /*
      2  * This file is part of GNU Taler, ©2022-26 Taler Systems S.A.
      3  * See LICENSE.md
      4  */
      5 /**
      6  * @author Marc Stibane
      7  */
      8 import SwiftUI
      9 import SymLog
     10 import taler_swift
     11 
     12 struct KycData {
     13     let debitIBAN: String
     14     let depositStr: (String, String)
     15     let debitPayto: String
     16 }
     17 // pretty much the same as ManualDetailsV
     18 struct KYCauth: View {
     19     let stack: CallStack
     20     let common: TransactionCommon
     21 
     22     func title(_ depositStr: String) -> String {
     23         String(localized: "You need to prove having control over the bank account for the deposit of \(depositStr).")
     24     }
     25 
     26     var body: some View {
     27         let kycErr = String(localized: "KYC Error")
     28         if let info = common.kycAuthTransferInfo {
     29             let debitPayTo = PayTo(info.debitPaytoUri)
     30             if let debitIban = debitPayTo.iban {
     31                 let accountDetails = info.transferOptionsExt
     32                 if let validDetails = accountDetails.validDetails {
     33                     if let scope: ScopeInfo = common.scopes.first {
     34                         let depositStr = common.amountRaw.formatted(scope, isNegative: false)
     35                         let kycData = KycData(debitIBAN: debitIban, depositStr: depositStr,
     36                                              debitPayto: info.debitPaytoUri)
     37                         WireTransferView(stack: stack.push(),
     38                                          title: title(depositStr.0),
     39                                      titleA11y: title(depositStr.1),
     40                                     reservePub: info.accountPub,
     41                                      obtainStr: nil,
     42                                        kycData: kycData,
     43                                   validDetails: validDetails)
     44                     } else { ErrorView(stack.push(), title: kycErr, message: String(localized: "No scope")) }
     45                 } else { ErrorView(stack.push(), title: kycErr, message: "No valid details") }
     46             } else {
     47                 // TODO: What if payto contains no IBAN, but URL?
     48                 ErrorView(stack.push(), title: kycErr, message: String(localized: "No IBAN"))
     49             }
     50         } else { ErrorView(stack.push(), title: kycErr, message: String(localized: "No KYC infos")) }
     51     } // body
     52 }