From Intrannuity
Download Source File
import ibilling.client.*
class Scenario5 {
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)
//execute find payment plan
def paymentPlan = session.loadPaymentPlan("groovy.pp-3")
def charge = paymentPlan.charges[1]
charge.isPrepaid = true
//get customer account
def customerAccount = paymentPlan.customerAccount
//Create payment for downpayment
def transaction = customerAccount.createAssetTransaction()
//code is optinal; if you specify the value, make sure the code is unique
transaction.code = "groovy.at-5"
//all amounts are in cents
transaction.amount = 3000
//Type of transaction
transaction.accountActivityType = AccountActivityType.Payment
transaction.transactionType = AssetTransactionType.Check
//check number
transaction.accountNumber = "10100125687"
transaction.isPrepayment = true
transaction.dueDate = charge.billingDate
//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()
}
}