Last updated:
0 purchases
flutter square pos
flutter_square_pos #
A flutter plugin to use square POS(point of sale) api.
Square supports sdk of POS for Andoid and iOS but not supported for flutter.
This library bundles them for flutter.
Setup #
Common #
Installation
Add flutter_square_pos to depencency in pubspec.yaml of your project.
depencendies:
flutter_square_pos: ^1.0.0
copied to clipboard
Define applicationId of square on code of your app
Get Application ID from developper dashboard and define it on your app.
For example on main.dart.
var squareApplicationId = 'sq0idp-sEIatSPRxB2uxxxxxxx';
copied to clipboard
Android #
Register Android app info to square account
Fingerprint and package name are required.
Andorid | Register your application
Change minSdkVersino for uni_links.
This plugin uses uni_links for iOS but Android also need to support it.
To build it, set minSdkVersion as 23 in android/build.gradle of your project.
android {
defaultConfig {
minSdkVersion 23 // required to set
}
}
copied to clipboard
iOS #
Activate url scheme
iOS | Add your URL schemes
Register iOS app info to square account
Bunde id and URL scheme are required.
iOS | Register your application
Define url schema in dart code
For example on main.dart.
var squareCallbackURL = 'your-ios-url-scheme://';
copied to clipboard
Usage #
Import #
import 'package:flutter_square_pos/flutter_square_pos.dart';
copied to clipboard
createClient #
Call createClient once.
This sample calls createClient on initState.
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
FlutterSquarePos.createClient(squareApplicationId)
}
}
copied to clipboard
startTransaction #
By calling startTransaction, you can get client_transaction_id or error information.
int amount = 809;
String currency = 'JPY';
Map<String, String> result = await FlutterSquarePos.startTransaction(
amount,
currency,
tenderTypes: ['CARD', 'CARD_ON_FILE', 'CASH', 'OTHER'])
callbackURL: squareCallbackURL, // Required for iOS
skipReceipt: true); // skipReceipt support only for iOS
if (result.containsKey("errorCode")) {
setState(() {
_result = result["errorCode"];
});
showDialog(
context: this.context,
builder: (context) => AlertDialog(
title: Text(result["errorCode"] ?? ""),
content: Text(result["errorMessage"] ?? ""),
actions: [
TextButton(
child: Text('close'),
onPressed: () => Navigator.pop(context, false))
],
),
);
} else {
setState(() {
_result = result["clientTransactionId"];
});
}
copied to clipboard
License #
MIT
References #
POS-apo Build on Android
Point of Sale Android SDK
POS-api Build on iOS
SquarePointOfSaleSDK-iOS
Type of expression is ambiguous using Square code
Writing custom platform-specific code
plug-in package
pos android fingerprint
matix-io/react-native-square-pos
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.