clover_connect 0.0.1 clover_connect: ^0.0.1 copied to clipboard
A flutter plugin to connect flutter app with Clover payment devices.
clover_connect #
A flutter plugin to connect flutter app with Clover payment devices.
Getting Started #
This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.
For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.
Clover Semi-Integration #
Learn more about Clover development basics
Secure Network Pay Display #
Configuring Secure Network Pay Display
Clover Connector iOS SDK #
This plugin uses Clover Connector iOS SDK
Usage #
Import package:clover_connect/clover_connect.dart
, call static methods of CloverConnect
.
Connect #
String _connectionStatus = 'Unknown';
final cloverEndpointTextEditingController = TextEditingController(text: 'wss://192.168.1.123:12345/remote_pay');
Future<void> connect() async {
String connectionStatus;
String endpoint = cloverEndpointTextEditingController.text;
try {
var cloverConfig = CloverConfig(endpoint: endpoint);
connectionStatus = await CloverConnect.connect(cloverConfig);
} on PlatformException {
connectionStatus = 'Failed to connect Clover.';
}
setState(() {
_connectionStatus = connectionStatus;
});
}
Get Pairing Code #
String _pairingCode = 'Unknown';
Future<void> getPairingCode() async {
String pairingCode;
try {
pairingCode = await CloverConnect.pairingCode;
} on PlatformException {
pairingCode = 'Failed to get pairing code.';
}
setState(() {
_pairingCode = pairingCode;
});
}
Get Current Status #
String _currentStatus = 'Unknown';
Future<void> getCurrentStatus() async {
String currentStatus;
try {
currentStatus = await CloverConnect.currentStatus;
} on PlatformException {
currentStatus = 'Failed to get current status.';
}
setState(() {
_currentStatus = currentStatus;
});
}
Sale #
String _saleStatus = 'Unknown';
final saleAmountTextEditingController = TextEditingController(text: '1.23');
final saleExternalIdTextEditingController = TextEditingController(text: '123456');
Future<void> sale() async {
String saleStatus;
int amount = (double.parse(saleAmountTextEditingController.text) * 100).toInt();
String externalId = saleExternalIdTextEditingController.text;
try {
var saleRequest = SaleRequest(amount: amount, externalId: externalId);
saleStatus = await CloverConnect.sale(saleRequest);
} on PlatformException {
saleStatus = 'Failed to connect Clover.';
}
setState(() {
_saleStatus = saleStatus;
});
}
Disconnect #
Future<void> disconnect() async {
String connectionStatus;
try {
connectionStatus = await CloverConnect.disconnect();
} on PlatformException {
connectionStatus = 'Failed to disconnect Clover.';
}
setState(() {
_connectionStatus = connectionStatus;
});
}