public async Task <string> Insert(Payment valPayment) { string vResult = string.Empty; try { ResponseGateway vProccessPayGateway = await InsertPaymentGateway(valPayment); GatewayService vGatewayService = new GatewayService(); if (vProccessPayGateway != null && vProccessPayGateway.transactionResponse.state == "APPROVED") { valPayment.IdTransaction = vProccessPayGateway.transactionResponse.transactionId; valPayment.GatewayJsonData = JsonConvert.SerializeObject(vProccessPayGateway); SQLToolsLibrary vSqlTools = new SQLToolsLibrary(); List <SqlParameter> vParameterList = new List <SqlParameter> { new SqlParameter("@Id", valPayment.Id), new SqlParameter("@IdTransaction", !(valPayment.IdTransaction == Guid.Empty) ? valPayment.IdTransaction : Guid.Empty), new SqlParameter("@GatewayJsonGata", !string.IsNullOrEmpty(valPayment.GatewayJsonData) ? valPayment.GatewayJsonData : "{}"), new SqlParameter("@IdUser", valPayment.IdUser != Guid.Empty ? valPayment.IdUser : throw new Exception(GlobalValues.vTextExceptionParameterNull)), new SqlParameter("@IdActivity", valPayment.IdActivity != Guid.Empty ? valPayment.IdActivity : throw new Exception(GlobalValues.vTextExceptionParameterNull)), new SqlParameter("@Mount", valPayment.Mount), new SqlParameter("@IdCurrency", valPayment.IdCurrency != Guid.Empty ? valPayment.IdCurrency : throw new Exception(GlobalValues.vTextExceptionParameterNull)), new SqlParameter("@FirstName", !string.IsNullOrEmpty(valPayment.FirstName) ? valPayment.FirstName : throw new Exception(GlobalValues.vTextExceptionParameterNull)), new SqlParameter("@LastName", !string.IsNullOrEmpty(valPayment.LastName) ? valPayment.LastName : throw new Exception(GlobalValues.vTextExceptionParameterNull)), new SqlParameter("@TypeNumberDocument", !string.IsNullOrEmpty(valPayment.TypeNumberDocument) ? valPayment.TypeNumberDocument : throw new Exception(GlobalValues.vTextExceptionParameterNull)), new SqlParameter("@NumberDocument", !string.IsNullOrEmpty(valPayment.NumberDocument) ? valPayment.NumberDocument : throw new Exception(GlobalValues.vTextExceptionParameterNull)), new SqlParameter("@Email", !string.IsNullOrEmpty(valPayment.Email) ? valPayment.Email : throw new Exception(GlobalValues.vTextExceptionParameterNull)), new SqlParameter("@Phone", !string.IsNullOrEmpty(valPayment.Phone) ? valPayment.Phone : throw new Exception(GlobalValues.vTextExceptionParameterNull)), new SqlParameter("@Persons", valPayment.Persons), new SqlParameter("@DateReserve", valPayment.DateReserve), new SqlParameter("@State", valPayment.State), new SqlParameter("@UserCreate", !string.IsNullOrEmpty(valPayment.UserCreate) ? valPayment.UserCreate : string.Empty), new SqlParameter("@DateCreate", valPayment.DateCreate) }; bool vInsert = vSqlTools.ExecuteIUWithStoreProcedure(vParameterList, "sp_Insert_Payment", vConnection); if (vInsert) { SenderMail vSenderMail = new SenderMail(); await vSenderMail.SendEmailWithPayment(valPayment); await vSenderMail.SendEmailToCompanies(valPayment); vResult = "1"; vResult = "1"; } else { vResult = "3"; } } else { vResult = GatewayUtils.ProccessingResponseGateway(vProccessPayGateway.transactionResponse.state); } } catch (Exception vEx) { string vMessage = vEx.Message; vResult = "4"; } return(vResult); }
private async Task <ResponseGatewayRefund> Refund(Payment valPayment) { ResponseGatewayRefund vResult = new ResponseGatewayRefund(); try { GatewayRefund vPaymentGateway = InstanceClassRefound(); GatewayService vGatewayService = new GatewayService(); ICurrencyData vCurrency = new CurrencyData(); ResponseGateway vInfoPayment = JsonConvert.DeserializeObject <ResponseGateway>(valPayment.GatewayJsonData); vPaymentGateway.transaction.order.id = vInfoPayment.transactionResponse.orderId; vPaymentGateway.transaction.parentTransactionId = valPayment.IdTransaction.ToString(); vResult = await vGatewayService.Refund(vPaymentGateway); } catch (Exception) { } return(vResult); }
public async Task <ResponseGateway> Create(PaymentGateway valModel) { ResponseGateway vResult = null; try { var vResponse = await _vApiClient.ExecutePost <ResponseGateway>(valModel); if (vResponse == null) { return(vResult); } if (vResponse.Status == HttpStatusCode.OK) { vResult = (ResponseGateway)vResponse.Content; } } catch (Exception vEx) { string vMensage = vEx.Message; vResult = null; } return(vResult); }
private async Task <ResponseGateway> InsertPaymentGateway(Payment valPayment) { ResponseGateway vResult = new ResponseGateway(); try { PaymentGateway vPaymentGateway = InstanceTransaction(); GatewayService vGatewayService = new GatewayService(); ICurrencyData vCurrency = new CurrencyData(); vPaymentGateway.transaction.creditCard.name = valPayment.FirstName + " " + valPayment.LastName; vPaymentGateway.transaction.creditCard.name = "APPROVED"; vPaymentGateway.transaction.creditCard.number = valPayment.CardNumber; vPaymentGateway.transaction.creditCard.expirationDate = valPayment.Year + "/" + valPayment.Month; vPaymentGateway.transaction.creditCard.securityCode = valPayment.SecurityCode; vPaymentGateway.transaction.order.additionalValues.TX_VALUE.value = valPayment.TotalMount; vPaymentGateway.transaction.order.additionalValues.TX_VALUE.value = 100; vPaymentGateway.transaction.order.additionalValues.TX_VALUE.currency = vCurrency.SelectById(valPayment.IdCurrency).Code; //vPaymentGateway.transaction.order.additionalValues.TX_VALUE.currency = vCurrency.SelectById(Guid.Parse("2AC154DA-120F-4BBA-B4E2-DB728AC89DA0")).Code; vPaymentGateway.transaction.paymentMethod = valPayment.PayMethod; //vPaymentGateway.transaction.paymentMethod = "VISA"; vResult = await vGatewayService.Create(vPaymentGateway); } catch (Exception) { } return(vResult); }