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
more docs
  • Loading branch information
LouiseHsu committed Sep 5, 2024
commit 8724d4039a364351ea7157cef7a825d71e07dccd
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ final class InAppPurchase2PluginTests: XCTestCase {
}

func testSuccessfulPurchase() async throws {
// plugin.purchase(id: "subscription_silver")
plugin.purchase(id: <#T##String#>, options: nil, completion: <#T##(Result<SK2ProductPurchaseResultMessage, any Error>) -> Void#>)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,19 @@ extension on SK2PriceLocaleMessage {
}
}

enum SK2ProductPurchaseResult { success, userCancelled, pending }
/// Wrapper around [PurchaseResult]
/// https://developer.apple.com/documentation/storekit/product/purchaseresult
enum SK2ProductPurchaseResult {
/// The purchase succeeded and results in a transaction.
success,
/// The user canceled the purchase.
userCancelled,
/// The purchase is pending, and requires action from the customer.
pending
}

class SK2ProductPurchaseOptions {
SK2ProductPurchaseOptions({this.appAccountToken, this.quantity});
// this.appAccountToken

final String? appAccountToken;
final int? quantity;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import '../../in_app_purchase_storekit.dart';
import '../../store_kit_wrappers.dart';
import '../sk2_pigeon.g.dart';

InAppPurchase2API _hostapi = InAppPurchase2API();
InAppPurchase2API _hostApi = InAppPurchase2API();

/// Dart wrapper around StoreKit2's [Transaction](https://developer.apple.com/documentation/storekit/transaction)
/// Note that in StoreKit2, a Transaction encompasses the data contained by
/// SKPayment and SKTransaction in StoreKit1
/// Dart wrapper around StoreKit2's [Transaction](https://developer.apple.com/documentation/storekit/transaction)
///
class SK2Transaction {
/// Creates a new instance of [SK2Transaction]
SK2Transaction(
{required this.id,
required this.originalId,
Expand All @@ -28,42 +28,65 @@ class SK2Transaction {
this.price,
this.error});

// SKTransaction
/// The unique identifier for the transaction.
final String id;

// The original transaction identifier, originalID, is identical to id except
// when the user restores a purchase or renews a transaction.
/// The original transaction identifier of a purchase.
/// The original transaction identifier, originalID, is identical to id except
/// when the user restores a purchase or renews a transaction.
final String originalId;

// SKPayment
/// The product identifier of the in-app purchase.
final String productId;

/// The date that the App Store charged the user’s account for a purchased or
/// restored product, or for a subscription purchase or renewal after a lapse.
final String purchaseDate;

/// The number of consumable products purchased.
final int quantity;

/// A UUID that associates the transaction with a user on your own service.
final String? appAccountToken;

/// The identifier of the subscription group that the subscription belongs to.
final String? subscriptionGroupID;

/// The price of the in-app purchase that the system records in the transaction.
final double? price;

/// Any error returned from StoreKit
final SKError? error;

/// Wrapper around [Transaction.finish]
/// https://developer.apple.com/documentation/storekit/transaction/3749694-finish
/// Indicates to the App Store that the app delivered the purchased content
/// or enabled the service to finish the transaction.
static Future<void> finish(int id) async {
await _hostapi.finish(id);
await _hostApi.finish(id);
}

/// A wrapper around [Transaction.all]
/// https://developer.apple.com/documentation/storekit/transaction/3851203-all
/// A sequence that emits all the customer’s transactions for your app.
static Future<List<SK2Transaction>> transactions() async {
List<SK2TransactionMessage?> msgs = await _hostapi.transactions();
List<SK2Transaction> transactions = msgs
final List<SK2TransactionMessage?> msgs = await _hostApi.transactions();
final List<SK2Transaction> transactions = msgs
.map((SK2TransactionMessage? e) => e?.convertFromPigeon())
.cast<SK2Transaction>()
.toList();
return transactions;
}

/// Start listening to transactions.
/// Call this as soon as you can your app to avoid missing transactions.
static void startListeningToTransactions() {
_hostapi.startListeningToTransactions();
_hostApi.startListeningToTransactions();
}

/// Stop listening to transactions.
static void stopListeningToTransactions() {
_hostapi.stopListeningToTransactions();
_hostApi.stopListeningToTransactions();
}
}

Expand All @@ -78,12 +101,11 @@ extension on SK2TransactionMessage {
}

PurchaseDetails convertToDetails() {
print("converting to details");
return SK2PurchaseDetails(
productID: productId,
verificationData: PurchaseVerificationData(
localVerificationData: "", serverVerificationData: "", source: ""),
transactionDate: "",
localVerificationData: '', serverVerificationData: '', source: ''),
transactionDate: '',
// Note that with sk2, any transactions that *can* be returned will require to be finished, and are already purchased.
// So set this
// as purchased for all transactions initially.
Expand All @@ -93,6 +115,7 @@ extension on SK2TransactionMessage {
}
}

/// An observer that listens to all transactions used
class SK2TransactionObserver implements InAppPurchase2CallbackAPI {
SK2TransactionObserver({required this.purchaseUpdatedController});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,22 +160,17 @@ enum SK2ProductPurchaseResultMessage { success, userCancelled, pending }
@HostApi(dartHostTestHandler: 'TestInAppPurchase2Api')
abstract class InAppPurchase2API {
// https://developer.apple.com/documentation/storekit/appstore/3822277-canmakepayments
// SK1 canMakePayments
bool canMakePayments();

// https://developer.apple.com/documentation/storekit/product/3851116-products
// SK1 startProductRequest
@async
List<SK2ProductMessage> products(List<String> identifiers);

// https://developer.apple.com/documentation/storekit/product/3791971-purchase
// SK1 addPayment
// needs id to reference product, and also purchaseOptions
@async
SK2ProductPurchaseResultMessage purchase(String id,
{SK2ProductPurchaseOptionsMessage? options});

// Note that the sk1 version of this only returns unfinished transactions.
@async
List<SK2TransactionMessage> transactions();

Expand Down