public ResponseModel ProcessExpensivePayment(PaymentModel request) { try { //call integration. var result = _restIntegration.UrlPost <ResponseModel>(appSettings.Value.ExpensiveUrl, request); //expensive gateway is not avalable use cheap gateway. if (string.IsNullOrEmpty(result?.ResponseCode) || result == null) { result = _restIntegration.UrlPost <ResponseModel>(appSettings.Value.CheapUrl, request); } //map payment model to db object var dbModel = _paymentProfile.MapPayment(request); //save to database. _baseRepo.SavePayment(dbModel, result); return(result); } catch (Exception ex) { Trace.TraceInformation($"An error occurred, {ex.Message}"); return(ResponseDictionary.ProvideResponse("06")); } }
public ResponseModel ProcessPremiumPayment(PaymentModel request) { int count = 1; var result = new ResponseModel(); try { //iterate for 3 times if service is not responding .. //the loop breaks if the response is successful for (int i = 1; i <= 3; i++) { //call integration. result = _restIntegration.UrlPost <ResponseModel>(appSettings.Value.PremiumUrl, request); if (result?.ResponseCode == "00") { break; } } //map payment model to db object var dbModel = _paymentProfile.MapPayment(request); //save to database. _baseRepo.SavePayment(dbModel, result); return(result); } catch (Exception ex) { Trace.TraceInformation($"An error occurred, {ex.Message}"); return(ResponseDictionary.ProvideResponse("06")); } }
public ResponseModel ProcessPayment(PaymentModel request) { try { //call integration. var result = _restIntegration.UrlPost <ResponseModel>(appSettings.Value.CheapUrl, request); //map payment model to db object var dbModel = _paymentProfile.MapPayment(request); if (dbModel == null) { return(ResponseDictionary.ProvideResponse("06")); } //save to database. _baseRepo.SavePayment(dbModel, result); return(result); } catch (Exception ex) { Trace.TraceInformation($"An error occurred, {ex.Message}"); return(ResponseDictionary.ProvideResponse("06")); } }