public ActionResult UpdateStatus(int id, int payid, short PayStatuses)
        {
            try
            {
                var    paymentWorker = new PaymentWorker();
                var    payments      = paymentWorker.GetManagerPaymentsByOrderId(id);
                string log           = null;
                if (payments.Any(a => a.Payment_Types.Method == 2))
                {
                    var     posWorker = new PosWorker();
                    var     payment   = payments.FirstOrDefault(f => f.Payment_Types.Method == 2);
                    dynamic settings  = null;
                    switch (payment.Payment_Types.PosType.ToLower())
                    {
                    case "paypal":
                        settings = posWorker.GetSitePosSetting("paypal");
                        var paypal = new Components.Payment.Paypal.Controller(settings.Parameters);
                        var result = paypal.Refund(payment.Log);
                        if (result.Status)
                        {
                            log = result.Data;
                        }
                        break;

                    case "isbank":
                        settings = posWorker.GetSitePosSetting("isbank");
                        log      = CancelPayflex(settings, payment);
                        break;

                    case "vakifbank":
                        settings = posWorker.GetSitePosSetting("vakifbank");
                        log      = CancelPayflex(settings, payment);
                        break;

                    case "ziraatbank":
                        settings = posWorker.GetSitePosSetting("ziraatbank");
                        log      = CancelPayflex(settings, payment);
                        break;

                    default:
                        break;
                    }
                }
                paymentWorker.UpdatePaymentStatus(payid, PayStatuses, log);
                return(RedirectToAction("Detail", "OrderManager", new { id = id }));
            }
            catch (Exception ex)
            {
                this.ShowError(ex);
                return(null);
            }
        }
예제 #2
0
        public ActionResult Payment(string message = null)
        {
            var orderLayer = new OrderLayer();
            var payment    = orderLayer.Order.Payments.FirstOrDefault(f => f.Id == orderLayer.Order.PaymentTypeId);

            var posWorker  = new PosWorker();
            var posSetting = posWorker.GetSitePosSetting(payment.PosType);

            switch (posSetting.AssemblyData)
            {
            case "paypal":
                var paypal = new Components.Payment.Paypal.Controller(posSetting.Parameters);
                return(Redirect(paypal.Payment()));

            case "payflex":
                ViewData["Pos"]         = posSetting.AssemblyData;
                ViewData["Installment"] = payment.Installments.FirstOrDefault(f => f.Id == orderLayer.Order.InstallmentId).NumberOf;
                ViewData["Message"]     = message;
                return(View());

            default:
                return(null);
            }
        }
예제 #3
0
        public ActionResult PaymentCallback(string id)
        {
            var orderLayer = new OrderLayer();
            var payment    = orderLayer.Order.Payments.FirstOrDefault(f => f.Id == orderLayer.Order.PaymentTypeId);

            var posWorker  = new PosWorker();
            var posSetting = posWorker.GetSitePosSetting(payment.PosType);


            switch (id.ToLower())
            {
            case "paypal":
                if (Request.Params["result"] == "fail")
                {
                    return(View("PaymentError"));
                }
                var paypal       = new Components.Payment.Paypal.Controller(posSetting.Parameters);
                var paypalresult = paypal.PaymentExcution(Request.Params["payerId"], Request.Params["paymentId"]);
                if (paypalresult.Status)
                {
                    var paymentWorker      = new PaymentWorker();
                    var paymentEntityModel = Mapper.Map <PaymentEntityViewModel>(orderLayer.Order);
                    paymentEntityModel.PaymentDate = DateTime.Now;
                    paymentEntityModel.Status      = 0;
                    paymentEntityModel.Log         = paypalresult.Data;
                    paymentWorker.InsertSitePaymentEntity(paymentEntityModel);
                }
                return(RedirectToAction("Commit", new { id = orderLayer.Order.Id.ToString("000000") }));

            case "payflex":
                if (Request.Params["result"] == "fail")
                {
                    return(RedirectToAction("Payment", "Bir hata oluştu lütfen tekrar deneyin!"));
                }
                Components.Payment.PayFlex.Controller payFlex  = Session["PayFlexInstance"] as Components.Payment.PayFlex.Controller;
                Dictionary <string, string>           formdata = new Dictionary <string, string>();
                foreach (string prm in Request.Params.AllKeys)
                {
                    formdata.Add(prm, Request.Params[prm]);
                }
                payFlex.MPITransaction = new Components.Payment.PayFlex.Models.MPITransactionResponse(formdata);
                payFlex.MPIChekout(posSetting.Parameters["mpicheckouturl"]);
                if (int.Parse(payFlex.PaymentModel.Installment) > 0)
                {
                    var result = payFlex.CheckoutResult as Components.Payment.PayFlex.Models.VInstallmentResponse;
                    if (result.ResultCode == "0000")
                    {
                        var paymentWorker      = new PaymentWorker();
                        var paymentEntityModel = Mapper.Map <PaymentEntityViewModel>(orderLayer.Order);
                        paymentEntityModel.PaymentDate = DateTime.Now;
                        paymentEntityModel.Status      = 0;
                        paymentEntityModel.Log         = Components.Converters.StringSerializer.Serialize <Components.Payment.PayFlex.Models.VInstallmentResponse>(payFlex.CheckoutResult);
                        paymentWorker.InsertSitePaymentEntity(paymentEntityModel);
                        return(RedirectToAction("Commit", new { id = orderLayer.Order.Id }));
                    }
                    else
                    {
                        return(RedirectToAction("Payment", "Bir hata oluştu lütfen tekrar deneyin!"));
                    }
                }
                else
                {
                    var result = payFlex.CheckoutResult as Components.Payment.PayFlex.Models.VPrepaidResponse;
                    if (result.ResultCode == "0000")
                    {
                        var paymentWorker      = new PaymentWorker();
                        var paymentEntityModel = Mapper.Map <PaymentEntityViewModel>(orderLayer.Order);
                        paymentEntityModel.PaymentDate = DateTime.Now;
                        paymentEntityModel.Status      = 0;
                        paymentEntityModel.Log         = Components.Converters.StringSerializer.Serialize <Components.Payment.PayFlex.Models.VPrepaidResponse>(payFlex.CheckoutResult);
                        paymentWorker.InsertSitePaymentEntity(paymentEntityModel);
                        return(RedirectToAction("Commit", new { id = orderLayer.Order.Id }));
                    }
                    else
                    {
                        return(RedirectToAction("Payment", "Bir hata oluştu lütfen tekrar deneyin!"));
                    }
                }

            default:
                return(null);
            }
        }
예제 #4
0
        public ActionResult Payment(Models.Internal.PaymentModel model)
        {
            if (ModelState.IsValid)
            {
                var posWorker  = new PosWorker();
                var posSetting = posWorker.GetSitePosSetting(model.Pos);

                var orderLayer = new OrderLayer();
                var payment    = orderLayer.Order.Payments.FirstOrDefault(f => f.Id == orderLayer.Order.PaymentTypeId);

                switch (model.Pos)
                {
                case "payflex":
                    var akposRequest = new Components.Payment.PayFlex.Models.MPIStatusRequest
                    {
                        BankId           = posSetting.Referance,
                        BrandName        = model.CardType == "visa" ? "100" : model.CardType == "mastercard" ? "200" : "",
                        ExpiryDate       = model.ExpiryMonth + model.ExpiryYear,
                        FailureUrl       = Request.Url.Host + "/Order/PaymentCallback/payflex?result=fail",
                        MerchantId       = posSetting.Parameters["merchantid"],
                        MerchantPassword = posSetting.Parameters["password"],
                        InstallmentCount = int.Parse(model.Installment) > 0 ? model.Installment : null,
                        Pan                       = model.CCNumber,
                        PurchaseAmount            = string.Format("{0:F0}", orderLayer.Order.GrandTotal * 100),
                        SuccessUrl                = Request.Url.Host + "/Order/PaymentCallback/payflex?result=ok",
                        VerifyEnrollmentRequestId = orderLayer.Order.Id.ToString()
                    };
                    var payFlex = new Components.Payment.PayFlex.Controller(akposRequest);
                    if (payFlex.Is3D(posSetting.Parameters["mpiurl"]))
                    {
                        payFlex.PaymentModel       = model;
                        Session["PayFlexInstance"] = payFlex;
                        return(View("PayFlexMpiPost", payFlex.MPIStatus));
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(akposRequest.InstallmentCount))
                        {
                            //TODO: payflex TRY kodu girilecek
                            var vprepaidRequest = new Components.Payment.PayFlex.Models.VPrepaidRequest
                            {
                                BankId          = akposRequest.BankId,
                                CurrencyAmount  = akposRequest.Currency,
                                CurrencyCode    = "888",
                                Cvv             = model.Ccv,
                                Expiry          = akposRequest.ExpiryDate,
                                MerchantId      = akposRequest.MerchantId,
                                Pan             = akposRequest.Pan,
                                Password        = akposRequest.MerchantPassword,
                                TransactionId   = Guid.NewGuid().ToString(),
                                TransactionType = "sale"
                            };
                            payFlex.VPrepaidCheckout(posSetting.Parameters["checkouturl"], vprepaidRequest);
                            if (payFlex.CheckoutResult.ResultCode == "0000")
                            {
                                var paymentWorker      = new PaymentWorker();
                                var paymentEntityModel = Mapper.Map <PaymentEntityViewModel>(orderLayer.Order);
                                paymentEntityModel.PaymentDate = DateTime.Now;
                                paymentEntityModel.Status      = 0;
                                paymentEntityModel.Log         = Components.Converters.StringSerializer.Serialize <Components.Payment.PayFlex.Models.VPrepaidResponse>(payFlex.CheckoutResult);
                                paymentWorker.InsertSitePaymentEntity(paymentEntityModel);
                                return(RedirectToAction("Commit", new { id = orderLayer.Order.Id }));
                            }
                            else
                            {
                                return(RedirectToAction("Payment", new { message = (new Components.Payment.PayFlex.ErrorCodes())[payFlex.CheckoutResult.ResultCode] }));
                            }
                        }
                        else
                        {
                            //TODO: payflex TRY kodu girilecek
                            var vinstallmentRequest = new Components.Payment.PayFlex.Models.VInstallmentRequest
                            {
                                BankId           = akposRequest.BankId,
                                CurrencyAmount   = akposRequest.Currency,
                                CurrencyCode     = "888",
                                Cvv              = model.Ccv,
                                Expiry           = akposRequest.ExpiryDate,
                                MerchantId       = akposRequest.MerchantId,
                                Pan              = akposRequest.Pan,
                                Password         = akposRequest.MerchantPassword,
                                TransactionId    = Guid.NewGuid().ToString(),
                                TransactionType  = "sale",
                                InstallmentCount = akposRequest.InstallmentCount
                            };
                            payFlex.VInstallmentCheckout(posSetting.Parameters["checkouturl"], vinstallmentRequest);
                            if (payFlex.CheckoutResult.ResultCode == "0000")
                            {
                                var paymentWorker      = new PaymentWorker();
                                var paymentEntityModel = Mapper.Map <PaymentEntityViewModel>(orderLayer.Order);
                                paymentEntityModel.PaymentDate = DateTime.Now;
                                paymentEntityModel.Status      = 0;
                                paymentEntityModel.Log         = Components.Converters.StringSerializer.Serialize <Components.Payment.PayFlex.Models.VInstallmentResponse>(payFlex.CheckoutResult);
                                paymentWorker.InsertSitePaymentEntity(paymentEntityModel);
                                return(RedirectToAction("Commit", new { id = orderLayer.Order.Id }));
                            }
                            else
                            {
                                return(RedirectToAction("Payment", new { message = (new Components.Payment.PayFlex.ErrorCodes())[payFlex.CheckoutResult.ResultCode] }));
                            }
                        }
                    }

                default:
                    return(RedirectToAction("Begin"));
                }
            }
            return(View(model));
        }