Example #1
0
        /// <summary>
        /// Captures payment
        /// </summary>
        /// <param name="capturePaymentRequest">Capture payment request</param>
        /// <returns>Capture payment result</returns>
        public virtual CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            var result = new CapturePaymentResult();

            result.AddError(T("Common.Payment.NoCaptureSupport"));
            return(result);
        }
		/// <summary>
		/// Captures payment
		/// </summary>
		/// <param name="capturePaymentRequest">Capture payment request</param>
		/// <returns>Capture payment result</returns>
		public override CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
		{
			var result = new CapturePaymentResult()
			{
				NewPaymentStatus = PaymentStatus.Pending,
				CaptureTransactionResult = "successful"
			};

			return result;
		}
        /// <summary>
        /// Captures payment
        /// </summary>
        /// <param name="capturePaymentRequest">Capture payment request</param>
        /// <returns>Capture payment result</returns>
        public virtual CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            var paymentMethod = LoadPaymentMethodBySystemName(capturePaymentRequest.Order.PaymentMethodSystemName);

            if (paymentMethod == null)
            {
                throw new SmartException("Payment method couldn't be loaded");
            }

            try
            {
                return(paymentMethod.Value.Capture(capturePaymentRequest));
            }
            catch (NotSupportedException)
            {
                var result = new CapturePaymentResult();
                result.AddError(_localizationService.GetResource("Common.Payment.NoCaptureSupport"));
                return(result);
            }
            catch
            {
                throw;
            }
        }
Example #4
0
        /// <summary>
        /// Captures payment
        /// </summary>
        /// <param name="capturePaymentRequest">Capture payment request</param>
        /// <returns>Capture payment result</returns>
        public virtual CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            var paymentMethod = LoadPaymentMethodBySystemName(capturePaymentRequest.Order.PaymentMethodSystemName);

            if (paymentMethod == null)
            {
                throw new SmartException(T("Payment.CouldNotLoadMethod"));
            }

            try
            {
                return(paymentMethod.Value.Capture(capturePaymentRequest));
            }
            catch (NotSupportedException)
            {
                var result = new CapturePaymentResult();
                result.AddError(T("Common.Payment.NoCaptureSupport"));
                return(result);
            }
            catch
            {
                throw;
            }
        }
        public void Capture(AmazonPayClient client, CapturePaymentRequest capture, CapturePaymentResult result)
        {
            result.NewPaymentStatus = capture.Order.PaymentStatus;

            var request = new CaptureRequest();
            request.SellerId = client.Settings.SellerId;
            request.AmazonAuthorizationId = capture.Order.AuthorizationTransactionId;
            request.CaptureReferenceId = GetRandomId("Capture");
            //request.SellerCaptureNote = client.Settings.SellerNoteCapture.Truncate(255);

            request.CaptureAmount = new Price()
            {
                Amount = capture.Order.OrderTotal.ToString("0.00", CultureInfo.InvariantCulture),
                CurrencyCode = capture.Order.CustomerCurrencyCode ?? "EUR"
            };

            var response = client.Service.Capture(request);

            if (response != null && response.IsSetCaptureResult() && response.CaptureResult.IsSetCaptureDetails())
            {
                var details = response.CaptureResult.CaptureDetails;

                result.CaptureTransactionId = details.AmazonCaptureId;

                if (details.IsSetCaptureStatus() && details.CaptureStatus.IsSetState())
                {
                    result.CaptureTransactionResult = details.CaptureStatus.State.ToString().Grow(details.CaptureStatus.ReasonCode, " ");

                    if (details.CaptureStatus.State == PaymentStatus.COMPLETED)
                        result.NewPaymentStatus = Core.Domain.Payments.PaymentStatus.Paid;
                }
            }
        }
		/// <summary>
		/// Captures payment
		/// </summary>
		/// <param name="capturePaymentRequest">Capture payment request</param>
		/// <returns>Capture payment result</returns>
		public virtual CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
		{
			throw Error.NotSupported();
		}
		/// <summary>
		/// Captures payment
		/// </summary>
		/// <param name="capturePaymentRequest">Capture payment request</param>
		/// <returns>Capture payment result</returns>
		public virtual CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
		{
			var result = new CapturePaymentResult();
			result.AddError(T("Common.Payment.NoCaptureSupport"));
			return result;
		}
        public PayPalResponse Capture(PayPalApiSettingsBase settings, PayPalSessionData session, CapturePaymentRequest request)
        {
            var data = new Dictionary<string, object>();
            //var isAuthorize = request.Order.AuthorizationTransactionCode.IsCaseInsensitiveEqual("authorize");

            var path = "/v1/payments/authorization/{0}/capture".FormatInvariant(request.Order.AuthorizationTransactionId);

            var store = _services.StoreService.GetStoreById(request.Order.StoreId);

            var amount = new Dictionary<string, object>();
            amount.Add("total", request.Order.OrderTotal.FormatInvariant());
            amount.Add("currency", store.PrimaryStoreCurrency.CurrencyCode);

            data.Add("amount", amount);

            var result = CallApi("POST", path, session.AccessToken, settings, JsonConvert.SerializeObject(data));

            if (result.Success && result.Json != null)
            {
                result.Id = (string)result.Json.id;
            }

            return result;
        }
 /// <summary>
 /// Captures payment
 /// </summary>
 /// <param name="capturePaymentRequest">Capture payment request</param>
 /// <returns>Capture payment result</returns>
 public override CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
 {
     var result = new CapturePaymentResult();
     result.AddError(_localizationService.GetResource("Common.Payment.NoCaptureSupport"));
     return result;
 }
        /// <summary>
        /// Captures payment
        /// </summary>
        /// <param name="capturePaymentRequest">Capture payment request</param>
        /// <returns>Capture payment result</returns>
        public virtual CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            var paymentMethod = LoadPaymentMethodBySystemName(capturePaymentRequest.Order.PaymentMethodSystemName);
            if (paymentMethod == null)
                throw new SmartException(T("Payment.CouldNotLoadMethod"));

            try
            {
                return paymentMethod.Value.Capture(capturePaymentRequest);
            }
            catch (NotSupportedException)
            {
                var result = new CapturePaymentResult();
                result.AddError(T("Common.Payment.NoCaptureSupport"));
                return result;
            }
            catch
            {
                throw;
            }
        }
 /// <summary>
 /// Captures payment
 /// </summary>
 /// <param name="capturePaymentRequest">Capture payment request</param>
 /// <returns>Capture payment result</returns>
 public override CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
 {
     var result = new CapturePaymentResult();
     result.AddError("Capture method not supported");
     return result;
 }
 /// <summary>
 /// Captures payment
 /// </summary>
 /// <param name="capturePaymentRequest">Capture payment request</param>
 /// <returns>Capture payment result</returns>
 public virtual CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
 {
     throw Error.NotSupported();
 }
		public override CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
		{
			var result = _apiService.Capture(capturePaymentRequest);
			return result;
		}
        /// <summary>
        /// Capture an order (from admin panel)
        /// </summary>
        /// <param name="order">Order</param>
        /// <returns>A list of errors; empty list if no errors</returns>
        public virtual IList<string> Capture(Order order)
        {
            if (order == null)
                throw new ArgumentNullException("order");

            if (!CanCapture(order))
                throw new SmartException("Cannot do capture for order.");

            var request = new CapturePaymentRequest();
            CapturePaymentResult result = null;
            try
            {
                //old info from placing order
                request.Order = order;
                result = _paymentService.Capture(request);

                if (result.Success)
                {
                    var paidDate = order.PaidDateUtc;
                    if (result.NewPaymentStatus == PaymentStatus.Paid)
                        paidDate = DateTime.UtcNow;

                    order.CaptureTransactionId = result.CaptureTransactionId;
                    order.CaptureTransactionResult = result.CaptureTransactionResult;
                    order.PaymentStatus = result.NewPaymentStatus;
                    order.PaidDateUtc = paidDate;
                    _orderService.UpdateOrder(order);

                    //add a note
                    order.OrderNotes.Add(new OrderNote()
                    {
                        Note = T("OrderCaptured"),
                        DisplayToCustomer = false,
                        CreatedOnUtc = DateTime.UtcNow
                    });
                    _orderService.UpdateOrder(order);

                    CheckOrderStatus(order);

                    //raise event
                    if (order.PaymentStatus == PaymentStatus.Paid)
                    {
                        _eventPublisher.PublishOrderPaid(order);
                    }
                }
            }
            catch (Exception exc)
            {
                if (result == null)
                    result = new CapturePaymentResult();
                result.AddError(string.Format("Error: {0}. Full exception: {1}", exc.Message, exc.ToString()));
            }

            //process errors
            string error = "";
            for (int i = 0; i < result.Errors.Count; i++)
            {
                error += string.Format("Error {0}: {1}", i, result.Errors[i]);
                if (i != result.Errors.Count - 1)
                    error += ". ";
            }
            if (!String.IsNullOrEmpty(error))
            {
                //add a note
                order.OrderNotes.Add(new OrderNote()
                {
                    Note = string.Format("Unable to capture order. {0}", error),
                    DisplayToCustomer = false,
                    CreatedOnUtc = DateTime.UtcNow
                });
                _orderService.UpdateOrder(order);

                //log it
                string logError = string.Format(T("OrderCaptureError"), order.GetOrderNumber(), error);
                _logger.InsertLog(LogLevel.Error, logError, logError);
            }
            return result.Errors;
        }
        public CapturePaymentResult Capture(CapturePaymentRequest request)
        {
            var result = new CapturePaymentResult()
            {
                NewPaymentStatus = request.Order.PaymentStatus
            };

            try
            {
                var settings = _services.Settings.LoadSetting<AmazonPaySettings>(request.Order.StoreId);
                var client = new AmazonPayClient(settings);

                _api.Capture(client, request, result);
            }
            catch (OffAmazonPaymentsServiceException exc)
            {
                LogAmazonError(exc, errors: result.Errors);
            }
            catch (Exception exc)
            {
                LogError(exc, errors: result.Errors);
            }
            return result;
        }
        /// <summary>
        /// Captures payment
        /// </summary>
        /// <param name="capturePaymentRequest">Capture payment request</param>
        /// <returns>Capture payment result</returns>
        public virtual CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            var paymentMethod = LoadPaymentMethodBySystemName(capturePaymentRequest.Order.PaymentMethodSystemName);
            if (paymentMethod == null)
                throw new SmartException("Payment method couldn't be loaded");

			try
			{
				return paymentMethod.Value.Capture(capturePaymentRequest);
			}
			catch (NotSupportedException)
			{
				var result = new CapturePaymentResult();
				result.AddError(_localizationService.GetResource("Common.Payment.NoCaptureSupport"));
				return result;
			}
			catch
			{
				throw;
			}
        }
        /// <summary>
        /// Capture an order (from admin panel)
        /// </summary>
        /// <param name="order">Order</param>
        /// <returns>A list of errors; empty list if no errors</returns>
        public virtual IList<string> Capture(Order order)
        {
            if (order == null)
                throw new ArgumentNullException("order");

            if (!CanCapture(order))
                throw new SmartException(T("Order.CannotCapture"));

            var request = new CapturePaymentRequest();
            CapturePaymentResult result = null;
            try
            {
                //old info from placing order
                request.Order = order;
                result = _paymentService.Capture(request);

                if (result.Success)
                {
                    var paidDate = order.PaidDateUtc;
                    if (result.NewPaymentStatus == PaymentStatus.Paid)
                    {
                        paidDate = DateTime.UtcNow;
                    }

                    order.CaptureTransactionId = result.CaptureTransactionId;
                    order.CaptureTransactionResult = result.CaptureTransactionResult;
                    order.PaymentStatus = result.NewPaymentStatus;
                    order.PaidDateUtc = paidDate;

                    _orderService.UpdateOrder(order);

                    _orderService.AddOrderNote(order, T("Admin.OrderNotice.OrderCaptured"));

                    CheckOrderStatus(order);

                    //raise event
                    if (order.PaymentStatus == PaymentStatus.Paid)
                    {
                        _eventPublisher.PublishOrderPaid(order);
                    }
                }
            }
            catch (Exception exception)
            {
                if (result == null)
                {
                    result = new CapturePaymentResult();
                }

                result.AddError(exception.ToAllMessages());
            }

            ProcessErrors(order, result.Errors, "Admin.OrderNotice.OrderCaptureError");

            return result.Errors;
        }