blob: 3b7f0463090e78ed97d57124098e24b111629ae5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
//
// StorePaymentEvent.swift
// MullvadVPN
//
// Created by pronebird on 26/10/2022.
// Copyright © 2025 Mullvad VPN AB. All rights reserved.
//
import Foundation
import MullvadREST
@preconcurrency import StoreKit
/// The payment event received by observers implementing ``StorePaymentObserver``.
enum StorePaymentEvent: @unchecked Sendable {
/// The payment is successfully completed.
case finished(StorePaymentCompletion)
/// Failure to complete the payment.
case failure(StorePaymentFailure)
/// An instance of `SKPayment` held in the associated value.
var payment: SKPayment {
switch self {
case let .finished(completion):
return completion.transaction.payment
case let .failure(failure):
return failure.payment
}
}
}
/// Successful payment metadata.
struct StorePaymentCompletion {
/// Transaction object.
let transaction: SKPaymentTransaction
/// The account number credited.
let accountNumber: String
/// The server response received after uploading the AppStore receipt.
let serverResponse: REST.CreateApplePaymentResponse
}
/// Failed payment metadata.
struct StorePaymentFailure: @unchecked Sendable {
/// Transaction object, if available.
/// May not be available due to account validation failure.
let transaction: SKPaymentTransaction?
/// The payment object associated with payment request.
let payment: SKPayment
/// The account number to credit.
/// May not be available if the payment manager couldn't establish the association between the payment and account number.
/// Typically in such case, the error would be set to ``StorePaymentManagerError/noAccountSet``.
let accountNumber: String?
/// The payment manager error.
let error: StorePaymentManagerError
}
|