From Intrannuity
Download Source File
using System;
using System.Collections.Generic;
using iBilling.Client;
namespace iBilling.Samples
{
public class Scenario4
{
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;
//Login;
Session session = Session.Login(2000, "welcome", config);
//Create customer account;
CustomerAccount customerAccount = session.CreateCustomerAccount();
//code is optinal; if you specify the value, make sure the code is unique;
customerAccount.Code = "csharp.ca-4";
customerAccount.MerchantAccountCode = 2001;
customerAccount.FirstName = "Mary";
customerAccount.LastName = "Doe";
customerAccount.Type = CustomerAccountTypes.Female;
customerAccount.HomePhone = "5469856876";
customerAccount.Email = "test@google.com";
customerAccount.Street1 = "203 16th Street";
customerAccount.City = "Honolulu";
customerAccount.State = "CA";
customerAccount.ZipCode = "30904";
//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-4";
//all amounts are in cents;
paymentPlan.Amount = 3000;
//Item Codes must be setup in portal prior to being used;
paymentPlan.ItemCode = "Membership";
paymentPlan.Type = PaymentPlanTypes.Complimentary;
//Billing Cycle codes must be setup in portal prior to being used;
paymentPlan.BillingCycleCode = "M03";
//Specify desired billing date; if nothing specified, next billing date of the selected cycle assumed.
//paymentPlan.FirstBillingDate = <DateTime>;
//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();
}
}
}