Ejemplo n.º 1
0
        /// <summary>
        /// Cancels recurring payment
        /// </summary>
        /// <param name="order">Order</param>
        /// <param name="cancelPaymentResult">Cancel payment result</param>
        public static void CancelRecurringPayment(Order order, ref CancelPaymentResult cancelPaymentResult)
        {
            var paymentMethod = PaymentMethodManager.GetPaymentMethodById(order.PaymentMethodId);

            if (paymentMethod == null)
            {
                throw new NopException("Payment method couldn't be loaded");
            }
            var iPaymentMethod = Activator.CreateInstance(Type.GetType(paymentMethod.ClassName)) as IPaymentMethod;

            iPaymentMethod.CancelRecurringPayment(order, ref cancelPaymentResult);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets a recurring payment type of payment method
        /// </summary>
        /// <param name="paymentMethodId">Payment method identifier</param>
        /// <returns>A recurring payment type of payment method</returns>
        public static RecurringPaymentTypeEnum SupportRecurringPayments(int paymentMethodId)
        {
            var paymentMethod = PaymentMethodManager.GetPaymentMethodById(paymentMethodId);

            if (paymentMethod == null)
            {
                return(RecurringPaymentTypeEnum.NotSupported);
            }
            var iPaymentMethod = Activator.CreateInstance(Type.GetType(paymentMethod.ClassName)) as IPaymentMethod;

            return(iPaymentMethod.SupportRecurringPayments);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets a payment method type
        /// </summary>
        /// <param name="paymentMethodId">Payment method identifier</param>
        /// <returns>A payment method type</returns>
        public static PaymentMethodTypeEnum GetPaymentMethodType(int paymentMethodId)
        {
            var paymentMethod = PaymentMethodManager.GetPaymentMethodById(paymentMethodId);

            if (paymentMethod == null)
            {
                return(PaymentMethodTypeEnum.Unknown);
            }
            var iPaymentMethod = Activator.CreateInstance(Type.GetType(paymentMethod.ClassName)) as IPaymentMethod;

            return(iPaymentMethod.PaymentMethodType);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets a value indicating whether void is supported by payment method
        /// </summary>
        /// <param name="paymentMethodId">Payment method identifier</param>
        /// <returns>A value indicating whether void is supported</returns>
        public static bool CanVoid(int paymentMethodId)
        {
            var paymentMethod = PaymentMethodManager.GetPaymentMethodById(paymentMethodId);

            if (paymentMethod == null)
            {
                return(false);
            }
            var iPaymentMethod = Activator.CreateInstance(Type.GetType(paymentMethod.ClassName)) as IPaymentMethod;

            return(iPaymentMethod.CanVoid);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets additional handling fee
        /// </summary>
        /// <param name="PaymentMethodID">Payment method identifier</param>
        /// <returns>Additional handling fee</returns>
        public static decimal GetAdditionalHandlingFee(int PaymentMethodID)
        {
            PaymentMethod paymentMethod = PaymentMethodManager.GetPaymentMethodByID(PaymentMethodID);

            if (paymentMethod == null)
            {
                return(decimal.Zero);
            }
            IPaymentMethod iPaymentMethod = Activator.CreateInstance(Type.GetType(paymentMethod.ClassName)) as IPaymentMethod;

            return(iPaymentMethod.GetAdditionalHandlingFee());
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Captures payment (from admin panel)
        /// </summary>
        /// <param name="order">Order</param>
        /// <param name="processPaymentResult">Process payment result</param>
        public static void Capture(Order order, ref ProcessPaymentResult processPaymentResult)
        {
            PaymentMethod paymentMethod = PaymentMethodManager.GetPaymentMethodByID(order.PaymentMethodID);

            if (paymentMethod == null)
            {
                throw new NopException("Payment method couldn't be loaded");
            }
            IPaymentMethod iPaymentMethod = Activator.CreateInstance(Type.GetType(paymentMethod.ClassName)) as IPaymentMethod;

            iPaymentMethod.Capture(order, ref processPaymentResult);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Gets a value indicating whether capture is allowed from admin panel
        /// </summary>
        /// <param name="PaymentMethodID">Payment method identifier</param>
        /// <returns>A value indicating whether capture is allowed from admin panel</returns>
        public static bool CanCapture(int PaymentMethodID)
        {
            PaymentMethod paymentMethod = PaymentMethodManager.GetPaymentMethodByID(PaymentMethodID);

            if (paymentMethod == null)
            {
                return(false);
            }
            IPaymentMethod iPaymentMethod = Activator.CreateInstance(Type.GetType(paymentMethod.ClassName)) as IPaymentMethod;

            return(iPaymentMethod.CanCapture);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Post process payment (payment gateways that require redirecting)
        /// </summary>
        /// <param name="order">Order</param>
        /// <returns>The error status, or String.Empty if no errors</returns>
        public static string PostProcessPayment(Order order)
        {
            //already paid or order.OrderTotal == decimal.Zero
            if (order.PaymentStatus == PaymentStatusEnum.Paid)
            {
                return(string.Empty);
            }

            var paymentMethod = PaymentMethodManager.GetPaymentMethodById(order.PaymentMethodId);

            if (paymentMethod == null)
            {
                throw new NopException("Payment method couldn't be loaded");
            }
            var iPaymentMethod = Activator.CreateInstance(Type.GetType(paymentMethod.ClassName)) as IPaymentMethod;

            return(iPaymentMethod.PostProcessPayment(order));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Gets additional handling fee
        /// </summary>
        /// <param name="paymentMethodId">Payment method identifier</param>
        /// <returns>Additional handling fee</returns>
        public static decimal GetAdditionalHandlingFee(int paymentMethodId)
        {
            var paymentMethod = PaymentMethodManager.GetPaymentMethodById(paymentMethodId);

            if (paymentMethod == null)
            {
                return(decimal.Zero);
            }
            var iPaymentMethod = Activator.CreateInstance(Type.GetType(paymentMethod.ClassName)) as IPaymentMethod;

            decimal result = iPaymentMethod.GetAdditionalHandlingFee();

            if (result < decimal.Zero)
            {
                result = decimal.Zero;
            }
            result = Math.Round(result, 2);
            return(result);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Process payment
 /// </summary>
 /// <param name="paymentInfo">Payment info required for an order processing</param>
 /// <param name="customer">Customer</param>
 /// <param name="OrderGuid">Unique order identifier</param>
 /// <param name="processPaymentResult">Process payment result</param>
 public static void ProcessPayment(PaymentInfo paymentInfo, Customer customer, Guid OrderGuid, ref ProcessPaymentResult processPaymentResult)
 {
     if (paymentInfo.OrderTotal == decimal.Zero)
     {
         processPaymentResult.Error         = string.Empty;
         processPaymentResult.FullError     = string.Empty;
         processPaymentResult.PaymentStatus = PaymentStatusEnum.Paid;
     }
     else
     {
         PaymentMethod paymentMethod = PaymentMethodManager.GetPaymentMethodByID(paymentInfo.PaymentMethodID);
         if (paymentMethod == null)
         {
             throw new NopException("Payment method couldn't be loaded");
         }
         IPaymentMethod iPaymentMethod = Activator.CreateInstance(Type.GetType(paymentMethod.ClassName)) as IPaymentMethod;
         iPaymentMethod.ProcessPayment(paymentInfo, customer, OrderGuid, ref processPaymentResult);
     }
 }