Coder Social home page Coder Social logo

lbloder / adyen_flutter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from intive/adyen_flutter

0.0 0.0 0.0 232 KB

A Flutter plugin for the Adyen Payment Provider DropIn UI

License: MIT License

Kotlin 53.03% Ruby 6.98% Shell 1.27% Swift 27.05% Objective-C 0.90% Dart 10.76%

adyen_flutter's Introduction

adyen_dropin

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.

The Plugin supports 3dSecure v2 and one time payment. It was not tested in a recurring payment scenario.

Prerequisites

Credentials

You need to have the following information:

  • publicKey (from Adyen)
  • clientKey (from Adyen)
  • amount & currency
  • shopperReference (e.g userId)
  • baseUrl from your backend
  • Adyen Environment (Test, LIVE_EU etc..)
  • locale (de_DE, en_US etc..)
  • return url after payment (ios URLScheme of you app) for redirecting back to the app

Payment Methods

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

An example response from payment methods can be seen here:

{
    "groups": [
        {
            "name": "Credit Card",
            "types": [
                "amex",
                "mc",
                "visa"
            ]
        }
    ],
    "paymentMethods": [
        {
            "brands": [
                "amex",
                "mc",
                "visa"
            ],
            "details": [
                {
                    "key": "encryptedCardNumber",
                    "type": "cardToken"
                },
                {
                    "key": "encryptedSecurityCode",
                    "type": "cardToken"
                },
                {
                    "key": "encryptedExpiryMonth",
                    "type": "cardToken"
                },
                {
                    "key": "encryptedExpiryYear",
                    "type": "cardToken"
                },
                {
                    "key": "holderName",
                    "optional": true,
                    "type": "text"
                }
            ],
            "name": "Credit Card",
            "type": "scheme"
        },
        {
            "name": "PayPal",
            "supportsRecurring": true,
            "type": "paypal"
        }
    ]
}

The app uses these endpoints for payment submit and payment details calls:

<your base url>/payment
<your base url>/payment/details

The plugin will send data for the payment submit call wrapped into another object like this:

{
  payment: <all data for payment which has to be sent to adyen>,
  additionalData: {key: value}
}

// additonalData can be used to send additional data to your own backend for payment


Setup

Android

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 ...>
    ...
 <service
            android:name="app.adyen.flutter_adyen.AdyenDropinService"
            android:permission="android.permission.BIND_JOB_SERVICE"/>

</application>

Proguard

you need to add this to your proguard rules

-keep class com.adyen.** { *; }
-keep class app.adyen.flutter_adyen.**  { *; }

iOS

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

Here is how to add one.

Flutter Implementation

To start a Payment you need to call the plugin like so:

 try {
      String dropInResponse = await FlutterAdyen.openDropIn(
          paymentMethods: paymentMethods,  // the result of your payment methods call
          baseUrl: 'https://your-server.com/',
          clientKey: <ADYEN_CLIENT_KEY>,
          amount: '1000', // amount in cents
          lineItem: {'id': 'your product ID', 'description': 'Your product description'},
          additionalData: {
            'someKey': 'Some String'
          },
          shopperReference: <YouShopperReference>,
          returnUrl: 'yourAppScheme://payment', //required for iOS
          environment: 'TEST',  // add you environment for produciton here: LIVE_US, LIVE_AUSTRALIA or LIVE_EUROPE
          locale: 'de_DE', // your preferred locale
          publicKey: <your adyen public key>,
          currency: 'EUR');  // your preferred currency


    } on PlatformException {
      // Network Error or other system errors
      return PaymentResponse.paymentError.rawValue;
    }
      // the dropin returns the following responses as string
      PAYMENT_CANCELLED
      PAYMENT_ERROR
      Authorised
      Refused
      Pending
      Cancelled
      Error
      Received

adyen_flutter's People

Contributors

alejandrocruz-intive avatar alexghiu avatar bennibau avatar ivanlunardi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.