TransactionPayDetailV.swift (4466B)
1 /* 2 * This file is part of GNU Taler, ©2022-26 Taler Systems S.A. 3 * See LICENSE.md 4 */ 5 /** 6 * Overview when there's more than 1 currency/exchange 7 * 8 * @author Marc Stibane 9 */ 10 import SwiftUI 11 12 struct TransactionPayDetailV: View { 13 let stack: CallStack 14 let paymentTx: PaymentTransaction 15 16 #if DEBUG 17 @AppStorage("developerMode") var developerMode: Bool = true 18 #else 19 @AppStorage("developerMode") var developerMode: Bool = false 20 #endif 21 22 var body: some View { 23 let common = paymentTx.common 24 let details = paymentTx.details 25 let info = details.info 26 Section { 27 if let posConfirmation = details.posConfirmation { 28 Text("Confirmation:", comment: "purchase may have a pos validation / confirmation") 29 .talerFont(.title3) 30 .listRowSeparator(.hidden) 31 let totp = Text(posConfirmation) 32 .talerFont(.title1) 33 let posConfirmationViaNfc = details.posConfirmationViaNfc 34 let isPaying = common.isDialog // We are ALWAYS already finished with the tx 35 if #available(iOS 17.7, *) { 36 BorderWithNFC(totpString: posConfirmation, nfcHint: true, 37 automaticNfc: isPaying ? posConfirmationViaNfc : false, 38 size: 250, scanHints: nil 39 ) { totp } 40 } else { 41 totp 42 } 43 } 44 // Text(info.summary) 45 if let info { 46 // Text(info.merchant.name) TODO: show name & logo here? 47 Text("Order-ID:") 48 .talerFont(.title3) 49 .listRowSeparator(.hidden) 50 Text(info.orderId) 51 .talerFont(.body) 52 53 if let fulfillmentUrl = info.fulfillmentUrl { 54 // per api-common.rst's WebURL definition, fulfillment_url must be http(s) - 55 // reject any other scheme (tel:, sms:, a third-party app's custom scheme, ...) 56 if let destination = URL(string: fulfillmentUrl), 57 let scheme = destination.scheme?.lowercased(), scheme == "http" || scheme == "https" { 58 let buttonTitle = info.fulfillmentMessage ?? String(localized: "Open merchant website") 59 Link(buttonTitle, destination: destination) 60 .buttonStyle(TalerButtonStyle(type: .prominent)) 61 .accessibilityHint(String(localized: "Will go to the merchant website.", comment: "a11y")) 62 } 63 } else if let fulfillmentMessage = info.fulfillmentMessage { 64 Text(fulfillmentMessage) 65 .talerFont(.body) 66 } 67 } 68 if let failReason = common.failReason { 69 if let hint = failReason.hint { 70 Text(hint) 71 .talerFont(.title3) 72 } 73 } 74 if let abortReason = details.abortReason { 75 if let exchangeResponse = abortReason.exchangeResponse, 76 let hint2 = exchangeResponse.hint { 77 Text(hint2) 78 .talerFont(.body) 79 } 80 if developerMode { 81 if let hint3 = abortReason.hint { 82 Text(hint3) 83 .talerFont(.body) 84 } 85 } 86 } 87 if let choiceIndex = details.choiceIndex { 88 if let contractTerms = details.contractTerms { 89 if let choices = contractTerms.choices, 90 choices.indices.contains(choiceIndex) { 91 let choice = choices[choiceIndex] 92 Text(choice.descI18n ?? "Index: \(choiceIndex)") // should never happen 93 .talerFont(.body) 94 } 95 } 96 } 97 } 98 if let products = info?.products { 99 ForEach(products) { product in 100 if let product_id = product.product_id { 101 Section { 102 Text(product_id) 103 .talerFont(.body) 104 } 105 } 106 } 107 } 108 } 109 } 110 111 // MARK: - 112 //#Preview { 113 // TransactionDetailV() 114 //}