[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 114/204: Pay
From: |
gnunet |
Subject: |
[taler-taler-ios] 114/204: Pay |
Date: |
Thu, 05 Dec 2024 23:51:22 +0100 |
This is an automated email from the git hooks/post-receive script.
marc-stibane pushed a commit to branch master
in repository taler-ios.
commit 36e1f7903b6cc8409208b1e5f1c6df52e55ba03e
Author: Marc Stibane <marc@taler.net>
AuthorDate: Fri Nov 8 21:52:20 2024 +0100
Pay
---
TalerWallet1/Model/Model+Payment.swift | 34 ++++++++++++----------
.../Views/Sheets/Payment/PayTemplateV.swift | 8 +++--
.../Views/Sheets/Payment/PaymentDone.swift | 2 +-
.../Views/Sheets/Payment/PaymentView.swift | 8 ++---
4 files changed, 29 insertions(+), 23 deletions(-)
diff --git a/TalerWallet1/Model/Model+Payment.swift
b/TalerWallet1/Model/Model+Payment.swift
index a1c29c0..7904889 100644
--- a/TalerWallet1/Model/Model+Payment.swift
+++ b/TalerWallet1/Model/Model+Payment.swift
@@ -137,13 +137,18 @@ struct ExchangeFeeGapEstimate: Codable {
let maxEffectiveSpendAmount: Amount
}
+struct PerScopeDetails: Codable {
+ let scopeInfo: ScopeInfo
+}
/// The result from PreparePayForUri
struct PreparePayResult: Codable {
let status: PreparePayResultType
let transactionId: String
let contractTerms: MerchantContractTerms
let scopes: [ScopeInfo]
+// let detailsPerScope: [ScopeInfo : PreparePayDetails]
let amountRaw: Amount
+
let amountEffective: Amount? // only if
status != insufficientBalance
let paid: Bool? // only if
status == alreadyConfirmed
let talerUri: String?
@@ -234,7 +239,7 @@ struct ConfirmPayResult: Decodable {
var transactionId: String
}
/// A request to get an exchange's payment details.
-fileprivate struct confirmPayForUri: WalletBackendFormattedRequest {
+fileprivate struct ConfirmPayForUri: WalletBackendFormattedRequest {
typealias Response = ConfirmPayResult
func operation() -> String { "confirmPay" }
func args() -> Args { Args(transactionId: transactionId) }
@@ -247,32 +252,31 @@ fileprivate struct confirmPayForUri:
WalletBackendFormattedRequest {
// MARK: -
extension WalletModel {
/// load payment details. Networking involved
- @MainActor
- func preparePayForUriM(_ talerPayUri: String, viewHandles: Bool = false)
// M for MainActor
- async throws -> PreparePayResult {
- let request = PreparePayForUri(talerPayUri: talerPayUri)
- let response = try await sendRequest(request, ASYNCDELAY,
viewHandles: viewHandles)
- return response
- }
- @MainActor
- func checkPayForTemplateM(_ talerPayTemplateUri: String, viewHandles: Bool
= false) // M for MainActor
+ nonisolated func checkPayForTemplate(_ talerPayTemplateUri: String,
viewHandles: Bool = false)
async throws -> WalletTemplateDetails {
let request = CheckPayForTemplate(talerPayTemplateUri:
talerPayTemplateUri)
let response = try await sendRequest(request, ASYNCDELAY, viewHandles:
viewHandles)
return response
}
- @MainActor
- func preparePayForTemplateM(_ talerPayTemplateUri: String, amount:
Amount?, summary: String?, viewHandles: Bool = false) // M for MainActor
+
+ nonisolated func preparePayForTemplate(_ talerPayTemplateUri: String,
amount: Amount?, summary: String?, viewHandles: Bool = false)
async throws -> PreparePayResult {
let templateParams = TemplateParams(amount: amount, summary: summary)
let request = PreparePayForTemplateRequest(talerPayTemplateUri:
talerPayTemplateUri, templateParams: templateParams)
let response = try await sendRequest(request, ASYNCDELAY, viewHandles:
viewHandles)
return response
}
- @MainActor
- func confirmPayM(_ transactionId: String, viewHandles: Bool = false)
// M for MainActor
+
+ nonisolated func preparePayForUri(_ talerPayUri: String, viewHandles: Bool
= false)
+ async throws -> PreparePayResult {
+ let request = PreparePayForUri(talerPayUri: talerPayUri)
+ let response = try await sendRequest(request, ASYNCDELAY, viewHandles:
viewHandles)
+ return response
+ }
+
+ nonisolated func confirmPay(_ transactionId: String, viewHandles: Bool =
false)
async throws -> ConfirmPayResult {
- let request = confirmPayForUri(transactionId: transactionId)
+ let request = ConfirmPayForUri(transactionId: transactionId)
let response = try await sendRequest(request, ASYNCDELAY, viewHandles:
viewHandles)
return response
}
diff --git a/TalerWallet1/Views/Sheets/Payment/PayTemplateV.swift
b/TalerWallet1/Views/Sheets/Payment/PayTemplateV.swift
index e296e61..e6d246d 100644
--- a/TalerWallet1/Views/Sheets/Payment/PayTemplateV.swift
+++ b/TalerWallet1/Views/Sheets/Payment/PayTemplateV.swift
@@ -54,10 +54,12 @@ struct PayTemplateV: View {
private func buttonAction2() {
buttonSelected2 = true
}
+
+ @MainActor
func acceptAction(preparePayResult: PreparePayResult) {
Task { // runs on MainActor
- if let confirmPayResult = try? await
model.confirmPayM(preparePayResult.transactionId) {
- // symLog.log(confirmPayResult as Any)
+ if let confirmPayResult = try? await
model.confirmPay(preparePayResult.transactionId) {
+// symLog.log(confirmPayResult as Any)
if confirmPayResult.type != "done" {
controller.playSound(0)
// TODO: show error
@@ -82,7 +84,7 @@ struct PayTemplateV: View {
@MainActor
private func viewDidLoad() async {
- if let response = try? await
model.checkPayForTemplateM(url.absoluteString) {
+ if let response = try? await
model.checkPayForTemplate(url.absoluteString) {
let details = response.templateDetails
let defaults = details.editableDefaults // might be nil, or
its fields might be nil
// TODO: let the user
choose a currency from supportedCurrencies[]
diff --git a/TalerWallet1/Views/Sheets/Payment/PaymentDone.swift
b/TalerWallet1/Views/Sheets/Payment/PaymentDone.swift
index 1fc8da1..5dcc6f0 100644
--- a/TalerWallet1/Views/Sheets/Payment/PaymentDone.swift
+++ b/TalerWallet1/Views/Sheets/Payment/PaymentDone.swift
@@ -25,7 +25,7 @@ struct PaymentDone: View {
@MainActor
private func viewDidLoad() async {
- if let confirmPayResult = try? await model.confirmPayM(transactionId) {
+ if let confirmPayResult = try? await model.confirmPay(transactionId) {
// symLog.log(confirmPayResult as Any)
if confirmPayResult.type == "done" {
paymentDone = true
diff --git a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
index 8534d52..69a36b5 100644
--- a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
+++ b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
@@ -115,14 +115,14 @@ struct PaymentView: View, Sendable {
private func viewDidLoad() async {
// symLog.log(".task")
if template {
- if let templateResponse = try? await
model.preparePayForTemplateM(url.absoluteString,
- amount:
amountIsEditable ? amountToTransfer : nil,
- summary:
summaryIsEditable ? summary : nil) {
+ if let templateResponse = try? await
model.preparePayForTemplate(url.absoluteString,
+ amount: amountIsEditable ?
amountToTransfer : nil,
+ summary: summaryIsEditable ?
summary : nil) {
await checkCurrencyInfo(for: templateResponse)
preparePayResult = templateResponse
}
} else {
- if let payResponse = try? await
model.preparePayForUriM(url.absoluteString) {
+ if let payResponse = try? await
model.preparePayForUri(url.absoluteString) {
amountToTransfer = payResponse.amountRaw
await checkCurrencyInfo(for: payResponse)
preparePayResult = payResponse
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] 99/204: wording, (continued)
- [taler-taler-ios] 99/204: wording, gnunet, 2024/12/05
- [taler-taler-ios] 97/204: TransactionCommon, row, gnunet, 2024/12/05
- [taler-taler-ios] 101/204: CheckDepositResponse, gnunet, 2024/12/05
- [taler-taler-ios] 104/204: split, gnunet, 2024/12/05
- [taler-taler-ios] 107/204: debug, fix wrong comparison, gnunet, 2024/12/05
- [taler-taler-ios] 102/204: task viewDidLoad, gnunet, 2024/12/05
- [taler-taler-ios] 105/204: NavLink, gnunet, 2024/12/05
- [taler-taler-ios] 109/204: loadBalances, gnunet, 2024/12/05
- [taler-taler-ios] 106/204: Use NavLink, gnunet, 2024/12/05
- [taler-taler-ios] 113/204: PendingOperations (unused), gnunet, 2024/12/05
- [taler-taler-ios] 114/204: Pay,
gnunet <=
- [taler-taler-ios] 110/204: deposit, gnunet, 2024/12/05
- [taler-taler-ios] 122/204: Yellow for confirm, gnunet, 2024/12/05
- [taler-taler-ios] 119/204: cleanup, gnunet, 2024/12/05
- [taler-taler-ios] 120/204: Withdraw, gnunet, 2024/12/05
- [taler-taler-ios] 116/204: Settings, gnunet, 2024/12/05
- [taler-taler-ios] 112/204: P2P, gnunet, 2024/12/05
- [taler-taler-ios] 121/204: TransactionById, gnunet, 2024/12/05
- [taler-taler-ios] 123/204: fake currency, gnunet, 2024/12/05
- [taler-taler-ios] 108/204: inputAccessory 'return', gnunet, 2024/12/05
- [taler-taler-ios] 124/204: move DB to AppSupport, gnunet, 2024/12/05