go_sell_sdk_flutter 1.2.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 80

go_sell_sdk_flutter #

Flutter plugin compatible version of goSellSDK library for both Android and iOS that fully covers payment/authorization/card saving/card tokenization process inside your Android application. Original SDKS

Getting Started #

Table of Contents #


  1. Requirements
  2. Installation
    1. Installation with pubspec.yaml
  3. Usage
    1. Configure Your App
    2. Configure SDK Session
    3. Use Tap Pay Button
    4. Handle SDK Result

Requirements #


To use the SDK the following requirements must be met:

  1. Visual Studio - InteliJ Idea
  2. Dart 2.7.1 or newer
  3. Flutter: 1.12.13+hotfix.9 or newer

Installation #


Include goSellSDK plugin as a dependency in your pubspec.yaml #

 dependencies:
     go_sell_sdk_flutter: ^1.2.0

Configure your app #

goSellSDK should be set up. To set it up, add the following lines of code somewhere in your project and make sure they will be called before any usage of goSellSDK.

/**
 * Configure App. (You must get those keys from tap)
 */
GoSellSdkFlutter.configureApp(
  bundleId: "ANDROIID-PACKAGE-NAME",
  productionSecreteKey: Platform.isAndroid? "Android-Live-Key" : "iOS-Live-Key",
  sandBoxsecretKey: Platform.isAndroid?"Android-SANDBOX-Key" : "iOS-SANDBOX-Key",
  lang: "en");

Configure SDK Session Example

Future<void> setupSDKSession() async {
    try {
    GoSellSdkFlutter.sessionConfigurations(
        trxMode: TransactionMode.TOKENIZE_CARD,
        transactionCurrency: "kwd",
        amount: '100',
        customer: Customer(
            customerId: "",
            email: "h@tap.company",
            isdNumber: "965",
            number: "65562630",
            firstName: "Haitham",
            middleName: "Mohammad",
            lastName: "Elsheshtawy",
            metaData: null),
        paymentItems: <PaymentItem>[
            PaymentItem(
                name: "item1",
                amountPerUnit: 1,
                quantity: Quantity(value: 1),
                discount: {
                "type": "F",
                "value": 10,
                "maximum_fee": 10,
                "minimum_fee": 1
                },
                description: "Item 1 Apple",
                taxes: [
                Tax(
                    amount: Amount(
                        type: "F",
                        value: 10,
                        minimum_fee: 1,
                        maximum_fee: 10),
                    name: "tax1",
                    description: "tax describtion")
                ],
                totalAmount: 100),
        ],
        // List of taxes
        taxes: [
            Tax(
                amount: Amount(
                    type: "F", value: 10, minimum_fee: 1, maximum_fee: 10),
                name: "tax1",
                description: "tax describtion"),
            Tax(
                amount: Amount(
                    type: "F", value: 10, minimum_fee: 1, maximum_fee: 10),
                name: "tax1",
                description: "tax describtion")
        ],
        // List of shippnig
        shippings: [
            Shipping(
                name: "shipping 1",
                amount: 100,
                description: "shiping description 1"),
            Shipping(
                name: "shipping 2",
                amount: 150,
                description: "shiping description 2")
        ],
        // Post URL
        postURL: "https://tap.company",
        // Payment description
        paymentDescription: "paymentDescription",
        // Payment Metadata
        paymentMetaData: {
            "a": "a meta",
            "b": "b meta",
        },
        // Payment Reference
        paymentReference: Reference(
            acquirer: "acquirer",
            gateway: "gateway",
            payment: "payment",
            track: "track",
            transaction: "trans_910101",
            order: "order_262625"),
        // payment Descriptor
        paymentStatementDescriptor: "paymentStatementDescriptor",
        // Save Card Switch
        isUserAllowedToSaveCard: true,
        // Enable/Disable 3DSecure
        isRequires3DSecure: false,
        // Receipt SMS/Email
        receipt: Receipt(true, false),
        // Authorize Action [Capture - Void]
        authorizeAction: AuthorizeAction(
            type: AuthorizeActionType.CAPTURE, timeInHours: 10),
        // Destinations
        destinations:Destinations(
            amount: 100,
            currency: 'kwd',
            count: 2,
            destinationlist: [
                Destination(
                    id: "",
                    amount: 100,
                    currency: "kwd",
                    description: "des",
                    reference: "ref_121299"),
                Destination(
                    id: "",
                    amount: 100,
                    currency: "kwd",
                    description: "des",
                   reference: "ref_22444444")
            ])
        ,
        // merchant id
        merchantID: "",
        // Allowed cards
        allowedCadTypes: CardType.CREDIT,
        applePayMerchantID: "applePayMerchantID",
        allowsToSaveSameCardMoreThanOnce: false,
        paymentType: PaymentType.ALL,
        sdkMode: SDKMode.Sandbox);
    } on PlatformException {
    }

Use Tap Pay Button

Positioned(
    bottom: Platform.isIOS ? 0 : 10,
    left: 18,
    right: 18,
    child: SizedBox(
        height: 45,
        child: RaisedButton(
          color: _buttonColor,
          clipBehavior: Clip.hardEdge,
          shape: RoundedRectangleBorder(
              borderRadius: BorderRadiusDirectional.all(
                  Radius.circular(30))),
          onPressed: startSDK,
          child: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Container(
                  width: 25,
                  height: 25,
                  child: AwesomeLoader(
                    outerColor: Colors.white,
                    innerColor: Colors.white,
                    strokeWidth: 3.0,
                    controller: loaderController,
                  ),
                ),
                Spacer(),
                Text('PAY',
                    style: TextStyle(
                        color: Colors.white, fontSize: 16.0)),
                Spacer(),
                Icon(
                  Icons.lock_outline,
                  color: Colors.white,
                ),
              ]),
        )),
          ),

Handle SDK Result

  • Start SDK
   tapSDKResult = await GoSellSdkFlutter.startPaymentSDK;
  • Hnadle SDK result
setState(() {
  switch (tapSDKResult['sdk_result']) {
    case "SUCCESS":
      sdkStatus = "SUCCESS";
      handleSDKResult();
      break;
    case "FAILED":
      sdkStatus = "FAILED";
      handleSDKResult();
      break;
    case "SDK_ERROR":
      sdkErrorCode                  = tapSDKResult['sdk_error_code'].toString();
      sdkErrorMessage               = tapSDKResult['sdk_error_message'];
      sdkErrorDescription           = tapSDKResult['sdk_error_description'];
      break;
    case "NOT_IMPLEMENTED":
      sdkStatus = "NOT_IMPLEMENTED";
      break;
  }
});
void handleSDKResult() {
  switch (tapSDKResult['trx_mode']) {
    case "CHARGE":
    case "AUTHORIZE":
    case "SAVE_CARD":
        extractSDKResultKeysAndValues();
        break;
    case "TOKENIZE":
        token :                          =tapSDKResult['token'];
        token_currency                   =tapSDKResult['token_currency'];
        card_first_six                   =tapSDKResult['card_first_six'];
        card_last_four                   =tapSDKResult['card_last_four'];
        card_object                      =tapSDKResult['card_object'];
        card_exp_month                   =tapSDKResult['card_exp_month'];
        card_exp_year                    =tapSDKResult['card_exp_year'];
        break;
  }
}
void extractSDKResultKeysAndValues() {
    id                             = tapSDKResult['charge_id'];
    description                    = tapSDKResult['description'];
    message                        = tapSDKResult['message'];
    card_first_six                 = tapSDKResult['card_first_six'];
    card_last_four                 = tapSDKResult['card_last_four'];
    card_object                    = tapSDKResult['card_object'];
    card_brand                     = tapSDKResult['card_brand'];
    card_exp_month                 = tapSDKResult['card_exp_month'];
    card_exp_year                  = tapSDKResult['card_exp_year'];
    acquirer_id                    = tapSDKResult['acquirer_id'];
    acquirer_response_code         = tapSDKResult['acquirer_response_code'];
    acquirer_response_message      = tapSDKResult['acquirer_response_message'];
    source_id                      = tapSDKResult['source_id'];
    source_channel                 = tapSDKResult['source_channel'];
    source_object                  = tapSDKResult['source_object'];
    source_payment_type            = tapSDKResult['source_payment_type'];
    responseID                     = tapSDKResult['charge_id'];
}

1.2.1 - 2020-06-18 #

  • Update README.md

1.2.0 - 2020-06-18 #

  • Update iOS SDK 2.2.21.
  • Update ios platform to 10
  • Update Android SDK 3.7.0
  • Add delegate for sessionCancelled

1.1.0 - 2020-04-26 #

  • Fix iOS crash when receive unmaped data.

1.0.2 - 2020-04-25 #

  • Integrate both Android and iOS SDK / Add changlog version

1.0.1 - 2020-04-25 #

  • Integrate both Android and iOS SDK / Apply Pub dart recomendations

1.0.0 - 2020-04-25 #

  • Integrate both Android and iOS SDK

0.0.1 - 2020-04-08 #

  • Initial release.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:go_sell_sdk_flutter/go_sell_sdk_flutter.dart';
import 'package:go_sell_sdk_flutter/model/models.dart';
import 'package:go_sell_sdk_flutter_example/tap_loader/awesome_loader.dart';

void main() => runApp(MyApp());

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

class _MyAppState extends State<MyApp> {
  Map<dynamic, dynamic> tapSDKResult;
  String responseID = "";
  String sdkStatus = "";
  String sdkErrorCode;
  String sdkErrorMessage;
  String sdkErrorDescription;
  AwesomeLoaderController loaderController = AwesomeLoaderController();
  Color _buttonColor;

  @override
  void initState() {
    super.initState();
    _buttonColor = Color(0xff2ace00);
    configureSDK();
  }

  // configure SDK
  Future<void> configureSDK() async {
    // configure app
    configureApp();
    // sdk session configurations
    setupSDKSession();
  }

  // configure app key and bundle-id (You must get those keys from tap)
  Future<void> configureApp() async {
    GoSellSdkFlutter.configureApp(
        bundleId:
            Platform.isAndroid ? "ANDROIID-PACKAGE-NAME" : "iOS-BUNDLE-ID",
        productionSecreteKey:
            Platform.isAndroid ? "Android-Live-Key" : "iOS-Live-Key",
        sandBoxsecretKey:
            Platform.isAndroid ? "Android-SANDBOX-Key" : "iOS-SANDBOX-Key",
        lang: "en");
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> setupSDKSession() async {
    try {
      GoSellSdkFlutter.sessionConfigurations(
          trxMode: TransactionMode.PURCHASE,
          transactionCurrency: "kwd",
          amount: '100',
          customer: Customer(
              customerId: "",
              email: "xxx@xxxxx.xxx",
              isdNumber: "000",
              number: "000000000",
              firstName: "Haitham",
              middleName: "Mohammad",
              lastName: "Elsheshtawy",
              metaData: null),
          paymentItems: <PaymentItem>[
            PaymentItem(
                name: "item1",
                amountPerUnit: 1,
                quantity: Quantity(value: 1),
                discount: {
                  "type": "F",
                  "value": 10,
                  "maximum_fee": 10,
                  "minimum_fee": 1
                },
                description: "Item 1 Apple",
                taxes: [
                  Tax(
                      amount: Amount(
                          type: "F", value: 10, minimumFee: 1, maximumFee: 10),
                      name: "tax1",
                      description: "tax describtion")
                ],
                totalAmount: 100),
          ],
          // List of taxes
          taxes: [
            Tax(
                amount:
                    Amount(type: "F", value: 10, minimumFee: 1, maximumFee: 10),
                name: "tax1",
                description: "tax describtion"),
            Tax(
                amount:
                    Amount(type: "F", value: 10, minimumFee: 1, maximumFee: 10),
                name: "tax1",
                description: "tax describtion")
          ],
          // List of shippnig
          shippings: [
            Shipping(
                name: "shipping 1",
                amount: 100,
                description: "shiping description 1"),
            Shipping(
                name: "shipping 2",
                amount: 150,
                description: "shiping description 2")
          ],
          // Post URL
          postURL: "https://tap.company",
          // Payment description
          paymentDescription: "paymentDescription",
          // Payment Metadata
          paymentMetaData: {
            "a": "a meta",
            "b": "b meta",
          },
          // Payment Reference
          paymentReference: Reference(
              acquirer: "acquirer",
              gateway: "gateway",
              payment: "payment",
              track: "track",
              transaction: "trans_910101",
              order: "order_262625"),
          // payment Descriptor
          paymentStatementDescriptor: "paymentStatementDescriptor",
          // Save Card Switch
          isUserAllowedToSaveCard: true,
          // Enable/Disable 3DSecure
          isRequires3DSecure: false,
          // Receipt SMS/Email
          receipt: Receipt(true, false),
          // Authorize Action [Capture - Void]
          authorizeAction: AuthorizeAction(
              type: AuthorizeActionType.CAPTURE, timeInHours: 10),
          // Destinations
          destinations: null,
          // merchant id
          merchantID: "",
          // Allowed cards
          allowedCadTypes: CardType.CREDIT,
          applePayMerchantID: "applePayMerchantID",
          allowsToSaveSameCardMoreThanOnce: false,
          paymentType: PaymentType.ALL,
          sdkMode: SDKMode.Sandbox);
    } on PlatformException {
      // platformVersion = 'Failed to get platform version.';
    }

    if (!mounted) return;

    setState(() {
      tapSDKResult = {};
    });
  }

  Future<void> startSDK() async {
    setState(() {
      loaderController.start();
    });

    tapSDKResult = await GoSellSdkFlutter.startPaymentSDK;
    loaderController.stopWhenFull();

    print('>>>> ${tapSDKResult['sdk_result']}');
    setState(() {
      switch (tapSDKResult['sdk_result']) {
        case "SUCCESS":
          sdkStatus = "SUCCESS";
          handleSDKResult();
          break;
        case "FAILED":
          sdkStatus = "FAILED";
          handleSDKResult();
          break;
        case "SDK_ERROR":
          print('sdk error............');
          print(tapSDKResult['sdk_error_code']);
          print(tapSDKResult['sdk_error_message']);
          print(tapSDKResult['sdk_error_description']);
          print('sdk error............');
          sdkErrorCode = tapSDKResult['sdk_error_code'].toString();
          sdkErrorMessage = tapSDKResult['sdk_error_message'];
          sdkErrorDescription = tapSDKResult['sdk_error_description'];
          break;

        case "NOT_IMPLEMENTED":
          sdkStatus = "NOT_IMPLEMENTED";
          break;
      }
    });
  }

  void handleSDKResult() {
    switch (tapSDKResult['trx_mode']) {
      case "CHARGE":
        printSDKResult('Charge');
        break;

      case "AUTHORIZE":
        printSDKResult('Authorize');
        break;

      case "SAVE_CARD":
        printSDKResult('Save Card');
        break;

      case "TOKENIZE":
        print('TOKENIZE token : ${tapSDKResult['token']}');
        print('TOKENIZE token_currency  : ${tapSDKResult['token_currency']}');
        print('TOKENIZE card_first_six : ${tapSDKResult['card_first_six']}');
        print('TOKENIZE card_last_four : ${tapSDKResult['card_last_four']}');
        print('TOKENIZE card_object  : ${tapSDKResult['card_object']}');
        print('TOKENIZE card_exp_month : ${tapSDKResult['card_exp_month']}');
        print('TOKENIZE card_exp_year    : ${tapSDKResult['card_exp_year']}');

        responseID = tapSDKResult['token'];
        break;
    }
  }

  void printSDKResult(String trx_mode) {
    print('$trx_mode status                : ${tapSDKResult['status']}');
    print('$trx_mode id               : ${tapSDKResult['charge_id']}');
    print('$trx_mode  description        : ${tapSDKResult['description']}');
    print('$trx_mode  message           : ${tapSDKResult['message']}');
    print('$trx_mode  card_first_six : ${tapSDKResult['card_first_six']}');
    print('$trx_mode  card_last_four   : ${tapSDKResult['card_last_four']}');
    print('$trx_mode  card_object         : ${tapSDKResult['card_object']}');
    print('$trx_mode  card_brand          : ${tapSDKResult['card_brand']}');
    print('$trx_mode  card_exp_month  : ${tapSDKResult['card_exp_month']}');
    print('$trx_mode  card_exp_year: ${tapSDKResult['card_exp_year']}');
    print('$trx_mode  acquirer_id  : ${tapSDKResult['acquirer_id']}');
    print(
        '$trx_mode  acquirer_response_code : ${tapSDKResult['acquirer_response_code']}');
    print(
        '$trx_mode  acquirer_response_message: ${tapSDKResult['acquirer_response_message']}');
    print('$trx_mode  source_id: ${tapSDKResult['source_id']}');
    print('$trx_mode  source_channel     : ${tapSDKResult['source_channel']}');
    print('$trx_mode  source_object      : ${tapSDKResult['source_object']}');
    print(
        '$trx_mode source_payment_type : ${tapSDKResult['source_payment_type']}');
    responseID = tapSDKResult['charge_id'];
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
            appBar: AppBar(
              title: const Text('Plugin example app'),
              backgroundColor: Colors.grey,
            ),
            body: SafeArea(
              child: Stack(
                alignment: Alignment.center,
                children: <Widget>[
                  Positioned(
                    top: 300,
                    left: 18,
                    right: 18,
                    child: Text("Status: [$sdkStatus $responseID ]",
                        style: TextStyle(
                            color: Colors.black,
                            fontWeight: FontWeight.w400,
                            fontFamily: "Roboto",
                            fontStyle: FontStyle.normal,
                            fontSize: 15.0),
                        textAlign: TextAlign.center),
                  ),
                  Positioned(
                    bottom: Platform.isIOS ? 0 : 10,
                    left: 18,
                    right: 18,
                    child: SizedBox(
                        height: 45,
                        child: RaisedButton(
                          color: _buttonColor,
                          clipBehavior: Clip.hardEdge,
                          shape: RoundedRectangleBorder(
                              borderRadius: BorderRadiusDirectional.all(
                                  Radius.circular(30))),
                          onPressed: startSDK,
                          child: Row(
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: [
                                Container(
                                  width: 25,
                                  height: 25,
                                  child: AwesomeLoader(
                                    outerColor: Colors.white,
                                    innerColor: Colors.white,
                                    strokeWidth: 3.0,
                                    controller: loaderController,
                                  ),
                                ),
                                Spacer(),
                                Text('PAY',
                                    style: TextStyle(
                                        color: Colors.white, fontSize: 16.0)),
                                Spacer(),
                                Icon(
                                  Icons.lock_outline,
                                  color: Colors.white,
                                ),
                              ]),
                        )),
                  ),
                ],
              ),
            )));
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  go_sell_sdk_flutter: ^1.2.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:go_sell_sdk_flutter/go_sell_sdk_flutter.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
61
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
80
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:go_sell_sdk_flutter/go_sell_sdk_flutter.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because:

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

Package does not support Flutter platform web

Because:

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

Package does not support Flutter platform windows

Because:

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

Package not compatible with SDK dart

Because:

  • go_sell_sdk_flutter that is a package requiring null.

Health suggestions

Format lib/utils/util.dart.

Run flutter format to format lib/utils/util.dart.

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