require "lib/iBilling" #Set up clients' settings config = Map.new config.put(SessionConnection::PROCESSOR_HOST, "http://server.ibillingclient.org/ibilling/xmlhttps") config.put("debug", true) #Login session = Session::login(2000, "welcome", config) #Find customer account customerAccount = session.loadCustomerAccount("rb.ca-1") #Create invoice for downpayment revenueTransaction = customerAccount.createRevenueTransaction() #code is optinal; if you specify the value, make sure the code is unique revenueTransaction.code = "rb.rt-10" #all amounts are in cents revenueTransaction.amount = 5000 #Item Codes must be setup in portal prior to being used revenueTransaction.itemCode = "NutritionPack" #Type of transaction revenueTransaction.accountActivityType = AccountActivityType::Invoice #Create payment for downpayment transaction = customerAccount.createAssetTransaction() #code is optinal; if you specify the value, make sure the code is unique transaction.code = "rb.at-10" #all amounts are in cents transaction.amount = 5000 transaction.transactionType = AssetTransactionType::Cash transaction.accountActivityType = AccountActivityType::Payment #Mark object for persistence session.save(customerAccount) #Synchronize changes with the server begin session.synchronize() rescue Exception => ex #Be sure to properly handle exception, this is just a sample solution puts(ex.message) return end #logout session.logout()