Skip to content

Commit

Permalink
Resolve #100 and release 2.0.0+8
Browse files Browse the repository at this point in the history
  • Loading branch information
hyochan committed Sep 27, 2019
1 parent b5a1093 commit 583f389
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 25 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 2.0.0+8
* Resolve [#100](https://github.com/dooboolab/flutter_inapp_purchase/issues/100).
## 2.0.0+7
* Resolve [#99](https://github.com/dooboolab/flutter_inapp_purchase/issues/99).
## 2.0.0+6
Expand Down
34 changes: 10 additions & 24 deletions lib/flutter_inapp_purchase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -346,21 +346,16 @@ class FlutterInappPurchase {
/// Acknowledge a purchase on `Android`.
///
/// No effect on `iOS`, whose iap purchases are consumed at the time of purchase.
Future<PurchaseResult> acknowledgePurchaseAndroid(String token, { String developerPayload }) async {
Future<String> acknowledgePurchaseAndroid(String token, { String developerPayload }) async {
if (_platform.isAndroid) {
String result = await _channel.invokeMethod('acknowledgePurchase', <String, dynamic>{
'token': token,
'developerPayload': developerPayload,
});

if (result == null) {
return null;
}

PurchaseResult decoded = json.decode(result);
return decoded;
return result;
} else if (_platform.isIOS) {
return PurchaseResult(debugMessage: 'no-ops in ios');
return 'no-ops in ios';
}
throw PlatformException(
code: _platform.operatingSystem, message: "platform not supported");
Expand All @@ -370,22 +365,16 @@ class FlutterInappPurchase {
/// Consumes a purchase on `Android`.
///
/// No effect on `iOS`, whose consumable purchases are consumed at the time of purchase.
Future<PurchaseResult> consumePurchaseAndroid(String token, { String developerPayload }) async {
Future<String> consumePurchaseAndroid(String token, { String developerPayload }) async {
if (_platform.isAndroid) {
String result =
await _channel.invokeMethod('consumeProduct', <String, dynamic>{
'token': token,
'developerPayload': developerPayload,
});

if (result == null) {
return null;
}

PurchaseResult decoded = json.decode(result);
return decoded;
return result;
} else if (_platform.isIOS) {
return PurchaseResult(debugMessage: 'no-ops in ios');
return 'no-ops in ios';
}
throw PlatformException(
code: _platform.operatingSystem, message: "platform not supported");
Expand Down Expand Up @@ -430,30 +419,27 @@ class FlutterInappPurchase {
/// Finish a transaction on both `android` and `iOS`.
///
/// Call this after finalizing server-side validation of the reciept.
Future<PurchaseResult> finishTransaction(String purchaseToken,
Future<String> finishTransaction(String purchaseToken,
{ String developerPayloadAndroid, bool isConsumable }) async {
if (_platform.isAndroid) {
if (isConsumable) {
String result = await _channel.invokeMethod('consumePurchase', <String, dynamic>{
'token': purchaseToken,
'developerPayload': developerPayloadAndroid,
});
PurchaseResult decoded = json.decode(result);
return decoded;
return result;
} else {
String result = await _channel.invokeMethod('acknowledgePurchase', <String, dynamic>{
'token': purchaseToken,
'developerPayload': developerPayloadAndroid,
});
PurchaseResult decoded = json.decode(result);
return decoded;
return result;
}
} else if (_platform.isIOS) {
String result = await _channel.invokeMethod('finishTransaction', <String, dynamic>{
'transactionIdentifier': purchaseToken,
});
PurchaseResult decoded = json.decode(result);
return decoded;
return result;
}
throw PlatformException(
code: _platform.operatingSystem, message: "platform not supported");
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_inapp_purchase
description: In App Purchase plugin for flutter. This project has been forked by react-native-iap and we are willing to share same experience with that on react-native.
version: 2.0.0+7
version: 2.0.0+8
author: dooboolab<dooboolab@gmail.com>
homepage: https://github.com/dooboolab/flutter_inapp_purchase/blob/master/pubspec.yaml
environment:
Expand Down

0 comments on commit 583f389

Please sign in to comment.