A flutter plugin to scan stripe readers and connect to the them and get the payment methods.

Overview

stripe_terminal

pub package

A flutter plugin to scan stripe readers and connect to the them and get the payment methods.

Installation

Android

No Configuration needed, workes out of the box.

iOS

You need to provide permission request strings to your Info.plist file. A sample content can be

	<key>NSLocationWhenInUseUsageDescription</key>
	<string>Location access is required in order to accept payments.</string>
	<key>NSBluetoothPeripheralUsageDescription</key>
	<string>Bluetooth access is required in order to connect to supported bluetooth card readers.</string>
	<key>NSBluetoothAlwaysUsageDescription</key>
	<string>This app uses Bluetooth to connect to supported card readers.</string>

You also need to authorize backround modes authorization for bluetooth-central. Paste the following to your Info.plist file

	<key>UIBackgroundModes</key>
	<array>
		<string>bluetooth-central</string>
	</array>

Usage

  • First initilize the SDK
    stripeTerminal = StripeTerminal(
      fetchToken: () async {
        // Call your backend to get the connection token and return to this function
        // Example token can be.
        const token = "pst_test_XXXXXXXXXX...."; 

        return token;
      },
    );
  • Example backend code to get the connection token written on node.js:
    import Stripe from "stripe";
    import express from "express"

    const stripe = new Stripe("sk_test_XXXXXXXXXXXXXXXXXX", {
        apiVersion: "2020-08-27"
    })

    const app = express();

    app.get("/connectionToken", async (req, res) => {
        const token = await stripe.terminal.connectionTokens.create();
        res.send({
            success: true,
            data: token.secret
        });
    });
    app.listen(8000, () => {
        console.log("Server started")
    });
  • Discover the devices nearby and show it to the user
    stripeTerminal
        .discoverReaders(simulated: true)
        .listen((List<StripeReader> readers) {
            setState(() {
                this.readers = readers;
            });
        });
  • Connect to a reader
    bool connected = await stripeTerminal.connectToReader(readers[0].serialNumber);
    if(connected) {
        print("Connected to a device");
    }
  • Scan a card from the reader
    stripeTerminal
        .readPaymentMethod()
        .then((StripePaymentMethod paymentMethod) {
            print("A card was read, the last four digit is ${paymentMethod.card?.last4}");
        });

And you are done!!!!

Currently supported features:

  • Initializing terminal SDK
  • Scanning the readers
  • Connecting to a device (Only bluetooth devices on android)
  • Checking connection status
  • Checking connected device
  • Read payment method from the device

Missing Features

  • Create payment intent
  • Process payment
  • Capture payment

Future Plan

Please feel free to send a PR for further feature as you need or just create an issue on the repo with the feature request.

I have no plans to maintain this package in the long future thus the package will be deprecated as soon as flutter_stripe adds support to their SDK as mentioned here

Support the creator

Creating software for free takes time and effort thus please consider buying me a cup of coffee. This we definitely put a smile on my face and motivate me to contribute more.

"Buy Me A Coffee"

❤️ Sponsor

Comments
  • Unable to discover M2 Reader

    Unable to discover M2 Reader

    Hey @awazgyawali,

    I love this contribution to the Flutter community it was much needed. I am however experiencing issues when I attempt to connect to the Stripe M2 Reader.

    When scanning for devices the reader just does not show up, what readers have you tested with? In simulated mode, it all works, but the actual Bluetooth reader is not being discovered.

    Let me know!

    opened by anthonysette 5
  • Question about skip-tipping on reader stripe

    Question about skip-tipping on reader stripe

    Hello ,

    I want to ask you a question please,

    I am working on using Stripe Reader M2 In flutter using your library (stripe_terminal) everything is fine but I am unable to do skip tipping because it is not supported in your library Do you have a solution to this issue or another way to remove the tips.

    Thank you very much ..

    Skip-tipping in documentation:

    https://stripe.com/docs/terminal/features/collecting-tips/on-reader#skip-tipping

    opened by obada15 4
  • Stripe Terminal doesn't support IPv6 - throws 'unable to resolve host' error

    Stripe Terminal doesn't support IPv6 - throws 'unable to resolve host' error

    Hi @awazgyawali,

    Fantastic plugin - just wanted to flag to other users that might experience the same issue as me. Using a Stripe BBPOS WisePOS E as an internet reader I wasn't able to connect to the Stripe reader initially - I was getting the following error.

    Unable to resolve host "192-168-248-61.nwd72wa5njobbzccXXXX.device.stripe-terminal-local-reader.net": No address associated with hostname
    

    Eventually I found this page: https://stripe.com/docs/terminal/readers/bbpos-wisepos-e#troubleshooting

    Stripe Terminal also requires that your reader be assigned an IP address in one of the private IPv4 address blocks.

    Thought it was worth flagging, as they mention on the above link, you can proxy your connection through another router to get an IPv4 - hopefully it might save someone else some time.

    Thanks again.

    opened by matloughnane 1
  • Question about skip-tipping on reader stripe

    Question about skip-tipping on reader stripe

    Thank you, I updated the package but when I insert the card it still asks me to insert it a second time to pull out the tips, the issue it still please can you check it another time , The issue is still the same as before, the payment process is not completed without inserting the card again

    opened by obada15 1
  • Fixed: Unable to discover M2 Reader

    Fixed: Unable to discover M2 Reader

    Was also encountering some issue when discovering M2 Card Readers.

    Going through the code, native code was actually able to discover the M2 Card Reader. It seems that it was failing when parsing the json to StripeReader object. When discovering an M2 Card reader, it was not having any originalJSON field which was causing it to fail.

    e.g Sample json object received when an M2 reader is discovered (I've only changed the serial number): {locationStatus: 2, deviceType: 3, originalJSON: null, serialNumber: <SERIAL_NO>, batteryStatus: 0, locationId: null, simulated: false, availableUpdate: false, label: null}]

    Added some null check into the field for it to not cause error.

    opened by MichaelCadavillo 1
  • How to reconnect to a Reader?

    How to reconnect to a Reader?

    Hello,

    When I close/kill my App, my BBPOS WisePad E keeps the Bluetooth Connection to my Android Device. When I then try to reconnect to it after the App got restarted, discoverReaders does not find the Reader until I have disconnected it manually from my Android Settings and stripeTerminal.connectionStatus() says I have no connection aswell.

    I tried to bypass this by using:

    void didChangeAppLifecycleState(AppLifecycleState state) async {
    
        switch (state) {
    
          case AppLifecycleState.resumed:
    
            connectToReader(lastTerminalSerial);
    
            break;
    
          case AppLifecycleState.paused:
    
            if (await stripeTerminal.connectionStatus() ==
                ConnectionStatus.connected) {
    
              stripeTerminal.disconnectFromReader();
    
            }
    
            break;
        }
      }
    

    Disconnecting from the Reader works just fine with that but unfortunately the Reader will now disconnect immediately after it reconnected, logging [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(stripeTerminal#unableToConnect, The Stripe Terminal ConnectionToken has already been redeemed. Please generate a new one using v1/terminal/connection_tokens.

    So, what am I supposed to do now? :o Because I can't re-initialize StripeTerminal and I cannot update the Connection Token because I believe there is no method for that... :(

    I hope you got an idea and i really want to thank you in advance! I really appreciate what you did :)

    opened by kimonneuhoff 0
  • Support Android Target SDK 33

    Support Android Target SDK 33

    Currently the terminal package only supports 31 and below.

    Are there plans to upgrade this package to support Android SDK Version 33? I have been seeing a lot of issues with this package on the Android side.

    opened by nick-happsnow 0
  • Android 12 permissions crashes app

    Android 12 permissions crashes app

    When I run my app on Android 12 devices, whenever I let the user ask for permission(every permission) it crashes and give's me this error:

    E/AndroidRuntime(13170): at com.stripe.stripeterminal.PermissionsValidator.validatePermissionsPre31(PermissionsValidator.kt:34) E/AndroidRuntime(13170): at com.stripe.stripeterminal.PermissionsValidator.validatePermissions$core_publish(PermissionsValidator.kt:14) E/AndroidRuntime(13170): at com.stripe.stripeterminal.Terminal$Companion.initTerminal(Terminal.kt:839) E/AndroidRuntime(13170): at com.stripe.stripe_terminal.StripeTerminalPlugin._startStripe(StripeTerminalPlugin.kt:78) E/AndroidRuntime(13170): at com.stripe.stripe_terminal.StripeTerminalPlugin.onRequestPermissionsResult(StripeTerminalPlugin.kt:568) E/AndroidRuntime(13170): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry$FlutterEngineActivityPluginBinding.onRequestPermissionsResult(FlutterEngineConnectionRegistry.java:777) E/AndroidRuntime(13170): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onRequestPermissionsResult(FlutterEngineConnectionRegistry.java:409) E/AndroidRuntime(13170): at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onRequestPermissionsResult(FlutterActivityAndFragmentDelegate.java:757) E/AndroidRuntime(13170): at io.flutter.embedding.android.FlutterActivity.onRequestPermissionsResult(FlutterActivity.java:748) E/AndroidRuntime(13170): at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:8532) E/AndroidRuntime(13170): at android.app.Activity.dispatchActivityResult(Activity.java:8389) E/AndroidRuntime(13170): at android.app.ActivityThread.deliverResults(ActivityThread.java:5333) E/AndroidRuntime(13170): ... 13 more I/Process (13170): Sending signal. PID: 13170 SIG: 9 Lost connection to device. If you can investigate it will be very helpful, thank you.

    My flutter environment:

    [✓] Flutter (Channel stable, 3.3.7, on macOS 12.6 21G115 darwin-arm, locale it-IT) [✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) [✓] Xcode - develop for iOS and macOS (Xcode 14.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.3) [✓] VS Code (version 1.73.0) [✓] Connected device (3 available) [✓] HTTP Host Availability

    opened by GiulioWecove 1
  • Add tap to pay with iPhone (No Hardware)

    Add tap to pay with iPhone (No Hardware)

    No need for credit card reader, simply tap a card on the iPhone to accept payment in person. Here is a link for reference on feature:

    iPhone Tap to Pay w/ Stripe

    I will see if I have time to implement this as well, just wanted to raise this issue because I know I won't have time to work on this for about a month.

    opened by anthonysette 0
  • iOS crash when setReaderDisplay

    iOS crash when setReaderDisplay

    The app discovers correctly nearby readers and successfully connect but as soon as I use setReaderDisplay it crashes.

    • thread 1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT frame #0: 0x00000001bae8dbbc libsystem_kernel.dylib__pthread_kill + 8 libsystem_kernel.dylib__pthread_kill: -> 0x1bae8dbbc <+8>: b.lo 0x1bae8dbd8 ; <+36> 0x1bae8dbc0 <+12>: stp x29, x30, [sp, #-0x10]! 0x1bae8dbc4 <+16>: mov x29, sp 0x1bae8dbc8 <+20>: bl 0x1bae8960c ; cerror_nocancel Target 0: (Runner) stopped.
    opened by jacopofranza 0
Releases(v1.2.0)
  • v1.2.0(May 20, 2022)

    Breaking Change

    • Refactored readReusableCardDetail function to only collect card detail using insert method.
    • Tested with real M2 reader
    • Added collectPaymentMethod function to collect payment method using NFC and swipe reader
    Source code(tar.gz)
    Source code(zip)
  • v1.0.0-1(May 1, 2022)

Owner
Aawaz Gyawali
Contributor at Flutter | FlutterFire.
Aawaz Gyawali
Muhammad Bilal 0 Jan 6, 2022
Esp touch flutter plugin - Client-side (mobile) Android Flutter implementation for ESP-Touch protocol

esp_touch_flutter_plugin Client-side (mobile) Android Flutter implementation for

huangyanxiong 0 Jan 21, 2022
Open as default - A flutter plugin that allows setting up your flutter app to open files as default

open_as_default A flutter plugin that allows setting up your flutter app to open

LuisDeLaValier 3 Nov 15, 2022
Flutter plugin that leverages Storage Access Framework (SAF) API to get access and perform the operations on files and folders

Flutter plugin that leverages Storage Access Framework (SAF) API to get access and perform the operations on files and folders.

Vehement 8 Nov 26, 2022
use kmm to write a flutter plugin

use KMM to write a flutter plugin The reference plugin_codelab example plugin that accompanies the How to write a Flutter plugin codelab. I changed pl

libill 8 Nov 9, 2022
A collection of useful extension methods for Android

Kotlin Jetpack A collection of useful extension methods for Android Arguments Bindings Preferences Bindings Resources Bindings Arguments Bindings publ

Vladimir Mironov 187 Nov 10, 2022
Most used extension methods for Kotlin

Extensify Most used extension methods for Kotlin Download Step 1. Add the JitPack repository to your build file allprojects { repositories {

Mobven 36 Aug 25, 2022
A kotlin library of extension functions that add smalltalk style methods to objects.

KtTalk A kotlin library of extension functions that add smalltalk style methods to objects. Motivation Smalltalk is a pure OO language in which everyt

null 11 Oct 16, 2021
Kstr is a set of helpful methods library for Kotlin intended for make the developer life easier.

Kstr is a set of helpful methods library for Kotlin intended for make the developer life easier. Kstr uses the powerful feature of extension func

Rafael Acioly 0 Nov 3, 2021
A android platform i.e, App that helps marriage/party halls and individuals to connect to the nearest places where this food could feed those in need and food wastage is minimised

(Muskan- The joy of giving by nature) , a android platform i.e, App that helps marriage/party halls and individuals to connect to the nearest places where this food could feed those in need and food wastage is minimised.

OxVidhi 15 Nov 26, 2022
A simple library that can connect your autocomplete edittext to Google places api

Google Places AutoComplete EditText A simple library that can connect your autocomplete edittext to Google's places api Supporting Places AutoComplete

Mukesh Solanki 71 Dec 28, 2022
A Flutter implementation of Salesforce Marketing Cloud for iOS and Android

sfmc_flutter A Flutter implementation of Salesforce Marketing Cloud for iOS and Android. Features Setup Marketing Cloud (iOS and Android) Support for

Alex Tarragó 5 Oct 19, 2022
Klutter: Flutter + Kotlin Multiplatform

Klutter Klutter is a framework and tool set which uses Flutter to create the frontend and Kotlin Multiplatform for the backend. The connective layer i

Gillian 159 Dec 22, 2022
1aingenieriaygas native base android - Project base for the migration of the Flutter App of 1A Ingenieria y Gas

1A Ingenieria y Gas App Versión Wordpress Backend Este proyecto se encuentra sol

Paul Osinga 1 Jan 26, 2022
💫 Small microservice to handle state changes of Kubernetes pods and post them to Instatus or Statuspages

?? Kanata Small microservice to handle state changes of Kubernetes pods and post them to Instatus or Statuspages ?? Why? I don't really want to implem

Noel 4 Mar 4, 2022
Extension functions over Android's callback-based APIs which allows writing them in a sequential way within coroutines or observe multiple callbacks through kotlin flow.

callback-ktx A lightweight Android library that wraps Android's callback-based APIs into suspending extension functions which allow writing them in a

Sagar Viradiya 171 Oct 31, 2022
🛠️ The missing drawable toolbox for Android. Create drawables programmatically and get rid of the boring and always repeated drawable.xml files.

DrawableToolbox English | 中文 The missing DrawableToolbox for Android. Create drawables programmatically and get rid of the boring and always repeated

Hong Duan 1.1k Jan 4, 2023
With Viola android face detection library, you can detect faces in a bitmap, crop faces using predefined algorithm and get additional information from the detected faces.

Viola Viola android face detection library detects faces automatically from a bitmap, crop faces using the predefined algorithms, and provides supplem

Darwin Francis 58 Nov 1, 2022
KaMP Kit by Touchlab is a collection of code and tools designed to get your mobile team started quickly with Kotlin Multiplatform.

KaMP Kit Welcome to the KaMP Kit! About Goal The goal of the KaMP Kit is to facilitate your evaluation of Kotlin Multiplatform (aka KMP). It is a coll

Touchlab 1.7k Jan 3, 2023