forked from flutter/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Doc and build script updates to the IAP plugin (flutter#1024)
Updates the example app README with all the steps required for enabling the IAP APIs in Google Play and the App Store. Also adds a bit to the plugin's generic README. Changes the example app's android build script so that it requires the package ID to be changed and signing keys added in order for it to be ran. Users will need to set up their own package ID and signing keys for the example app to work with `BillingClient`. Also adds `StoreKit` and enables in app purchases to the XCode project. flutter/flutter#25987
- Loading branch information
Michael Klimushyn
authored
Jan 7, 2019
1 parent
fe834b6
commit 809ccde
Showing
7 changed files
with
190 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,32 @@ | ||
# In App Purchase | ||
|
||
A Flutter plugin for in-app purchases. | ||
|
||
## Getting Started | ||
|
||
This plugin is not ready to be used yet. Follow | ||
[flutter/flutter#9591](https://github.com/flutter/flutter/issues/9591) for more | ||
updates. | ||
updates. | ||
|
||
There's a significant amount of setup required for testing in app purchases | ||
successfully, including registering new app IDs and store entries to use for | ||
testing in both the Play Developer Console and App Store Connect. Both Google | ||
Play and the App Store require developers to configure an app with in-app items | ||
for purchase to call their in-app-purchase APIs. You can check out the [example | ||
app](example/README.md) for an example on configuring both. | ||
|
||
## Design | ||
|
||
The API surface is stacked into 2 main layers. | ||
|
||
1. [in_app_purchase.dart](lib/in_app_purchase.dart), the generic idiommatic | ||
Flutter API. This exposes the most basic IAP-related functionality. The goal | ||
is that Flutter apps should be able to use this API surface on its own for | ||
the vast majority of cases. | ||
|
||
2. The dart wrappers around the platform specific IAP APIs and their platform | ||
specific implementations of the generic interface. See | ||
[google_play.dart](lib/google_play.dart) and | ||
[app_store.dart](lib/app_store.dart). These API surfaces should expose all | ||
the platform-specific behavior and allow for more fine-tuned control when | ||
needed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,7 @@ android { | |
disable 'InvalidPackage' | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation 'com.android.billingclient:billing:1.2' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,85 @@ | ||
# in_app_purchase_example | ||
# In App Purchase Example | ||
|
||
Demonstrates how to use the in_app_purchase plugin. | ||
Demonstrates how to use the In App Purchase (IAP) Plugin. | ||
|
||
## Getting Started | ||
|
||
For help getting started with Flutter, view our online | ||
[documentation](https://flutter.io/). | ||
WARNING: This plugin and example are not ready to be used. Right now the example | ||
app doesn't actually demonstrate any IAP functionality yet. Follow | ||
[flutter/flutter#9591](https://github.com/flutter/flutter/issues/9591) for more | ||
updates. | ||
|
||
There's a significant amount of setup required for testing in app purchases | ||
successfully, including registering new app IDs and store entries to use for | ||
testing in both the Play Developer Console and App Store Connect. Both Google | ||
Play and the App Store require developers to configure an app with in-app items | ||
for purchase to call their in-app-purchase APIs. | ||
|
||
### Android | ||
|
||
1. Create a new app in the [Play Developer | ||
Console](https://play.google.com/apps/publish/) (PDC). | ||
|
||
2. Sign up for a merchant's account in the PDC. | ||
|
||
3. Create IAPs in the PDC available for purchase in the app. The example assumes | ||
the following SKU IDs exist: | ||
|
||
- `consumable`: A managed product. | ||
- `upgrade`: A managed product. | ||
- `subscription`: A subscription. | ||
|
||
Make sure that all of the products are set to `ACTIVE`. | ||
|
||
4. Update `APP_ID` in `example/android/app/build.gradle` to match your package | ||
ID in the PDC. | ||
|
||
5. Create an `example/android/keystore.properties` file with all your signing | ||
information. `keystore.example.properties` exists as an example to follow. | ||
It's impossible to use any of the `BillingClient` APIs from an unsigned APK. | ||
See | ||
[here](https://developer.android.com/studio/publish/app-signing#secure-shared-keystore) | ||
and [here](https://developer.android.com/studio/publish/app-signing#sign-apk) | ||
for more information. | ||
|
||
6. Build a signed apk. `flutter build apk` will work for this, the gradle files | ||
in this project have been configured to sign even debug builds. | ||
|
||
7. Upload the signed APK from step 6 to the PDC, and publish that to the alpha | ||
test channel. Add your test account as an approved tester. The | ||
`BillingClient` APIs won't work unless the app has been fully published to | ||
the alpha channel and is being used by an authorized test account. See | ||
[here](https://support.google.com/googleplay/android-developer/answer/3131213) | ||
for more info. | ||
|
||
8. Sign in to the test device with the test account from step #7. Then use | ||
`flutter run` to install the app to the device and test like normal. | ||
|
||
### iOS | ||
|
||
1. Follow ["Workflow for configuring in-app | ||
purchases"](https://help.apple.com/app-store-connect/#/devb57be10e7), a | ||
detailed guide on all the steps needed to enable IAPs for an app. Complete | ||
steps 1 ("Sign a Paid Applications Agreement") and 2 ("Configure in-app | ||
purchases"). | ||
|
||
For step #2, "Configure in-app purchases in App Store Connect," you'll want | ||
to create the following products: | ||
|
||
- A consumable with product ID `consumable` | ||
- An upgrade with product ID `upgrade` | ||
- An auto-renewing subscription with product ID `subscription` | ||
|
||
2. In XCode, `File > Open File` `example/ios/Runner.xcworkspace`. Update the | ||
Bundle ID to match the Bundle ID of the app created in step #1. | ||
|
||
3. [Create a Sandbox tester | ||
account](https://help.apple.com/app-store-connect/#/dev8b997bee1) to test the | ||
in-app purchases with. | ||
|
||
4. Use `flutter run` to install the app and test it. Note that you need to test | ||
it on a real device instead of a simulator, and signing into any production | ||
service (including iTunes!) with the test account will permanently invalidate | ||
it. Sign in to the test account in the example app following the steps in the | ||
[*In-App Purchase Programming | ||
Guide*](https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/ShowUI.html#//apple_ref/doc/uid/TP40008267-CH3-SW11). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
storePassword=??? | ||
keyPassword=??? | ||
keyAlias=??? | ||
storeFile=??? |