Scenario 4: Groovy

From Intrannuity

Jump to: navigation, search

Download Source File

import ibilling.client.*
 
class Scenario4 {
 
 static void main(args) {
			//Set up clients' settings
	def config  = [:]
	config[SessionConnection.PROCESSOR_HOST] = "http://server.ibillingclient.org/ibilling/xmlhttps"
	config["debug"] = true
	//Login
	def session  = Session.login(2000, "welcome", config)
	//Create customer account
	def customerAccount  = session.createCustomerAccount()
	//code is optinal; if you specify the value, make sure the code is unique
	customerAccount.code = "groovy.ca-4"
	customerAccount.merchantAccountCode = 2001
	customerAccount.firstName = "Mary"
	customerAccount.lastName = "Doe"
	customerAccount.type = CustomerAccountType.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
	def paymentPlan  = customerAccount.createPaymentPlan()
	//code is optinal; if you specify the value, make sure the code is unique
	paymentPlan.code = "groovy.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 = PaymentPlanType.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 = date
	//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