A Flutter wrapper to use the Zettle POS SDK.
With this plugin, your app can easily request payment via the Zettle readers on Android and iOS.
You Must Call the init function Only once a time in your app
Zettle.init(iosClientId, androidClientId, redirectUrl);
- Registered for a Zettle developer account via Zettle.
- Deployment Target iOS 12.0 or higher.
- Android minSdkVersion 21 or higher.
Add to build.gradle (as per https://github.com/iZettle/sdk-android) Add your personal access token to build.gradle (as per https://github.com/iZettle/sdk-android), this is used to access the Zettle maven repo on github
android {
packagingOptions {
exclude 'META-INF/*.kotlin_module'
}
}
allprojects {
repositories {
google()
mavenCentral()
maven {
url = uri("https://maven.pkg.github.com/iZettle/sdk-android")
credentials(HttpHeaderCredentials) {
name "Authorization"
value "Bearer <YOUR TOKEN HERE>"
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
}
Add to manifest (as per https://github.com/iZettle/sdk-android)
<activity
android:name="com.izettle.android.auth.OAuthActivity"
android:launchMode="singleTask"
android:taskAffinity="@string/oauth_activity_task_affinity"
android:exported="true">
<intent-filter>
<data
android:host="[redirect url host]"
android:scheme="[redirect url scheme]" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
Add reader protocol to info.plist (https://github.com/iZettle/sdk-ios)
<key>UISupportedExternalAccessoryProtocols</key>
<array>
<string>com.izettle.cardreader-one</string>
</array>
Add elements to info.plist (https://github.com/iZettle/sdk-ios)
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-central</string>
<string>external-accessory</string>
</array>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Our app uses bluetooth to find, connect and transfer data with Zettle card reader devices.</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>Our app uses bluetooth to find, connect and transfer data with Zettle card reader devices.</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>"The scheme of your OAuth Redirect URI *"</string>
</array>
</dict>
</array>
<key>NSLocationWhenInUseUsageDescription</key>
<string>You need to allow this to be able to accept card payments</string>
Add zettle to your pubspec.yaml:
dependencies:
zettle:
Import zettle:
import 'package:zettle/zettle.dart';
Init Zettle SDK:
Zettle.init(iosClientId, androidClientId, redirectUrl);
Complete a transaction:
var request = ZettlePaymentRequest(
amount: 100,
reference: reference,
enableLogin: true,
enableTipping: false,
enableInstalments: false);
Zettle.requestPayment(request);
Zettle.init(iosClientId, androidClientId, redirectUrl);
bool Zettle.isInitialized;
Zettle.requestPayment(request);
Zettle.requestRefund(request);