generate static method

  1. @visibleForTesting
String generate({
  1. required String terminalKey,
  2. required AcquiringRequest request,
  3. String? password,
})

Создает токен, на основе terminalKey, password, request

Можно использовать только для тестирования

Implementation

@visibleForTesting
static String generate({
  required String terminalKey,
  required AcquiringRequest request,
  String? password,
}) {
  final Map<String, dynamic> temp = request.toJson()
    ..addAll(<String, dynamic>{
      JsonKeys.terminalKey: terminalKey,
      if (password != null && password.isNotEmpty)
        JsonKeys.password: password,
    });
  final List<String> sortedKeys = List<String>.from(temp.keys)..sort();
  final StringBuffer buffer = StringBuffer();

  for (int i = 0; i < sortedKeys.length; i++) {
    if (!request.ignoredFields.contains(sortedKeys[i])) {
      buffer.write(temp[sortedKeys[i]]);
    }
  }

  return CryptoUtils.sha256(buffer.toString());
}