/// <summary> /// Verify if the result of payment process was successful or not in any time. /// </summary> /// <param name="checkTransaction">To query data, necessitating the token, transaction client id and amount.</param> /// <returns>CheckTransactionResponseDto with contains result of the process and data of the payment</returns> public CheckTransactionResponseDto CheckStatusTransaction(CheckTransactionRequestDto checkTransaction) { _logger.Debug("Start CheckStatusTransaction"); var dateNow = DateTime.UtcNow; var message = string.Format("{0}{1}{2}{1}{3}{1}{4}{5}", _configuration.GetCheckTransactionFunction(), "\n", checkTransaction.Token, checkTransaction.TransactionId, checkTransaction.Currency, dateNow.ToString("r")); _logger.Debug(string.Format("Generate message for check notification transaction: {0}", message)); var authorization = _authorization.GetAuthorizationHeader(message); var response = _webExecute.Execute(_configuration.GetCheckTransactionUrl(), "GET", null, authorization, dateNow); _logger.Debug("End execute check transaction, now create CheckTransactionResponseDto"); var checkResponseDto = new CheckTransactionResponseDto(response); _logger.Info(string.Format("The result for check transaction with Token: {0} and TransactionId {1} is {2}", checkResponseDto.Token, checkResponseDto.TransactionId, checkResponseDto.IsTransactionSuccessful() ? "Successful" : "Unsuccessful")); _logger.Debug("End CheckStatusTransaction"); return checkResponseDto; }
public void given_error_json_response_from_punto_pago_when_call_json_serializer_then_return_check_transaction_response_dto() { const string json = "{\"respuesta\":\"99\",\"token\":\"9XJ08401WN0071839\",\"error\":\"Pago Rechazado\"}"; var checkTransactionDto = new CheckTransactionResponseDto(JsonSerializerService.DeserializeFromString(json)); Assert.IsTrue(checkTransactionDto.WithError, "WithError"); Assert.AreEqual(checkTransactionDto.Token, "9XJ08401WN0071839", "Token"); Assert.AreEqual(checkTransactionDto.ErrorMessage, "Pago Rechazado", "ErrorMessage"); }
public void given_default_json_response_from_punto_pago_when_call_json_serializer_then_return_check_transaction_response_dto() { const string json = "{\"respuesta\":\"00\",\"token\":\"9XJ08401WN0071839\",\"trx_id\":9787415132,\"medio_pago\":\"999\",\"monto\":1000000.00,\"fecha_aprobacion\":\"2009-06-15T20:49:00\",\"numero_operacion\":\"7897851487\",\"codigo_autorizacion\":\"34581\"}"; var checkTransactionDto = new CheckTransactionResponseDto(JsonSerializerService.DeserializeFromString(json)); Assert.IsFalse(checkTransactionDto.WithError, "WithError"); Assert.AreEqual(checkTransactionDto.Token, "9XJ08401WN0071839", "Token"); Assert.AreEqual(checkTransactionDto.TransactionId, 9787415132, "TransactionId"); Assert.IsNull(checkTransactionDto.PaymentMethod, "PaymentMethod"); Assert.AreEqual(checkTransactionDto.Currency.Amount, 1000000, "Amount"); Assert.AreEqual(checkTransactionDto.DateTimeAcceptance, new DateTime(2009, 6, 15, 20, 49, 00), "DateTimeAcceptance"); Assert.AreEqual(checkTransactionDto.OperationNumber, "7897851487", "OperationNumber"); Assert.AreEqual(checkTransactionDto.AuthorizationCode, "34581", "AuthorizationCode"); }