Scenario 3: Groovy

From Intrannuity

Jump to: navigation, search

Download Source File

import ibilling.client.*
 
class Scenario3 {
 
 static void main(args) {
			//Set up clients' settings
	def config  = [:]
	config[SessionConnection.PROCESSOR_HOST] = "http://server.ibillingclient.org/ibilling/xmlhttps"
	config["debug"] = true
	def session  = Session.login(2000, "welcome", config)
	//Find customer account
	def customerAccount  = session.loadCustomerAccount("groovy.ca-1")
	//Create payment plan
	def paymentPlan  = customerAccount.createPaymentPlan()
	//code is optinal; if you specify the value, make sure the code is unique
	paymentPlan.code = "groovy.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 = PaymentPlanType.Fixed
	//Specify desired billing date; if nothing specified, next billing date of the selected cycle assumed.
	//paymentPlan.firstBillingDate = date
	paymentPlan.add(0, 6, false)
	//Create child payment plan
	def childPaymentPlan  = paymentPlan.createLinkedPaymentPlan()
	//code is optinal; if you specify the value, make sure the code is unique
	childPaymentPlan.code = "groovy.pp-3-1"
	childPaymentPlan.type = PaymentPlanType.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
		println(ex.message)
		return ;
	}
	//logout
	session.logout()
 
	}
 
}
Personal tools