diff options
| author | Jon Petersson <jon.petersson@mullvad.net> | 2026-04-23 10:15:45 +0200 |
|---|---|---|
| committer | Jon Petersson <jon.petersson@mullvad.net> | 2026-04-23 10:15:45 +0200 |
| commit | cd5b65ffdf50f4c9408fbb8db1f2d2140126e64f (patch) | |
| tree | 53c9b1985d856214e9bb885dbdc4d02ce3a526c5 | |
| parent | ed45d9a73d29f97f18f832160fa336e21b687970 (diff) | |
| parent | d77b2417bec8aa6a1d36fdb2b12fabd193ae7d25 (diff) | |
| download | mullvadvpn-cd5b65ffdf50f4c9408fbb8db1f2d2140126e64f.tar.xz mullvadvpn-cd5b65ffdf50f4c9408fbb8db1f2d2140126e64f.zip | |
Merge branch 'add-more-logs-to-payment-flows'
3 files changed, 36 insertions, 3 deletions
diff --git a/ios/MullvadLogging/Date+LogFormat.swift b/ios/MullvadLogging/Date+LogFormat.swift index 694c966b63..3d78f6f47e 100644 --- a/ios/MullvadLogging/Date+LogFormat.swift +++ b/ios/MullvadLogging/Date+LogFormat.swift @@ -19,6 +19,16 @@ extension Date { return formatter.string(from: self) } + public var safeLogFormatted: String { + let formatter = DateFormatter() + + formatter.dateFormat = "dd/MM/yyyy" + formatter.locale = Locale(identifier: "en_US_POSIX") + formatter.timeZone = TimeZone(abbreviation: "UTC") + + return formatter.string(from: self) + } + public var logFileFormatted: String { let formatter = DateFormatter() diff --git a/ios/MullvadVPN/StorePaymentManager/StorePaymentManager.swift b/ios/MullvadVPN/StorePaymentManager/StorePaymentManager.swift index ef638ffaef..62a8b11715 100644 --- a/ios/MullvadVPN/StorePaymentManager/StorePaymentManager.swift +++ b/ios/MullvadVPN/StorePaymentManager/StorePaymentManager.swift @@ -69,6 +69,8 @@ final actor StorePaymentManager: @unchecked Sendable { } func purchase(product: Product) async { + logger.debug("Purchasing product: \(product.id)") + let token: UUID do { token = try await self.getPaymentToken() @@ -140,12 +142,16 @@ final actor StorePaymentManager: @unchecked Sendable { } static func finishOutstandingSandboxAndOldAPITransactions() async { + let logger = Logger(label: "StorePaymentManager") + + logger.debug("Finishing outstanding sandbox and old transactions") + for await verification in Transaction.unfinished { guard let payload = try? verification.payloadValue else { + logger.debug("Verification is missing a valid payload") continue } - let logger = Logger(label: "StorePaymentManager") logger.debug("Unfinished transaction environment is \(payload.environment)") let isStagingEnvironment = payload.environment != .production @@ -155,8 +161,13 @@ final actor StorePaymentManager: @unchecked Sendable { if isStagingEnvironment || isOldAPI { logger.debug( - "Finishing transaction. isStagingEnvironment: \(isStagingEnvironment), isOldAPI: \(isOldAPI)") + "Finishing transaction. isStagingEnvironment: \(isStagingEnvironment), isOldAPI: \(isOldAPI)" + ) await payload.finish() + } else { + logger.debug( + "Skipping transaction. isStagingEnvironment: \(isStagingEnvironment), isOldAPI: \(isOldAPI)" + ) } } } @@ -173,7 +184,15 @@ final actor StorePaymentManager: @unchecked Sendable { } private func uploadReceipt(verification: VerificationResult<Transaction>) async throws { - logger.debug("Uploading receipt") + let payload = try verification.payloadValue + + let logMessage: String = + "Uploading receipt. " + + "Product ID: \(payload.productID), " + + "Environment: \(payload.environment), " + + "Purchase date: \(payload.purchaseDate.safeLogFormatted), " + + "Revocation date: \(payload.revocationDate?.safeLogFormatted ?? "none")" + logger.debug(.init(stringLiteral: logMessage)) let result = await interactor.checkPayment(jwsRepresentation: verification.jwsRepresentation) diff --git a/ios/MullvadVPN/View controllers/InAppPurchase/InAppPurchaseViewController.swift b/ios/MullvadVPN/View controllers/InAppPurchase/InAppPurchaseViewController.swift index b8a6c44393..663a4c6a86 100644 --- a/ios/MullvadVPN/View controllers/InAppPurchase/InAppPurchaseViewController.swift +++ b/ios/MullvadVPN/View controllers/InAppPurchase/InAppPurchaseViewController.swift @@ -6,10 +6,12 @@ // Copyright © 2026 Mullvad VPN AB. All rights reserved. // +import MullvadLogging import StoreKit import UIKit class InAppPurchaseViewController: UIViewController, StorePaymentObserver { + private let logger = Logger(label: "InAppPurchaseViewController") private let storePaymentManager: StorePaymentManager private let accountNumber: String private let paymentAction: PaymentAction @@ -81,6 +83,7 @@ class InAppPurchaseViewController: UIViewController, StorePaymentObserver { } func startRestorationBeforePurchaseFlow() async { + logger.debug("Restoring purchases before starting payment flow") spinnerView.startAnimating() do { @@ -106,6 +109,7 @@ class InAppPurchaseViewController: UIViewController, StorePaymentObserver { } func startPaymentFlow() async { + logger.debug("Starting payment flow") spinnerView.startAnimating() var products: [Product] |
