This should not be visible to end-users on normal circumstances, but we should regardless show an error message if something goes wrong with the IAP receipt verification, to prompt them to contact support. Testing ------- PASS Device: iPhone simulator iOS: 17.2 Damus: This commit damus-api: d3801376fa204433661be6de8b7974f12b0ad25f Setup: - Local Testing server - Xcode StoreKit environment Steps: 1. Set MOCK_VERIFY to false on the server (that means receipt verification will fail on Xcode environment) 2. Try to make IAP purchase. Error should appear on UI 3. Set MOCK_VERIFY to true on the server and restart StoreKit environment (Receipt validation will always work) 5. Try to make IAP purchase. Onboarding flow should go as normal with no error messages. PASS Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
34 lines
745 B
Swift
34 lines
745 B
Swift
//
|
||
// StoreObserver.swift
|
||
// damus
|
||
//
|
||
// Created by Daniel D’Aquino on 2023-12-08.
|
||
//
|
||
|
||
import Foundation
|
||
import StoreKit
|
||
|
||
class StoreObserver: NSObject, SKPaymentTransactionObserver {
|
||
static let standard = StoreObserver()
|
||
|
||
var delegate: StoreObserverDelegate?
|
||
|
||
init(delegate: StoreObserverDelegate? = nil) {
|
||
self.delegate = delegate
|
||
super.init()
|
||
}
|
||
|
||
//Observe transaction updates.
|
||
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
|
||
//Handle transaction states here.
|
||
|
||
Task {
|
||
try await self.delegate?.send_receipt()
|
||
}
|
||
}
|
||
}
|
||
|
||
protocol StoreObserverDelegate {
|
||
func send_receipt() async throws
|
||
}
|