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);
            }
        }