public List <Field> PaymentInfo(string SKU, string Reference) { if (!IsConfigured) { throw new Exception(); } string[] credentials = { Url, User, Password, EncryptedKey }; int[] config = { Group, Chain, Merchant, POS, Cashier }; List <Field> fields = new List <Field>(); fields.Add(new Field() { Name = "TRANSACCION", Value = 1, Length = 0, Type = 0, Class = 0, Encrypt = false }); fields.Add(new Field() { Name = "SKU", Value = SKU, Length = 0, Type = 0, Class = 0, Encrypt = false }); fields.Add(new Field() { Name = "REFERENCIA", Value = Reference, Length = 0, Type = 0, Class = 0, Encrypt = true }); var _DT = new Class_DT(); var task = Task.Run(() => { return(_DT.Send_Request("Info", credentials, fields, config)); }); try { var success = task.Wait(45000); if (success) { var x = _DT.GetFieldsFromXml(task.Result.response); var responseService = new ResponseService(); if (x.field.Count > 0) { foreach (var item in x.field) { if (item.Name == "REFERENCIA") { item.Value = _DT.Decrypt(item.Value.ToString(), EncryptedKey); } } return(x.field); } } } catch (AggregateException ex) { throw ex.InnerException; } return(new List <Field>()); }
public ResponseService Request(List <Field> Fields) { if (!IsConfigured) { throw new Exception(); } string[] credentials = { Url, User, Password, EncryptedKey }; int[] config = { Group, Chain, Merchant, POS, Cashier }; var _DT = new Class_DT(); var task = Task.Run(() => { return(_DT.Send_Request("Ejecuta", credentials, Fields, config)); }); try { var success = task.Wait(45000); if (success) { var x = _DT.GetFieldsFromXml(task.Result.response); var responseService = new ResponseService(); if (x.field.Count > 0) { responseService.Success = true; responseService.XML = x.xmlResponse; foreach (var item in x.field) { switch (item.Name) { case "CODIGORESPUESTA": responseService.ResponseCode = int.Parse(item.Value.ToString()); break; case "AUTORIZACION": responseService.AuthorizeCode = int.Parse(item.Value.ToString()); break; case "REFERENCIA": item.Value = _DT.Decrypt(item.Value.ToString(), EncryptedKey); break; } } responseService.Fields = x.field; return(responseService); } } } catch (AggregateException ex) { throw ex.InnerException; } return(new ResponseService()); }