UpiResponse.fromResponseString constructor

UpiResponse.fromResponseString(
  1. String responseString
)

Factory method to create an instance of UpiResponse from a UPI response string.

Parameters:

  • responseString: The UPI response string received after a transaction.

Returns: An instance of UpiResponse with parsed information from the response string.

Implementation

factory UpiResponse.fromResponseString(String responseString) {
  final builder = UpiResponseBuilder();

  List<String> partOfResponse = responseString.split('&');
  for (int i = 0; i < partOfResponse.length; ++i) {
    String key = partOfResponse[i].split('=')[0];
    String value = partOfResponse[i].split('=')[1];
    builder._processKeyValue(key.toLowerCase(), value);
  }

  return UpiResponse._builder(builder);
}