Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b126a15
pigeon stuff
LouiseHsu Sep 3, 2024
ae9095a
refactored AND working heh
LouiseHsu Sep 4, 2024
c38b66f
format
LouiseHsu Sep 4, 2024
268a50e
pre refactor for cache
LouiseHsu Sep 4, 2024
f6ec07a
.
LouiseHsu Sep 4, 2024
aa36dfd
fix configuration file
LouiseHsu Sep 5, 2024
8724d40
more docs
LouiseHsu Sep 5, 2024
a6cbd98
more docs and clean up
LouiseHsu Sep 5, 2024
b75eec7
.
LouiseHsu Sep 13, 2024
4d2fd59
FIXED TESTING ISSUE
LouiseHsu Sep 24, 2024
aeef979
native tests are donesies
LouiseHsu Sep 25, 2024
acf499f
moreeee clean up and tests,
LouiseHsu Sep 26, 2024
c3c7204
format, comments, remove prints
LouiseHsu Sep 26, 2024
9021b6f
versioning, analyze
LouiseHsu Sep 26, 2024
666df56
symlink the test files
LouiseHsu Sep 26, 2024
97b746f
fix mac cant build
LouiseHsu Sep 26, 2024
add5bf5
podspec, licensing
LouiseHsu Sep 26, 2024
06b42d0
.
LouiseHsu Sep 27, 2024
0701d2a
remove any to get around old linter
LouiseHsu Sep 27, 2024
8f225c0
remove more anys to appease format gods
LouiseHsu Sep 27, 2024
2c6efdb
Merge branch 'main' into iap_add_purchase
LouiseHsu Sep 27, 2024
72ce51c
a lil bit of refactioring
LouiseHsu Oct 1, 2024
2e940fe
Merge branch 'iap_add_purchase' of github.com:LouiseHsu/packages into…
LouiseHsu Oct 1, 2024
442c158
better error messages
LouiseHsu Oct 1, 2024
f48510b
some refactoring
LouiseHsu Oct 1, 2024
6076bf1
.
LouiseHsu Oct 1, 2024
d8dcad2
remove uneeded filed
LouiseHsu Oct 2, 2024
9c2893b
oops pathing
LouiseHsu Oct 2, 2024
1a74fb7
.
LouiseHsu Oct 2, 2024
1b688ae
.
LouiseHsu Oct 2, 2024
74c2de3
.
LouiseHsu Oct 4, 2024
71c9a1b
.
LouiseHsu Oct 4, 2024
582156b
no message
LouiseHsu Oct 4, 2024
e6bec70
.
LouiseHsu Oct 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove uneeded filed
  • Loading branch information
LouiseHsu committed Oct 2, 2024
commit d8dcad2cc754a65c5d52b5da7678f6f20c49f0e0

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ final class InAppPurchase2PluginTests: XCTestCase {
fetchedProductMsg = productMessages.first
expectation.fulfill()
case .failure(let error):
// Handle the error
print("Failed to fetch products: \(error.localizedDescription)")
}
}
Expand All @@ -70,9 +69,7 @@ final class InAppPurchase2PluginTests: XCTestCase {
case .success(let productMessages):
fetchedProductMsg = productMessages.first
expectation.fulfill()
case .failure(let error):
// Handle the error
print("Failed to fetch products: \(error.localizedDescription)")
case .failure(let error): print("Failed to fetch products: \(error.localizedDescription)")
}
}
await fulfillment(of: [expectation], timeout: 5)
Expand Down Expand Up @@ -104,7 +101,7 @@ final class InAppPurchase2PluginTests: XCTestCase {
}

//TODO(louisehsu): Add testing for lower versions.
@available(iOS 17.0, *)
@available(iOS 17.0, macOS 14.0, *)
func testGetProductsWithStoreKitError() async throws {
try await session.setSimulatedError(
.generic(.networkError(URLError(.badURL))), forAPI: .loadProducts)
Expand All @@ -128,9 +125,7 @@ final class InAppPurchase2PluginTests: XCTestCase {

func testSuccessfulPurchase() async throws {
let expectation = self.expectation(description: "Purchase request should succeed")
plugin.purchase(
id: "consumable", options: nil
) { result in
plugin.purchase(id: "consumable", options: nil) { result in
switch result {
case .success(let purchaseResult):
expectation.fulfill()
Expand All @@ -141,14 +136,12 @@ final class InAppPurchase2PluginTests: XCTestCase {
await fulfillment(of: [expectation], timeout: 5)
}

@available(iOS 17.0, *)
@available(iOS 17.0, macOS 14.0, *)
func testFailedNetworkErrorPurchase() async throws {
try await session.setSimulatedError(
.generic(.networkError(URLError(.badURL))), forAPI: .loadProducts)
let expectation = self.expectation(description: "products request should fail")
plugin.purchase(
id: "consumable", options: nil
) { result in
plugin.purchase(id: "consumable", options: nil) { result in
switch result {
case .success(_):
XCTFail("Purchase should NOT suceed.")
Expand All @@ -162,14 +155,12 @@ final class InAppPurchase2PluginTests: XCTestCase {
await fulfillment(of: [expectation], timeout: 5)
}

@available(iOS 17.0, *)
@available(iOS 17.0, macOS 14.0, *)
func testFailedProductUnavilablePurchase() async throws {
try await session.setSimulatedError(
.purchase(.productUnavailable), forAPI: .purchase)
let expectation = self.expectation(description: "Purchase request should succeed")
plugin.purchase(
id: "consumable", options: nil
) { result in
plugin.purchase(id: "consumable", options: nil) { result in
switch result {
case .success(_):
XCTFail("Purchase should NOT suceed.")
Expand All @@ -183,9 +174,7 @@ final class InAppPurchase2PluginTests: XCTestCase {

func testInvalidProductPurchase() async throws {
let expectation = self.expectation(description: "products request should fail")
plugin.purchase(
id: "invalid_product", options: nil
) { result in
plugin.purchase(id: "invalid_product", options: nil) { result in
switch result {
case .success(_):
XCTFail("Purchase should NOT suceed.")
Expand All @@ -201,9 +190,7 @@ final class InAppPurchase2PluginTests: XCTestCase {

func testPurchaseUpgradeConsumableSuccess() async throws {
let expectation = self.expectation(description: "Purchase request should succeed")
plugin.purchase(
id: "subscription_discounted", options: nil
) { result in
plugin.purchase(id: "subscription_discounted", options: nil) { result in
switch result {
case .success(let purchaseResult):
expectation.fulfill()
Expand All @@ -216,9 +203,7 @@ final class InAppPurchase2PluginTests: XCTestCase {

func testDiscountedSubscriptionSuccess() async throws {
let expectation = self.expectation(description: "Purchase request should succeed")
plugin.purchase(
id: "subscription_discounted", options: nil
) { result in
plugin.purchase(id: "subscription_discounted", options: nil) { result in
switch result {
case .success(let purchaseResult):
expectation.fulfill()
Expand All @@ -231,9 +216,7 @@ final class InAppPurchase2PluginTests: XCTestCase {

func testDiscountedProductSuccess() async throws {
let expectation = self.expectation(description: "Purchase request should succeed")
plugin.purchase(
id: "consumable_discounted", options: nil
) { result in
plugin.purchase(id: "consumable_discounted", options: nil) { result in
switch result {
case .success(let purchaseResult):
expectation.fulfill()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ class InAppPurchaseStoreKitPlatform extends InAppPurchasePlatform {

/// StoreKit1
static late SKPaymentQueueWrapper _skPaymentQueueWrapper;
static late _TransactionObserver _observer;
static late _TransactionObserver _sk1transactionObserver;

/// StoreKit2
static late SK2TransactionObserver _sk2transactionObserver;
static late SK2TransactionObserverWrapper _sk2transactionObserver;

@override
Stream<List<PurchaseDetails>> get purchaseStream => _useStoreKit2
? _sk2transactionObserver.transactionsCreatedController.stream
: _observer.purchaseUpdatedController.stream;
: _sk1transactionObserver.purchaseUpdatedController.stream;

/// Callback handler for transaction status changes.
@visibleForTesting
static SKTransactionObserverWrapper get observer => _observer;
static SKTransactionObserverWrapper get observer => _sk1transactionObserver;

/// Callback handler for transaction status changes for StoreKit2 transactions
@visibleForTesting
static SK2TransactionObserver get sk2transactionObserver =>
static SK2TransactionObserverWrapper get sk2transactionObserver =>
_sk2transactionObserver;

/// Registers this class as the default instance of [InAppPurchasePlatform].
Expand All @@ -73,7 +73,7 @@ class InAppPurchaseStoreKitPlatform extends InAppPurchasePlatform {
onListen: () => SK2Transaction.startListeningToTransactions(),
onCancel: () => SK2Transaction.stopListeningToTransactions(),
);
_sk2transactionObserver = SK2TransactionObserver(
_sk2transactionObserver = SK2TransactionObserverWrapper(
transactionsCreatedController: updateController2);
InAppPurchase2CallbackAPI.setUp(_sk2transactionObserver);
} else {
Expand All @@ -84,7 +84,7 @@ class InAppPurchaseStoreKitPlatform extends InAppPurchasePlatform {
onListen: () => _skPaymentQueueWrapper.startObservingTransactionQueue(),
onCancel: () => _skPaymentQueueWrapper.stopObservingTransactionQueue(),
);
_observer = _TransactionObserver(updateController);
_sk1transactionObserver = _TransactionObserver(updateController);
_skPaymentQueueWrapper.setTransactionObserver(observer);
}
}
Expand Down Expand Up @@ -149,11 +149,12 @@ class InAppPurchaseStoreKitPlatform extends InAppPurchasePlatform {

@override
Future<void> restorePurchases({String? applicationUserName}) async {
return _observer
return _sk1transactionObserver
.restoreTransactions(
queue: _skPaymentQueueWrapper,
applicationUserName: applicationUserName)
.whenComplete(() => _observer.cleanUpRestoredTransactions());
.whenComplete(
() => _sk1transactionObserver.cleanUpRestoredTransactions());
}

/// Query the product detail list.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ extension on SK2TransactionMessage {
}

/// An observer that listens to all transactions created
class SK2TransactionObserver implements InAppPurchase2CallbackAPI {
/// Creates a new instance of [SK2TransactionObserver]
SK2TransactionObserver({required this.transactionsCreatedController});
class SK2TransactionObserverWrapper implements InAppPurchase2CallbackAPI {
/// Creates a new instance of [SK2TransactionObserverWrapper]
SK2TransactionObserverWrapper({required this.transactionsCreatedController});

/// The transactions stream to listen to
final StreamController<List<PurchaseDetails>> transactionsCreatedController;
Expand Down