Beispiel #1
0
        public async Task <string> CancelAndRefund(Payment valPayment)
        {
            string vResult = string.Empty;

            try {
                ResponseGatewayRefund vProccessPayGateway = await Refund(valPayment);

                GatewayService vGatewayService = new GatewayService();
                // if (vProccessPayGateway != null && vProccessPayGateway.transactionResponse.state == "PENDING" && vProccessPayGateway.code != "ERROR") {

                valPayment.GatewayJsonData = JsonConvert.SerializeObject(vProccessPayGateway);
                SQLToolsLibrary     vSqlTools      = new SQLToolsLibrary();
                List <SqlParameter> vParameterList = new List <SqlParameter> {
                    new SqlParameter("@Id", valPayment.Id),
                    new SqlParameter("@GatewayJsonData", !string.IsNullOrEmpty(valPayment.GatewayJsonData) ? valPayment.GatewayJsonData : "{}"),
                    new SqlParameter("@UserUpdate", valPayment.UserUpdate),
                    new SqlParameter("@DateUpdate", valPayment.DateUpdate)
                };
                bool vUpdate = vSqlTools.ExecuteIUWithStoreProcedure(vParameterList, "sp_Cancel_Payment", vConnection);

                if (vUpdate)
                {
                    SenderMail vSenderMail = new SenderMail();
                    Payment    vPaymenNew  = SelectById(valPayment.Id, valPayment.IdLanguage);
                    vPaymenNew.LanguageInitials = valPayment.LanguageInitials;
                    await vSenderMail.SendEmailClientWithCancelAndRefund(vPaymenNew);

                    ICompanyData vCompanyData = new CompanyData();
                    Company      vCompany     = vCompanyData.SelectCompanyByPayment(valPayment.Id);
                    vPaymenNew.EmailCompany1 = vCompany.Email1;
                    vPaymenNew.EmailCompany2 = vCompany.Email2;
                    await vSenderMail.SendEmailCompaniesWithCancelAndRefund(vPaymenNew);

                    vResult = "1";
                }
                else
                {
                    vResult = "3";
                }
                //} else {
                //    vResult = GatewayUtils.ProccessingResponseGateway(vProccessPayGateway.transactionResponse.state);
                //}
            } catch (Exception vEx) {
                string vMessage = vEx.Message;
                vResult = "4";
            }
            return(vResult);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        public async Task <ResponseGatewayRefund> Refund(GatewayRefund valModel)
        {
            ResponseGatewayRefund vResult = null;

            try {
                var vResponse = await _vApiClient.ExecutePost <ResponseGatewayRefund>(valModel);

                if (vResponse == null)
                {
                    return(vResult);
                }
                if (vResponse.Status == HttpStatusCode.OK)
                {
                    vResult = (ResponseGatewayRefund)vResponse.Content;
                }
            } catch (Exception vEx) {
                string vMensage = vEx.Message;
                vResult = null;
            }
            return(vResult);
        }