Scenario 10: 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")>
	<!---// Find customer account --->
	<cfset customerAccount  = session.loadCustomerAccount("cf.ca-1")>
	<!---// Create invoice for downpayment --->
	<cfset revenueTransaction  = customerAccount.createRevenueTransaction()>
	<!---// code is optinal; if you specify the value, make sure the code is unique --->
	<cfset revenueTransaction.setCode("cf.rt-10")>
	<!---// all amounts are in cents --->
	<cfset revenueTransaction.setAmount(5000)>
	<!---// Item Codes must be setup in portal prior to being used --->
	<cfset revenueTransaction.setItemCode("NutritionPack")>
	<!---// Type of transaction --->
	<cfset revenueTransaction.setAccountActivityType(session.AccountActivityType().Invoice())>
	<!---// Create payment for downpayment --->
	<cfset transaction  = customerAccount.createAssetTransaction()>
	<!---// code is optinal; if you specify the value, make sure the code is unique --->
	<cfset transaction.setCode("cf.at-10")>
	<!---// all amounts are in cents --->
	<cfset transaction.setAmount(5000)>
	<cfset transaction.setTransactionType(session.AssetTransactionType().Cash())>
	<cfset transaction.setAccountActivityType(session.AccountActivityType().Payment())>
	<!---// 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