encrypt_card 0.0.7

  • Readme
  • Changelog
  • Example
  • Installing
  • 78

encrypt #

An Adyen Flutter plugin to support the Adyen API integration inspired in adyen_flutter https://github.com/lab-box/adyen_flutter.

It exposes the EncryptedCard class's method encryptToken and encryptCard.

Getting Started #

This Plugin relies on the following Adyen SDK:

Android #

The Android version requires the following permission to be set:

<uses-permission android:name="android.permission.INTERNET"/>

iOS #

The iOS version requires the ios hosting project to target iOS 10.3 or above. This is a limitation of the iOS SDK.

0.0.7 #

  • Return void credit card if error.

0.0.6 #

  • Android imports updated

0.0.5 #

  • Return an exception on android

0.0.4 #

  • Return void credit card if error.

0.0.3 #

  • New package name

0.0.2 #

  • iOS bug fixed

0.0.1 #

  • Exposes the EncryptedCard class's method encryptToken and encryptCard.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:flutter/services.dart';
import 'package:encrypt_card/encrypt_card.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(home: AppCardValidator());
  }
}

class AppCardValidator extends StatefulWidget {
  @override
  _AppCardValidatorState createState() => _AppCardValidatorState();
}

class _AppCardValidatorState extends State<AppCardValidator> {
  String token;
  String cardNumber;
  String securityCode;
  String month;
  String year;
  String encryptedResult = '';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Adyen Card Encrypt Test'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(8.0),
        child: Column(
          children: <Widget>[
            TextField(
              decoration: InputDecoration(
                hintText: "Token",
              ),
              onChanged: (value) {
                token = value;
              },
            ),
            Row(
              children: <Widget>[
                Expanded(
                  flex: 8,
                  child: TextField(
                    keyboardType: TextInputType.number,
                    decoration: InputDecoration(
                        hintText: "Card Number", counterText: ""),
                    onChanged: (value) {
                      cardNumber = value;
                    },
                  ),
                ),
                SizedBox(
                  width: 15,
                ),
                Expanded(
                  flex: 2,
                  child: TextField(
                      maxLength: 4,
                      maxLengthEnforced: true,
                      keyboardType: TextInputType.number,
                      decoration:
                          InputDecoration(hintText: "CVC", counterText: ""),
                      onChanged: (value) {
                        securityCode = value;
                      }),
                ),
              ],
            ),
            Row(
              children: <Widget>[
                Expanded(
                  flex: 6,
                  child: Container(),
                ),
                Expanded(
                  flex: 2,
                  child: TextField(
                      maxLength: 2,
                      maxLengthEnforced: true,
                      keyboardType: TextInputType.number,
                      decoration:
                          InputDecoration(hintText: "Month", counterText: ""),
                      onChanged: (value) {
                        month = value;
                      }),
                ),
                SizedBox(width: 15),
                Expanded(
                  flex: 4,
                  child: TextField(
                      maxLength: 4,
                      maxLengthEnforced: true,
                      keyboardType: TextInputType.number,
                      decoration:
                          InputDecoration(hintText: "Year", counterText: ""),
                      onChanged: (value) {
                        year = value;
                      }),
                ),
              ],
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                RaisedButton(
                  onPressed: () async {
                    FocusScope.of(context).requestFocus(new FocusNode());
                    var encryptedCard = await EncryptCard.encryptedCard(
                        publicKeyToken: token,
                        environment: Environment.TEST,
                        card: CreditCard(
                          number: cardNumber,
                          securityCode: securityCode,
                          expiryMonth: month,
                          expiryYear: year,
                        ),
                        generationDate: DateTime.now());
                    setState(() {
                      encryptedResult = '''
encryptedNumber:${encryptedCard.number}\r\n
encryptedCode:${encryptedCard.securityCode}\r\n
encryptedMonth:${encryptedCard.expiryMonth}\r\n
encryptedYear:${encryptedCard.expiryYear}\r\n
''';
                      print('Encrypted number:');
                      print(encryptedCard.number);
                      print('');
                      print('Encrypted security code:');
                      print(encryptedCard.securityCode);
                      print('');
                      print('Encrypted expiry month:');
                      print(encryptedCard.expiryMonth);
                      print('');
                      print('Encrypted expiry year:');
                      print(encryptedCard.expiryYear);

                    });
                  },
                  child: Text('Encrypt Card'),
                ),
              ],
            ),
            Expanded(
                child: ListView(children: <Widget>[Text(encryptedResult)])),
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  encrypt_card: ^0.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:encrypt_card/encrypt_card.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
60
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]
78
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:encrypt_card/encrypt_card.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:encrypt_card/encrypt_card.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:encrypt_card/encrypt_card.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:encrypt_card/encrypt_card.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [encrypt_card] that is in a package requiring null.

Health suggestions

Format lib/encrypt_card.dart.

Run flutter format to format lib/encrypt_card.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.12 1.14.13
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test