Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 31
compileSdkVersion 33

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@ class IboxproFlutterHandlerImpl: MethodCallHandler {
methodChannel.invokeMethod("onLogin", arguments)
}

private fun setCustomReaderParams(call: MethodCall) {
val params = call.arguments as HashMap<String, Any>
val notup = params["NOTUP"] as Boolean

val readerParams = Hashtable<String, Any>()
readerParams["NOTUP"] = notup

paymentController.setCustomReaderParams(readerParams)
}

private fun startPayment(call: MethodCall) {
val params = call.arguments as HashMap<String, Any>
val inputType = PaymentController.PaymentInputType.fromValue(params["inputType"] as Int)
Expand Down Expand Up @@ -306,6 +316,10 @@ class IboxproFlutterHandlerImpl: MethodCallHandler {
login(call)
result.success(null)
}
"setCustomReaderParams" -> {
setCustomReaderParams(call)
result.success(null)
}
"startPayment" -> {
startPayment(call)
result.success(null)
Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ subprojects {

task clean(type: Delete) {
delete rootProject.buildDir
}
}
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
2 changes: 1 addition & 1 deletion example/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
}
}
54 changes: 46 additions & 8 deletions example/lib/pages/main_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class _MainPage extends State<MainPage> {
String _loginEmail = '';
String _password = '';
String _deviceName = '';
bool _isHidden = true;
bool _nfcActivation = false;

late StreamSubscription<PaymentLoginEvent> _onLoginSubscription;
late StreamSubscription<PaymentReaderSetDeviceEvent> _onReaderSetDeviceSubscription;
Expand Down Expand Up @@ -54,14 +56,27 @@ class _MainPage extends State<MainPage> {
TextFormField(
initialValue: _loginEmail,
maxLines: 1,
keyboardType: TextInputType.emailAddress,
decoration: InputDecoration(labelText: 'Логин'),
onChanged: (val) => _loginEmail = val
),
onChanged: (val) => _loginEmail = val),
TextFormField(
initialValue: _password,
obscureText: true,
obscureText: _isHidden,
keyboardType: _isHidden ? null : TextInputType.visiblePassword,
enableSuggestions: false,
autocorrect: false,
maxLines: 1,
decoration: InputDecoration(labelText: 'Пароль'),
decoration: InputDecoration(
labelText: 'Пароль',
suffixIcon: IconButton(
icon: Icon(_isHidden ? Icons.visibility : Icons.visibility_off),
onPressed: () {
setState(() {
_isHidden = !_isHidden;
});
},
),
),
onChanged: (val) => _password = val
),
ElevatedButton(
Expand Down Expand Up @@ -102,11 +117,35 @@ class _MainPage extends State<MainPage> {
];
}

List<Widget> _buildPaymentPart(BuildContext context) {
List<Widget> _buildReaderParams(BuildContext context) {
return [
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Expanded(
child: Text('Авто NFC: ${_nfcActivation ? "Включено" : "Отключено"}'),
),
Switch(
value: _nfcActivation,
onChanged: (bool newValue) async {
await PaymentController.setCustomReaderParams(nfcActivation: newValue);
setState(() {
_nfcActivation = newValue;
});
_showSnackBar(newValue
? 'Автоматическое включение NFC активировано'
: 'Автоматическое включение NFC отключено');
},
),
],
)
];
}

List<Widget> _buildPaymentPart(BuildContext context) {
return [
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
ElevatedButton(
child: Text('Оплатить'),
Expand All @@ -133,9 +172,8 @@ class _MainPage extends State<MainPage> {
padding: EdgeInsets.all(8),
children: _buildLoginPart(context)
..addAll(_buildSearchDevicePart(context))
..addAll(_buildPaymentPart(context))
)
),
..addAll(_buildReaderParams(context))
..addAll(_buildPaymentPart(context)))),
);
}
}
13 changes: 13 additions & 0 deletions ios/Classes/SwiftIboxproFlutterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ public class SwiftIboxproFlutterPlugin: NSObject, FlutterPlugin {
}
}

private func setCustomReaderParams(call: FlutterMethodCall) {
let params = call.arguments as! [String: Any]
let notup = params["NOTUP"] as! Bool

var readerParams = [String: Any]()
readerParams["NOTUP"] = notup

paymentController.setCustomReaderParams(readerParams: readerParams)
}

public func startPayment(_ call: FlutterMethodCall) {
let params = call.arguments as! [String: Any]
let inputType = TransactionInputType(
Expand Down Expand Up @@ -211,6 +221,9 @@ public class SwiftIboxproFlutterPlugin: NSObject, FlutterPlugin {
case "login":
login(call)
return result(nil)
case "setCustomReaderParams":
setCustomReaderParams(call)
return result(nil)
case "startPayment":
startPayment(call)
return result(nil)
Expand Down
5 changes: 3 additions & 2 deletions lib/src/events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ class PaymentCompleteEvent extends PaymentEvent {
}

class PaymentAdjustEvent extends PaymentEvent {
final Result result;
final Result result;

PaymentAdjustEvent(this.result);
}

class PaymentAdjustReverseEvent extends PaymentEvent {
final Result result;
final Result result;

PaymentAdjustReverseEvent(this.result);
}
Expand All @@ -59,6 +59,7 @@ class PaymentReaderSetDeviceEvent extends PaymentEvent {

PaymentReaderSetDeviceEvent(this.deviceName);
}

class PaymentRejectReverseEvent extends PaymentEvent {
PaymentRejectReverseEvent();
}
10 changes: 10 additions & 0 deletions lib/src/payment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ class PaymentController {
});
}

/// Устанавливает параметры работы ридера.
///
/// [nfcActivation] (true/false) – автоматическое включение NFC на ридере P17
/// при проведении транзакции
static Future<void> setCustomReaderParams({bool nfcActivation = false}) async {
await _channel.invokeMethod('setCustomReaderParams', {
'NOTUP': nfcActivation,
});
}

/// Начинает операцию принятия оплаты терминалом
///
/// [inputType] вид оплаты, все возможные значения в [InputType]
Expand Down