Scenario 4: Cold Fusion

From Intrannuity

Jump to: navigation, search

Download Source File

<!---// Create Session Object --->
	<cfset session = CreateObject( 'component', 'Session' )>
	<!---// Login --->
	<cfset session.login(2000, "password", "http://server.ibillingclient.org/ibilling/xmlhttps")>
	<!---// Create customer account --->
	<cfset customerAccount  = session.createCustomerAccount()>
	<!---// code is optinal; if you specify the value, make sure the code is unique --->
	<cfset customerAccount.setCode("cf.ca-4")>
	<cfset customerAccount.setMerchantAccountCode(2001)>
	<cfset customerAccount.setFirstName("Mary")>
	<cfset customerAccount.setLastName("Doe")>
	<cfset customerAccount.setType(session.CustomerAccountType().Female())>
	<cfset customerAccount.setHomePhone("5469856876")>
	<cfset customerAccount.setEmail("test@google.com")>
	<cfset customerAccount.setStreet1("203 16th Street")>
	<cfset customerAccount.setCity("Honolulu")>
	<cfset customerAccount.setState("CA")>
	<cfset customerAccount.setZipCode("30904")>
	<!---// Create payment plan --->
	<cfset paymentPlan  = customerAccount.createPaymentPlan()>
	<!---// code is optinal; if you specify the value, make sure the code is unique --->
	<cfset paymentPlan.setCode("cf.pp-4")>
	<!---// all amounts are in cents --->
	<cfset paymentPlan.setAmount(3000)>
	<!---// Item Codes must be setup in portal prior to being used --->
	<cfset paymentPlan.setItemCode("Membership")>
	<cfset paymentPlan.setType(session.PaymentPlanType().Complimentary())>
	<!---// Billing Cycle codes must be setup in portal prior to being used --->
	<cfset paymentPlan.setBillingCycleCode("M03")>
	<!---// Specify desired billing date; if nothing specified, next billing date of the selected cycle assumed. --->
	<!---// <cfset paymentPlan.setFirstBillingDate(<Date) --->
	<!---// Mark object for persistence --->
	<cfset session.save(customerAccount)>
	<!---// Synchronize changes with the server --->
	<cftry>
		<cfset session.synchronize()>
		<cfcatch type="Exception">
			<cfoutput>
			#cfcatch.message#
			</cfoutput>
		</cfcatch>
	</cftry>
	<!---// Logout --->
	<cfset session.logout()>

Download Source File

Personal tools