public HttpResponseMessage ValidateTokenId(string tokenID, string cardtype) { string customerVaultId = ""; string ccexp = ""; string ccnumber = ""; XmlDocument xmlRequest = new XmlDocument(); XmlDeclaration xmlDecl = xmlRequest.CreateXmlDeclaration("1.0", "UTF-8", "yes"); XmlElement root = xmlRequest.DocumentElement; xmlRequest.InsertBefore(xmlDecl, root); XmlElement xmlCompleteTransaction = xmlRequest.CreateElement("complete-action"); XmlElement xmlApiKey = xmlRequest.CreateElement("api-key"); xmlApiKey.InnerText = ConfigurationManager.AppSettings["CardflexApikey"]; xmlCompleteTransaction.AppendChild(xmlApiKey); XmlElement xmlTokenId = xmlRequest.CreateElement("token-id"); xmlTokenId.InnerText = tokenID; xmlCompleteTransaction.AppendChild(xmlTokenId); xmlRequest.AppendChild(xmlCompleteTransaction); string responseFromServer = _bankService.sendXMLRequest(xmlRequest); XmlReader responseReader = XmlReader.Create(new StringReader(responseFromServer)); XmlDocument xDoc = new XmlDocument(); xDoc.Load(responseReader); XmlNodeList response = xDoc.GetElementsByTagName("result"); XmlNodeList responseText = xDoc.GetElementsByTagName("result-text"); responseReader.Close(); if (response[0].InnerText.Equals("1")) { XmlNodeList VaultId = xDoc.GetElementsByTagName("customer-vault-id"); XmlNodeList xmlccexp = xDoc.GetElementsByTagName("cc-exp"); XmlNodeList CCNumber = xDoc.GetElementsByTagName("cc-number"); customerVaultId = VaultId[0].InnerText; ccexp = xmlccexp[0].InnerText; ccnumber = (CCNumber[0].InnerText.Length > 3) ? CCNumber[0].InnerText.Substring(CCNumber[0].InnerText.Length - 4, 4) : CCNumber[0].InnerText; ccnumber = "************" + ccnumber; _bankService.AddCreditCardDetails(customerVaultId, ccexp, ccnumber, cardtype); } else { throw new InvalidParameterException("Invalid Credit Card Information."); } return(Request.CreateResponse(HttpStatusCode.OK, true)); }