Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit b0f84b8

Browse files
[in_app_purchase] Rename iOS implementation to _storekit (#4518)
Renames the iOS implementation package to `in_app_purchase_storekit`, and renames it types and files accordingly, to allow for adding a symlink-based macOS implementation to this package in the future. Temporarily marks `in_app_purchase` as unpublishable so that this can be a move, rather than a copy-and-delete-later, which makes for difficult reviews and destroys git blame. Part of flutter/flutter#86076 Supports flutter/flutter#84391
1 parent c3149e1 commit b0f84b8

110 files changed

Lines changed: 259 additions & 305 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/in_app_purchase/in_app_purchase/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## NEXT
2+
3+
* **BREAKING CHANGES**:
4+
* Renames `in_app_purchase_ios` to `in_app_purchase_storekit`.
5+
* Renames `InAppPurchaseIosPlatform` to `InAppPurchaseStoreKitPlatform`.
6+
* Renames `InAppPurchaseIosPlatformAddition` to
7+
`InAppPurchaseStoreKitPlatformAddition`.
8+
19
## 1.0.9
210

311
* Handle purchases with `PurchaseStatus.restored` correctly in the example App.

packages/in_app_purchase/in_app_purchase/README.md

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ can start using the plugin. Two basic options are available:
4141
1. A generic, idiomatic Flutter API: [in_app_purchase](https://pub.dev/documentation/in_app_purchase/latest/in_app_purchase/in_app_purchase-library.html).
4242
This API supports most use cases for loading and making purchases.
4343

44-
2. Platform-specific Dart APIs: [store_kit_wrappers](https://pub.dev/documentation/in_app_purchase_ios/latest/store_kit_wrappers/store_kit_wrappers-library.html)
44+
2. Platform-specific Dart APIs: [store_kit_wrappers](https://pub.dev/documentation/in_app_purchase_storekit/latest/store_kit_wrappers/store_kit_wrappers-library.html)
4545
and [billing_client_wrappers](https://pub.dev/documentation/in_app_purchase_android/latest/billing_client_wrappers/billing_client_wrappers-library.html).
4646
These APIs expose platform-specific behavior and allow for more fine-tuned
4747
control when needed. However, if you use one of these APIs, your
@@ -70,7 +70,7 @@ This section has examples of code for the following tasks:
7070
The following initialization code is required for Google Play:
7171

7272
```dart
73-
// Import `in_app_purchase_android.dart` to be able to access the
73+
// Import `in_app_purchase_android.dart` to be able to access the
7474
// `InAppPurchaseAndroidPlatformAddition` class.
7575
import 'package:in_app_purchase_android/in_app_purchase_android.dart';
7676
import 'package:flutter/foundation.dart';
@@ -131,7 +131,7 @@ void _listenToPurchaseUpdated(List<PurchaseDetails> purchaseDetailsList) {
131131
} else {
132132
if (purchaseDetails.status == PurchaseStatus.error) {
133133
_handleError(purchaseDetails.error!);
134-
} else if (purchaseDetails.status == PurchaseStatus.purchased ||
134+
} else if (purchaseDetails.status == PurchaseStatus.purchased ||
135135
purchaseDetails.status == PurchaseStatus.restored) {
136136
bool valid = await _verifyPurchase(purchaseDetails);
137137
if (valid) {
@@ -175,7 +175,7 @@ List<ProductDetails> products = response.productDetails;
175175
### Restoring previous purchases
176176

177177
Restored purchases will be emitted on the `InAppPurchase.purchaseStream`, make
178-
sure to validate restored purchases following the best practices for each
178+
sure to validate restored purchases following the best practices for each
179179
underlying store:
180180

181181
* [Verifying App Store purchases](https://developer.apple.com/documentation/storekit/in-app_purchase/validating_receipts_with_the_app_store)
@@ -213,8 +213,8 @@ if (_isConsumable(productDetails)) {
213213
### Completing a purchase
214214

215215
The `InAppPurchase.purchaseStream` will send purchase updates after
216-
you initiate the purchase flow using `InAppPurchase.buyConsumable`
217-
or `InAppPurchase.buyNonConsumable`. After delivering the content to
216+
you initiate the purchase flow using `InAppPurchase.buyConsumable`
217+
or `InAppPurchase.buyNonConsumable`. After delivering the content to
218218
the user, call `InAppPurchase.completePurchase` to tell the App Store
219219
and Google Play that the purchase has been finished.
220220

@@ -249,18 +249,18 @@ InAppPurchase.instance
249249

250250
### Confirming subscription price changes
251251

252-
When the price of a subscription is changed the consumer will need to confirm that price change. If the consumer does not
253-
confirm the price change the subscription will not be auto-renewed. By default on both iOS and Android the consumer will
252+
When the price of a subscription is changed the consumer will need to confirm that price change. If the consumer does not
253+
confirm the price change the subscription will not be auto-renewed. By default on both iOS and Android the consumer will
254254
automatically get a popup to confirm the price change, but App developers can override this mechanism and show the popup on a later moment so it doesn't interrupt the critical flow of the App. This works different on the Apple App Store and on the Google Play Store.
255255

256256
#### Google Play Store (Android)
257-
When the subscription price is raised, the consumer should approve the price change within 7 days. The official
257+
When the subscription price is raised, the consumer should approve the price change within 7 days. The official
258258
documentation can be found [here](https://support.google.com/googleplay/android-developer/answer/140504?hl=en#zippy=%2Cprice-changes).
259259
When the price is lowered the consumer will automatically receive the lower price and does not have to approve the price change.
260260

261261
After 7 days the consumer will be notified through email and notifications on Google Play to agree with the new price. App developers have 7 days to explain the consumer that the price is going to change and ask them to accept this change. App developers have to keep track of whether or not the price change is already accepted within the app or in the backend. The [Google Play API](https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions) can be used to check whether or not the price change is accepted by the consumer by reading the `priceChange` property on a subscription object.
262262

263-
The `InAppPurchaseAndroidPlatformAddition` can be used to show the price change confirmation flow. The additions contain the function `launchPriceChangeConfirmationFlow` which needs the SKU code of the subscription.
263+
The `InAppPurchaseAndroidPlatformAddition` can be used to show the price change confirmation flow. The additions contain the function `launchPriceChangeConfirmationFlow` which needs the SKU code of the subscription.
264264

265265
```dart
266266
//import for InAppPurchaseAndroidPlatformAddition
@@ -272,7 +272,7 @@ if (Platform.isAndroid) {
272272
final InAppPurchaseAndroidPlatformAddition androidAddition =
273273
_inAppPurchase
274274
.getPlatformAddition<InAppPurchaseAndroidPlatformAddition>();
275-
var priceChangeConfirmationResult =
275+
var priceChangeConfirmationResult =
276276
await androidAddition.launchPriceChangeConfirmationFlow(
277277
sku: 'purchaseId',
278278
);
@@ -286,43 +286,43 @@ if (Platform.isAndroid) {
286286

287287
#### Apple App Store (iOS)
288288

289-
When the price of a subscription is raised iOS will also show a popup in the app.
289+
When the price of a subscription is raised iOS will also show a popup in the app.
290290
The StoreKit Payment Queue will notify the app that it wants to show a price change confirmation popup.
291-
By default the queue will get the response that it can continue and show the popup.
292-
However, it is possible to prevent this popup via the InAppPurchaseIosPlatformAddition and show the
291+
By default the queue will get the response that it can continue and show the popup.
292+
However, it is possible to prevent this popup via the 'InAppPurchaseStoreKitPlatformAddition' and show the
293293
popup at a different time, for example after clicking a button.
294294

295295
To know when the App Store wants to show a popup and prevent this from happening a queue delegate can be registered.
296-
The `InAppPurchaseIosPlatformAddition` contains a `setDelegate(SKPaymentQueueDelegateWrapper? delegate)` function that
296+
The `InAppPurchaseStoreKitPlatformAddition` contains a `setDelegate(SKPaymentQueueDelegateWrapper? delegate)` function that
297297
can be used to set a delegate or remove one by setting it to `null`.
298298
```dart
299-
//import for InAppPurchaseIosPlatformAddition
300-
import 'package:in_app_purchase_ios/in_app_purchase_ios.dart';
299+
//import for InAppPurchaseStoreKitPlatformAddition
300+
import 'package:in_app_purchase_storekit/in_app_purchase_storekit.dart';
301301
302302
Future<void> initStoreInfo() async {
303303
if (Platform.isIOS) {
304304
var iosPlatformAddition = _inAppPurchase
305-
.getPlatformAddition<InAppPurchaseIosPlatformAddition>();
306-
await iosPlatformAddition.setDelegate(ExamplePaymentQueueDelegate());
305+
.getPlatformAddition<InAppPurchaseStoreKitPlatformAddition>();
306+
await iosPlatformAddition.setDelegate(ExamplePaymentQueueDelegate());
307307
}
308308
}
309309
310310
@override
311311
Future<void> disposeStore() {
312312
if (Platform.isIOS) {
313313
var iosPlatformAddition = _inAppPurchase
314-
.getPlatformAddition<InAppPurchaseIosPlatformAddition>();
314+
.getPlatformAddition<InAppPurchaseStoreKitPlatformAddition>();
315315
await iosPlatformAddition.setDelegate(null);
316316
}
317317
}
318318
```
319-
The delegate that is set should implement `SKPaymentQueueDelegateWrapper` and handle `shouldContinueTransaction` and
319+
The delegate that is set should implement `SKPaymentQueueDelegateWrapper` and handle `shouldContinueTransaction` and
320320
`shouldShowPriceConsent`. When setting `shouldShowPriceConsent` to false the default popup will not be shown and the app
321321
needs to show this later.
322322

323323
```dart
324324
// import for SKPaymentQueueDelegateWrapper
325-
import 'package:in_app_purchase_ios/store_kit_wrappers.dart';
325+
import 'package:in_app_purchase_storekit/store_kit_wrappers.dart';
326326
327327
class ExamplePaymentQueueDelegate implements SKPaymentQueueDelegateWrapper {
328328
@override
@@ -338,20 +338,20 @@ class ExamplePaymentQueueDelegate implements SKPaymentQueueDelegateWrapper {
338338
}
339339
```
340340

341-
The dialog can be shown by calling `showPriceConsentIfNeeded` on the `InAppPurchaseIosPlatformAddition`. This future
341+
The dialog can be shown by calling `showPriceConsentIfNeeded` on the `InAppPurchaseStoreKitPlatformAddition`. This future
342342
will complete immediately when the dialog is shown. A confirmed transaction will be delivered on the `purchaseStream`.
343343
```dart
344344
if (Platform.isIOS) {
345-
var iapIosPlatformAddition = _inAppPurchase
346-
.getPlatformAddition<InAppPurchaseIosPlatformAddition>();
347-
await iapIosPlatformAddition.showPriceConsentIfNeeded();
345+
var iapStoreKitPlatformAddition = _inAppPurchase
346+
.getPlatformAddition<InAppPurchaseStoreKitPlatformAddition>();
347+
await iapStoreKitPlatformAddition.showPriceConsentIfNeeded();
348348
}
349349
```
350350

351351
### Accessing platform specific product or purchase properties
352352

353-
The function `_inAppPurchase.queryProductDetails(productIds);` provides a `ProductDetailsResponse` with a
354-
list of purchasable products of type `List<ProductDetails>`. This `ProductDetails` class is a platform independent class
353+
The function `_inAppPurchase.queryProductDetails(productIds);` provides a `ProductDetailsResponse` with a
354+
list of purchasable products of type `List<ProductDetails>`. This `ProductDetails` class is a platform independent class
355355
containing properties only available on all endorsed platforms. However, in some cases it is necessary to access platform specific properties. The `ProductDetails` instance is of subtype `GooglePlayProductDetails`
356356
when the platform is Android and `AppStoreProductDetails` on iOS. Accessing the skuDetails (on Android) or the skProduct (on iOS) provides all the information that is available in the original platform objects.
357357

@@ -371,20 +371,20 @@ if (productDetails is GooglePlayProductDetails) {
371371
And this is the way to get the subscriptionGroupIdentifier of a subscription on iOS:
372372
```dart
373373
//import for AppStoreProductDetails
374-
import 'package:in_app_purchase_ios/in_app_purchase_ios.dart';
374+
import 'package:in_app_purchase_storekit/in_app_purchase_storekit.dart';
375375
//import for SKProductWrapper
376-
import 'package:in_app_purchase_ios/store_kit_wrappers.dart';
376+
import 'package:in_app_purchase_storekit/store_kit_wrappers.dart';
377377
378378
if (productDetails is AppStoreProductDetails) {
379379
SKProductWrapper skProduct = (productDetails as AppStoreProductDetails).skProduct;
380380
print(skProduct.subscriptionGroupIdentifier);
381381
}
382382
```
383383

384-
The `purchaseStream` provides objects of type `PurchaseDetails`. PurchaseDetails' provides all
385-
information that is available on all endorsed platforms, such as purchaseID and transactionDate. In addition, it is
386-
possible to access the platform specific properties. The `PurchaseDetails` object is of subtype `GooglePlayPurchaseDetails`
387-
when the platform is Android and `AppStorePurchaseDetails` on iOS. Accessing the billingClientPurchase, resp.
384+
The `purchaseStream` provides objects of type `PurchaseDetails`. PurchaseDetails' provides all
385+
information that is available on all endorsed platforms, such as purchaseID and transactionDate. In addition, it is
386+
possible to access the platform specific properties. The `PurchaseDetails` object is of subtype `GooglePlayPurchaseDetails`
387+
when the platform is Android and `AppStorePurchaseDetails` on iOS. Accessing the billingClientPurchase, resp.
388388
skPaymentTransaction provides all the information that is available in the original platform objects.
389389

390390
This is an example on how to get the `originalJson` on Android:
@@ -403,17 +403,17 @@ if (purchaseDetails is GooglePlayPurchaseDetails) {
403403
How to get the `transactionState` of a purchase in iOS:
404404
```dart
405405
//import for AppStorePurchaseDetails
406-
import 'package:in_app_purchase_ios/in_app_purchase_ios.dart';
406+
import 'package:in_app_purchase_storekit/in_app_purchase_storekit.dart';
407407
//import for SKProductWrapper
408-
import 'package:in_app_purchase_ios/store_kit_wrappers.dart';
408+
import 'package:in_app_purchase_storekit/store_kit_wrappers.dart';
409409
410410
if (purchaseDetails is AppStorePurchaseDetails) {
411411
SKPaymentTransactionWrapper skProduct = (purchaseDetails as AppStorePurchaseDetails).skPaymentTransaction;
412412
print(skProduct.transactionState);
413413
}
414414
```
415415

416-
Please note that it is required to import `in_app_purchase_android` and/or `in_app_purchase_ios`.
416+
Please note that it is required to import `in_app_purchase_android` and/or `in_app_purchase_storekit`.
417417

418418
### Presenting a code redemption sheet (iOS 14)
419419

@@ -422,15 +422,15 @@ codes that you've set up in App Store Connect. For more information on
422422
redeeming offer codes, see [Implementing Offer Codes in Your App](https://developer.apple.com/documentation/storekit/in-app_purchase/subscriptions_and_offers/implementing_offer_codes_in_your_app).
423423

424424
```dart
425-
InAppPurchaseIosPlatformAddition iosPlatformAddition =
426-
InAppPurchase.getPlatformAddition<InAppPurchaseIosPlatformAddition>();
425+
InAppPurchaseStoreKitPlatformAddition iosPlatformAddition =
426+
InAppPurchase.getPlatformAddition<InAppPurchaseStoreKitPlatformAddition>();
427427
iosPlatformAddition.presentCodeRedemptionSheet();
428428
```
429429

430-
> **note:** The `InAppPurchaseIosPlatformAddition` is defined in the `in_app_purchase_ios.dart`
431-
> file so you need to import it into the file you will be using `InAppPurchaseIosPlatformAddition`:
430+
> **note:** The `InAppPurchaseStoreKitPlatformAddition` is defined in the `in_app_purchase_storekit.dart`
431+
> file so you need to import it into the file you will be using `InAppPurchaseStoreKitPlatformAddition`:
432432
> ```dart
433-
> import 'package:in_app_purchase_ios/in_app_purchase_ios.dart';
433+
> import 'package:in_app_purchase_storekit/in_app_purchase_storekit.dart';
434434
> ```
435435
436436
## Contributing to this plugin

packages/in_app_purchase/in_app_purchase/example/lib/main.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import 'package:flutter/material.dart';
99
import 'package:in_app_purchase/in_app_purchase.dart';
1010
import 'package:in_app_purchase_android/billing_client_wrappers.dart';
1111
import 'package:in_app_purchase_android/in_app_purchase_android.dart';
12-
import 'package:in_app_purchase_ios/in_app_purchase_ios.dart';
13-
import 'package:in_app_purchase_ios/store_kit_wrappers.dart';
12+
import 'package:in_app_purchase_storekit/in_app_purchase_storekit.dart';
13+
import 'package:in_app_purchase_storekit/store_kit_wrappers.dart';
1414
import 'consumable_store.dart';
1515

1616
void main() {
@@ -88,7 +88,7 @@ class _MyAppState extends State<_MyApp> {
8888

8989
if (Platform.isIOS) {
9090
var iosPlatformAddition = _inAppPurchase
91-
.getPlatformAddition<InAppPurchaseIosPlatformAddition>();
91+
.getPlatformAddition<InAppPurchaseStoreKitPlatformAddition>();
9292
await iosPlatformAddition.setDelegate(ExamplePaymentQueueDelegate());
9393
}
9494

@@ -137,7 +137,7 @@ class _MyAppState extends State<_MyApp> {
137137
void dispose() {
138138
if (Platform.isIOS) {
139139
var iosPlatformAddition = _inAppPurchase
140-
.getPlatformAddition<InAppPurchaseIosPlatformAddition>();
140+
.getPlatformAddition<InAppPurchaseStoreKitPlatformAddition>();
141141
iosPlatformAddition.setDelegate(null);
142142
}
143143
_subscription.cancel();
@@ -477,9 +477,9 @@ class _MyAppState extends State<_MyApp> {
477477
}
478478
}
479479
if (Platform.isIOS) {
480-
var iapIosPlatformAddition = _inAppPurchase
481-
.getPlatformAddition<InAppPurchaseIosPlatformAddition>();
482-
await iapIosPlatformAddition.showPriceConsentIfNeeded();
480+
var iapStoreKitPlatformAddition = _inAppPurchase
481+
.getPlatformAddition<InAppPurchaseStoreKitPlatformAddition>();
482+
await iapStoreKitPlatformAddition.showPriceConsentIfNeeded();
483483
}
484484
}
485485

packages/in_app_purchase/in_app_purchase/lib/in_app_purchase.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:flutter/foundation.dart';
66
import 'package:flutter/material.dart';
77
import 'package:in_app_purchase_platform_interface/in_app_purchase_platform_interface.dart';
88
import 'package:in_app_purchase_android/in_app_purchase_android.dart';
9-
import 'package:in_app_purchase_ios/in_app_purchase_ios.dart';
9+
import 'package:in_app_purchase_storekit/in_app_purchase_storekit.dart';
1010

1111
export 'package:in_app_purchase_platform_interface/in_app_purchase_platform_interface.dart'
1212
show
@@ -36,7 +36,7 @@ class InAppPurchase implements InAppPurchasePlatformAdditionProvider {
3636
if (defaultTargetPlatform == TargetPlatform.android) {
3737
InAppPurchaseAndroidPlatform.registerPlatform();
3838
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
39-
InAppPurchaseIosPlatform.registerPlatform();
39+
InAppPurchaseStoreKitPlatform.registerPlatform();
4040
}
4141

4242
_instance = InAppPurchase._();

packages/in_app_purchase/in_app_purchase/pubspec.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ description: A Flutter plugin for in-app purchases. Exposes APIs for making in-a
33
repository: https://github.com/flutter/plugins/tree/master/packages/in_app_purchase/in_app_purchase
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
55
version: 1.0.9
6+
# Temporarily disable publishing until in_app_purchase_storekit is published.
7+
publish_to: none
68

79
environment:
810
sdk: ">=2.12.0 <3.0.0"
@@ -14,14 +16,16 @@ flutter:
1416
android:
1517
default_package: in_app_purchase_android
1618
ios:
17-
default_package: in_app_purchase_ios
19+
default_package: in_app_purchase_storekit
1820

1921
dependencies:
2022
flutter:
2123
sdk: flutter
2224
in_app_purchase_platform_interface: ^1.0.0
2325
in_app_purchase_android: ^0.1.5
24-
in_app_purchase_ios: ^0.1.3+5
26+
# Temporary path-based dependency to allow for renaming.
27+
in_app_purchase_storekit:
28+
path: ../in_app_purchase_storekit
2529

2630
dev_dependencies:
2731
flutter_driver:

0 commit comments

Comments
 (0)