/// <summary> /// Executes processing of the amex auth request. /// </summary> public ResultCode Execute() { ResultCode result = ResultCode.None; SharedAuthorizationLogic sharedAuthorizationLogic = new SharedAuthorizationLogic(Context, CommerceOperationsFactory.AuthorizationOperations(Context)); Authorization authorization = new Authorization(); Context[Key.Authorization] = authorization; Amex amex = new Amex(Context); amex.MarshalAuthorization(); result = sharedAuthorizationLogic.AddAuthorization(); // Build the response to send back to Amex based on the result of adding the Authorization. Context[Key.ResultCode] = result; amex.BuildAuthorizationResponse(); if (result == ResultCode.Created) { Context.Log.Verbose("Authorization successfully persisted, now send notification"); // Send notification. NotifyAuthorization notifyAuthorization = new NotifyAuthorization(Context); Context[Key.CardBrand] = CardBrand.AmericanExpress; notifyAuthorization.SendNotification(); Context.Log.Verbose("Authorization notification sent"); } return(result); }
public void TestInverteNumero() { var cartao = new Amex(); var numeroInvertido = cartao.InverteNumero("12345"); var teste = new List <int>() { 5, 4, 3, 2, 1 }; CollectionAssert.AreEqual(numeroInvertido, teste); }
private void btnTestAmex_Click(object sender, EventArgs e) { LayoutImport li = importFile("SampleFiles\\Amex.txt", LayoutType.Amex); if (li != null) { Amex layout = (Amex)li.LayoutBase.ImportFile.ImportAttributes; //Mostra o arquivo lido na integra txtResult2.Text = li.LayoutBase.Lines.ToString(); //Mostar apenas as colunas mapeadas StringBuilder sb = new StringBuilder(); string tab1 = " "; string tab2 = " "; string tab3 = " "; foreach (Amex.HeaderRow header in layout.HeaderRows) { sb.Append(header.LineNumber + Environment.NewLine); foreach (Amex.PagamentoRow pagto in layout.PagamentoRows.Where(p => p.ParentLineNumber == header.LineNumber)) { sb.Append(tab1 + pagto.LineNumber + Environment.NewLine); foreach (Amex.SOCRow soc in layout.SOCRows.Where(p => p.ParentLineNumber == pagto.LineNumber)) { sb.Append(tab2 + soc.LineNumber + Environment.NewLine); foreach (Amex.ROCRow roc in layout.ROCRows.Where(p => p.ParentLineNumber == soc.LineNumber)) { sb.Append(tab3 + roc.LineNumber + Environment.NewLine); } foreach (Amex.AjustesRow ajuste in layout.AjustesRows.Where(p => p.ParentLineNumber == pagto.LineNumber)) { sb.Append(tab3 + ajuste.LineNumber + Environment.NewLine); } } } foreach (Amex.TrailerRow trailer in layout.TrailerRows.Where(p => p.ParentLineNumber == header.LineNumber)) { sb.Append(tab1 + trailer.LineNumber + Environment.NewLine); } } txtResult1.Text = sb.ToString(); } }
public void TestDobraNumeroes() { var cartao = new Amex(); var numeroDobrado = cartao.DobraNumeros(new List <int>() { 1, 2, 3, 4, 5 }); var teste = new List <int>() { 1, 4, 3, 8, 5 }; CollectionAssert.AreEqual(numeroDobrado, teste); }
// POST /Amex/token/ public HttpResponseMessage Post(string token, [FromBody] Amex param) { try { HttpResponseMessage retorno = new HttpResponseMessage(); if (Permissoes.Autenticado(token)) { return(Request.CreateResponse <Int32>(HttpStatusCode.OK, GatewayAmex.Add(token, param))); } else { return(Request.CreateResponse(HttpStatusCode.Unauthorized)); } } catch { throw new HttpResponseException(HttpStatusCode.InternalServerError); } }
/// <summary> /// Altera Amex /// </summary> /// <param name="param"></param> /// <returns></returns> public static void Update(string token, Amex param) { Amex value = _db.Amexes .Where(e => e.id.Equals(param.id)) .First <Amex>(); // OBSERVAÇÂO: VERIFICAR SE EXISTE ALTERAÇÃO NO PARAMETROS if (param.id != null && param.id != value.id) { value.id = param.id; } if (param.dataRecebimento != null && param.dataRecebimento != value.dataRecebimento) { value.dataRecebimento = param.dataRecebimento; } if (param.dataVenda != null && param.dataVenda != value.dataVenda) { value.dataVenda = param.dataVenda; } if (param.nsu != null && param.nsu != value.nsu) { value.nsu = param.nsu; } if (param.cdAutorizador != null && param.cdAutorizador != value.cdAutorizador) { value.cdAutorizador = param.cdAutorizador; } if (param.cnpj != null && param.cnpj != value.cnpj) { value.cnpj = param.cnpj; } if (param.numCartao != null && param.numCartao != value.numCartao) { value.numCartao = param.numCartao; } if (param.totalParcelas != null && param.totalParcelas != value.totalParcelas) { value.totalParcelas = param.totalParcelas; } if (param.valorTotal != null && param.valorTotal != value.valorTotal) { value.valorTotal = param.valorTotal; } if (param.numSubmissao != null && param.numSubmissao != value.numSubmissao) { value.numSubmissao = param.numSubmissao; } if (param.idOperadora != null && param.idOperadora != value.idOperadora) { value.idOperadora = param.idOperadora; } if (param.idBandeira != null && param.idBandeira != value.idBandeira) { value.idBandeira = param.idBandeira; } if (param.idTerminalLogico != null && param.idTerminalLogico != value.idTerminalLogico) { value.idTerminalLogico = param.idTerminalLogico; } _db.SaveChanges(); }
/// <summary> /// Adiciona nova Amex /// </summary> /// <param name="param"></param> /// <returns></returns> public static Int32 Add(string token, Amex param) { _db.Amexes.Add(param); _db.SaveChanges(); return(param.id); }
public AmexTest() { _amex = new Amex(); }
public void SetupTest() { a = new Amex(); }