Episerver Commerce supports both purchase orders and payment plans/subscriptions. Both are meta classes, which allow for configuration to store field information appropriate to your implementation. To use payment plans/subscriptions, use the PaymentPlan class.
The PaymentPlan class contains properties for storing information unique to payment plans, such as cycle length, start date, and end date. When a payment/subscription plan is submitted by a customer, the cart can be saved as a PaymentPlan (as opposed to a PurchasePlan) by using the Cart.SaveAsPaymentPlan() method.
Classes in this topic are in the Mediachase.Commerce.Orders namespace, which contains OrderGroup and PaymentPlan.
Key classes and files
- OrderGroup. Base class for PaymentPlan. It is also the base class for the Cart and PurchaseOrder classes. This means that the PaymentPlan class contains OrderForm, Shipment, Payment, and LineItem instances, just like a Cart.
- PaymentPlan. Meta-class for payment plans/subscriptions.
Configuring the PaymentPlan meta-class
In the Administration section of Commerce Manager, navigate to the Order System/Meta Classes node, where you can access and modify meta-classes in the order system. To find the PaymentPlan meta-class, select the OrderGroup element and PaymentPlan type.
To determine which meta-fields are associated with the PaymentPlan meta-class, check the checkboxes for the desired meta-fields and click OK. To create new meta fields, navigate to the Meta Fields node and select New Meta Field.
Saving a payment plan
When you submit a payment plan/subscription (saving a cart as a payment plan), use the Cart.SaveAsPaymentPlan() method. You can then set the properties of a payment plan relating to the schedule of payments.
Example: setting the properties of a payment plan with scheduled payments
// Create payment plan PaymentPlan plan = cart.SaveAsPaymentPlan(); // Set some payment plan values // Monthly subscription for a year plan.CycleMode = PaymentPlanCycle.Months; plan.CycleLength = 1; plan.MaxCyclesCount = 12; plan.StartDate = DateTime.UtcNow; plan.EndDate = DateTime.UtcNow.AddMonths(13); plan.LastTransactionDate = DateTime.UtcNow; // Save changes plan.AcceptChanges();