Beispiel #1
0
        /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param>
        public virtual void PostProcessTransactionPayment(PostProcessTransactionPaymentRequest postProcessPaymentRequest)
        {
            //already paid or order.OrderTotal == decimal.Zero
            if (postProcessPaymentRequest.CurrentOrderTransaction.PaymentStatus == PaymentStatus.Paid)
            {
                return;
            }

            var paymentMethod = LoadPaymentMethodBySystemName(postProcessPaymentRequest.Order.PaymentMethodSystemName);

            if (paymentMethod == null)
            {
                throw new NopException("Payment method couldn't be loaded");
            }
            paymentMethod.PostProcessPaymentDistributedOrder(postProcessPaymentRequest);
        }
 public void PostProcessPaymentDistributedOrder(PostProcessTransactionPaymentRequest postProcessPaymentRequest)
 {
     throw new NotImplementedException();
 }
Beispiel #3
0
 /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param>
 public virtual void PostProcessTransactionPayment(PostProcessTransactionPaymentRequest postProcessPaymentRequest)
 {
     //already paid or order.OrderTotal == decimal.Zero
     if (postProcessPaymentRequest.CurrentOrderTransaction.PaymentStatus == PaymentStatus.Paid)
         return;
  
     var paymentMethod = LoadPaymentMethodBySystemName(postProcessPaymentRequest.Order.PaymentMethodSystemName);
     if (paymentMethod == null)
         throw new NopException("Payment method couldn't be loaded");
     paymentMethod.PostProcessPaymentDistributedOrder(postProcessPaymentRequest);
 }
        /// <summary>
        /// Post process payment (used by payment gateways that require redirecting to a third-party URL)
        /// </summary>
        /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param>
        public void PostProcessPaymentDistributedOrder(PostProcessTransactionPaymentRequest postProcessPaymentRequest)
        {
            var myUtility = new PayuHelper();
            var orderId = postProcessPaymentRequest.CurrentOrderTransaction.Id;
            var remotePostHelper = new RemotePost();
            remotePostHelper.FormName = "PayuForm";
            remotePostHelper.Url = _PayuPaymentSettings.PayUri;
            remotePostHelper.Add("key", _PayuPaymentSettings.MerchantId.ToString());
            remotePostHelper.Add("amount", postProcessPaymentRequest.CurrentOrderTransaction.TransactionAmount.ToString(new CultureInfo("en-US", false).NumberFormat));
            remotePostHelper.Add("productinfo", "productinfo");
            remotePostHelper.Add("Currency", _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode);
            remotePostHelper.Add("Order_Id", orderId.ToString());
            remotePostHelper.Add("txnid", postProcessPaymentRequest.CurrentOrderTransaction.TransactionId);

            remotePostHelper.Add("surl", _webHelper.GetStoreLocation(true) + "PaymentPayu/ReturnDistributedOrder");
            remotePostHelper.Add("furl", _webHelper.GetStoreLocation(true) + "PaymentPayu/ReturnDistributedOrder");
            remotePostHelper.Add("hash", myUtility.getchecksum(_PayuPaymentSettings.MerchantId.ToString(),
                postProcessPaymentRequest.CurrentOrderTransaction.TransactionId, postProcessPaymentRequest.CurrentOrderTransaction.TransactionAmount.ToString(new CultureInfo("en-US", false).NumberFormat),
                "productinfo", postProcessPaymentRequest.Order.BillingAddress.FirstName.ToString(),
                postProcessPaymentRequest.Order.BillingAddress.Email.ToString(), _PayuPaymentSettings.Key));


            //Billing details
            remotePostHelper.Add("firstname", postProcessPaymentRequest.Order.BillingAddress.FirstName.ToString());
            remotePostHelper.Add("billing_cust_address", postProcessPaymentRequest.Order.BillingAddress.Address1);
            remotePostHelper.Add("phone", postProcessPaymentRequest.Order.BillingAddress.PhoneNumber);
            remotePostHelper.Add("email", postProcessPaymentRequest.Order.BillingAddress.Email.ToString());
            remotePostHelper.Add("billing_cust_city", postProcessPaymentRequest.Order.BillingAddress.City);
            var billingStateProvince = postProcessPaymentRequest.Order.BillingAddress.StateProvince;
            if (billingStateProvince != null)
                remotePostHelper.Add("billing_cust_state", billingStateProvince.Abbreviation);
            else
                remotePostHelper.Add("billing_cust_state", "");
            remotePostHelper.Add("billing_zip_code", postProcessPaymentRequest.Order.BillingAddress.ZipPostalCode);
            var billingCountry = postProcessPaymentRequest.Order.BillingAddress.Country;
            if (billingCountry != null)
                remotePostHelper.Add("billing_cust_country", billingCountry.ThreeLetterIsoCode);
            else
                remotePostHelper.Add("billing_cust_country", "");

            //Delivery details

            if (postProcessPaymentRequest.Order.ShippingStatus != ShippingStatus.ShippingNotRequired)
            {
                remotePostHelper.Add("delivery_cust_name", postProcessPaymentRequest.Order.ShippingAddress.FirstName);
                remotePostHelper.Add("delivery_cust_address", postProcessPaymentRequest.Order.ShippingAddress.Address1);
                remotePostHelper.Add("delivery_cust_notes", string.Empty);
                remotePostHelper.Add("delivery_cust_tel", postProcessPaymentRequest.Order.ShippingAddress.PhoneNumber);
                remotePostHelper.Add("delivery_cust_city", postProcessPaymentRequest.Order.ShippingAddress.City);
                var deliveryStateProvince = postProcessPaymentRequest.Order.ShippingAddress.StateProvince;
                if (deliveryStateProvince != null)
                    remotePostHelper.Add("delivery_cust_state", deliveryStateProvince.Abbreviation);
                else
                    remotePostHelper.Add("delivery_cust_state", "");
                remotePostHelper.Add("delivery_zip_code", postProcessPaymentRequest.Order.ShippingAddress.ZipPostalCode);
                var deliveryCountry = postProcessPaymentRequest.Order.ShippingAddress.Country;
                if (deliveryCountry != null)
                    remotePostHelper.Add("delivery_cust_country", deliveryCountry.ThreeLetterIsoCode);
                else
                    remotePostHelper.Add("delivery_cust_country", "");
            }

            //  remotePostHelper.Add("Merchant_Param", _PayuPaymentSettings.MerchantParam);
            remotePostHelper.Post();
        }
            /// <summary>
            /// Post process payment (used by payment gateways that require redirecting to a third-party URL)
            /// </summary>
            /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param>
            public void PostProcessPaymentDistributedOrder(PostProcessTransactionPaymentRequest postProcessPaymentRequest)
            {

                PGResponse objPGResponse = new PGResponse();
                CustomerDetails oCustomer = new CustomerDetails();
                SessionDetail oSession = new SessionDetail();
                AirLineTransaction oAirLine = new AirLineTransaction();
                MerchanDise oMerchanDise = new MerchanDise();

                SFA.CardInfo objCardInfo = new SFA.CardInfo();

                SFA.Merchant objMerchant = new SFA.Merchant();

                ShipToAddress objShipToAddress = new ShipToAddress();
                BillToAddress oBillToAddress = new BillToAddress();
                ShipToAddress oShipToAddress = new ShipToAddress();
                MPIData objMPI = new MPIData();
                PGReserveData oPGreservData = new PGReserveData();
                Address oHomeAddress = new Address();
                Address oOfficeAddress = new Address();
                // For getting unique MerchantTxnID 
                // Only for testing purpose. 
                // In actual scenario the merchant has to pass his transactionID
                DateTime oldTime = new DateTime(1970, 01, 01, 00, 00, 00);
                DateTime currentTime = DateTime.Now;
                TimeSpan structTimespan = currentTime - oldTime;
                string lMrtTxnID = ((long)structTimespan.TotalMilliseconds).ToString();
                var merchantId = _EmiPaymentSettings.MerchantId.ToString();
                var orderId = postProcessPaymentRequest.CurrentOrderTransaction.TransactionId;
                var Id = orderId.ToString();
                var amount = postProcessPaymentRequest.CurrentOrderTransaction.TransactionAmount.ToString(new CultureInfo("en-US", false).NumberFormat);


                //Setting Merchant Details
                objMerchant.setMerchantDetails(merchantId, merchantId, merchantId, "", lMrtTxnID, Id, "https://www.laorigin.com/PaymentEmi/ReturnDistributedOrder?orderId=" + Id, "POST", "INR", "INV123", "req.Sale", amount, "GMT+05:30", "ASP.NET64", "true", "ASP.NET64", "ASP.NET64", "ASP.NET64");

                // Setting BillToAddress Details
                oBillToAddress.setAddressDetails(postProcessPaymentRequest.Order.CustomerId.ToString(),
                                                   postProcessPaymentRequest.Order.Customer.SystemName,
                                                postProcessPaymentRequest.Order.BillingAddress.Address1,
                                                 postProcessPaymentRequest.Order.BillingAddress.Address2,
                                                 "",
                                                  postProcessPaymentRequest.Order.BillingAddress.City,
                                                 postProcessPaymentRequest.Order.BillingAddress.StateProvince.Name
                                                 , postProcessPaymentRequest.Order.BillingAddress.ZipPostalCode,
                                                 postProcessPaymentRequest.Order.BillingAddress.Country.Name,
                                                  postProcessPaymentRequest.Order.Customer.Email);

                // Setting ShipToAddress Details
                oShipToAddress.setAddressDetails(postProcessPaymentRequest.Order.BillingAddress.Address1,
                                                postProcessPaymentRequest.Order.BillingAddress.Address2,
                                                "",
                                                postProcessPaymentRequest.Order.BillingAddress.City,
                                                postProcessPaymentRequest.Order.BillingAddress.StateProvince.Name,

                                                postProcessPaymentRequest.Order.BillingAddress.ZipPostalCode,
                                                postProcessPaymentRequest.Order.BillingAddress.Country.Name,
                                                postProcessPaymentRequest.Order.Customer.Email);

                //Setting MPI datails.
                //objMPI.setMPIRequestDetails ("1000","INR10.00","356","2","2 shirts","","","","0","","image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-shockwave-flash, */*","Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)");

                // Setting Name home/office Address Details 
                // Order of Parameters =>        AddLine1, AddLine2,      AddLine3,   City,   State ,  Zip,          Country, Email id
                oHomeAddress.setAddressDetails("2Sandeep", "Uttam Corner", "Chinchwad", "Pune", "state", "4385435873", "IND", "*****@*****.**");

                // Order of Parameters =>        AddLine1, AddLine2,      AddLine3,   City,   State ,  Zip,          Country, Email id
                oOfficeAddress.setAddressDetails("2Opus", "MayFairTowers", "Wakdewadi", "Pune", "state", "4385435873", "IND", "*****@*****.**");

                // Stting  Customer Details 
                // Order of Parameters =>  First Name,LastName ,Office Address Object,Home Address Object,Mobile No,RegistrationDate, flag for matching bill to address and ship to address 
                oCustomer.setCustomerDetails(postProcessPaymentRequest.Order.Customer.SystemName, "", oOfficeAddress, oHomeAddress, "", "13-06-2007", "Y");

                //Setting Merchant Dise Details 
                // Order of Parameters =>       Item Purchased,Quantity,Brand,ModelNumber,Buyers Name,flag value for matching CardName and BuyerName
                oMerchanDise.setMerchanDiseDetails("Computer", "2", "Intel", "P4", "Sandeep Patil", "Y");

                //Setting  Session Details        
                // Order of Parameters =>     Remote Address, Cookies Value            Browser Country,Browser Local Language,Browser Local Lang Variant,Browser User Agent'
                oSession.setSessionDetails(getRemoteAddr(), getSecureCookie(HttpContext.Current.Request), "", HttpContext.Current.Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"], "", HttpContext.Current.Request.ServerVariables["HTTP_USER_AGENT"]);

                //Settingr AirLine Transaction Details  
                //Order of Parameters =>               Booking Date,FlightDate,Flight   Time,Flight Number,Passenger Name,Number Of Tickets,flag for matching card name and customer name,PNR,sector from,sector to'
                oAirLine.setAirLineTransactionDetails("10-06-2007", "22-06-2007", "13:20", "119", "Sandeep", "1", "Y", "25c", "Pune", "Mumbai");

                SFAClient objSFAClient = new SFAClient("c:\\inetpub\\wwwroot\\SFAClient\\Config\\");
                objPGResponse = objSFAClient.postSSL(objMPI, objMerchant, oBillToAddress, oShipToAddress, oPGreservData, oCustomer, oSession, oAirLine, oMerchanDise);

                if (objPGResponse.RedirectionUrl != "" & objPGResponse.RedirectionUrl != null)
                {
                    string strResponseURL = objPGResponse.RedirectionUrl;
                    HttpContext.Current.Response.Redirect(strResponseURL);
                }
                else
                {
                    HttpContext.Current.Response.Write("Response Code:" + objPGResponse.RespCode);
                    HttpContext.Current.Response.Write("Response message:" + objPGResponse.RespMessage);
                }
            }
        public ActionResult ConfirmOrderTransaction(int orderId, decimal amount, bool IsEmiOption)
        {
            //validation
            var customer = _workContext.CurrentCustomer;

            if ((_workContext.CurrentCustomer.IsGuest() && !_orderSettings.AnonymousCheckoutAllowed))
                return new HttpUnauthorizedResult();
            var model = new CheckoutConfirmModel();
            try
            {
                var processPaymentRequest = _httpContext.Session["OrderPaymentInfo"] as ProcessPaymentRequest;
                if (processPaymentRequest == null)
                {

                    processPaymentRequest = new ProcessPaymentRequest();
                }

                //place order
                processPaymentRequest.StoreId = _storeContext.CurrentStore.Id;
                processPaymentRequest.CustomerId = _workContext.CurrentCustomer.Id;
                processPaymentRequest.PaymentMethodSystemName = _workContext.CurrentCustomer.GetAttribute<string>(
                    SystemCustomerAttributeNames.SelectedPaymentMethod,
                    _genericAttributeService, _storeContext.CurrentStore.Id);

                OrderTransactionDetailServiceModel transactionModel = new OrderTransactionDetailServiceModel()
                {
                     Amount = amount,
                     OrderId = orderId,
                     CustomerId = _workContext.CurrentCustomer.Id,
                     IsEmiOption = IsEmiOption,
                     PaymentMethodSystemName = processPaymentRequest.PaymentMethodSystemName
                };

                var placeOrderResult = _orderProcessingService.ProcessOrderTransaction(transactionModel);

                if (placeOrderResult.Success)
                {
                    _httpContext.Session["OrderPaymentInfo"] = null;
                    var postProcessPaymentRequest = new PostProcessTransactionPaymentRequest
                    {
                         CurrentOrderTransaction = placeOrderResult.PlacedOrder
                    };
                    var order = _orderService.GetOrderById(placeOrderResult.PlacedOrder.OrderId);
                    postProcessPaymentRequest.Order = order;
                    postProcessPaymentRequest.Order.PaymentMethodSystemName = processPaymentRequest.PaymentMethodSystemName;
                    _paymentService.PostProcessTransactionPayment(postProcessPaymentRequest);

                    if (_webHelper.IsRequestBeingRedirected || _webHelper.IsPostBeingDone)
                    {
                        //redirection or POST has been done in PostProcessPayment
                        return Content("Redirected");
                    }

                    return RedirectToRoute("CheckoutCompleted", new { orderId = placeOrderResult.PlacedOrder.Id });
                }

                foreach (var error in placeOrderResult.Errors)
                {
                    //Check the code
                }

            }
            catch (Exception exc)
            {
                _logger.Warning(exc.Message, exc);
                // model.Warnings.Add(exc.Message);
            }

            //If we got this far, something failed, redisplay form
            return View(model);
        }