flutter-cielo

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 .

Libraries

flutter_cielo

Dart

dart:ui
Built-in types and core primitives for a Flutter application. [...]

Core

dart:async
Support for asynchronous programming, with classes such as Future and Stream. [...]
dart:collection
Classes and utilities that supplement the collection support in dart:core. [...]
dart:convert
Encoders and decoders for converting between different data representations, including JSON and UTF-8. [...]
dart:core
Built-in types, collections, and other core functionality for every Dart program. [...]
dart:developer
Interact with developer tools such as the debugger and inspector. [...]
dart:math
Mathematical constants and functions, plus a random number generator. [...]
dart:typed_data
Lists that efficiently handle fixed sized data (for example, unsigned 8 byte integers) and SIMD numeric types. [...]

VM

dart:io
File, socket, HTTP, and other I/O support for non-web applications. [...]
dart:isolate
Concurrent programming using isolates: independent workers that are similar to threads but don't share memory, communicating only via messages. [...]