Exemple #1
0
        public async Task <string> fiservReverseTransaction(decimal Amount, string orderId)
        {
            using (var client = new HttpClient())
            {
                long   timestamp, nonce;
                string apiKeyFD, apiSecretFD, clientRequestId;
                SettingsGenerateForReloadBalance(out timestamp, out nonce, out apiKeyFD, out apiSecretFD, out clientRequestId);

                string URLTransaction = string.Concat(_configuration["FiservReverseTransaction"], "/", orderId);
                var    paymentPayload = new PayloadSecondaryTransaction()
                {
                    transactionAmount = new TransactionAmount()
                    {
                        total    = Amount,
                        currency = "USD"
                    },
                    requestType = "ReturnTransaction",
                };

                string payloadJson = JsonConvert.SerializeObject(paymentPayload);

                string messageSignature;

                SetMessageHeadersSignature(timestamp, apiKeyFD, apiSecretFD, clientRequestId, payloadJson, out messageSignature);

                HttpContent stringContent       = StringContentSetting(payloadJson);
                string      FiservRequestCreate = string.Empty;
                RequestHeaderSetting(client, timestamp, nonce, apiKeyFD, clientRequestId, messageSignature);

                FiservRequestCreate = LogRequestCreateForTransaction(timestamp, nonce, apiKeyFD, clientRequestId, payloadJson, URLTransaction, messageSignature);
                var result = await client.PostAsync(URLTransaction, stringContent).ConfigureAwait(true);

                var transactionResult = await result.Content.ReadAsStringAsync().ConfigureAwait(true);

                FiservPaymentTransactionLogModel oModelLog = new FiservPaymentTransactionLogModel()
                {
                    //creditUserId = model.ReloadUserId,
                    //debitUserId = model.BenefactorUserId,
                    FiservRequestContent  = FiservRequestCreate,
                    FiservRequestDate     = DateTime.UtcNow,
                    FiservResponseContent = transactionResult,
                    FiservResponseDate    = DateTime.UtcNow
                };
                var objToken = _mapper.Map <FiservPaymentTransactionLog>(oModelLog);
                await _paymentTransactionLog.AddAsync(objToken);

                return("ok");
            }
        }
Exemple #2
0
 public async Task <IActionResult> AddPaymentTransactionLog(FiservPaymentTransactionLogModel model)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(Ok(new ApiBadRequestResponse(ModelState, MessagesConstants.BadRequest))); //400
         }
         var objToken = _mapper.Map <FiservPaymentTransactionLog>(model);
         return(Ok(new ApiResponse(Microsoft.AspNetCore.Http.StatusCodes.Status200OK, true, MessagesConstants.DataSuccessfullyReturned, await _paymentTransactionLog.AddAsync(objToken))));
     }
     catch (Exception ex)
     {
         HttpContext.RiseError(new Exception(string.Concat("API := (Fiserv := GetUsersWebToken)", ex.Message, " Stack Trace : ", ex.StackTrace, " Inner Exception : ", ex.InnerException)));
         return(Ok(new ApiResponse(StatusCodes.Status200OK, false, MessagesConstants.SomeIssueInProcessing)));
     }
 }