本文整理汇总了C#中Nop.Core.Domain.Orders.RecurringPayment类的典型用法代码示例。如果您正苦于以下问题:C# RecurringPayment类的具体用法?C# RecurringPayment怎么用?C# RecurringPayment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RecurringPayment类属于Nop.Core.Domain.Orders命名空间,在下文中一共展示了RecurringPayment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareRecurringPaymentModel
protected virtual void PrepareRecurringPaymentModel(RecurringPaymentModel model,
RecurringPayment recurringPayment)
{
if (model == null)
throw new ArgumentNullException("model");
if (recurringPayment == null)
throw new ArgumentNullException("recurringPayment");
model.Id = recurringPayment.ID;
model.CycleLength = recurringPayment.CycleLength;
model.CyclePeriodId = recurringPayment.CyclePeriodId;
model.CyclePeriodStr = recurringPayment.CyclePeriod.GetLocalizedEnum(_localizationService, _workContext);
model.TotalCycles = recurringPayment.TotalCycles;
model.StartDate = _dateTimeHelper.ConvertToUserTime(recurringPayment.StartDateUtc, DateTimeKind.Utc).ToString();
model.IsActive = recurringPayment.IsActive;
model.NextPaymentDate = recurringPayment.NextPaymentDate.HasValue ? _dateTimeHelper.ConvertToUserTime(recurringPayment.NextPaymentDate.Value, DateTimeKind.Utc).ToString() : "";
model.CyclesRemaining = recurringPayment.CyclesRemaining;
model.InitialOrderId = recurringPayment.InitialOrder.ID;
var customer = recurringPayment.InitialOrder.Customer;
model.CustomerId = customer.ID;
model.CustomerEmail = customer.IsRegistered() ? customer.Email : _localizationService.GetResource("Admin.Customers.Guest");
model.PaymentType = _paymentService.GetRecurringPaymentType(recurringPayment.InitialOrder.PaymentMethodSystemName).GetLocalizedEnum(_localizationService, _workContext);
model.CanCancelRecurringPayment = _orderProcessingService.CanCancelRecurringPayment(_workContext.CurrentCustomer, recurringPayment);
}
示例2: Can_save_and_load_recurringPayment
public void Can_save_and_load_recurringPayment()
{
var rp = new RecurringPayment
{
CycleLength = 1,
CyclePeriod = RecurringProductCyclePeriod.Days,
TotalCycles= 3,
StartDateUtc = new DateTime(2010, 01, 01),
IsActive= true,
Deleted = true,
CreatedOnUtc = new DateTime(2010, 01, 02),
InitialOrder = GetTestOrder()
};
var fromDb = SaveAndLoadEntity(rp);
fromDb.ShouldNotBeNull();
fromDb.CycleLength.ShouldEqual(1);
fromDb.CyclePeriod.ShouldEqual(RecurringProductCyclePeriod.Days);
fromDb.TotalCycles.ShouldEqual(3);
fromDb.StartDateUtc.ShouldEqual(new DateTime(2010, 01, 01));
fromDb.IsActive.ShouldEqual(true);
fromDb.Deleted.ShouldEqual(true);
fromDb.CreatedOnUtc.ShouldEqual(new DateTime(2010, 01, 02));
fromDb.InitialOrder.ShouldNotBeNull();
}
示例3: Can_save_and_load_recurringPayment_with_history
public void Can_save_and_load_recurringPayment_with_history()
{
var rp = new RecurringPayment
{
CycleLength = 1,
CyclePeriod = RecurringProductCyclePeriod.Days,
TotalCycles = 3,
StartDateUtc = new DateTime(2010, 01, 01),
IsActive = true,
Deleted = true,
CreatedOnUtc = new DateTime(2010, 01, 02),
InitialOrder = GetTestOrder()
};
rp.RecurringPaymentHistory.Add
(
new RecurringPaymentHistory
{
CreatedOnUtc = new DateTime(2010, 01, 03),
//Order = GetTestOrder()
}
);
var fromDb = SaveAndLoadEntity(rp);
fromDb.ShouldNotBeNull();
fromDb.RecurringPaymentHistory.ShouldNotBeNull();
(fromDb.RecurringPaymentHistory.Count == 1).ShouldBeTrue();
fromDb.RecurringPaymentHistory.First().CreatedOnUtc.ShouldEqual(new DateTime(2010, 01, 03));
}
示例4: Can_calculate_nextPaymentDate_with_months_as_cycle_period
public void Can_calculate_nextPaymentDate_with_months_as_cycle_period()
{
var rp = new RecurringPayment()
{
CycleLength = 2,
CyclePeriod = RecurringProductCyclePeriod.Months,
TotalCycles = 3,
StartDateUtc = new DateTime(2010, 3, 1),
CreatedOnUtc = new DateTime(2010, 1, 1),
IsActive = true,
};
rp.NextPaymentDate.ShouldEqual(new DateTime(2010, 3, 1));
//add one history record
rp.RecurringPaymentHistory.Add(new RecurringPaymentHistory() { });
rp.NextPaymentDate.ShouldEqual(new DateTime(2010, 5, 1));
//add one more history record
rp.RecurringPaymentHistory.Add(new RecurringPaymentHistory() { });
rp.NextPaymentDate.ShouldEqual(new DateTime(2010, 7, 1));
//add one more history record
rp.RecurringPaymentHistory.Add(new RecurringPaymentHistory() { });
rp.NextPaymentDate.ShouldBeNull();
}
示例5: CancelRecurringPayment
/// <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 = "Recurring payment has been cancelled",
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("Unable to cancel recurring payment. {0}", 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;
}
示例6: CanCancelRecurringPayment
/// <summary>
/// Gets a value indicating whether a customer can cancel recurring payment
/// </summary>
/// <param name="customerToValidate">Customer</param>
/// <param name="recurringPayment">Recurring Payment</param>
/// <returns>value indicating whether a customer can cancel recurring payment</returns>
public virtual bool CanCancelRecurringPayment(Customer customerToValidate, RecurringPayment recurringPayment)
{
if (recurringPayment == null)
return false;
if (customerToValidate == null)
return false;
var initialOrder = recurringPayment.InitialOrder;
if (initialOrder == null)
return false;
var customer = recurringPayment.InitialOrder.Customer;
if (customer == null)
return false;
if (initialOrder.OrderStatus == OrderStatus.Cancelled)
return false;
if (!customerToValidate.IsAdmin())
{
if (customer.Id != customerToValidate.Id)
return false;
}
if (!recurringPayment.NextPaymentDate.HasValue)
return false;
return true;
}
示例7: ProcessNextRecurringPayment
/// <summary>
/// Process next recurring psayment
/// </summary>
/// <param name="recurringPayment">Recurring payment</param>
public virtual void ProcessNextRecurringPayment(RecurringPayment recurringPayment)
{
if (recurringPayment == null)
throw new ArgumentNullException("recurringPayment");
try
{
if (!recurringPayment.IsActive)
throw new NopException("Recurring payment is not active");
var initialOrder = recurringPayment.InitialOrder;
if (initialOrder == null)
throw new NopException("Initial order could not be loaded");
var customer = initialOrder.Customer;
if (customer == null)
throw new NopException("Customer could not be loaded");
var nextPaymentDate = recurringPayment.NextPaymentDate;
if (!nextPaymentDate.HasValue)
throw new NopException("Next payment date could not be calculated");
//payment info
var paymentInfo = new ProcessPaymentRequest
{
StoreId = initialOrder.StoreId,
CustomerId = customer.Id,
OrderGuid = Guid.NewGuid(),
IsRecurringPayment = true,
InitialOrderId = initialOrder.Id,
RecurringCycleLength = recurringPayment.CycleLength,
RecurringCyclePeriod = recurringPayment.CyclePeriod,
RecurringTotalCycles = recurringPayment.TotalCycles,
};
//place a new order
var result = this.PlaceOrder(paymentInfo);
if (result.Success)
{
if (result.PlacedOrder == null)
throw new NopException("Placed order could not be loaded");
var rph = new RecurringPaymentHistory
{
RecurringPayment = recurringPayment,
CreatedOnUtc = DateTime.UtcNow,
OrderId = result.PlacedOrder.Id,
};
recurringPayment.RecurringPaymentHistory.Add(rph);
_orderService.UpdateRecurringPayment(recurringPayment);
}
else
{
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 += ". ";
}
throw new NopException(error);
}
}
catch (Exception exc)
{
_logger.Error(string.Format("Error while processing recurring order. {0}", exc.Message), exc);
throw;
}
}
示例8: PlaceOrder
/// <summary>
/// Places an order
/// </summary>
/// <param name="processPaymentRequest">Process payment request</param>
/// <returns>Place order result</returns>
public virtual PlaceOrderResult PlaceOrder(ProcessPaymentRequest processPaymentRequest)
{
//think about moving functionality of processing recurring orders (after the initial order was placed) to ProcessNextRecurringPayment() method
if (processPaymentRequest == null)
throw new ArgumentNullException("processPaymentRequest");
if (processPaymentRequest.OrderGuid == Guid.Empty)
processPaymentRequest.OrderGuid = Guid.NewGuid();
var result = new PlaceOrderResult();
try
{
#region Order details (customer, addresses, totals)
//Recurring orders. Load initial order
Order initialOrder = _orderService.GetOrderById(processPaymentRequest.InitialOrderId);
if (processPaymentRequest.IsRecurringPayment)
{
if (initialOrder == null)
throw new ArgumentException("Initial order is not set for recurring payment");
processPaymentRequest.PaymentMethodSystemName = initialOrder.PaymentMethodSystemName;
}
//customer
var customer = _customerService.GetCustomerById(processPaymentRequest.CustomerId);
if (customer == null)
throw new ArgumentException("Customer is not set");
//affilites
int affiliateId = 0;
var affiliate = _affiliateService.GetAffiliateById(customer.AffiliateId);
if (affiliate != null && affiliate.Active && !affiliate.Deleted)
affiliateId = affiliate.Id;
//customer currency
string customerCurrencyCode = "";
decimal customerCurrencyRate;
if (!processPaymentRequest.IsRecurringPayment)
{
var currencyTmp = _currencyService.GetCurrencyById(customer.GetAttribute<int>(SystemCustomerAttributeNames.CurrencyId, processPaymentRequest.StoreId));
var customerCurrency = (currencyTmp != null && currencyTmp.Published) ? currencyTmp : _workContext.WorkingCurrency;
customerCurrencyCode = customerCurrency.CurrencyCode;
var primaryStoreCurrency = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId);
customerCurrencyRate = customerCurrency.Rate / primaryStoreCurrency.Rate;
}
else
{
customerCurrencyCode = initialOrder.CustomerCurrencyCode;
customerCurrencyRate = initialOrder.CurrencyRate;
}
//customer language
Language customerLanguage;
if (!processPaymentRequest.IsRecurringPayment)
{
customerLanguage = _languageService.GetLanguageById(customer.GetAttribute<int>(
SystemCustomerAttributeNames.LanguageId, processPaymentRequest.StoreId));
}
else
{
customerLanguage = _languageService.GetLanguageById(initialOrder.CustomerLanguageId);
}
if (customerLanguage == null || !customerLanguage.Published)
customerLanguage = _workContext.WorkingLanguage;
//check whether customer is guest
if (customer.IsGuest() && !_orderSettings.AnonymousCheckoutAllowed)
throw new NopException("Anonymous checkout is not allowed");
//billing address
Address billingAddress;
if (!processPaymentRequest.IsRecurringPayment)
{
if (customer.BillingAddress == null)
throw new NopException("Billing address is not provided");
if (!CommonHelper.IsValidEmail(customer.BillingAddress.Email))
throw new NopException("Email is not valid");
//clone billing address
billingAddress = (Address)customer.BillingAddress.Clone();
if (billingAddress.Country != null && !billingAddress.Country.AllowsBilling)
throw new NopException(string.Format("Country '{0}' is not allowed for billing", billingAddress.Country.Name));
}
else
{
if (initialOrder.BillingAddress == null)
throw new NopException("Billing address is not available");
//clone billing address
billingAddress = (Address)initialOrder.BillingAddress.Clone();
if (billingAddress.Country != null && !billingAddress.Country.AllowsBilling)
throw new NopException(string.Format("Country '{0}' is not allowed for billing", billingAddress.Country.Name));
}
//.........这里部分代码省略.........
示例9: PrepareRecurringPaymentModel
protected void PrepareRecurringPaymentModel(RecurringPaymentModel model,
RecurringPayment recurringPayment, bool includeHistory)
{
if (model == null)
throw new ArgumentNullException("model");
if (recurringPayment == null)
throw new ArgumentNullException("recurringPayment");
model.Id = recurringPayment.Id;
model.CycleLength = recurringPayment.CycleLength;
model.CyclePeriodId = recurringPayment.CyclePeriodId;
model.CyclePeriodStr = recurringPayment.CyclePeriod.GetLocalizedEnum(_localizationService, _workContext);
model.TotalCycles = recurringPayment.TotalCycles;
model.StartDate = _dateTimeHelper.ConvertToUserTime(recurringPayment.StartDateUtc, DateTimeKind.Utc).ToString();
model.IsActive = recurringPayment.IsActive;
model.NextPaymentDate = recurringPayment.NextPaymentDate.HasValue ? _dateTimeHelper.ConvertToUserTime(recurringPayment.NextPaymentDate.Value, DateTimeKind.Utc).ToString() : "";
model.CyclesRemaining = recurringPayment.CyclesRemaining;
model.InitialOrderId = recurringPayment.InitialOrder.Id;
var customer = recurringPayment.InitialOrder.Customer;
model.CustomerId = customer.Id;
model.CustomerEmail = customer.IsGuest() ? _localizationService.GetResource("Admin.Customers.Guest") : customer.Email;
model.PaymentType = _paymentService.GetRecurringPaymentType(recurringPayment.InitialOrder.PaymentMethodSystemName).GetLocalizedEnum(_localizationService, _workContext);
model.CanCancelRecurringPayment = _orderProcessingService.CanCancelRecurringPayment(_workContext.CurrentCustomer, recurringPayment);
if (includeHistory)
foreach (var rph in recurringPayment.RecurringPaymentHistory.OrderBy(x => x.CreatedOnUtc))
{
var rphModel = new RecurringPaymentModel.RecurringPaymentHistoryModel();
PrepareRecurringPaymentHistoryModel(rphModel, rph);
model.History.Add(rphModel);
}
}
示例10: ProcessNextRecurringPayment
/// <summary>
/// Process next recurring payment
/// </summary>
/// <param name="recurringPayment">Recurring payment</param>
/// <param name="paymentResult">Process payment result (info about last payment for automatic recurring payments)</param>
public virtual void ProcessNextRecurringPayment(RecurringPayment recurringPayment, ProcessPaymentResult paymentResult = null)
{
if (recurringPayment == null)
throw new ArgumentNullException("recurringPayment");
try
{
if (!recurringPayment.IsActive)
throw new NopException("Recurring payment is not active");
var initialOrder = recurringPayment.InitialOrder;
if (initialOrder == null)
throw new NopException("Initial order could not be loaded");
var customer = initialOrder.Customer;
if (customer == null)
throw new NopException("Customer could not be loaded");
var nextPaymentDate = recurringPayment.NextPaymentDate;
if (!nextPaymentDate.HasValue)
throw new NopException("Next payment date could not be calculated");
//payment info
var processPaymentRequest = new ProcessPaymentRequest
{
StoreId = initialOrder.StoreId,
CustomerId = customer.Id,
OrderGuid = Guid.NewGuid(),
InitialOrderId = initialOrder.Id,
RecurringCycleLength = recurringPayment.CycleLength,
RecurringCyclePeriod = recurringPayment.CyclePeriod,
RecurringTotalCycles = recurringPayment.TotalCycles,
};
//prepare order details
var details = PrepareRecurringOrderDetails(processPaymentRequest);
ProcessPaymentResult processPaymentResult;
//skip payment workflow if order total equals zero
var skipPaymentWorkflow = details.OrderTotal == decimal.Zero;
if (!skipPaymentWorkflow)
{
var paymentMethod = _paymentService.LoadPaymentMethodBySystemName(processPaymentRequest.PaymentMethodSystemName);
if (paymentMethod == null)
throw new NopException("Payment method couldn't be loaded");
if (!paymentMethod.IsPaymentMethodActive(_paymentSettings))
throw new NopException("Payment method is not active");
//Old credit card info
if (details.InitialOrder.AllowStoringCreditCardNumber)
{
processPaymentRequest.CreditCardType = _encryptionService.DecryptText(details.InitialOrder.CardType);
processPaymentRequest.CreditCardName = _encryptionService.DecryptText(details.InitialOrder.CardName);
processPaymentRequest.CreditCardNumber = _encryptionService.DecryptText(details.InitialOrder.CardNumber);
processPaymentRequest.CreditCardCvv2 = _encryptionService.DecryptText(details.InitialOrder.CardCvv2);
try
{
processPaymentRequest.CreditCardExpireMonth = Convert.ToInt32(_encryptionService.DecryptText(details.InitialOrder.CardExpirationMonth));
processPaymentRequest.CreditCardExpireYear = Convert.ToInt32(_encryptionService.DecryptText(details.InitialOrder.CardExpirationYear));
}
catch { }
}
//payment type
switch (_paymentService.GetRecurringPaymentType(processPaymentRequest.PaymentMethodSystemName))
{
case RecurringPaymentType.NotSupported:
throw new NopException("Recurring payments are not supported by selected payment method");
case RecurringPaymentType.Manual:
processPaymentResult = _paymentService.ProcessRecurringPayment(processPaymentRequest);
break;
case RecurringPaymentType.Automatic:
//payment is processed on payment gateway site, info about last transaction in paymentResult parameter
processPaymentResult = paymentResult ?? new ProcessPaymentResult();
break;
default:
throw new NopException("Not supported recurring payment type");
}
}
else
processPaymentResult = paymentResult ?? new ProcessPaymentResult { NewPaymentStatus = PaymentStatus.Paid };
if (processPaymentResult == null)
throw new NopException("processPaymentResult is not available");
if (processPaymentResult.Success)
{
//save order details
var order = SaveOrderDetails(processPaymentRequest, processPaymentResult, details);
foreach (var orderItem in details.InitialOrder.OrderItems)
{
//save item
var newOrderItem = new OrderItem
//.........这里部分代码省略.........
示例11: DeleteRecurringPayment
/// <summary>
/// Deletes a recurring payment
/// </summary>
/// <param name="recurringPayment">Recurring payment</param>
public virtual void DeleteRecurringPayment(RecurringPayment recurringPayment)
{
if (recurringPayment == null)
throw new ArgumentNullException("recurringPayment");
recurringPayment.Deleted = true;
UpdateRecurringPayment(recurringPayment);
}
示例12: PaypalOrderDetails
public PlaceOrderResult PaypalOrderDetails(ProcessPaymentRequest processPaymentRequest)
{
//think about moving functionality of processing recurring orders (after the initial order was placed) to ProcessNextRecurringPayment() method
if (processPaymentRequest == null)
throw new ArgumentNullException("processPaymentRequest");
var result = new PlaceOrderResult();
try
{
//if (processPaymentRequest.OrderGuid == Guid.Empty)
// processPaymentRequest.OrderGuid = Guid.NewGuid();
//prepare order details
var details = PreparePlaceOrderDetails(processPaymentRequest);
#region Payment workflow
//process payment
ProcessPaymentResult processPaymentResult = null;
//skip payment workflow if order total equals zero
var skipPaymentWorkflow = details.OrderTotal == decimal.Zero;
if (!skipPaymentWorkflow)
{
var paymentMethod = _paymentService.LoadPaymentMethodBySystemName(processPaymentRequest.PaymentMethodSystemName);
if (paymentMethod == null)
throw new NopException("Payment method couldn't be loaded");
//ensure that payment method is active
if (!paymentMethod.IsPaymentMethodActive(_paymentSettings))
throw new NopException("Payment method is not active");
if (!processPaymentRequest.IsRecurringPayment)
{
if (details.IsRecurringShoppingCart)
{
//recurring cart
var recurringPaymentType = _paymentService.GetRecurringPaymentType(processPaymentRequest.PaymentMethodSystemName);
switch (recurringPaymentType)
{
case RecurringPaymentType.NotSupported:
throw new NopException("Recurring payments are not supported by selected payment method");
case RecurringPaymentType.Manual:
case RecurringPaymentType.Automatic:
processPaymentResult = _paymentService.ProcessRecurringPayment(processPaymentRequest);
break;
default:
throw new NopException("Not supported recurring payment type");
}
}
else
{
//standard cart
processPaymentResult = _paymentService.ProcessPayment(processPaymentRequest);
}
}
else
{
if (details.IsRecurringShoppingCart)
{
//Old credit card info
processPaymentRequest.CreditCardType = details.InitialOrder.AllowStoringCreditCardNumber ? _encryptionService.DecryptText(details.InitialOrder.CardType) : "";
processPaymentRequest.CreditCardName = details.InitialOrder.AllowStoringCreditCardNumber ? _encryptionService.DecryptText(details.InitialOrder.CardName) : "";
processPaymentRequest.CreditCardNumber = details.InitialOrder.AllowStoringCreditCardNumber ? _encryptionService.DecryptText(details.InitialOrder.CardNumber) : "";
processPaymentRequest.CreditCardCvv2 = details.InitialOrder.AllowStoringCreditCardNumber ? _encryptionService.DecryptText(details.InitialOrder.CardCvv2) : "";
try
{
processPaymentRequest.CreditCardExpireMonth = details.InitialOrder.AllowStoringCreditCardNumber ? Convert.ToInt32(_encryptionService.DecryptText(details.InitialOrder.CardExpirationMonth)) : 0;
processPaymentRequest.CreditCardExpireYear = details.InitialOrder.AllowStoringCreditCardNumber ? Convert.ToInt32(_encryptionService.DecryptText(details.InitialOrder.CardExpirationYear)) : 0;
}
catch { }
var recurringPaymentType = _paymentService.GetRecurringPaymentType(processPaymentRequest.PaymentMethodSystemName);
switch (recurringPaymentType)
{
case RecurringPaymentType.NotSupported:
throw new NopException("Recurring payments are not supported by selected payment method");
case RecurringPaymentType.Manual:
processPaymentResult = _paymentService.ProcessRecurringPayment(processPaymentRequest);
break;
case RecurringPaymentType.Automatic:
//payment is processed on payment gateway site
processPaymentResult = new ProcessPaymentResult();
break;
default:
throw new NopException("Not supported recurring payment type");
}
}
else
{
throw new NopException("No recurring products");
}
}
}
else
{
//payment is not required
if (processPaymentResult == null)
//.........这里部分代码省略.........
开发者ID:propeersinfo,项目名称:nopcommerce-PayPalStandard-3.70,代码行数:101,代码来源:PaypalStandardOrderProcessingService.cs
示例13: Can_calculate_number_of_remaining_cycle
public void Can_calculate_number_of_remaining_cycle()
{
var rp = new RecurringPayment()
{
CycleLength = 2,
CyclePeriod = RecurringProductCyclePeriod.Days,
TotalCycles = 3,
StartDateUtc = new DateTime(2010, 3, 1),
CreatedOnUtc = new DateTime(2010, 1, 1),
IsActive = true,
};
rp.CyclesRemaining.ShouldEqual(3);
//add one history record
rp.RecurringPaymentHistory.Add(new RecurringPaymentHistory() { });
rp.CyclesRemaining.ShouldEqual(2);
//add one more history record
rp.RecurringPaymentHistory.Add(new RecurringPaymentHistory() { });
rp.CyclesRemaining.ShouldEqual(1);
//add one more history record
rp.RecurringPaymentHistory.Add(new RecurringPaymentHistory() { });
rp.CyclesRemaining.ShouldEqual(0);
//add one more history record
rp.RecurringPaymentHistory.Add(new RecurringPaymentHistory() { });
rp.CyclesRemaining.ShouldEqual(0);
}
示例14: Next_payment_date_is_null_when_recurring_payment_is_not_active
public void Next_payment_date_is_null_when_recurring_payment_is_not_active()
{
var rp = new RecurringPayment()
{
CycleLength = 7,
CyclePeriod = RecurringProductCyclePeriod.Days,
TotalCycles = 3,
StartDateUtc = new DateTime(2010, 3, 1),
CreatedOnUtc = new DateTime(2010, 1, 1),
IsActive = false,
};
rp.NextPaymentDate.ShouldBeNull();
//add one history record
rp.RecurringPaymentHistory.Add(new RecurringPaymentHistory() { });
rp.NextPaymentDate.ShouldBeNull();
//add one more history record
rp.RecurringPaymentHistory.Add(new RecurringPaymentHistory() { });
rp.NextPaymentDate.ShouldBeNull();
//add one more history record
rp.RecurringPaymentHistory.Add(new RecurringPaymentHistory() { });
rp.NextPaymentDate.ShouldBeNull();
}
示例15: GenerateTokens
private IList<Token> GenerateTokens(RecurringPayment recurringPayment, int languageId)
{
var tokens = new List<Token>();
_messageTokenProvider.AddStoreTokens(tokens);
_messageTokenProvider.AddOrderTokens(tokens, recurringPayment.InitialOrder, languageId);
_messageTokenProvider.AddCustomerTokens(tokens, recurringPayment.InitialOrder.Customer);
_messageTokenProvider.AddRecurringPaymentTokens(tokens, recurringPayment);
return tokens;
}