pagseguro_flutter 0.0.6

  • Readme
  • Changelog
  • Example
  • Installing
  • 76

pagseguro_flutter #

Sobre #

O pacote tem como objetivo facilitar o uso das tecnologias do pagseguro.

  • PlugPag Agora você pode integrar os seus aplicativos Flutter com as máquinas de cartão através da tecnologia BLUETOOTH.

    Para mais informações acesse: Documento Oficial

Setup - Android #

Adicione no seu AndroidManifest.xml

Antes

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="plugpag.dev.gabul.pagseguro_flutter_example">

Depois

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="YOUR_PACKAGE_NAME"
    xmlns:tools="http://schemas.android.com/tools">

No mesmo arquivo precisa adicionar mais uma linha

android:name="io.flutter.app.FlutterApplication"
android:label="pagseguro_flutter_example"

//ADICIONE TOOLS EM BAIXO DO LABEL
tools:replace="android:label"

Agora vamos adicionar no app/build.gradle #

 dependencies {
    ...
    
    implementation 'com.android.support:design:28.0.0'
    implementation 'br.com.uol.pagseguro:plugpag:3.1.2'
    implementation 'com.android.support:support-annotations:28.0.0'
}


Sistemas #

ANDROID - OK
IOS - IMPLEMENTAR

0.0.6 #

*TODO: Migration to androidX

0.0.5 #

  • TODO: Update kotlin verison for 1.3.10

0.0.4 #

  • TODO: Update documentation.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'PagSeguro Example',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'PagSeguro - by Gabul Dev'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  var pag;

  @override
  void initState() {
    pag = PlugPag(onState: (state) {
      if (Navigator.canPop(context)) {
        Navigator.pop(context);
      }
      showDialog(
          context: context,
          builder: (context) => AlertDialog(
                content: Column(
                  mainAxisSize: MainAxisSize.min,
                  children: <Widget>[
                    if (state.type == Type.loading) CircularProgressIndicator(),
                    Text(state.message)
                  ],
                ),
              ));
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Padding(
          padding: const EdgeInsets.symmetric(horizontal: 16),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text(
                "Antes de tudo, faça o pareamento da sua máquina de cartão!",
                textAlign: TextAlign.center,
                style: TextStyle(color: Colors.red, fontSize: 20),
              ),
              Text(
                "Se nao fizer isso o aplicativo vai fechar, estou resolvendo isso...",
                textAlign: TextAlign.center,
                style: TextStyle(color: Colors.red, fontSize: 20),
              ),
              SizedBox(
                height: 30,
              ),
              Text("Execute os botões na ordem"),
              FlatButton(
                child: Text("Pedir permissões"),
                onPressed: () {
                  pag.requestPermissions();
                },
              ),
              FlatButton(
                child: Text("Autenticar no PagSeguro"),
                onPressed: () {
                  pag.requestAuthentication();
                },
              ),
              FlatButton(
                child: Text("Verificar o status da autenticacao"),
                onPressed: () {
                  pag.checkAuthentication();
                },
              ),
              Text("Se for uma minizinha ou similares"),
              FlatButton(
                child: Text(
                    "Realizar uma trasacao de debito no valor de R\$: 2,00"),
                onPressed: () {
                  pag.startPinpadDebitPayment(2.00);
                },
              ),
              Text("Se for uma a pro use esse"),
              FlatButton(
                child: Text(
                    "Realizar uma trasacao de debito no valor de R\$: 2,00"),
                onPressed: () {
                  pag.startTerminalDebitPayment(2.00);
                },
              )
            ],
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  pagseguro_flutter: ^0.0.6

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

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

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Format lib/pagseguro_flutter.dart.

Run flutter format to format lib/pagseguro_flutter.dart.

Format lib/src/plugpag.dart.

Run flutter format to format lib/src/plugpag.dart.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the 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.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test