public IReportItem Parse(string[] elements)
        {
            if (elements.Length < 18)
            {
                throw new InvalidDataException("The expected parameter count is 18");
            }

            BoletoTransaction boletoTransaction = new BoletoTransaction();

            boletoTransaction.Order                = new Order();
            boletoTransaction.Order.OrderKey       = Guid.Parse(elements[Constants.IDX_BT_ORDER_ORDER_KEY]);
            boletoTransaction.Order.OrderReference = elements[Constants.IDX_BT_ORDER_ORDER_REFERENCE];
            boletoTransaction.Order.MerchantKey    = Guid.Parse(elements[Constants.IDX_BT_ORDER_MERCHANT_KEY]);
            boletoTransaction.Order.MerchantName   = elements[Constants.IDX_BT_ORDER_MERCHANT_NAME];

            boletoTransaction.TransactionKey       = Guid.Parse(elements[Constants.IDX_BT_TRANSACTION_KEY]);
            boletoTransaction.TransactionReference = elements[Constants.IDX_BT_TRANSACTION_REFERENCE];
            boletoTransaction.Status            = elements[Constants.IDX_BT_STATUS];
            boletoTransaction.NossoNumero       = elements[Constants.IDX_BT_NOSSO_NUMERO];
            boletoTransaction.BankNumber        = elements[Constants.IDX_BT_BANK_NUMBER];
            boletoTransaction.Agency            = elements[Constants.IDX_BT_AGENCY];
            boletoTransaction.Account           = elements[Constants.IDX_BT_ACCOUNT];
            boletoTransaction.BarCode           = elements[Constants.IDX_BT_BARCODE];
            boletoTransaction.ExpirationDate    = DateTime.ParseExact(elements[Constants.IDX_BT_EXPIRATION_DATE], Constants.BT_DATE_TIME_FORMAT, CultureInfo.InvariantCulture);
            boletoTransaction.AmountInCents     = long.Parse(elements[Constants.IDX_BT_AMOUNT_IN_CENTS]);
            boletoTransaction.AmountPaidInCents = string.IsNullOrWhiteSpace(elements[Constants.IDX_BT_AMOUNT_PAID_IN_CENTS]) == false?long.Parse(elements[Constants.IDX_BT_AMOUNT_PAID_IN_CENTS]) : 0;

            boletoTransaction.PaymentDate = string.IsNullOrWhiteSpace(elements[Constants.IDX_BT_PAYMENT_DATE]) == false?DateTime.ParseExact(elements[Constants.IDX_BT_PAYMENT_DATE], Constants.BT_DATE_TIME_FORMAT, CultureInfo.InvariantCulture) : (DateTime?)null;

            boletoTransaction.CreditDate = string.IsNullOrWhiteSpace(elements[Constants.IDX_BT_CREDIT_DATE]) == false?DateTime.ParseExact(elements[Constants.IDX_BT_CREDIT_DATE], Constants.BT_DATE_TIME_FORMAT, CultureInfo.InvariantCulture) : (DateTime?)null;

            return(boletoTransaction);
        }
Пример #2
0
        /// <summary>
        /// Cria uma transação de boleto
        /// </summary>
        /// <param name="boletoTransaction">Dados da transação de boleto</param>
        /// <param name="orderReference">Identificação do pedido na loja</param>
        /// <returns></returns>
        public HttpResponse <CreateSaleResponse> Create(BoletoTransaction boletoTransaction, string orderReference)
        {
            Collection <BoletoTransaction> boletoTransactionCollection = new Collection <BoletoTransaction>();

            boletoTransactionCollection.Add(boletoTransaction);

            return(this.Create(boletoTransactionCollection, orderReference));
        }
Пример #3
0
        /// <summary>
        /// Cria uma transação de boleto
        /// </summary>
        /// <param name="boletoTransaction">Dados da transação de boleto</param>
        /// <returns></returns>
        public HttpResponse <CreateSaleResponse> Create(BoletoTransaction boletoTransaction)
        {
            Collection <BoletoTransaction> boletoTransactionCollection = new Collection <BoletoTransaction>();

            boletoTransactionCollection.Add(boletoTransaction);

            return(this.Create(boletoTransactionCollection));
        }
Пример #4
0
        public async Task <Transaction> PostBoletoAsync(BoletoTransaction boletoTransaction)
        {
            var secret = _configuration.GetSection("pagseguro:token").Get <string>();
            var email  = _configuration.GetSection("pagseguro:email").Get <string>();

            boletoTransaction.Email = email;
            boletoTransaction.token = secret;
            var content  = new StringContent(JsonConvert.SerializeObject(boletoTransaction));
            var response = await PostTransactionAsync(content);

            if (response.IsSuccessStatusCode)
            {
                return(JsonConvert.DeserializeObject <Transaction>(await response.Content.ReadAsStringAsync()));
            }
            else
            {
                throw new Exception(response.ReasonPhrase);
            }
        }
Пример #5
0
 /// <summary>
 /// Cria uma transação de boleto
 /// </summary>
 /// <param name="boletoTransaction">Dados da transação de boleto</param>
 /// <returns></returns>
 public HttpResponse <CreateSaleResponse> Create(BoletoTransaction boletoTransaction)
 {
     return(this.Create(boletoTransaction, null));
 }