flutter_cielo 1.0.7

flutter-cielo #

Donate

Package para criar transações usando o SDK da Cielo e-Commerce. Para mais informações acesse a documentação.

Start #

Adicionar flutter_cielo no seu pubspec.yaml.

import 'package:flutter_cielo/flutter_cielo.dart';

...
//inicia objeto da api
final CieloEcommerce cielo = CieloEcommerce(
      environment: Environment.SANDBOX, // ambiente de desenvolvimento
      merchant: Merchant(
        merchantId: "SEU_MERCHANT_ID",
        merchantKey: "SEU_MERCHANT_KEY",
      ));

...
    //Objeto de venda
    Sale sale = Sale(
      merchantOrderId: "123", // id único de sua venda
      customer: Customer( //objeto de dados do usuário
        name: "Comprador crédito simples"
      ),
      payment: Payment(    // objeto para de pagamento
        type: TypePayment.creditCard, //tipo de pagamento
        amount: 7777, // valor da compra em centavos
        installments: 1, // número de parcelas
        softDescriptor: "Cielo", //descrição que aparecerá no extrato do usuário. Apenas 15 caracteres
        creditCard: CreditCard( //objeto de Cartão de crédito
          cardNumber: "1234123412341231", //número do cartão
          holder: "Teste Holder", //nome do usuário impresso no cartão
          expirationDate: "12/2030", // data de expiração
          securityCode: "123", // código de segurança
          brand: "Visa", // bandeira
        )
      )
    );

  try{
    var response = await cielo.createSale(sale);
    print(response.payment.paymentId);
    } catch(e){
      print(e);
    }

Tokenizando um cartão #


...

CreditCard cart = CreditCard(
          customerName: "Comprador Teste Cielo",
          cardNumber: "1234123412341231",
          holder: "Teste Holder",
          expirationDate: "12/2030",
          brand: "Visa",
        );
    try {
      var response = await cielo.tokenizeCard(cart);
      print(response.cardToken);
    } on CieloException catch(e){
      print(e.message);
      print(e.errors[0].message);
      print(e.errors[0].code);
    }

...

Venda com um cartão tokenizado #


 Sale sale = Sale(
      merchantOrderId: "123",
      customer: Customer(
        name: "Comprador crédito simples"
      ),
      payment: Payment(
        type: TypePayment.creditCard,
        amount: 7777,
        installments: 1,
        softDescriptor: "Cielo",
        creditCard: CreditCard.token(
          cardToken: "1234123412341231",
          securityCode: "123",
          brand: "Visa",
        );
      )
    );

  try{
    var response = await cielo.createSale(sale);
    print(response.payment.paymentId);
     } on CieloException catch(e){
      print(e.message);
      print(e.errors[0].message);
      print(e.errors[0].code);
    }

  ....


}

Para mais informações #

Acesse o Blog do Flutterando Clicando aqui .

[1.0.5] - 12 de Fevereiro 2019.

  • Correções na criação de cartão tokenizado

[1.0.1] - 12 de Fevereiro 2019.

  • Adicionado tratamento de erros (veja página principal)
  • Correções no README.md

[1.0.0] - 11 de Fevereiro 2019.

  • Adicionado tutorial

[0.0.1] - TODO: Add release date.

  • TODO: Describe initial release.

example/README.md

exemple #

A new Flutter project.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_cielo: ^1.0.7

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

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

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

172 out of 172 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/Environment.dart. (-1 points)

Analysis of lib/src/Environment.dart reported 2 hints:

line 2 col 26: Name non-constant identifiers using lowerCamelCase.

line 5 col 26: Name non-constant identifiers using lowerCamelCase.

Fix lib/src/cielo_ecommerce.dart. (-1 points)

Analysis of lib/src/cielo_ecommerce.dart reported 2 hints:

line 21 col 3: The class 'Future' was not exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 40 col 3: The class 'Future' was not exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

Format lib/src/Payment.dart.

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
dio ^2.0.0 2.1.13
flutter 0.0.0
Transitive dependencies
collection 1.14.11
cookie_jar 1.0.1
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
build_runner ^1.0.0
json_serializable ^2.0.0

Admin