public void given_json_response_with_error_from_punto_pago_when_call_json_serializer_then_return_transaction_response_dto_with_error()
        {
            const string json = "{\"respuesta\":\"99\",\"token\":\"9XJ08401WN0071839\",\"trx_id\":\"9787415132\"}";

            _configuration.Setup(x => x.GetProcessTransactionUrl()).Returns("/url");
            var transactionResponseDto = new CreateTransactionResponseDto(JsonSerializerService.DeserializeFromString(json), _configuration.Object);

            Assert.AreEqual("9XJ08401WN0071839", transactionResponseDto.Token);
            Assert.AreEqual(9787415132, transactionResponseDto.TransactionId);
            Assert.IsTrue(transactionResponseDto.WithError);
            Assert.IsNull(transactionResponseDto.PaymentMethod);
            Assert.IsNull(transactionResponseDto.Currency);
            Assert.IsNullOrEmpty(transactionResponseDto.ErrorMessage);
            Assert.AreEqual("/url/9XJ08401WN0071839", transactionResponseDto.ProcessUrl);
        }
Esempio n. 2
0
        /// <summary>
        /// Create the transaction in puntopago
        /// </summary>
        /// <param name="transactionDto">Data for the token that begins the payment process.</param>
        /// <returns>CreateTransactionResponseDto with contains the Token and Url for the payment process</returns>
        public CreateTransactionResponseDto CreateTransaction(CreateTransactionRequestDto transactionDto)
        {
            _logger.Debug(string.Format("Call to Create Transaction for TransactionId: {0}, and amount: {1}", transactionDto.TransactionId, transactionDto.Currency));
            var dateNow = DateTime.UtcNow;
            var message = string.Format("{0}{1}{2}{1}{3}{1}{4}", _configuration.GetCreateTransactionFunction(), "\n",
                                        transactionDto.TransactionId, transactionDto.Currency, dateNow.ToString("r"));

            _logger.Debug(string.Format("Generate message {0}, for PuntoPago", message));

            var authorization = _authorization.GetAuthorizationHeader(message);

            var response = _webExecute.Execute(_configuration.GetCreateTransactionUrl(), "POST", transactionDto.GetJson(), authorization, dateNow);

            _logger.Debug("End create transaction, start CreateTransactionResponseDto");

            var createTransactionResponseDto = new CreateTransactionResponseDto(response, _configuration);

            _logger.Info(string.Format("Create new Transaction for TransactionId: {0} with Token: {1}",
                                       createTransactionResponseDto.TransactionId, createTransactionResponseDto.Token));
            return(createTransactionResponseDto);
        }