fourpaypayments 0.1.3

  • Readme
  • Changelog
  • Example
  • Installing
  • new63

4PayPayments #

4PayPayments.

class PaymentResult {
  String errorText;
  bool get hasError => (errorText ?? "").isNotEmpty;
  String response;
}

Example #

PaymentResult result;
if (Platform.isIOS) {
    result = await FourPayPayments.makeApplePayment(
        <authToken>,
        <merchant_identifier>,
        label: 'Label',
        description: 'Description',
        amount: 1,
        txid: Uuid().v1(),
    );
} else if (Platform.isAndroid){
    result = await FourPayPayments.makeGooglePayment(
        <authToken>,
        <merchantId>,
        amount: 1,
        description: 'Description',
        gateway: <gateway>,
        environment: <'test' or 'production'>,
        merchantInfo: <merchantName>,
        txid: Uuid().v1(),
    );
} else {
    throw UnsupportedError("Unsupported platform");
}
if (result.hasError) {
    print(result.errorText);
} else {
    print(result.response);
}

0.1.3 #

  • TODO: Describe initial release.

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';

import 'package:fourpaypayments/fourpaypayments.dart';
import 'package:uuid/uuid.dart';

void main() => runApp(
      MyApp(
        config: {
          "linkId": "your_auth_token",
          "apple_pay_params": {"merchant_identifier": "merchant.YourId"},
          "gpay_params": {
            "gateway": "themap",
            "gatewayMerchantId": "yourGatewayMerchantId",
            "merchantId": "yourMerchantId",
            "merchantName": "yourMerchantName"
          },
          'amount': 1,
          'txid': Uuid().v1(),
        },
      ),
    );

class MyApp extends StatefulWidget {
  final Map<String, dynamic> config;

  MyApp({
    Key key,
    this.config,
  }) : super(key: key);
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

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

  @override
  Widget build(BuildContext context) {

    
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            children: <Widget>[
              RaisedButton(
                child: Text('Test Apple Pay'),
                onPressed: () async {
                  var result = await _makeApplePay();
                  print(result);
                },
              ),
              SizedBox(height: 20),
              RaisedButton(
                child: Text('Test Google Pay'),
                onPressed: () async {
                  var result = await _makeGooglePay();
                  print(result);
                },
              ),
            ],
          ),
        ),
      ),
    );
  }

  Future<PaymentResult> _makeApplePay() {
    return FourPayPayments.makeApplePayment(
      widget.config['linkId'],
      widget.config['apple_pay_params']['merchant_identifier'],
      label: 'Test Apple Pay',
      description: 'Test Apple Pay',
      amount: 1,
      txid: Uuid().v1(),
    );
  }

  Future<PaymentResult> _makeGooglePay() {
    return FourPayPayments.makeGooglePayment(
      widget.config['linkId'],
      widget.config['gpay_params']['merchantId'],
      amount: 1,
      description: 'Test Google Pay',
      gateway: widget.config['gpay_params']['gateway'],
      environment: 'test',
      merchantInfo: widget.config['gpay_params']['merchantName'],
      txid: Uuid().v1(),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  fourpaypayments: ^0.1.3

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:fourpaypayments/fourpaypayments.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
29
Health:
Code health derived from static analysis. [more]
96
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
63
Learn more about scoring.

We analyzed this package on Jul 9, 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:fourpaypayments/fourpaypayments.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because:

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

Package does not support Flutter platform web

Because:

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

Package does not support Flutter platform windows

Because:

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

Package not compatible with SDK dart

Because:

  • fourpaypayments that is a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

13 out of 13 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.

Fix lib/src/flutter_apple_pay.dart. (-2.96 points)

Analysis of lib/src/flutter_apple_pay.dart reported 6 hints, including:

line 81 col 3: The value of the field 'amex' isn't used.

line 82 col 3: The value of the field 'quicPay' isn't used.

line 83 col 3: The value of the field 'chinaUnionPay' isn't used.

line 84 col 3: The value of the field 'discover' isn't used.

line 85 col 3: The value of the field 'interac' isn't used.

Fix lib/src/flutter_google_pay.dart. (-0.50 points)

Analysis of lib/src/flutter_google_pay.dart reported 1 hint:

line 311 col 51: The value of the field 'AMEX' isn't used.

Format lib/fourpaypayments.dart.

Run flutter format to format lib/fourpaypayments.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
dio ^3.0.8 3.0.9
flutter 0.0.0
Transitive dependencies
charcode 1.1.3
collection 1.14.12 1.14.13
http_parser 3.1.4
meta 1.1.8 1.2.2
path 1.7.0
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test