myket_flutter 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 65

myket_flutter #

MyKet In-App Billing package for flutter this package is just for android applications and not work on ios

This plugin is just for Android applications

این نسخه از پلایگن به صورت کامل تست نشده است و ممکن است خطای وجود داشته باشد در صورت وجود هر گونه خطا لطفا از طریق صفحه گیت هاب برای ما ارسال نماید

Getting Started #

Import this line in Flutter pubspec #

myket_flutter: <Last Version>

Updating Your Application's Manifest #

Adding the ir.mservices.market.BILLING permission to your AndroidManifest.xml file for In-App Billing Adding ir.mservices.market.CHECK_LICENSE permission to your AndroidManifest.xml file for CHECK LICENSE


<uses-permission android:name="ir.mservices.market.CHECK_LICENSE" />
    <uses-permission android:name="ir.mservices.market.BILLING" />

To Use myket plugin import below code to your class(your payment class) #

import 'package:myket_flutter/myket_flutter.dart';
  • All method be static and don't need to initialize any class

To check License (نمایش صفحه برنامه نویس) #

for more info visit http://kb.myket.ir/pages/viewpage.action?pageId=1900832 #

MyketFlutter.checkLicense() 

To show developer applications page in myket use this code(نمایش صفحه برنامه نویس) #

MyketFlutter.showDeveloperApplicationsPage("packageName")  // Replace "package Name" with Your application Package Name. you can find package name on gradle file

To show comment and privilege in myket use this code(ثبت نظر و امتیاز به برنامه) #

MyketFlutter.setComment("packageName")  // Replace "package Name" with Your application Package Name. you can find package name on gradle file

Access to app details page(دسترسی به صفحه‌ی جزئیات برنامه) #

MyketFlutter.showApplicationDetails("packageName")  // Replace "package Name" with Your application Package Name. you can find package name on gradle file

If you want to start downloading the app when you open the app's details page on Myket, you can use the below pattern(در صورت به‌ کار‌بردن الگوی زیر، همراه با بازشدن صفحه‌ اطلاعات برنامه در مایکت، دانلود آن هم آغاز می‌شود) #

MyketFlutter.showApplicationDetails("packageName")  // Replace "package Name" with Your application Package Name. you can find package name on gradle file

You can view an app's video directly by using the below pattern(با استفاده از الگوی زیر می‌توان به صورت مستقیم، ویدئو یک برنامه را مشاهده کرد) #

MyketFlutter.showApplicationVideo("packageName")  // Replace "package Name" with Your application Package Name. you can find package name on gradle file

For use In-app purchases on your application use below code جهت استفاده از پرداخت درون برنامه ای به صورت زیر عملکنید.

First of all initialize payment and ras Key in initState #

use async and await

await MyketFlutter.initPay(rsaKey:"Your RSA Key From myket");

To start a purchase request from your app, call the launchPurchaseFlow method on the In-app Billing plugin #

Map<String,dynamic> result = await MyketFlutter.launchPurchaseFlow(
                        sku: "wm2", consumption: false,payload:"bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
 // after pay you get some data from myket, if you get response code -1005 the payment is canceled by the user and  if get code 0  the payment is Success

  1. sku : your product id on MyketFlutter

  2. consumption : if your product is not a subscriber type you must consume it, For product consumption, set the consumption to true

consumption : زمانی که محصول شما از نوع اشتراکی نباشد و از نوع مصرفی می باشد باید ان را مصرف کنید تا در خرید ها بعدی کاربر بتواند ان را خریداری کند بجت مصرف یک محصول consumption را به صورت true تنظیم کنید

4.payload : The developerPayload String is used to specify any additional arguments that you want Myket to send back along with the purchase information.

  • Result If pay is success
'{
    "isSuccess": "true",
    "response":"0",
    "message":"Success (response: 0:OK)",
    "purchase":{
       "orderId":"12999763169054705758.1371079406387615",
       "packageName":"com.example.app",
       "productId":"exampleSku",
       "purchaseTime":1345678900000,
       "purchaseState":0,
       "developerPayload":"bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ",
       "purchaseToken":"rojeslcdyyiapnqcynkjyyjh"
     }
}'

To get Purchase details use below code #

Map<String,dynamic> result = MyketFlutter.getPurchase(sku:"your product sku") // you can find sku(product id) in your application in-app section
// you get the payment details if you consumption the product result is null

Result

'{
   "orderId":"12999763169054705758.1371079406387615",
   "packageName":"com.example.app",
   "productId":"exampleSku",
   "purchaseTime":1345678900000,
   "purchaseState":0,
   "developerPayload":"bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ",
   "purchaseToken":"rojeslcdyyiapnqcynkjyyjh"
 }'
  • Security Recommendation: When you send a purchase request, create a String token that uniquely identifies this purchase request and include this token in the developerPayload.You can use a randomly generated string as the token. When you receive the purchase response from Myket, make sure to check the returned data signature, the orderId, and the developerPayload String. For added security, you should perform the checking on your own secure server. Make sure to verify that the orderId is a unique value that you have not previously processed, and the developerPayload String matches the token that you sent previously with the purchase request.

After Payment result check developerPayload result true or false #

bool result = await MyketFlutter.verifyDeveloperPayload("your developerPayload");
  • Important: Remember to unbind from the In-app Billing service when you are done with your Activity. If you don’t unbind, the open service connection could cause your device’s performance to degrade. This example shows how to perform the unbind operation on a service connection to In-app Billing called mServiceConn by overriding the activity’s onDestroy method.
await MyketFlutter.dispose();

1.0.1 #

  • Update description

1.0.0 #

  • First initialize
  • بروز رسانی اولیه

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:myket_flutter/myket_flutter.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  Future<void> initPlatformState() async {
    MyketFlutter.initPay(
        base6PublicKey:"");
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          children: <Widget>[
            Center(
              child: Text('Running on: $_platformVersion\n'),
            ),
            RaisedButton(
              onPressed: () async {
                try {
                  Map<String,dynamic> result = await MyketFlutter.launchPurchaseFlow(
                        sku: "p_one", consumption: false,payload:"bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
                } catch (e) {
                  print(e.message);
                }
              },
              child: Text("Ok"),
            )
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  myket_flutter: ^1.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:myket_flutter/myket_flutter.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
32
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
65
Learn more about scoring.

We analyzed this package on Jul 10, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because:

  • package:myket_flutter/myket_flutter.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because:

  • package:myket_flutter/myket_flutter.dart that declares support for platforms: android, ios

Package does not support Flutter platform web

Because:

  • package:myket_flutter/myket_flutter.dart that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because:

  • package:myket_flutter/myket_flutter.dart that declares support for platforms: android, ios

Package not compatible with SDK dart

Because:

  • myket_flutter that is a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

15 out of 15 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test