Scenario 5: CFScript

From Intrannuity

Jump to: navigation, search

Download Source File

<cfscript>
	// Create Session component
	session = CreateObject( 'component', 'Session' );
	// Login
	session.login(2000, "password", "http://server.ibillingclient.org/ibilling/xmlhttps");
	// execute find payment plan
	paymentPlan  = session.loadPaymentPlan("cfs.pp-3");
	charges  = paymentPlan.getCharges();
	charge = charges[2];
	charge.setIsPrepaid(true);
	// get customer account
	customerAccount  = paymentPlan.getCustomerAccount();
	// Create payment for downpayment
	transaction  = customerAccount.createAssetTransaction();
	// code is optinal; if you specify the value, make sure the code is unique
	transaction.setCode("cfs.at-5");
	// all amounts are in cents
	transaction.setAmount(3000);
	// Type of transaction
	transaction.setAccountActivityType(session.AccountActivityType().Payment());
	transaction.setTransactionType(session.AssetTransactionType().Check());
	// check number
	transaction.setAccountNumber("10100125687");
	transaction.setIsPrepayment(true);
	transaction.setDueDate(charge.getBillingDate());
	// 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
		WriteOutput(ex.message);
		return ;
	}
	// Logout
	session.logout();
 
 
</cfscript>

Download Source File

Personal tools