| @@ -43,6 +43,8 @@ public class MyketpaymentPlugin implements FlutterPlugin, MethodCallHandler, Act | |||||
| public String payload; | public String payload; | ||||
| public String sku; | public String sku; | ||||
| public boolean consume; | public boolean consume; | ||||
| public String purchasedSku; | |||||
| public boolean isPurchased = false; | |||||
| @@ -75,6 +77,9 @@ public class MyketpaymentPlugin implements FlutterPlugin, MethodCallHandler, Act | |||||
| else if (call.method.equals("buy")) { | else if (call.method.equals("buy")) { | ||||
| buy(call, result); | buy(call, result); | ||||
| } | } | ||||
| else if (call.method.equals("check")) { | |||||
| check(call, result); | |||||
| } | |||||
| else { | else { | ||||
| result.notImplemented(); | result.notImplemented(); | ||||
| } | } | ||||
| @@ -82,6 +87,10 @@ public class MyketpaymentPlugin implements FlutterPlugin, MethodCallHandler, Act | |||||
| public void setup(@NonNull MethodCall call, @NonNull Result result) { | public void setup(@NonNull MethodCall call, @NonNull Result result) { | ||||
| Log.d(TAG, call.argument("rsa").toString()); | Log.d(TAG, call.argument("rsa").toString()); | ||||
| Log.d(TAG, call.argument("purchasedSku").toString()); | |||||
| purchasedSku = call.argument("purchasedSku").toString(); | |||||
| // Create the helper, passing it our context and the public key to verify signatures with | // Create the helper, passing it our context and the public key to verify signatures with | ||||
| String base64EncodedPublicKey = call.argument("rsa").toString(); | String base64EncodedPublicKey = call.argument("rsa").toString(); | ||||
| Log.d(TAG, "Creating IAB helper."); | Log.d(TAG, "Creating IAB helper."); | ||||
| @@ -127,6 +136,10 @@ public class MyketpaymentPlugin implements FlutterPlugin, MethodCallHandler, Act | |||||
| mPurchaseFinishedListener, payload); | mPurchaseFinishedListener, payload); | ||||
| } | } | ||||
| public void check(@NonNull MethodCall call, @NonNull Result result) { | |||||
| _result.success(isPurchased); | |||||
| } | |||||
| // Listener that's called when we finish querying the items and subscriptions we own | // Listener that's called when we finish querying the items and subscriptions we own | ||||
| IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() { | IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() { | ||||
| @Override | @Override | ||||
| @@ -146,6 +159,14 @@ public class MyketpaymentPlugin implements FlutterPlugin, MethodCallHandler, Act | |||||
| return; | return; | ||||
| } | } | ||||
| Log.d(TAG, "Query inventory was successful."); | Log.d(TAG, "Query inventory was successful."); | ||||
| if(purchasedSku != "") { | |||||
| Purchase premiumPurchase = inventory.getPurchase(purchasedSku); | |||||
| isPurchased = (premiumPurchase != null && verifyDeveloperPayload(premiumPurchase)); | |||||
| Log.d(TAG, "User is " + (isPurchased ? "PREMIUM" : "NOT PREMIUM")); | |||||
| } | |||||
| _result.success(true); | _result.success(true); | ||||
| } | } | ||||
| @@ -69,6 +69,23 @@ class _MyAppState extends State<MyApp> { | |||||
| } | } | ||||
| }, | }, | ||||
| ), | ), | ||||
| SizedBox(height: 20,), | |||||
| FlatButton( | |||||
| child: Text("check purchase"), | |||||
| onPressed: () async { | |||||
| if(!setup) { | |||||
| setup = await Myketpayment.setup(rsa, purchasedSku: 'flunlimit'); | |||||
| } | |||||
| print("setup: $setup"); | |||||
| if(setup) { | |||||
| final result = await Myketpayment.check(); | |||||
| print("IsPurchased: $result"); | |||||
| } | |||||
| else { | |||||
| print("can not connect to myket"); | |||||
| } | |||||
| }, | |||||
| ), | |||||
| ], | ], | ||||
| ), | ), | ||||
| ), | ), | ||||
| @@ -7,7 +7,7 @@ packages: | |||||
| name: async | name: async | ||||
| url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
| source: hosted | source: hosted | ||||
| version: "2.5.0" | |||||
| version: "2.8.1" | |||||
| boolean_selector: | boolean_selector: | ||||
| dependency: transitive | dependency: transitive | ||||
| description: | description: | ||||
| @@ -28,7 +28,7 @@ packages: | |||||
| name: charcode | name: charcode | ||||
| url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
| source: hosted | source: hosted | ||||
| version: "1.2.0" | |||||
| version: "1.3.1" | |||||
| clock: | clock: | ||||
| dependency: transitive | dependency: transitive | ||||
| description: | description: | ||||
| @@ -80,7 +80,7 @@ packages: | |||||
| name: meta | name: meta | ||||
| url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
| source: hosted | source: hosted | ||||
| version: "1.3.0" | |||||
| version: "1.7.0" | |||||
| myketpayment: | myketpayment: | ||||
| dependency: "direct main" | dependency: "direct main" | ||||
| description: | description: | ||||
| @@ -106,7 +106,7 @@ packages: | |||||
| name: source_span | name: source_span | ||||
| url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
| source: hosted | source: hosted | ||||
| version: "1.8.0" | |||||
| version: "1.8.1" | |||||
| stack_trace: | stack_trace: | ||||
| dependency: transitive | dependency: transitive | ||||
| description: | description: | ||||
| @@ -141,7 +141,7 @@ packages: | |||||
| name: test_api | name: test_api | ||||
| url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
| source: hosted | source: hosted | ||||
| version: "0.2.19" | |||||
| version: "0.4.2" | |||||
| typed_data: | typed_data: | ||||
| dependency: transitive | dependency: transitive | ||||
| description: | description: | ||||
| @@ -157,5 +157,5 @@ packages: | |||||
| source: hosted | source: hosted | ||||
| version: "2.1.0" | version: "2.1.0" | ||||
| sdks: | sdks: | ||||
| dart: ">=2.12.0-0.0 <3.0.0" | |||||
| dart: ">=2.12.0 <3.0.0" | |||||
| flutter: ">=1.10.0" | flutter: ">=1.10.0" | ||||
| @@ -7,8 +7,8 @@ class Myketpayment { | |||||
| static const MethodChannel _channel = const MethodChannel('myketpayment'); | static const MethodChannel _channel = const MethodChannel('myketpayment'); | ||||
| static Future<bool> setup(String rsa) async { | |||||
| final bool version = await _channel.invokeMethod('setup', {"rsa": rsa}); | |||||
| static Future<bool> setup(String rsa, {String purchasedSku = ''}) async { | |||||
| final bool version = await _channel.invokeMethod('setup', {"rsa": rsa, 'purchasedSku': purchasedSku}); | |||||
| return version; | return version; | ||||
| } | } | ||||
| @@ -17,5 +17,9 @@ class Myketpayment { | |||||
| return result; | return result; | ||||
| } | } | ||||
| static Future<bool> check() async { | |||||
| final bool version = await _channel.invokeMethod('check', {}); | |||||
| return version; | |||||
| } | |||||
| } | } | ||||
| @@ -7,7 +7,7 @@ packages: | |||||
| name: async | name: async | ||||
| url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
| source: hosted | source: hosted | ||||
| version: "2.5.0" | |||||
| version: "2.8.1" | |||||
| boolean_selector: | boolean_selector: | ||||
| dependency: transitive | dependency: transitive | ||||
| description: | description: | ||||
| @@ -28,7 +28,7 @@ packages: | |||||
| name: charcode | name: charcode | ||||
| url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
| source: hosted | source: hosted | ||||
| version: "1.2.0" | |||||
| version: "1.3.1" | |||||
| clock: | clock: | ||||
| dependency: transitive | dependency: transitive | ||||
| description: | description: | ||||
| @@ -73,7 +73,7 @@ packages: | |||||
| name: meta | name: meta | ||||
| url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
| source: hosted | source: hosted | ||||
| version: "1.3.0" | |||||
| version: "1.7.0" | |||||
| path: | path: | ||||
| dependency: transitive | dependency: transitive | ||||
| description: | description: | ||||
| @@ -92,7 +92,7 @@ packages: | |||||
| name: source_span | name: source_span | ||||
| url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
| source: hosted | source: hosted | ||||
| version: "1.8.0" | |||||
| version: "1.8.1" | |||||
| stack_trace: | stack_trace: | ||||
| dependency: transitive | dependency: transitive | ||||
| description: | description: | ||||
| @@ -127,7 +127,7 @@ packages: | |||||
| name: test_api | name: test_api | ||||
| url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
| source: hosted | source: hosted | ||||
| version: "0.2.19" | |||||
| version: "0.4.2" | |||||
| typed_data: | typed_data: | ||||
| dependency: transitive | dependency: transitive | ||||
| description: | description: | ||||
| @@ -143,5 +143,5 @@ packages: | |||||
| source: hosted | source: hosted | ||||
| version: "2.1.0" | version: "2.1.0" | ||||
| sdks: | sdks: | ||||
| dart: ">=2.12.0-0.0 <3.0.0" | |||||
| dart: ">=2.12.0 <3.0.0" | |||||
| flutter: ">=1.10.0" | flutter: ">=1.10.0" | ||||