diff options
| -rw-r--r-- | ios/CHANGELOG.md | 3 | ||||
| -rw-r--r-- | ios/MullvadREST/MullvadAPI/APIHandlers/MullvadAPIProxy.swift | 47 | ||||
| -rw-r--r-- | ios/MullvadVPN/StorePaymentManager/SendStoreReceiptOperation.swift | 49 |
3 files changed, 11 insertions, 88 deletions
diff --git a/ios/CHANGELOG.md b/ios/CHANGELOG.md index f66c3c9e00..9859a8e6ae 100644 --- a/ios/CHANGELOG.md +++ b/ios/CHANGELOG.md @@ -23,6 +23,9 @@ Line wrap the file at 100 chars. Th ## UNRELEASED +### Fixed +- Fix in-app purchases. + ## [2025.6 - 2025-09-23] ### Added - Add support for obfuscating WireGuard tunnel traffic as the QUIC protocol. This helps diff --git a/ios/MullvadREST/MullvadAPI/APIHandlers/MullvadAPIProxy.swift b/ios/MullvadREST/MullvadAPI/APIHandlers/MullvadAPIProxy.swift index fb458532d1..b48095abf5 100644 --- a/ios/MullvadREST/MullvadAPI/APIHandlers/MullvadAPIProxy.swift +++ b/ios/MullvadREST/MullvadAPI/APIHandlers/MullvadAPIProxy.swift @@ -23,11 +23,6 @@ public protocol APIQuerying: Sendable { completionHandler: @escaping @Sendable ProxyCompletionHandler<REST.ServerRelaysCacheResponse> ) -> Cancellable - func createApplePayment( - accountNumber: String, - receiptString: Data - ) -> any RESTRequestExecutor<REST.CreateApplePaymentResponse> - func legacyStorekitPayment( accountNumber: String, request: LegacyStorekitRequest, @@ -156,16 +151,6 @@ extension REST { AnyCancellable() } - /// Not implemented. Use `RESTAPIProxy` instead. - public func createApplePayment( - accountNumber: String, - receiptString: Data - ) -> any RESTRequestExecutor<REST.CreateApplePaymentResponse> { - RESTRequestExecutorStub<REST.CreateApplePaymentResponse>(success: { - .timeAdded(0, .now) - }) - } - public func checkApiAvailability( retryStrategy: REST.RetryStrategy, accessMethod: PersistentAccessMethod, @@ -328,35 +313,3 @@ extension REST { let newExpiry: Date } } - -// TODO: Remove when Mullvad API is production ready. -private struct RESTRequestExecutorStub<Success: Sendable>: RESTRequestExecutor { - var success: (() -> Success)? - - func execute(completionHandler: @escaping (Result<Success, Error>) -> Void) -> Cancellable { - if let result = success?() { - completionHandler(.success(result)) - } - return AnyCancellable() - } - - func execute( - retryStrategy: REST.RetryStrategy, - completionHandler: @escaping (Result<Success, Error>) -> Void - ) -> Cancellable { - if let result = success?() { - completionHandler(.success(result)) - } - return AnyCancellable() - } - - func execute() async throws -> Success { - try await execute(retryStrategy: .noRetry) - } - - func execute(retryStrategy: REST.RetryStrategy) async throws -> Success { - guard let success = success else { throw POSIXError(.EINVAL) } - - return success() - } -} diff --git a/ios/MullvadVPN/StorePaymentManager/SendStoreReceiptOperation.swift b/ios/MullvadVPN/StorePaymentManager/SendStoreReceiptOperation.swift index a271166cce..c143f59215 100644 --- a/ios/MullvadVPN/StorePaymentManager/SendStoreReceiptOperation.swift +++ b/ios/MullvadVPN/StorePaymentManager/SendStoreReceiptOperation.swift @@ -132,45 +132,12 @@ class SendStoreReceiptOperation: ResultOperation<REST.CreateApplePaymentResponse } } - #if DEBUG - private func sendReceipt(_ receiptData: Data) { - submitReceiptTask = apiProxy.legacyStorekitPayment( - accountNumber: accountNumber, - request: LegacyStorekitRequest(receiptString: receiptData), - retryStrategy: .default, - completionHandler: { result in - switch result { - case let .success(response): - self.logger.info( - """ - AppStore receipt was processed. \ - Time added: \(response.timeAdded), \ - New expiry: \(response.newExpiry.logFormatted) - """ - ) - self.finish(result: .success(response)) - - case let .failure(error): - if error.isOperationCancellationError { - self.logger.debug("Receipt submission cancelled.") - self.finish(result: .failure(error)) - } else { - self.logger.error( - error: error, - message: "Failed to send the AppStore receipt." - ) - self.finish(result: .failure(StorePaymentManagerError.sendReceipt(error))) - } - } - } - ) - } - #else - private func sendReceipt(_ receiptData: Data) { - submitReceiptTask = apiProxy.createApplePayment( - accountNumber: accountNumber, - receiptString: receiptData - ).execute(retryStrategy: .noRetry) { result in + private func sendReceipt(_ receiptData: Data) { + submitReceiptTask = apiProxy.legacyStorekitPayment( + accountNumber: accountNumber, + request: LegacyStorekitRequest(receiptString: receiptData), + retryStrategy: .default, + completionHandler: { result in switch result { case let .success(response): self.logger.info( @@ -195,8 +162,8 @@ class SendStoreReceiptOperation: ResultOperation<REST.CreateApplePaymentResponse } } } - } - #endif + ) + } } struct StoreReceiptNotFound: LocalizedError { |
