/// <summary> /// Cancels a recurring payment /// </summary> /// <param name="cancelPaymentRequest">Request</param> /// <returns>Result</returns> public virtual CancelRecurringPaymentResult CancelRecurringPayment(CancelRecurringPaymentRequest cancelPaymentRequest) { var result = new CancelRecurringPaymentResult(); result.AddError(T("Common.Payment.NoRecurringPaymentSupport")); return(result); }
/// <summary> /// Cancels a recurring payment /// </summary> /// <param name="cancelPaymentRequest">Request</param> /// <returns>Result</returns> public virtual CancelRecurringPaymentResult CancelRecurringPayment(CancelRecurringPaymentRequest cancelPaymentRequest) { if (cancelPaymentRequest.Order.OrderTotal == decimal.Zero) { return(new CancelRecurringPaymentResult()); } var paymentMethod = LoadPaymentMethodBySystemName(cancelPaymentRequest.Order.PaymentMethodSystemName); if (paymentMethod == null) { throw new SmartException("Payment method couldn't be loaded"); } try { return(paymentMethod.Value.CancelRecurringPayment(cancelPaymentRequest)); } catch (NotSupportedException) { var result = new CancelRecurringPaymentResult(); result.AddError(_localizationService.GetResource("Common.Payment.NoRecurringPaymentSupport")); return(result); } catch { throw; } }
/// <summary> /// Cancels a recurring payment /// </summary> /// <param name="cancelPaymentRequest">Request</param> /// <returns>Result</returns> public virtual CancelRecurringPaymentResult CancelRecurringPayment(CancelRecurringPaymentRequest cancelPaymentRequest) { if (cancelPaymentRequest.Order.OrderTotal == decimal.Zero) return new CancelRecurringPaymentResult(); var paymentMethod = LoadPaymentMethodBySystemName(cancelPaymentRequest.Order.PaymentMethodSystemName); if (paymentMethod == null) throw new SmartException("Payment method couldn't be loaded"); try { return paymentMethod.Value.CancelRecurringPayment(cancelPaymentRequest); } catch (NotSupportedException) { var result = new CancelRecurringPaymentResult(); result.AddError(_localizationService.GetResource("Common.Payment.NoRecurringPaymentSupport")); return result; } catch { throw; } }
/// <summary> /// Cancels a recurring payment /// </summary> /// <param name="recurringPayment">Recurring payment</param> public virtual IList<string> CancelRecurringPayment(RecurringPayment recurringPayment) { if (recurringPayment == null) throw new ArgumentNullException("recurringPayment"); var initialOrder = recurringPayment.InitialOrder; if (initialOrder == null) return new List<string>() { "Initial order could not be loaded" }; var request = new CancelRecurringPaymentRequest(); CancelRecurringPaymentResult result = null; try { request.Order = initialOrder; result = _paymentService.CancelRecurringPayment(request); if (result.Success) { //update recurring payment recurringPayment.IsActive = false; _orderService.UpdateRecurringPayment(recurringPayment); //add a note initialOrder.OrderNotes.Add(new OrderNote() { Note = T("RecurringPaymentCancelled"), DisplayToCustomer = false, CreatedOnUtc = DateTime.UtcNow }); _orderService.UpdateOrder(initialOrder); //notify a store owner _workflowMessageService .SendRecurringPaymentCancelledStoreOwnerNotification(recurringPayment, _localizationSettings.DefaultAdminLanguageId); } } catch (Exception exc) { if (result == null) result = new CancelRecurringPaymentResult(); 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 initialOrder.OrderNotes.Add(new OrderNote() { Note = string.Format(T("RecurringPaymentCancellationError"), error), DisplayToCustomer = false, CreatedOnUtc = DateTime.UtcNow }); _orderService.UpdateOrder(initialOrder); //log it string logError = string.Format("Error cancelling recurring payment. Order #{0}. Error: {1}", initialOrder.Id, error); _logger.InsertLog(LogLevel.Error, logError, logError); } return result.Errors; }
/// <summary> /// Cancels a recurring payment /// </summary> /// <param name="cancelPaymentRequest">Request</param> /// <returns>Result</returns> public virtual CancelRecurringPaymentResult CancelRecurringPayment(CancelRecurringPaymentRequest cancelPaymentRequest) { var result = new CancelRecurringPaymentResult(); result.AddError(T("Common.Payment.NoRecurringPaymentSupport")); return result; }
/// <summary> /// Cancels a recurring payment /// </summary> /// <param name="cancelPaymentRequest">Request</param> /// <returns>Result</returns> public override CancelRecurringPaymentResult CancelRecurringPayment(CancelRecurringPaymentRequest cancelPaymentRequest) { var result = new CancelRecurringPaymentResult(); result.AddError(_localizationService.GetResource("Common.Payment.NoRecurringPaymentSupport")); return result; }
/// <summary> /// Cancels a recurring payment /// </summary> /// <param name="cancelPaymentRequest">Request</param> /// <returns>Result</returns> public override CancelRecurringPaymentResult CancelRecurringPayment(CancelRecurringPaymentRequest cancelPaymentRequest) { var result = new CancelRecurringPaymentResult(); result.AddError("Cancelling recurring orders not supported"); return result; }
/// <summary> /// Cancels a recurring payment /// </summary> /// <param name="recurringPayment">Recurring payment</param> public virtual IList<string> CancelRecurringPayment(RecurringPayment recurringPayment) { if (recurringPayment == null) throw new ArgumentNullException("recurringPayment"); var initialOrder = recurringPayment.InitialOrder; if (initialOrder == null) return new List<string> { T("Order.InitialOrderDoesNotExistForRecurringPayment") }; var request = new CancelRecurringPaymentRequest(); CancelRecurringPaymentResult result = null; try { request.Order = initialOrder; result = _paymentService.CancelRecurringPayment(request); if (result.Success) { //update recurring payment recurringPayment.IsActive = false; _orderService.UpdateRecurringPayment(recurringPayment); _orderService.AddOrderNote(initialOrder, T("Admin.OrderNotice.RecurringPaymentCancelled")); //notify a store owner _workflowMessageService.SendRecurringPaymentCancelledStoreOwnerNotification(recurringPayment, _localizationSettings.DefaultAdminLanguageId); } } catch (Exception exception) { if (result == null) { result = new CancelRecurringPaymentResult(); } result.AddError(exception.ToAllMessages()); } ProcessErrors(initialOrder, result.Errors, "Admin.OrderNotice.RecurringPaymentCancellationError"); return result.Errors; }