From Intrannuity
Download Source File
using System;
using System.Collections.Generic;
using iBilling.Client;
namespace iBilling.Samples
{
public class Scenario3
{
public static void Main(string[] args){
//Set up clients' settings;
Dictionary<string, object> config = new Dictionary<string, object>();
config[SessionConnection.PROCESSOR_HOST] = "http://server.ibillingclient.org/ibilling/xmlhttps";
config["debug"] = true;
Session session = Session.Login(2000, "welcome", config);
//Find customer account;
CustomerAccount customerAccount = session.LoadCustomerAccount("csharp.ca-1");
//Create payment plan;
PaymentPlan paymentPlan = customerAccount.CreatePaymentPlan();
//code is optinal; if you specify the value, make sure the code is unique;
paymentPlan.Code = "csharp.pp-3";
//all amounts are in cents;
paymentPlan.Amount = 3000;
//Item Codes must be setup in portal prior to being used;
paymentPlan.ItemCode = "Membership";
//Billing Cycle codes must be setup in portal prior to being used;
paymentPlan.BillingCycleCode = "M03";
paymentPlan.Type = PaymentPlanTypes.Fixed;
//Specify desired billing date; if nothing specified, next billing date of the selected cycle assumed.
//paymentPlan.FirstBillingDate = <DateTime>;
paymentPlan.Add(0, 6, false);
//Create child payment plan;
PaymentPlan childPaymentPlan = paymentPlan.CreateLinkedPaymentPlan();
//code is optinal; if you specify the value, make sure the code is unique;
childPaymentPlan.Code = "csharp.pp-3-1";
childPaymentPlan.Type = PaymentPlanTypes.Perpetual;
//all amounts are in cents;
childPaymentPlan.Amount = 2000;
//Item Codes must be setup in portal prior to being used;
childPaymentPlan.ItemCode = "Membership";
//Mark object for persistence;
session.Save(customerAccount);
//Synchronize changes with the server;
try{
session.Synchronize();
}
catch(Exception ex){
//Be sure to properly handle exception, this is just a sample solution;
Console.WriteLine(ex.Message);
return ;
}
//logout;
session.Logout();
}
}
}