Skip to content

Commit

Permalink
Corrigido bug no retorno da consulta de transação
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcos Gonçalves committed Aug 22, 2017
1 parent 6fc4ecb commit dbf185f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 9 deletions.
31 changes: 26 additions & 5 deletions Cielo.Demo/Helpers/ConsoleHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,31 @@ public static void WriteResult(CheckTransactionResponse response)

Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("Reason Code".PadRight(25, ' ') + $": {response.ReasonCode}");
Console.WriteLine("Reason Message".PadRight(25, ' ') + $": {response.ReasonMessage}");
Console.WriteLine("");
Console.WriteLine("");

if (response?.Payments.Count > 0)
{
Console.WriteLine("ReasonCode".PadRight(25, ' ') + $": {response?.ReasonCode}");
Console.WriteLine("ReasonMessage".PadRight(25, ' ') + $": {response?.ReasonMessage}");
Console.WriteLine("Number of Payments".PadRight(25, ' ') + $": {response?.Payments.Count}");
Console.WriteLine("PaymentId".PadRight(25, ' ') + $": {response?.Payments[0].PaymentId}");
Console.WriteLine("");
Console.WriteLine("");
}
else
{
Console.WriteLine("MerchantOrderId".PadRight(25, ' ') + $": {response?.MerchantOrderId}");
Console.WriteLine("Installments".PadRight(25, ' ') + $": {response?.Payment?.Installments}");
Console.WriteLine("ServiceTaxAmount".PadRight(25, ' ') + $": {response?.Payment?.ServiceTaxAmount}");
Console.WriteLine("Capture".PadRight(25, ' ') + $": {response?.Payment?.Capture}");
Console.WriteLine("Authenticate".PadRight(25, ' ') + $": {response?.Payment?.Authenticate}");
Console.WriteLine("ProofOfSale".PadRight(25, ' ') + $": {response?.Payment?.ProofOfSale}");
Console.WriteLine("Tid".PadRight(25, ' ') + $": {response?.Payment?.Tid}");
Console.WriteLine("AuthorizationCode".PadRight(25, ' ') + $": {response?.Payment?.AuthorizationCode}");
Console.WriteLine("PaymentId".PadRight(25, ' ') + $": {response?.Payment?.PaymentId}");
Console.WriteLine("Status".PadRight(25, ' ') + $": {response?.Payment?.Status}");
Console.WriteLine("");
Console.WriteLine("");
}

Console.ForegroundColor = ConsoleColor.Gray;
}
Expand Down Expand Up @@ -128,7 +149,7 @@ public static void WriteError(ResponseException ex)
Console.ForegroundColor = ConsoleColor.Gray;

Console.WriteLine("");
Console.WriteLine("HttpStatusCode".PadRight(20, ' ') + $": {ex.ResponseError.HttpStatusCode}");
Console.WriteLine("HttpStatusCode".PadRight(20, ' ') + $": {ex.ResponseError.HttpStatusCode.ToString()}");
Console.WriteLine("Id".PadRight(20, ' ') + $": {ex.ResponseError.Id}");
Console.WriteLine("Message".PadRight(20, ' ') + $": {ex.ResponseError.Message}");
}
Expand Down
2 changes: 1 addition & 1 deletion Cielo.Demo/Services/CancelTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private void ExecuteRequest()

try
{
var response = cieloService.CancelTransaction(merchantOrderId: "123123");
var response = cieloService.CancelTransaction(paymentId: Guid.Parse("1a2d178a-dc87-4627-92a2-b5d18ba076cd"));

ConsoleHelper.WriteResult(response);
}
Expand Down
2 changes: 1 addition & 1 deletion Cielo.Demo/Services/CheckTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private void ExecuteRequest()

try
{
var response = cieloService.CheckTransaction(merchantOrderId: "14421");
var response = cieloService.CheckTransaction(paymentId: Guid.Parse("1a2d178a-dc87-4627-92a2-b5d18ba076cd"));

ConsoleHelper.WriteResult(response);
}
Expand Down
5 changes: 5 additions & 0 deletions Cielo/Responses/CheckTransactionResponse.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
using System;
using System.Collections.Generic;
using Cielo.Responses.Entities;

namespace Cielo.Responses
{
public class CheckTransactionResponse
{
public string ReasonCode { get; set; }
public string ReasonMessage { get; set; }
public List<PaymentResponse> Payments { get; set; }
public string MyProperty { get; set; }
public string MerchantOrderId { get; set; }
public CustomerResponse Customer { get; set; }
public PaymentResponse Payment { get; set; }
Expand Down
5 changes: 3 additions & 2 deletions Cielo/Responses/Entities/PaymentResponse.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using Cielo.Enums;

namespace Cielo.Responses.Entities
Expand All @@ -15,7 +16,7 @@ public class PaymentResponse
public string ProofOfSale { get; set; }
public string Tid { get; set; }
public string AuthorizationCode { get; set; }
public string PaymentId { get; set; }
public Guid PaymentId { get; set; }
public PaymentType Type { get; set; }
public int Amount { get; set; }
public string Currency { get; set; }
Expand Down

0 comments on commit dbf185f

Please sign in to comment.