|
5 | 5 | #import <Foundation/Foundation.h>
|
6 | 6 | #import <StoreKit/StoreKit.h>
|
7 | 7 | #import "FIATransactionCache.h"
|
| 8 | +#import "FLTPaymentQueueHandlerProtocol.h" |
| 9 | +#import "FLTPaymentQueueProtocol.h" |
| 10 | +#import "FLTTransactionCacheProtocol.h" |
8 | 11 |
|
9 | 12 | @class SKPaymentTransaction;
|
10 | 13 |
|
11 | 14 | NS_ASSUME_NONNULL_BEGIN
|
12 | 15 |
|
13 |
| -typedef void (^TransactionsUpdated)(NSArray<SKPaymentTransaction *> *transactions); |
14 |
| -typedef void (^TransactionsRemoved)(NSArray<SKPaymentTransaction *> *transactions); |
15 |
| -typedef void (^RestoreTransactionFailed)(NSError *error); |
16 |
| -typedef void (^RestoreCompletedTransactionsFinished)(void); |
17 |
| -typedef BOOL (^ShouldAddStorePayment)(SKPayment *payment, SKProduct *product); |
18 |
| -typedef void (^UpdatedDownloads)(NSArray<SKDownload *> *downloads); |
19 |
| - |
20 |
| -@interface FIAPaymentQueueHandler : NSObject <SKPaymentTransactionObserver> |
21 |
| - |
22 |
| -@property(NS_NONATOMIC_IOSONLY, weak, nullable) id<SKPaymentQueueDelegate> delegate API_AVAILABLE( |
23 |
| - ios(13.0), macos(10.15), watchos(6.2)); |
24 |
| -@property(nonatomic, readonly, nullable) |
25 |
| - SKStorefront *storefront API_AVAILABLE(ios(13.0), macos(10.15), watchos(6.2)); |
26 |
| - |
27 |
| -/// Creates a new FIAPaymentQueueHandler initialized with an empty |
28 |
| -/// FIATransactionCache. |
29 |
| -/// |
30 |
| -/// @param queue The SKPaymentQueue instance connected to the App Store and |
31 |
| -/// responsible for processing transactions. |
32 |
| -/// @param transactionsUpdated Callback method that is called each time the App |
33 |
| -/// Store indicates transactions are updated. |
34 |
| -/// @param transactionsRemoved Callback method that is called each time the App |
35 |
| -/// Store indicates transactions are removed. |
36 |
| -/// @param restoreTransactionFailed Callback method that is called each time |
37 |
| -/// the App Store indicates transactions failed |
38 |
| -/// to restore. |
39 |
| -/// @param restoreCompletedTransactionsFinished Callback method that is called |
40 |
| -/// each time the App Store |
41 |
| -/// indicates restoring of |
42 |
| -/// transactions has finished. |
43 |
| -/// @param shouldAddStorePayment Callback method that is called each time an |
44 |
| -/// in-app purchase has been initiated from the |
45 |
| -/// App Store. |
46 |
| -/// @param updatedDownloads Callback method that is called each time the App |
47 |
| -/// Store indicates downloads are updated. |
48 |
| -- (instancetype)initWithQueue:(nonnull SKPaymentQueue *)queue |
49 |
| - transactionsUpdated:(nullable TransactionsUpdated)transactionsUpdated |
50 |
| - transactionRemoved:(nullable TransactionsRemoved)transactionsRemoved |
51 |
| - restoreTransactionFailed:(nullable RestoreTransactionFailed)restoreTransactionFailed |
52 |
| - restoreCompletedTransactionsFinished: |
53 |
| - (nullable RestoreCompletedTransactionsFinished)restoreCompletedTransactionsFinished |
54 |
| - shouldAddStorePayment:(nullable ShouldAddStorePayment)shouldAddStorePayment |
55 |
| - updatedDownloads:(nullable UpdatedDownloads)updatedDownloads |
56 |
| - DEPRECATED_MSG_ATTRIBUTE( |
57 |
| - "Use the " |
58 |
| - "'initWithQueue:transactionsUpdated:transactionsRemoved:restoreTransactionsFinished:" |
59 |
| - "shouldAddStorePayment:updatedDownloads:transactionCache:' message instead."); |
60 |
| - |
61 |
| -/// Creates a new FIAPaymentQueueHandler. |
62 |
| -/// |
63 |
| -/// The "transactionsUpdated", "transactionsRemoved" and "updatedDownloads" |
64 |
| -/// callbacks are only called while actively observing transactions. To start |
65 |
| -/// observing transactions send the "startObservingPaymentQueue" message. |
66 |
| -/// Sending the "stopObservingPaymentQueue" message will stop actively |
67 |
| -/// observing transactions. When transactions are not observed they are cached |
68 |
| -/// to the "transactionCache" and will be delivered via the |
69 |
| -/// "transactionsUpdated", "transactionsRemoved" and "updatedDownloads" |
70 |
| -/// callbacks as soon as the "startObservingPaymentQueue" message arrives. |
71 |
| -/// |
72 |
| -/// Note: cached transactions that are not processed when the application is |
73 |
| -/// killed will be delivered again by the App Store as soon as the application |
74 |
| -/// starts again. |
75 |
| -/// |
76 |
| -/// @param queue The SKPaymentQueue instance connected to the App Store and |
77 |
| -/// responsible for processing transactions. |
78 |
| -/// @param transactionsUpdated Callback method that is called each time the App |
79 |
| -/// Store indicates transactions are updated. |
80 |
| -/// @param transactionsRemoved Callback method that is called each time the App |
81 |
| -/// Store indicates transactions are removed. |
82 |
| -/// @param restoreTransactionFailed Callback method that is called each time |
83 |
| -/// the App Store indicates transactions failed |
84 |
| -/// to restore. |
85 |
| -/// @param restoreCompletedTransactionsFinished Callback method that is called |
86 |
| -/// each time the App Store |
87 |
| -/// indicates restoring of |
88 |
| -/// transactions has finished. |
89 |
| -/// @param shouldAddStorePayment Callback method that is called each time an |
90 |
| -/// in-app purchase has been initiated from the |
91 |
| -/// App Store. |
92 |
| -/// @param updatedDownloads Callback method that is called each time the App |
93 |
| -/// Store indicates downloads are updated. |
94 |
| -/// @param transactionCache An empty [FIATransactionCache] instance that is |
95 |
| -/// responsible for keeping track of transactions that |
96 |
| -/// arrive when not actively observing transactions. |
97 |
| -- (instancetype)initWithQueue:(nonnull SKPaymentQueue *)queue |
98 |
| - transactionsUpdated:(nullable TransactionsUpdated)transactionsUpdated |
99 |
| - transactionRemoved:(nullable TransactionsRemoved)transactionsRemoved |
100 |
| - restoreTransactionFailed:(nullable RestoreTransactionFailed)restoreTransactionFailed |
101 |
| - restoreCompletedTransactionsFinished: |
102 |
| - (nullable RestoreCompletedTransactionsFinished)restoreCompletedTransactionsFinished |
103 |
| - shouldAddStorePayment:(nullable ShouldAddStorePayment)shouldAddStorePayment |
104 |
| - updatedDownloads:(nullable UpdatedDownloads)updatedDownloads |
105 |
| - transactionCache:(nonnull FIATransactionCache *)transactionCache; |
106 |
| -// Can throw exceptions if the transaction type is purchasing, should always used in a @try block. |
107 |
| -- (void)finishTransaction:(nonnull SKPaymentTransaction *)transaction; |
108 |
| -- (void)restoreTransactions:(nullable NSString *)applicationName; |
109 |
| -- (void)presentCodeRedemptionSheet API_UNAVAILABLE(tvos, macos, watchos); |
110 |
| -- (NSArray<SKPaymentTransaction *> *)getUnfinishedTransactions; |
111 |
| - |
112 |
| -// This method needs to be called before any other methods. |
113 |
| -- (void)startObservingPaymentQueue; |
114 |
| -// Call this method when the Flutter app is no longer listening |
115 |
| -- (void)stopObservingPaymentQueue; |
116 |
| - |
117 |
| -// Appends a payment to the SKPaymentQueue. |
118 |
| -// |
119 |
| -// @param payment Payment object to be added to the payment queue. |
120 |
| -// @return whether "addPayment" was successful. |
121 |
| -- (BOOL)addPayment:(SKPayment *)payment; |
122 |
| - |
123 |
| -// Displays the price consent sheet. |
124 |
| -// |
125 |
| -// The price consent sheet is only displayed when the following |
126 |
| -// is true: |
127 |
| -// - You have increased the price of the subscription in App Store Connect. |
128 |
| -// - The subscriber has not yet responded to a price consent query. |
129 |
| -// Otherwise the method has no effect. |
130 |
| -- (void)showPriceConsentIfNeeded API_AVAILABLE(ios(13.4))API_UNAVAILABLE(tvos, macos, watchos); |
131 |
| - |
| 16 | +@interface FIAPaymentQueueHandler |
| 17 | + : NSObject <SKPaymentTransactionObserver, FLTPaymentQueueHandlerProtocol> |
132 | 18 | @end
|
133 | 19 |
|
134 | 20 | NS_ASSUME_NONNULL_END
|
0 commit comments