flutter_adyen 0.2.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 74

flutter_adyen #

Note: This library is not official from Adyen.

Flutter plugin to integrate with the Android and iOS libraries of Adyen. This library enables you to open the Drop-in method of Adyen with just calling one function.

This should support One time payment and recurring payment.

Prerequisites #

Before calling the plugin, make sure to get the payment methods from Adyen or better from your backend. For this, call the a /paymentMethods endpoint:

POST: https://checkout-test.adyen.com/v46/paymentMethods // Version number might be different Payload should contain the merchant account

  "merchantAccount": "<YOUR ACCOUNT>"

Append your API key and a content-type to the headers:

Content-Type: application/json

It's not recommended to store the API key in the front-end for security reasons!

####You also need to have the:

  • publicKey (from Adyen)
  • merchantAccount (from Adyen)
  • amount & currency
  • shopperReference (e.g userId)
  • reference (e.g transactionId)


###Android Add this in your android/build.gradle

implementation "com.adyen.checkout:drop-in:3.2.1"

And in the AndroidManifest.xml in your application tag add this service, this allows adyen to tell the android app the result of the payment.

<application ...>
           android:permission="android.permission.BIND_JOB_SERVICE" />


you also might need to set minifyEnabled & useProguard to false if it crashes on a release build

buildTypes {
           release {
               signingConfig signingConfigs.release               
               minifyEnabled false
               useProguard false
               proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

###iOS You need to add a URL_SCHEME if you do not have one yet.

Here is how to add one.

You might need to run this command pod update Adyen/Card in your ios folder.

##Usage Just add this in your dart code

 String dropInResponse = await FlutterAdyen.openDropIn(
                paymentMethods: jsonEncode(examplePaymentMethods),
                baseUrl: 'https://YOURBACKEND/payment/',
                authToken: 'Bearer AAABBBCCCDDD222111',
                merchantAccount: 'YOURMERCHANTACCOUNTCOM',
                publicKey: pubKey,
                amount: '1230',
                currency: 'EUR',
                iosReturnUrl: 'YOURAPP://' <-- URL_SCHEME_FOR_YOUR_iOS_APP
                shopperReference: DateTime.now().millisecondsSinceEpoch.toString(),
                reference: DateTime.now().millisecondsSinceEpoch.toString(),
  if(dropInResponse == 'PAYMENT_SUCCESS') ... 
  if(dropInResponse == 'PAYMENT_CANCELLED') ...
  else ... // you will get the error message here. (It is not translated to any languages)

Important to know #

The library expect your backend to provide the following endpoints as documented by Adyen:

0.2.3 #

  • Initial release.


import 'dart:async';
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_adyen/flutter_adyen.dart';

import 'mock_data.dart';

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

class MyApp extends StatefulWidget {
  _MyAppState createState() => _MyAppState();

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  void initState() {

  String dropInResponse;

  Future<void> initPlatformState() async {
    if (!mounted) return;

    setState(() {
      _platformVersion = dropInResponse;

  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        floatingActionButton: FloatingActionButton(
          child: Icon(Icons.add),
          onPressed: () async {
            try {
              dropInResponse = await FlutterAdyen.openDropIn(
                paymentMethods: jsonEncode(examplePaymentMethods),
                baseUrl: 'https://xxxxxxxxx/payment/',
                authToken: 'Bearer AAABBBCCCDDD222111',
                merchantAccount: 'YOURMERCHANTACCOUNTCOM',
                publicKey: pubKey,
                amount: '1230',
                currency: 'EUR',
                shopperReference: DateTime.now().millisecondsSinceEpoch.toString(),
                reference: DateTime.now().millisecondsSinceEpoch.toString(),
            } on PlatformException {
              dropInResponse = 'Failed to get platform version.';
            setState(() {
              _platformVersion = dropInResponse;
            setState(() {});
        appBar: AppBar(
          title: const Text('Flutter Adyen'),
        body: Center(
          child: Text('Running on: $_platformVersion\n'),

Use this package as a library

1. Depend on it

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

  flutter_adyen: ^0.2.3

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_adyen/flutter_adyen.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 Mar 31, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Format lib/flutter_adyen.dart.

Run flutter format to format lib/flutter_adyen.dart.

Format lib/generated/i18n.dart.

Run flutter format to format lib/generated/i18n.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies