public ResponseModel ProcessTransaction(TransactionModel model) { ArgumentValidator.ThrowOnNull("model", model); TransactionCommand command; bool success = false; var responseValue = new PayFabricResponseModel(); var payfabricTransactionResponse = new PayfabricTransactionResponse(); IRestResponse response = new RestResponse(); var keyResponse = string.Empty; try { _payFabricCommands.TryGetValue(Command.ProcessTrans, out command); var url = command.Url.Replace("{key}", model.Key); var client = new RestClient(url); var request = new RestRequest(command.HttpVerb); //request.AddHeader("authorization", _auth); var token = CreateSecurityToken(); request.AddHeader("authorization", token.Token); request.AddHeader("content-type", "application/json"); response = client.Execute(request); keyResponse = response.Content; if (Helpers.ResponseStatus(response.StatusCode)) { success = true; responseValue = GetResult(keyResponse); payfabricTransactionResponse = _serializer.Deserialize <PayfabricTransactionResponse>(response.Content); //write the response to the logs, for debugging //_logger.Log(LogLevel.Info, response.Content); } else { success = false; } return(ConvertToResponseModel(response, success, responseValue, new List <PayfabricCustomerResponseModel>(), payfabricTransactionResponse)); } catch (Exception ex) { //_logger.Log(LogLevel.Error, ex, response.Content); //_logger.Log(LogLevel.Error, ex, ex.StackTrace); throw new Exception(response.Content, ex); } }
private ResponseModel ConvertToResponseModel(IRestResponse response, bool success, PayFabricResponseModel responseValue, List <PayfabricCustomerResponseModel> customerPaymentDetails, PayfabricTransactionResponse transactionalResponse) { return(new ResponseModel() { Success = success, Message = response.Content, ResponseValue = responseValue, CustomerPaymentDetails = customerPaymentDetails, TransactionResponse = transactionalResponse }); }