forked from flutter-tizen/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.
[in_app_purchase] Add in_app_purchase package (flutter-tizen#562)
Co-authored-by: Swift Kim <[email protected]>
- Loading branch information
Showing
35 changed files
with
2,874 additions
and
0 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
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,7 @@ | ||
.DS_Store | ||
.dart_tool/ | ||
|
||
.packages | ||
.pub/ | ||
|
||
build/ |
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,3 @@ | ||
## 0.1.0 | ||
|
||
* Initial release. |
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,26 @@ | ||
Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved. | ||
Copyright (c) 2013 The Flutter Authors. All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
* Neither the names of the copyright holders nor the names of the | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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,79 @@ | ||
# in_app_purchase_tizen | ||
|
||
The Tizen implementation of [`in_app_purchase`](https://pub.dev/packages/in_app_purchase) based on the [Samsung Checkout](https://developer.samsung.com/smarttv/develop/guides/samsung-checkout/samsung-checkout.html) API. | ||
|
||
## Supported devices | ||
|
||
This plugin is only supported on Samsung Smart TVs running Tizen 5.5 and above. | ||
|
||
## Required privileges | ||
|
||
To use this plugin in a Tizen application, you need to declare the following privileges in your `tizen-manifest.xml` file. | ||
|
||
```xml | ||
<privileges> | ||
<privilege>http://developer.samsung.com/privilege/billing</privilege> | ||
<privilege>http://developer.samsung.com/privilege/sso.partner</privilege> | ||
<privilege>http://tizen.org/privilege/appmanager.launch</privilege> | ||
</privileges> | ||
``` | ||
|
||
The sso.partner privilege is required by the [Sso API](https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/sso-api.html) to internally obtain the user's custom ID (UID). Your app must be signed with a [partner-level certificate](https://docs.tizen.org/application/dotnet/get-started/certificates/creating-certificates) to use this privilege. | ||
|
||
## Preparation | ||
|
||
Follow these steps before setting up in-app purchases for your application: | ||
|
||
1. [Register your application](https://github.com/flutter-tizen/flutter-tizen/blob/master/doc/publish-app.md) at the [Samsung Apps TV Seller Office](https://seller.samsungapps.com/tv) if you haven't registered yet. You do not need to complete the registration process at this point. Go to the **Billing Info** page of the app and set the **Samsung Checkout** checkbox to ON. You can return back to this page and finish the registration process when the final version of your app is ready. | ||
|
||
2. Log in to the [Samsung Checkout DPI Portal](https://dpi.samsungcheckout.com) and register your in-app items. You can find your **App ID** and **Security Key** in the [**App Details Setting**](https://dpi.samsungcheckout.com/settings/appdetails) page. These values will be used as request parameters in your app code. | ||
|
||
## Usage | ||
|
||
This package is not an _endorsed_ implementation of `in_app_purchase`. Therefore, you have to include `in_app_purchase_tizen` alongside `in_app_purchase` as dependencies in your `pubspec.yaml` file. | ||
|
||
```yaml | ||
dependencies: | ||
in_app_purchase: ^3.1.4 | ||
in_app_purchase_tizen: ^0.1.0 | ||
``` | ||
Then you can import `in_app_purchase` and `in_app_purchase_tizen` in your Dart code: | ||
|
||
```dart | ||
import 'package:in_app_purchase/in_app_purchase.dart'; | ||
import 'package:in_app_purchase_tizen/in_app_purchase_tizen.dart'; | ||
``` | ||
|
||
You must call `setRequestParameters` to set required parameters before making any plugin API call. | ||
|
||
```dart | ||
final InAppPurchaseTizenPlatformAddition platformAddition = _inAppPurchase | ||
.getPlatformAddition<InAppPurchaseTizenPlatformAddition>(); | ||
platformAddition.setRequestParameters( | ||
appId: 'your_dpi_app_id', | ||
pageSize: 20, | ||
pageNum: 1, | ||
securityKey: 'your_security_key', | ||
); | ||
final ProductDetailsResponse response = | ||
await _inAppPurchase.queryProductDetails(<String>{}); | ||
``` | ||
|
||
For detailed usage, see https://pub.dev/packages/in_app_purchase#usage and the [example](example/lib) app. | ||
|
||
For more information on the Samsung Checkout API, visit the following pages. | ||
|
||
- [Samsung Developers: Implementing the Purchase Process](https://developer.samsung.com/smarttv/develop/guides/samsung-checkout/implementing-the-purchase-process.html) | ||
- [Samsung Developers: Billing API References](https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html) | ||
|
||
## Supported APIs | ||
|
||
- [x] `InAppPurchase.purchaseStream` | ||
- [x] `InAppPurchase.isAvailable` | ||
- [x] `InAppPurchase.queryProductDetails` | ||
- [x] `InAppPurchase.buyNonConsumable` | ||
- [x] `InAppPurchase.buyConsumable` | ||
- [ ] `InAppPurchase.completePurchase` (Andriod/iOS-only) | ||
- [x] `InAppPurchase.restorePurchases` |
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,41 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
**/doc/api/ | ||
**/ios/Flutter/.last_build_id | ||
.dart_tool/ | ||
.flutter-plugins | ||
.flutter-plugins-dependencies | ||
.packages | ||
.pub-cache/ | ||
.pub/ | ||
/build/ | ||
|
||
# Web related | ||
lib/generated_plugin_registrant.dart | ||
|
||
# Symbolication related | ||
app.*.symbols | ||
|
||
# Obfuscation related | ||
app.*.map.json |
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,7 @@ | ||
# in_app_purchase_tizen_example | ||
|
||
Demonstrates how to use the in_app_purchase_tizen plugin. | ||
|
||
## Getting Started | ||
|
||
To run this app on your Tizen device, use [flutter-tizen](https://github.com/flutter-tizen/flutter-tizen). |
16 changes: 16 additions & 0 deletions
16
packages/in_app_purchase/example/integration_test/in_app_purchase_test.dart
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,16 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:in_app_purchase/in_app_purchase.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
|
||
void main() { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
testWidgets('Can create InAppPurchase instance', (WidgetTester tester) async { | ||
final InAppPurchase iapInstance = InAppPurchase.instance; | ||
expect(iapInstance, isNotNull); | ||
}); | ||
} |
Oops, something went wrong.