UpiResponse constructor

UpiResponse(
  1. String responseString
)

Implementation

UpiResponse(String responseString) {
  List<String> _parts = responseString.split('&');
  for (int i = 0; i < _parts.length; ++i) {
    String key = _parts[i].split('=')[0];
    String value = _parts[i].split('=')[1];
    if (key.toLowerCase() == "txnid") {
      transactionId = _getValue(value);
    } else if (key.toLowerCase() == "responsecode") {
      responseCode = _getValue(value);
    } else if (key.toLowerCase() == "approvalrefno") {
      approvalRefNo = _getValue(value);
    } else if (key.toLowerCase() == "status") {
      if (value.toLowerCase().contains("success"))
        status = "success";
      else if (value.toLowerCase().contains("fail"))
        status = "failure";
      else if (value.toLowerCase().contains("submit"))
        status = "submitted";
      else
        status = "other";
    } else if (key.toLowerCase() == "txnref") {
      transactionRefId = _getValue(value);
    }
  }
}