From Intrannuity
Download Source File
import ibilling.client.*
class Scenario9 {
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)
//Find customer account
def customerAccount = session.loadCustomerAccount("groovy.ca-2")
//Create invoice1
def invoice1 = customerAccount.createRevenueTransaction()
//code is optinal; if you specify the value, make sure the code is unique
invoice1.code = "groovy.rt-9-1"
//all amounts are in cents
invoice1.amount = 2000
//Item Codes must be setup in portal prior to being used
invoice1.itemCode = "T-Shirt"
//Type of transaction
invoice1.accountActivityType = AccountActivityType.Invoice
//Create payment1
def payment1 = customerAccount.createAssetTransaction()
//code is optinal; if you specify the value, make sure the code is unique
payment1.code = "groovy.at-9-1"
//all amounts are in cents
payment1.amount = 2000
payment1.transactionType = AssetTransactionType.Visa
payment1.accountActivityType = AccountActivityType.Payment
//Credit card number to charge
payment1.accountNumber = "4111111111111111"
//Credit card expiration date
payment1.accessory = "1209"
//Add processing specific info (for better qualification rates)
def captureInfo1 = payment1.captureInfo
captureInfo1.holderName = "John Smith"
captureInfo1.city = "Columbus"
captureInfo1.state = "CA"
captureInfo1.street = "233 12th Street"
captureInfo1.zipCode = "31909"
captureInfo1.phone = "2129856472"
captureInfo1.email = "test@yahoo.com"
captureInfo1.cvv2 = "999"
//Create invoice2
def invoice2 = customerAccount.createRevenueTransaction()
//code is optinal; if you specify the value, make sure the code is unique
invoice2.code = "groovy.rt-9-2"
//all amounts are in cents
invoice2.amount = 1500
//Item Codes must be setup in portal prior to being used
invoice2.itemCode = "T-Shirt"
//Type of transaction
invoice2.accountActivityType = AccountActivityType.Invoice
//Create payment2
def payment2 = customerAccount.createAssetTransaction()
//code is optinal; if you specify the value, make sure the code is unique
payment2.code = "groovy.at-9-2"
///all amounts are in cents
payment2.amount = 1500
payment2.transactionType = AssetTransactionType.Visa
payment2.accountActivityType = AccountActivityType.Payment
//Credit card number to charge
payment2.accountNumber = "4111111111111111"
//Credit card expiration date
payment2.accessory = "1209"
//Add processing specific info (for better qualification rates)
def captureInfo2 = payment2.captureInfo
captureInfo2.holderName = "John Smith"
captureInfo2.city = "Columbus"
captureInfo2.state = "CA"
captureInfo2.street = "233 12th Street"
captureInfo2.zipCode = "31909"
captureInfo2.phone = "2129856472"
captureInfo2.email = "test@yahoo.com"
captureInfo2.cvv2 = "999"
//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()
}
}