# flutter_inapp_purchase
[![Pub Version](https://img.shields.io/pub/v/flutter_inapp_purchase.svg?style=flat-square)](https://pub.dartlang.org/packages/flutter_inapp_purchase)
[![Build Status](https://travis-ci.com/dooboolab/flutter_inapp_purchase.svg?branch=master)](https://travis-ci.com/dooboolab/flutter_inapp_purchase)
![License](https://img.shields.io/badge/license-MIT-blue.svg)
[![Coverage Status](https://coveralls.io/repos/github/dooboolab/flutter_inapp_purchase/badge.svg?branch=master)](https://coveralls.io/github/dooboolab/flutter_inapp_purchase?branch=master)
## Flutter V2
This packages is compatible with flutter v2 from `4.0.0`. For those who use older version please use `< 4.0.0`.
## Sun Rise :sunrise:
Since many one of you wanted me to keep working on this plugin in [#93](https://github.com/dooboolab/flutter_inapp_purchase/issues/93), I've decided to keep working on current project. I hope many one of you can help me maintain this. Thank you for all your supports in advance :tada:.
~~## Deprecated
I've been maintaining this plugin since there wasn't an official plugin out when I implemented it. I saw in `flutter` github [issue #9591](https://github.com/flutter/flutter/issues/9591) that many people have been waiting for this plugin for more than a year before I've thought of building one. However, there has been an official `Google` plugin rised today which is [in_app_purchase](https://pub.dev/packages/in_app_purchase). Please try to use an official one because you might want to get much prompt support from giant `Google`.
Also, thanks for all your supports that made me stubborn to work hard on this plugin. I've had great experience with all of you and hope we can meet someday with other projects.
I'll leave this project as live for those who need time. I'll also try to merge the new `PR`'s and publish to `pub` if there's any further work given to this repo.~~
## What this plugin do
This is an `In App Purchase` plugin for flutter. This project has been `forked` from [react-native-iap](https://github.com/dooboolab/react-native-iap). We are trying to share same experience of `in-app-purchase` in `flutter` as in `react-native`.
We will keep working on it as time goes by just like we did in `react-native-iap`.
`PR` is always welcomed.
## Breaking Changes
* Sunrise in `2.0.0` for highly requests from customers on discomfort in what's called an `official` plugin [in_app_purchase](https://pub.dev/packages/in_app_purchase).
* Migrated to Android X in `0.9.0`. Please check the [Migration Guide](#migration-guide).
* There was parameter renaming in `0.5.0` to identify different parameters sent from the device. Please check the readme.
## Migration Guide
To migrate to `0.9.0` you must migrate your Android app to Android X by following the [Migrating to AndroidX Guide](https://developer.android.com/jetpack/androidx/migrate).
## Getting Started
Follow the [Medium Blog](https://medium.com/@dooboolab/flutter-in-app-purchase-7a3fb9345e2a) for the configuration.
Follow the [Medium Blog](https://medium.com/bosc-tech-labs-private-limited/how-to-implement-subscriptions-in-app-purchase-in-flutter-7ce8906e608a) to add **subscriptions** in app purchase.
For help getting started with Flutter, view our online
[documentation](https://flutter.io/).
For help on editing plugin code, view the [documentation](https://flutter.io/developing-packages/#edit-plugin-package).
## Methods
| Func | Param | Return | Description |
| :------------ |:---------------:| :---------------:| :-----|
| initConnection | | `String` | Prepare IAP module. Must be called on Android before any other purchase flow methods. In ios, it will simply call `canMakePayments` method and return value.|
| getProducts | `List<String>` Product IDs/skus | `List<IAPItem>` | Get a list of products (consumable and non-consumable items, but not subscriptions). Note: On iOS versions earlier than 11.2 this method _will_ return subscriptions if they are included in your list of SKUs. This is because we cannot differentiate between IAP products and subscriptions prior to 11.2. |
| getSubscriptions | `List<String>` Subscription IDs/skus | `List<IAPItem>` | Get a list of subscriptions. Note: On iOS this method has the same output as `getProducts`. Because iOS does not differentiate between IAP products and subscriptions. |
| getPurchaseHistory | | `List<IAPItem>` | Gets an invetory of purchases made by the user regardless of consumption status (where possible) |
| getAvailablePurchases | | `List<PurchasedItem>` | (aka restore purchase) Get all purchases made by the user (either non-consumable, or haven't been consumed yet)
| getAppStoreInitiatedProducts | | `List<IAPItem>` | If the user has initiated a purchase directly on the App Store, the products that the user is attempting to purchase will be returned here. (iOS only) Note: On iOS versions earlier than 11.0 this method will always return an empty list, as the functionality was introduced in v11.0. [See Apple Docs for more info](https://developer.apple.com/documentation/storekit/skpaymenttransactionobserver/2877502-paymentqueue) Always returns an empty list on Android.
| requestSubscription | `String` sku, `String` oldSkuAndroid?, `int` prorationModeAndroid?, `String` obfuscatedAccountIdAndroid?, `String` obfuscatedProfileIdAndroid?, `String` purchaseTokenAndroid? | Null | Create (request) a subscription to a sku. For upgrading/downgrading subscription on Android pass second parameter with current subscription ID, on iOS this is handled automatically by store. `purchaseUpdatedListener` will receive the result. |
| requestPurchase | `String` sku, `String` obfuscatedAccountIdAndroid?, `String` obfuscatedProfileIdAndroid?, `String` purchaseToken? | Null | Request a purchase. `purchaseUpdatedListener` will receive the result. |
| finishTransactionIOS | `String` purchaseTokenAndroid | `PurchaseResult` | Send finishTransaction call to Apple IAP server. Call this function after receipt validation process |
| acknowledgePurchaseAndroid | `String` purchaseToken | `PurchaseResult` | Acknowledge a product (on Android) for `non-consumable` and `subscription` purchase. No-op on iOS. |
| consumePurchaseAndroid | `String` purchaseToken | `PurchaseResult` | Consume a product (on Android) for `consumable` purchase. No-op on iOS. |
| finishTransaction | `String` purchaseToken, `bool` isConsumable? } | `PurchaseResult` | Send finishTransaction call that abstracts all `acknowledgePurchaseAndroid`, `finishTransactionIOS`, `consumePurchaseAndroid` methods. |
| endConnection | | `String` | End billing connection. |
| consumeAllItems | | `String` | Manually consume all items in android. Do NOT call if you have any non-consumables (one time purchase items). No-op on iOS. |
| validateReceiptIos | `Map<String,String>` receiptBody, `bool` isTest | `http.Response` | Validate receipt for ios. |
| validateReceiptAndroid | `String` packageName, `String` productId, `String` productToken, `String` accessToken, `bool` isSubscription | `http.Response` | Validate receipt for android. |
Purchase flow in `flutter_inapp_purchase@2.0.0+
-----------------
![purchase-flow-sequence](https://github.com/dooboolab/react-native-iap/blob/master/docs/react-native-iapv3.svg)
> When you've successfully received result from `purchaseUpdated` listener, you'll have to `verify` the purchase either by `acknowledgePurchaseAndroid`, `consumePurchaseAndroid`, `finishTransactionIOS` depending on the purchase types or platforms. You'll have to use `consumePurchaseAndroid` for `consumable` products and `android` and `acknowledgePurchaseAndroid` for `non-consumable` products either `subscription`. For `ios`, there is no differences in `verifying` purchases. You can just call `finishTransaction`. If you do not verify the purchase, it will be refunded within 3 days to users. We recommend you to `verifyReceipt` first before actually finishing transaction. Lastly, if you want to abstract three different methods
没有合适的资源?快使用搜索试试~ 我知道了~
flutter_inapp_purchase
共102个文件
png:23个
dart:7个
java:6个
需积分: 50 3 下载量 46 浏览量
2021-03-25
18:48:25
上传
评论
收藏 271KB ZIP 举报
温馨提示
flutter_inapp_purchase Flutter V2 该软件包与4.0.0 flutter v2兼容。 对于使用旧版本的用户,请使用< 4.0.0 。 太阳升起 :sunrise: 由于你们中的许多人都希望我在继续使用此插件,因此我决定继续从事当前项目。 我希望你们中的许多人可以帮助我保持这一点。 预先感谢您的支持 :party_popper: 。 ##不推荐使用我一直在维护此插件,因为在实现它时没有官方的插件。 我在flutter github中看到,很多人在我想构建一个插件之前已经等待了一年多。 但是,今天出现了一个正式的Google插件 。 请尝试使用正式版,因为您可能希望得到巨型Google大量及时支持。 另外,感谢您的所有支持,使我强地致力于此插件的工作。 我在所有人中都有丰富的经验,希望我们有一天能与其他项目会面。 对于需要时间的人,我将保留该项目。 如果对此仓库有任何进一步的工作,我还将尝试合并新
资源详情
资源评论
资源推荐
收起资源包目录
flutter_inapp_purchase (102个子文件)
gradlew.bat 2KB
flutter_inapp_purchase_test.dart 51KB
flutter_inapp_purchase.dart 22KB
main.dart 13KB
modules.dart 13KB
utils.dart 1KB
widget_test.dart 954B
utils_test.dart 317B
.gitignore 512B
.gitignore 360B
.gitignore 183B
.gitignore 136B
.gitignore 97B
.gitignore 65B
.gitkeep 0B
build.gradle 2KB
build.gradle 717B
settings.gradle 484B
build.gradle 470B
settings.gradle 44B
gradlew 5KB
IAPPromotionObserver.h 552B
FlutterInappPurchasePlugin.h 259B
AppDelegate.h 103B
flutter_inapp_purchase_android.iml 2KB
flutter_inapp_purchase_example_android.iml 1KB
flutter_inapp_purchase_example.iml 896B
in-app-purchasing-2.0.76.jar 98KB
gradle-wrapper.jar 52KB
AndroidInappPurchasePlugin.java 22KB
AmazonInappPurchasePlugin.java 11KB
FlutterInappPurchasePlugin.java 5KB
DoobooUtils.java 3KB
MainActivity.java 369B
MainActivity.java 363B
Contents.json 2KB
amazon.sdktester.json 921B
Contents.json 391B
.last_build_id 32B
LICENSE 1KB
Podfile.lock 578B
FlutterInappPurchasePlugin.m 33KB
IAPPromotionObserver.m 1KB
AppDelegate.m 424B
main.m 226B
README.md 17KB
README.md 13KB
CHANGELOG.md 9KB
KINDLE.md 2KB
README.md 336B
issue_template.md 229B
.metadata 283B
project.pbxproj 19KB
Info.plist 1KB
AppFrameworkInfo.plist 773B
IDEWorkspaceChecks.plist 238B
Icon-App-1024x1024@1x.png 11KB
Icon-App-60x60@3x.png 4KB
Icon-App-83.5x83.5@2x.png 4KB
Icon-App-76x76@2x.png 3KB
Icon-App-40x40@3x.png 3KB
Icon-App-60x60@2x.png 3KB
Icon-App-29x29@3x.png 2KB
Icon-App-40x40@2x.png 2KB
Icon-App-76x76@1x.png 2KB
Icon-App-29x29@2x.png 2KB
Icon-App-20x20@3x.png 2KB
ic_launcher.png 1KB
Icon-App-40x40@1x.png 1KB
Icon-App-20x20@2x.png 1KB
ic_launcher.png 1KB
Icon-App-29x29@1x.png 1KB
ic_launcher.png 721B
Icon-App-20x20@1x.png 564B
ic_launcher.png 544B
ic_launcher.png 442B
LaunchImage@2x.png 68B
LaunchImage.png 68B
LaunchImage@3x.png 68B
Podfile 2KB
flutter_inapp_purchase.podspec 926B
Flutter.podspec 758B
gradle-wrapper.properties 234B
gradle.properties 104B
gradle.properties 82B
LaunchScreen.storyboard 2KB
Main.storyboard 2KB
Release.xcconfig 108B
Debug.xcconfig 106B
Runner.xcscheme 3KB
contents.xcworkspacedata 224B
contents.xcworkspacedata 152B
AndroidManifest.xml 2KB
launch_background.xml 434B
styles.xml 361B
AndroidManifest.xml 129B
pubspec.yaml 2KB
pubspec.yaml 2KB
analysis_options.yaml 76B
.travis.yml 3KB
共 102 条
- 1
- 2
是十五呀
- 粉丝: 23
- 资源: 4635
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0