Skip to content

Commit 1a4cee7

Browse files
authored
[in_app_purchase] Federated Android implementation (flutter#3841)
* Implement BillingClientWrapper and unit-tests * Android specific implementation * Moved Android specific methods into addition class * Added missing line end * Purchases status to restored after call restorePurchases * Don't force GooglePlayPurchaseParam * Implement registerPlatform method * Added TODO comment to add example * Fixed mistake in API documentation * Added additional assert to test enablePendingPurchase * Update Android implementation with latest platform_interface
1 parent f06a2b4 commit 1a4cee7

Some content is hidden

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

46 files changed

+5591
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 0.1.0
2+
3+
* Initial open-source release.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright 2013 The Flutter Authors. All rights reserved.
2+
3+
Redistribution and use in source and binary forms, with or without modification,
4+
are permitted provided that the following conditions are met:
5+
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above
9+
copyright notice, this list of conditions and the following
10+
disclaimer in the documentation and/or other materials provided
11+
with the distribution.
12+
* Neither the name of Google Inc. nor the names of its
13+
contributors may be used to endorse or promote products derived
14+
from this software without specific prior written permission.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# in_app_purchase_android
2+
3+
The Android implementation of [`in_app_purchase`][1].
4+
5+
## Usage
6+
7+
### Import the package
8+
9+
This package has been endorsed, meaning that you only need to add `in_app_purchase`
10+
as a dependency in your `pubspec.yaml`. It will be automatically included in your app
11+
when you depend on `package:in_app_purchase`.
12+
13+
This is what the above means to your `pubspec.yaml`:
14+
15+
```yaml
16+
...
17+
dependencies:
18+
...
19+
in_app_purchase: ^0.6.0
20+
...
21+
```
22+
23+
If you wish to use the Android package only, you can add `in_app_purchase_android` as a
24+
dependency:
25+
26+
```yaml
27+
...
28+
dependencies:
29+
...
30+
in_app_purchase_android: ^1.0.0
31+
...
32+
```
33+
34+
## TODO
35+
- [ ] Add an example application demonstrating the use of the [in_app_purchase_android] package (see also issue [flutter/flutter#81695](https://github.com/flutter/flutter/issues/81695)).
36+
37+
38+
[1]: ../in_app_purchase/in_app_purchase
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: ../../../analysis_options_legacy.yaml
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
group 'io.flutter.plugins.inapppurchase'
2+
version '1.0-SNAPSHOT'
3+
4+
buildscript {
5+
repositories {
6+
google()
7+
jcenter()
8+
}
9+
10+
dependencies {
11+
classpath 'com.android.tools.build:gradle:3.3.0'
12+
}
13+
}
14+
15+
rootProject.allprojects {
16+
repositories {
17+
google()
18+
jcenter()
19+
}
20+
}
21+
22+
apply plugin: 'com.android.library'
23+
24+
android {
25+
compileSdkVersion 29
26+
27+
defaultConfig {
28+
minSdkVersion 16
29+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
30+
}
31+
lintOptions {
32+
disable 'InvalidPackage'
33+
}
34+
compileOptions {
35+
sourceCompatibility JavaVersion.VERSION_1_8
36+
targetCompatibility JavaVersion.VERSION_1_8
37+
}
38+
}
39+
40+
dependencies {
41+
implementation 'androidx.annotation:annotation:1.0.0'
42+
implementation 'com.android.billingclient:billing:3.0.2'
43+
testImplementation 'junit:junit:4.12'
44+
testImplementation 'org.json:json:20180813'
45+
testImplementation 'org.mockito:mockito-core:3.6.0'
46+
androidTestImplementation 'androidx.test:runner:1.1.1'
47+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
48+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.gradle.jvmargs=-Xmx1536M
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Mon Oct 29 10:30:44 PDT 2018
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'in_app_purchase'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="io.flutter.plugins.inapppurchase">
3+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
package io.flutter.plugins.inapppurchase;
6+
7+
import android.content.Context;
8+
import androidx.annotation.NonNull;
9+
import com.android.billingclient.api.BillingClient;
10+
import io.flutter.plugin.common.MethodChannel;
11+
12+
/** Responsible for creating a {@link BillingClient} object. */
13+
interface BillingClientFactory {
14+
15+
/**
16+
* Creates and returns a {@link BillingClient}.
17+
*
18+
* @param context The context used to create the {@link BillingClient}.
19+
* @param channel The method channel used to create the {@link BillingClient}.
20+
* @param enablePendingPurchases Whether to enable pending purchases. Throws an exception if it is
21+
* false.
22+
* @return The {@link BillingClient} object that is created.
23+
*/
24+
BillingClient createBillingClient(
25+
@NonNull Context context, @NonNull MethodChannel channel, boolean enablePendingPurchases);
26+
}

0 commit comments

Comments
 (0)