flutter_openpay

A flutter plugin to tokenize cards using Openpay

pub package

Installation

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

flutter_openpay: ^1.0.0

Android

Add

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

before <application> to your app's AndroidManifest.xml file. This is required due to Openpay using its remote API to tokenize the card.

iOS

For tokenizing the card information correctly, you need to add some keys to your iOS app's Info.plist file, located in <project root>/ios/Runner/Info.plist:

  • UIBackgroundModes with the fetch and remote-notifications keys - Required. Describe why your app needs to access background taks, suck talking to an external API (to tokenize the card). This is called Required background modes, with the keys App download content from network and App downloads content in response to push notifications respectively in the visual editor (since both methods aren't actually overriden, not adding this property/keys may only display a warning, but shouldn't prevent its correct usage).

    <key>UIBackgroundModes</key>
    <array>
       <string>fetch</string>
       <string>remote-notification</string>
    </array>
    

Usage

There is only one method that should be used with this package:

FlutterOpenpay.tokenizeCard()

Will let you tokenize a card. This receives eight required parameters: the publicApiKey to specify your Openpay public key, the productionMode flag to indicate whether it should tokenize the card using the production or the sandbox API, the merchantId from Openpay, the cardholderName, the cardNumber, the cvv, the expiryMonth and the expiryYear. Returns a String with the token representing the card.

FlutterOpenpay.getDeviceSessionId()

Will let you generate a unique device session id, which you should use to access resources from the Openpay API. This receives three required parameters: the productionMode flag, the publicApiKey to specify your Openpay public key, and the merchantId from Openpay. Returns a String with the device session id.

Currently supported features

  • x Tokenize card using Openpay.
  • x Generate device session id to access Openpay API resources.

Demo App

Demo

Example

See example app.

Libraries

flutter_openpay