pagarme_flutter_card_hash 0.1.0

pagarme_flutter_card_hash #

Build Status

A Flutter package that allows you to generate card hashes to be used with's payment platform.

Is this safe? #

Well, that's something I wondered too when I was looking for a third party package to use to generate card hashes when facing the fact that generating the card_hash using pagarme.js library wasn't neat enough in Flutter.

I began looking into's C# and PHP libraries and found out that what they do is basically the process documented here.

So I basically replicated that process.

I tried to keep the code as simple as possible so that people could see that there's no monkey business amidst the lines.


Getting Started #

First, add pagarme_flutter_card_hash as a dependency in your pubspec.yaml file.

Then all you have to do is the following:

String pagarMeApiKey = "ek_test_yCRumKDVQgqFkjlQojnTSHgWw7UI5g";

PagarMeCard pagarMeCard = new PagarMeCard(
      cardHolderName: "John Snow",
      cardCvv: "235",
      cardNumber: "5448280000000007",
      cardExpirationDate: "0620");

PagarMeFlutterCardHash pagarMeFlutterCardHash = new PagarMeFlutterCardHash(
    pagarMeApiKey: pagarMeApiKey, 
    pagarMeCard: pagarMeCard);

String cardHash = await pagarMeFlutterCardHash.generateCardHash();

print(cardHash); //Outputs something like: 1842883_Ha6Q2D/xYkuKXpgbDwy3HnrJpO2oX3c...

P.S.: This package assumes that the card data you are using has already been validated.


Improve exceptions
Write (more) tests
Improve documentation

Author #

  • Charles Washington de Aquino dos Santos - Caws

0.1.0 #

  • Add example, bump version to 0.1.0 and format pagarme_public_key.dart file.

0.0.3 #

  • Add comments to a few methods. Fix formatting for a few files.

0.0.2 #

  • Add PagarMeCard model to clean up the code a bit. Correct typo in a few classes. Add basic tests for basic coverage.

0.0.1 #

  • Initial Release


pagarme_flutter_card_hash_example #

An example flutter app showcasing the usage of the package pagarme_flutter_card_hash.


Author #

  • Charles Washington de Aquino dos Santos - Caws

Use this package as a library

1. Depend on it

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

  pagarme_flutter_card_hash: ^0.1.0

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

We analyzed this package on Feb 21, 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

Maintenance issues and suggestions

Support latest dependencies. (-20 points)

The version constraint in pubspec.yaml does not support the latest published versions for 2 dependencies (dio, encrypt).


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
dio ^2.1.5 2.2.2 3.0.8
encrypt ^3.2.0 3.3.1 4.0.0
flutter 0.0.0
Transitive dependencies
args 1.5.2
asn1lib 0.5.15 0.6.4
charcode 1.1.3
clock 1.0.1
collection 1.14.11 1.14.12
convert 2.1.1
cookie_jar 1.0.1
crypto 2.1.4
meta 1.1.8
pointycastle 1.0.2
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies