culqi_flutter 1.0.1

culqi_flutter #

Resumen #

Es una librería para flutter que implementa la creación de token en la pasarela de pagos Culqi. Este repositorio no es oficial, por lo que no es mantenida por el equipo de desarrollo de Culqi.

Características #

  • Proporciona una clase que gestiona los datos de la tarjeta.
  • Brinda diferentes validaciones para evitar problemas innecesarios al enviar los datos bancarios a los servidores de Culqi.
  • Implementa las excepciones arrojadas por la API de Culqi.
  • Proporciona una clase con los datos generados por la API de Culqi al generar el token.

Uso #

Agregue esta línea a su archivo pubspec.yaml


    dependencies:
        culqi_flutter: ^1.0.0

Importe el paquete de esta manera


    import 'package:culqi_flutter/culqi_flutter.dart';

Primero deberá pedir al usuario los datos de su tarjeta mediante un formulario para luego instanciar un objeto de la clase "CCard"


    CCard card = CCard(
      cardNumber: '4111 1111 1111 1111',
      expirationMonth: 09,
      expirationYear: 20,
      cvv: '123',
      email: 'test@test.com'
    );

Recuerda que la clase CCard tiene métodos que te ayudarán a validar los datos antes de enviarlo a la API de Culqi:

  • isCardNumberValid() return bool
  • isYearValid() return bool
  • isMonthValid() return bool
  • isExpirationDateValid() return bool
  • isCcvValid() return bool
  • isEmailValid() return bool
  • getBrand() return int - ejemplo

    Switch(card.getBrand()){
        case CCard.DINERS_CLUB:
            break;
        case CCard.AMERICAN_EXPRESS:
            break;
        case CCard.MASTER_CARD:
            break;
        case CCard.VISA:
            break;
        default:
            // no se detecta la marca de la tarjeta
            break;
    }

Para enviar los datos de la tarjeta hacemos uso del método asíncrono "createToken":


    createToken(card: card, apiKey: "sk_test_UTCQSGcXW8bCyU59").then((CToken token){
        //su token
        print(token.id);
    }).catchError((error){
        try{
            throw error;
        } on CulqiBadRequestException catch(ex){
            print(ex.cause);
        } on CulqiUnknownException catch(ex){
            //codigo de error del servidor
            print(ex.cause);
        }
    });

Si utiliza aync/await su código se vería de la siguiente manera:


    try{
        CToken token = await createToken(card: card, apiKey: "sk_test_UTCQSGcXW8bCyU59");
        //su token
        print(token.id);
    } on CulqiBadRequestException catch(ex){
        print(ex.cause);
    } on CulqiUnknownException catch(ex){
        //codigo de error del servidor
        print(ex.cause);
    }

LICENCIA #


MIT License

Copyright (c) 2020 Gucodero

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

[1.0.0]

  • initRelease
  • Clase CCard para validación de tarjeta de manera local
  • Clase CToken con datos recibidos por los servidores de culqi al generar token
  • Implementación de errores
  • Metodo createToken para gestionar petición de token a servidor culqi
  • Implementación de pruebas unitarias a CCard y createToken

Use this package as a library

1. Depend on it

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


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

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

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7

Health issues and suggestions

Document public APIs. (-1 points)

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

Format lib/culqi_flutter.dart.

Run flutter format to format lib/culqi_flutter.dart.

Format lib/src/CCard.dart.

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

Format lib/src/CToken.dart.

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

Format lib/src/errors/CulqiBadRequestException.dart.

Run flutter format to format lib/src/errors/CulqiBadRequestException.dart.

Format lib/src/errors/CulqiUnknownException.dart.

Run flutter format to format lib/src/errors/CulqiUnknownException.dart.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and culqi_flutter.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
email_validator ^1.0.0 1.0.4
flutter 0.0.0
http ^0.12.0+4 0.12.0+4
Transitive dependencies
async 2.4.0
charcode 1.1.3
collection 1.14.11 1.14.12
http_parser 3.1.3
meta 1.1.8
path 1.6.4
pedantic 1.9.0
sky_engine 0.0.99
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test