private TrayCheckouttransactionRet Notification(out int statusret) { TrayCheckouttransactionRet rett = new TrayCheckouttransactionRet(); statusret = 200; var form = formData(); var content = new FormUrlEncodedContent(form); //Método pode ser excluido, utilizado apenas para quebrar linha dos dados do form para melhor visualização formatForm(form); TrayCheckout tc = new TrayCheckout(); tc.RequestTrayCheckout(content, ConfigTrayCheckout.UrlGetByToken()); if (tc.getHttpStatusCode().Equals(HttpStatusCode.OK)) { //Response.StatusCode = 200; XmlDocument xml = new XmlDocument(); xmlResponse = tc.getContent(); xml.LoadXml(xmlResponse); tc.setXml(xml); if (!tc.sucessResponse()) { message = tc.getMessage(); rett.lsterros.AddRange(tc.getGeneralError()); rett.lsterros.AddRange(tc.getValidationError()); statusret = 206; } else { message = tc.getMessage(); XmlNodeList transaction = xml.GetElementsByTagName("transaction"); rett.order_number = transaction[0]["order_number"].InnerText; rett.transaction_id = transaction[0]["transaction_id"].InnerText; rett.status_id = transaction[0]["status_id"].InnerText; rett.status_name = transaction[0]["status_name"].InnerText; XmlNodeList payment = xml.GetElementsByTagName("payment"); rett.price_original = payment[0]["price_original"].InnerText; rett.payment_response = payment[0]["payment_response"].InnerText; rett.payment_split = payment[0]["split"].InnerText; rett.payment_payment_method_id = payment[0]["payment_method_id"].InnerText; rett.price_original = payment[0]["price_original"].InnerText; rett.payment_payment_method_name = payment[0]["payment_method_name"].InnerText; } } return(rett); }
private TrayCheckoutPaymentResponse BuildRequest(TrayCheckout tc) { TrayCheckoutPaymentResponse tcpret = new TrayCheckoutPaymentResponse(); tcpret.sucessResponse = tc.sucessResponse(); XmlDocument xmlDocument = tc.getXml(); if (!tc.sucessResponse())//erro { /* Generic Errors */ XmlNodeList generalErrorList = xmlDocument.GetElementsByTagName("general_error"); foreach (XmlNode pm in generalErrorList) { validation_error vr = new validation_error(); vr.code = pm["code"].InnerText; vr.message = pm["message"].InnerText; tcpret.validation_errors.Add(vr); } XmlNodeList errorList = xmlDocument.GetElementsByTagName("error"); foreach (XmlNode pm in errorList) { validation_error vr = new validation_error(); vr.code = pm["code"].InnerText; vr.message = pm["message"].InnerText; tcpret.validation_errors.Add(vr); } XmlNodeList validationerrorList = xmlDocument.GetElementsByTagName("validation_error"); foreach (XmlNode pm in validationerrorList) { validation_error vr = new validation_error(); vr.code = pm["code"].InnerText; vr.message = pm["message"].InnerText; vr.field = pm["field"].InnerText; vr.message_complete = pm["message_complete"].InnerText; tcpret.validation_errors.Add(vr); } } else//ok { XmlNodeList transaction = xmlDocument.GetElementsByTagName("transaction"); tcpret.order_number = transaction[0]["order_number"].InnerText; tcpret.status_id = transaction[0]["status_id"].InnerText; tcpret.status_name = transaction[0]["status_name"].InnerText; tcpret.transaction_id = transaction[0]["transaction_id"].InnerText; tcpret.token_transaction = transaction[0]["token_transaction"].InnerText; XmlNodeList payment = xmlDocument.GetElementsByTagName("payment"); tcpret.price_payment = payment[0]["price_payment"].InnerText; tcpret.payment_response = payment[0]["payment_response"].InnerText; tcpret.url_payment = payment[0]["url_payment"].InnerText; tcpret.tid = payment[0]["tid"].InnerText; tcpret.split = payment[0]["split"].InnerText; tcpret.payment_method_id = payment[0]["payment_method_id"].InnerText; tcpret.payment_method_name = payment[0]["payment_method_name"].InnerText; tcpret.linha_digitavel = payment[0]["price_payment"].InnerText; } return(tcpret); }